12 Ağustos 2014 Salı

HTTP Host header attacks

Paylaşım Unknown on 15:06 with Şuan Yorum Yok

Practical HTTP Host header attacks

    Password reset and web-cache poisoning

        (And a little surprise in RFC-2616)


Introduction

   
How does a deployable web-application know where it is? Creating a trustworthy absolute URI is trickier than it sounds. Developers often resort to the exceedingly untrustworthy HTTP Host header (_SERVER["HTTP_HOST"] in PHP). Even otherwise-secure applications trust this value enough to write it to the page without HTML-encoding it with code equivalent to:
     <link href="http://_SERVER['HOST']"    (Joomla)

...and append secret keys and tokens to links containing it:
    <a href="http://_SERVER['HOST']?token=topsecret">  (Django, Gallery, others)

....and even directly import scripts from it:
      <script src="http://_SERVER['HOST']/misc/jquery.js?v=1.4.4">  (Various)

    There are two main ways to exploit this trust in regular web applications. The first approach is web-cache poisoning; manipulating caching systems into storing a page generated with a malicious Host and serving it to others. The second technique abuses alternative channels like password reset emails where the poisoned content is delivered directly to the target. In this post I'll look at how to exploit each of these in the presence of 'secured' server configurations, and how to successfully secure applications and servers.


Password reset poisoning


    Popular photo-album platform Gallery uses a common approach to forgotten password functionality. When a user requests a password reset it generates a (now) random key:



Places it in a link to the site:


and emails to the address on record for that user. [Full code] When the user visits the link, the presence of the key proves that they can read content sent to the email address, and thus must be the rightful owner of the account.

The vulnerability was that url::abs_site used the Host header provided by the person requesting the reset, so an attacker could trigger password reset emails poisoned with a hijacked link by tampering with their Host header:
> POST /password/reset HTTP/1.1
> Host: evil.com
> ...
> csrf=1e8d5c9bceb16667b1b330cc5fd48663&name=admin

    This technique also worked on Django, Piwik and Joomla, and still works on a few other major applications, frameworks and libraries that I can't name due to an unfortunate series of mistakes on my part.

Of course, this attack will fail unless the target clicks the poisoned link in the unexpected password reset email. There are some techniques for encouraging this click but I'll leave those to your imagination.

In other cases, the Host may be URL-decoded and placed directly into the email header allowing mail header injection. Using this, attackers can easily hijack accounts by BCCing password reset emails to themselves - Mozilla Persona had an issue somewhat like this, back in alpha. Even if the application's mailer ignores attempts to BCC other email addresses directly, it's often possible to bounce the email to another address by injecting \r\nReturn-To: attacker@evil.com followed by an attachment engineered to trigger a bounce, like a zip bomb.


Cache poisoning

Web-cache poisoning using the Host header was first raised as a potential attack vector by Carlos Beuno in 2008. 5 years later there's no shortage of sites implicitly trusting the host header so I'll focus on the practicalities of poisoning caches. Such attacks are often difficult as all modern standalone caches are Host-aware; they will never assume that the following two requests reference the same resource:

> GET /index.html HTTP/1.1       > GET /index.html HTTP/1.1
> Host: example.com              > Host: evil.com


So, to persuade a cache to serve our poisoned response to someone else we need to create a disconnect between the host header the cache sees, and the host header the application sees. In the case of the popular caching solution Varnish, this can be achieved using duplicate Host headers. Varnish uses the first host header it sees to identify the request, but Apache concatenates all host headers present and Nginx uses the last host header[1]. This means that you can poison a Varnish cache with URLs pointing at evil.com by making the following request:
> GET / HTTP/1.1
> Host: example.com
> Host: evil.com
Application-level caches can also be susceptible. Joomla writes the Host header to every page without HTML-encoding it, and its cache is entirely oblivious to the Host header. Gaining persistent XSS on the homepage of a Joomla installation was as easy as:
curl -H "Host: cow\"onerror='alert(1)'rel='stylesheet'" http://example.com/ | fgrep cow\"

This will create the following request:
> GET / HTTP/1.1
> Host: cow"onerror='alert(1)'rel='stylesheet'

The response should show a poisoned <link> element:
<link href="http://cow"onerror='alert(1)'rel='stylesheet'/" rel="canonical"/>
To verify that the cache has been poisoned, just load the homepage in a browser and observe the popup.

'Secured' configurations

    So far I've assumed that you can make a HTTP request with an arbitrary Host header arrive at any application. Given that the intended purpose of the Host header is to ensure that a request is passed to the correct application at a given IP address, it's not always that simple.

Sometimes it is trivial. If Apache receives an unrecognized Host header, it passes it to the first virtual host defined in httpd.conf. As such, it's possible to pass requests with arbitrary host headers directly to a sizable number of applications. Django was aware of this default-vhost risk and responded by advising that users create a dummy default-vhost to act as a catchall for requests with unexpected Host headers, ensuring that Django applications never got passed requests with unexpected Host headers.

The first bypass for this used X-Forwarded-For's friend, the X-Forwarded-Host header, which effectively overrode the Host header. Django was aware of the cache-poisoning risk and fixed this issue in September 2011 by disabling support for the X-Forwarded-Host header by default. Mozilla neglected to update addons.mozilla.org, which I discovered in April 2012 with the following request:
> POST /en-US/firefox/user/pwreset HTTP/1.1> Host: addons.mozilla.org
> X-Forwarded-Host: evil.com

Even patched Django installations were still vulnerable to attack. Webservers allow a port to be specified in the Host header, but ignore it for the purpose of deciding which virtual host to pass the request to. This is simple to exploit using the ever-useful http://username:password@domain.com syntax:
> POST /en-US/firefox/user/pwreset HTTP/1.1> Host: addons.mozilla.org:@passwordreset.net

This resulted in the following (admittedly suspicious) password reset link:
https://addons.mozilla.org:@passwordreset.net/users/pwreset/3f6hp/3ab-9ae3db614fc0d0d036d4

If you click it, you'll notice that your browser sends the key to passwordreset.net before creating the suspicious URL popup. Django released a patch for this issue shortly after I reported it: https://www.djangoproject.com/weblog/2012/oct/17/security/

Unfortunately, Django's patch simply used a blacklist to filter @ and a few other characters. As the password reset email is sent in plaintext rather than HTML, a space breaks the URL into two separate links:
> POST /en-US/firefox/users/pwreset HTTP/1.1
> Host: addons.mozilla.org: www.securepasswordreset.com
Django's followup patch ensured that the port specification in the Host header could only contain numbers, preventing the port-based attack entirely.  However, the arguably ultimate authority on virtual hosting, RFC2616, has the following to say:

5.2 The Resource Identified by a Request
[...]
If Request-URI is an absoluteURI, the host is part of the Request-URI. Any Host header field value in the request MUST be ignored.
The result? On Apache and Nginx  (and all compliant servers) it's possible to route requests with arbitrary host headers to any application present by using an absolute URI:
> POST https://addons.mozilla.org/en-US/firefox/users/pwreset HTTP/1.1
> Host: evil.com
This request results in a SERVER_NAME of addons.mozilla.org but a HTTP['HOST'] of evil.com. Applications that use SERVER_NAME rather than HTTP['HOST'] are unaffected by this particular trick, but can still be exploited on common server configurations. See HTTP_HOST vs. SERVER_NAME for more information of the difference between these two variables.  Django fixed this in February 2013 by enforcing a whitelist of allowed hosts. See the documentation for more details. However, these attack techniques still work fine on many other web applications.


Securing servers

Due to the aforementioned absolute request URI technique, making the Host header itself trustworthy is almost a lost cause. What you can do is make SERVER_NAME trustworthy. This can be achieved under Apache (instructions) and Nginx (instructions) by creating a dummy vhost that catches all requests with unrecognized Host headers. It can also be done under Nginx by specifying a non-wildcard SERVER_NAME, and under Apache by using a non-wildcard serverName and turning the UseCanonicalName directive on. I'd recommend using both approaches wherever possible.

A patch for Varnish should be released shortly. As a workaround until then, you can add the following to the config file:
        import std;

        sub vcl_recv {
                std.collect(req.http.host);
        }

Securing applications

Fixing this issue is difficult, as there is no entirely automatic way to identify which host names the administrator trusts. The safest, albeit mildly inconvenient solution, is to use Django's approach of requiring administrators to provide a whitelist of trusted domains during the initial site setup process. If that is too drastic, at least ensure that SERVER_NAME is used instead of the Host header, and encourage users to use a secure server configuration.

Further research

  • More effective / less inconvenient fixes
  • Automated detection
  • Exploiting wildcard whitelists with XSS & window.history
  • Exploiting multipart password reset emails by predicting boundaries
  • Better cache fuzzing (trailing Host headers?)

Thanks to Mozilla for funding this research via their bug-bounty program, Varnish for the handy workaround, and the teams behind Django, Gallery, and Joomla for their speedy patches.

Feel free to drop a comment, email or DM me if you have any observations or queries.




7 Ağustos 2014 Perşembe

İngiliz İstihbarat Servisi GCHQ ‘nın Kullandığı 5 Casusluk Uygulaması

Paylaşım Unknown on 17:30 with Şuan Yorum Yok
siber istihbarat
Selamlar Dostlar;
Yıl 2014. Bilgi ve İstihbarat konusunda tüm Dünya’nın gözü kulağı artık Siber Dünya’da. Bundan 5, 10 yıl önce Aksiyon, Macera türünde filmlerde izlediğimiz hemen hemen her şey artık Teknoloji dünyasında yer alıyor ve İstihbarat Servisleri tarafından aktif olarak kullanılıyor.
Siber Dünya’nın karanlık tarafıyla ve Hacking işleriyle ilgilenen tarafları sayın bana desem? White hat hackerler, Black hat hackerler, Gray hat hackerler dersiniz. Ancak Günümüzde artık Kategorisel olarak baz alınması ve Bilinmesi gereken bir taraf daha var. Ve bu taraf diğer tüm taraflardan daha GÜÇLÜ, daha ACIMASIZ ve daha fazla İMKANA SAHİP!
“DEVLETLERİN İSTİHBARAT SERVİSLERİ!”
Önce WikiLeaks, daha sonra NSA Skandallarının ardından ortaya çıkan belgelere baktığımız zaman hep devletlerin kendi vatandaşlarını ya da diğer devletlerin yöneticilerini, istihbarat servislerini dinlemek için Teknolojiler geliştirdiklerini ve kullandıklarını görürüz. Özellikle Snowden’ın sızdırdığı NSA Belgelerinde açıkça görülüyordu ki, Amerika ve İngiltere kantarın topunuzu oldukça abartmış dinlemedikleri ülke ve yönetici yada servis kalmamıştı.
Yani artık insanlar sadece Beyaz, Siyah, Gri Şapkalı hackerlerin değil, Devletlerin Gizli Servislerinin de Hedefinde yer alıyor! Üstelik dedğim gibi bu adamların paraya, cihaza, teknolojiye, adama ve dolayısıyla paraya ihtiyaçları yok. Her şey ellerinin altında. Para var, Mekan var, Cihaz var, Kanun zaten kendileri ;) Anlayacağınız Tehlikenin boyutu oldukça yüksek.
Herksin bildiği NSA gibi çalışan ancak ülke olarak İngiltere’de yer alan ve bu yazıya konu olan Gizli Servisimizin adı GCHQ. Belkide çoğunuz bu ismi yani baş harflerinden oluşan bu GCHQ tanımlamasını yeni duydunuz. Ancak kendileri İngiliz İstihbaratının bel kemiği durumundalar. Kendilerini Modern her türlü Teknolojiyi kullanarak her türlü ortam, şart ve koşulda İngiliz Devleti ve Vatandaşlarının Güvenli İletişim Kurmasını sağlamak amaçlı Faaliyetler yapmak ve bunları yaparken İstihbarat kardeşliği kurdukları bir diğer İngilizlerin genel istihbarat servisi (Bizdeki MİT gibi) MI5 ile Bilgi Paylaşımı yapmak olarak tanımlıyorlar.
Yani bu adamlar Teknoloji İstihbaratı yapıyorlar. Diğer İstihbarat Servislerinden farkları bu. NSA ile de ortak yanları bu. Doğrudan ajanlık ve casusluk faaliyetleri Siber Dünya hedefli.
GCHQ ‘nun gündeme gelmesi NSA Skandallarında oldu. Benimde kendilerinin yaptığı işleri araştırmam yine bu dosyalar sayesinde oldu.
Yaptığım araştırmalara ve medyada siber dünyada dönen dökümanlara göre bu zathı muhterem GCHQ Servisi aşağıdaki 5 adet Hack Tool Programını Casusluk yapmak üzere kendileri yazıp, Siber Dünya’ya salıyorlar. Yani bir Hacker gibi Hacking yapmanızı sağlayan Yazılımları üretip, İçlerine BackDoor yerleştirip, piyasa salıyorlar.
Amaç ne ?
Tabii ki DATA toplamak. Programları kimler ne için nereden ne zaman kullanıyor? Her türlü data GCHQ tarafından toplanıyor. Ve siz o Programları kullanırken sanıyorsunuz ki bizde hackeriz ve güvendeyiz.
Yani “AVA GİDEN AVCIYI AVLIYORLAR!”
GCHQ adına çalışan Casus Hack Yazılımları şu şekilde ;
1-       Nosey Smurf : Angry Birds gibi bir Mobil oyun düşünün. Ancak bu Kuşlardan falan değil, Bildiğimiz Şirinlerden oluşuyor. Nosey Smurf mobil yazılımını indirdiğiniz zaman Cep Telefonunuzun GPS, SMS, Telefon görüşmeleri gibi bilgilerini GCHQ’ya gönderiyorsunuz. En çok da bu programdan MİKROFON ORTAM DİNLEMESİ yapmak gibi konularda ekmek yemişler.
2-       GumFish : Bu da Mobil tabanlı bir yazılım. Her şeyi yapmasından ziyade Kamera görüntüsü üzerine odaklanılmış.
3-       FoggyBottom : Internet arama geçmişlerini kayıt edip gönderen bir Yazılım.
4-       Tracker Smurf : Kullandığı kişinin Çoğrafi Bilgilerini gönderen bir Yazılım.
5-       Grok : Bildiğiniz Keylogger. Ama sizi de avlıyor.
Durum böyle dostlar. Bunlar çok bilinenler. Elbetteki asıl ÇOK BİLİNMEYENLERİ bilmiyoruz. Siber Dünya gün geçtikçe büyüyor. Hiç durmuyor. Ve hiç durmayacak.
Yeni bir makale ile daha sizlerle olana kadar kendinizi Güvenli kılmaya bakın.

4 Ağustos 2014 Pazartesi

Pompem Exploit Finder (exploit-db , 1337day tarama vb.) Kali linux.

Paylaşım Unknown on 13:31 with Şuan Yorum Yok
Merhabalar Arkadaşlar;
Bugün sizlere Kali Linux’ta “Pompem  Exploit  Finder Tool”’unu tanıtacağım. Pompem büyük veritabanlarında (exploit-db , 1337day vb.) otomatik olarak exploit araştırmak üzere tasarlanmış açık kaynak kodlu bir araçtır. Python diliyle yazılmıştır ve gelişmiş bir arama sistemi mevcuttur, dolayısıyla pentester ve ethical hackerların işini oldukça kolaylaştırmaktadır. Meccut versiyonda çeşitli veri tabanlarında aramalar gerçekleştirir , bunlar: Exploit-db, 1337day, Packetstorm Security gibi sitelerdir.
Öncelikle buradan(http://www.mediafire.com/download/w5qoqzqb6fjrdqb/Pompem-master.zip) pompem tool’unu Kali Linux masaüstünüze indirin. Dosya .zip formatında indi.
Öncelikle terminal penceresini açıyoruz ve cd Desktop komutulya masaüstü dizinine geliyoruz.
Şimdi ise unzip Pompem-master.zip komutuyla pompem’i zip’ten ççıkarıyoruz.
Pompem Exploit Finder Tool
zip’ten çıktığına dair görüntü;
Pompem Exploit Finder Tool
Evet artık tool’umuz kullanıma hazır hale geldi. Terminal penceresini kapatıp tekrardan açalım.
cd Desktop komutuyla masaüstü dizinine geçiyoruz.
Pompem Exploit Finder Tool
Şimdi Pompem’i kullanbilmek için cd Pompem-master komutuyla Pompem dizinine geçelim.
Pompem Exploit Finder Tool
Pompem’in çalıştığına dair görüntü;
Pompem Exploit Finder Tool
Artık rahatlıkla amacımıza göre kullanabiliriz.Kullanım şekli python pompem-master.py -s arayacağımız_degisken şeklinde olacak. Biz burada python pompem-master.py -h komutunu vererek nasıl kullanabileceğimiz öğrenebiliriz.
Pompem Exploit Finder Tool
Wordpress için gösterelim;
python pompem-master.py -s Wordpress komutunu verdiğimizde gördüğünüz gibi aramanın gerçekleştiğine dair yazımız çıktı.
Pompem Exploit Finder Tool
Bu fotoğrafta ise sonuçlar çıktı;
Pompem Exploit Finder Tool
Joomla için gösterelim;
python pompem-master.py -s Joomla komutunu verdiğimizde gördüğünüz gibi aramanın gerçekleştiğine dair yazımız çıktı ve sonuçlarımız gözüktü;
Pompem Exploit Finder Tool
Linux için gösterelim;
python pompem-master.py -s Linux komutunu verdiğimizde gördüğünüz gibi aramanın gerçekleştiğine dair yazımız çıktı ve sonuçlarımız gözüktü;
Pompem Exploit Finder Tool
Bu şekilde kullandığımız sisteme ait exploit olup olmadığını anlayabiliriz.

Nikto ile Zafiyet (Açık) Tarama

Paylaşım Unknown on 12:56 with Şuan Yorum Yok
Nikto CIRT tarafından yapılmış açık kaynak kodlu, Web Uygulama Zafiyet Aracıdır. Bu araç Kali ve Backtrack işletim sistemlerine kurulu olarak gelmektedir. Diğer Linux Dağıtımları için aşağıda ki link’den indirip kurabilirsiniz. Nikto aşağı yukarı 6500 zafiyet tespit’i yapabilir.

Adresinden indirebilirsiniz.
Anlatımı ben Backtrack üzerinden yapacağım.
1.png
Nikto yazılımına Terminal’den girmek isterseniz bu şekilde gireceksiniz. Normal menülerden girecekseniz ise bu şekilde.3.png
Nikto Aracımızın Arayüzü arkadaşlar.
4.png
Öncelikle bi hedef site’de basit bir tarama yapalım.

5.png
Şimdi bir site’de SQL, XSS gibi açıklar arayalım.
Terminal’e perl nikto.pl -H yazıp help komutunu yansıtacağız.

6.png
Zafiyet çeşitleri biz SQL zafiyeti arayacağız. O yüzden 9 numara. :)

7.png
Birşey tespit edemedi.
Nikto Komutları
-host+ ---> hedef site
-port+ ---> hedef port (default 80)
-evasion ---> IDS’ ten kaçınma özelliği. -e parametresinden sonra Encoding technique: altındaki parametrelerden kullanılmak istenilen yazılır
-tuning ---> tarama şeklini belirler. SQL mi tarayacaksınız, XSS mi tarayacaksınız onu belirler. sadece zafiyet tarar.
-CgiDirs+ ---> CGI dizinleri tarar. Eğer taramasını istemezseniz none komutunu kullanacaksınız.
-verbose ---> ayrıntılı tarama yapar.
-update ---> yazılım güncellemesi
-generic ---> Full tarama yapar. Eğer site log tutarsa yakalanma ihtimaliniz çok yüksek o yüzden pek tavsiye etmiyorum.

General Mobile Discovery ‘e Uzaktan Reset Atma.

Paylaşım Unknown on 12:17 with Şuan Yorum Yok
Öyle uzun uzun anlatmaya gerek yok.
General Mobile Discovery Telefonu olan birisine SMS olarak şunu gönderin ;

“ = “ (tırnaklar yok)
Cihaz önce Reset atacak, daha sonra İngilizce dil seçeneği ile açılacak ve sonra Türkçe Dil Seçeneğine dönüş yaparak biraz kasılarak kendine gelecektir.
Bu işlem Telefonda kalıcı bir zarar bırakmadığı gibi, SD Kart yada Telefon Hafızasından da Veri kaybı yaşanmasına neden olmamaktadır.
Cihazın “=” sembolüne karşı verdiği tepkiyi anlamakta güçlük çekmekle birlikte piyasada var olan General Mobile Discovery modellerinin hepsinde işe yaramaktadır. Ayrıca Android işletim sistemini güncelleseniz dahi problem devam etmektedir.
Açık linux ile bulunup hala devam etmekdetir.

Bilgi ve guvenligi akademisi



Şifreli Haberleşmenin Yenisi: “BitTorrent Bleep Messenger”

Paylaşım Unknown on 11:58 with Şuan Yorum Yok

Malumunuz Dünya üzerinde artık Gizlilik, Güvenlik ve Mahremiyet gibi kavramların daha çok sorgulandığı, kırmızı çizgilerin daha da keskinleştiği günlerden geçiyoruz. Edward Snowden abimizin Nation Security Agency (NSA) ‘in belgelerini ifşa etmesiyle zaten bildiğimiz ama millete anlattığımız da “abi sen çok Amerikan filmi izliyorsun” dediği olayların herkes tarafından bilinmesi bizim Güvenlik, Gizlilik gibi konuları daha çok aydınlatmamıza ve Konuya daha çok farkındalık katmamıza olanak sağladı.
bleep messenger
Devletler, kendi vatandaşlarını dinlemek için her türlü yola başvurmuşken, Siber İstihbarat gün ve gün değerli hale geldi. Teknolojinin nimetlerinden yararlanmak ve teknolojiye kendi çıkarları doğrultusunda kullanmak isteyen Devletler, kendi istihbarat vb. birimleri sayesinde bu işlere imza attılar.
Durum böyleyken sadece Teknolojinin nimetlerinden yararlananlar tabi ki devletler yada özel istihbarat servisleri değil. Bizler de varız işin içinde. Yani Siber Dünya’nın gerçek sahipleri, bu dünyayı yaşayanlar var.
BitTorrent ‘i herkes kullanır bizim buralarda. Herkeste bilir ne olduğunu. İstediğiniz bir Program, Data ne varsa BitTorrent üzerinden rahatlıkla dağıtık server yapısı sayesinde kimliğiniz ve bağlantı adresiniz belli olmadan çekebilirsiniz.
BitTorrent’in yapımcıları yeni bir hizmet ile karşımızdalar. Bleep ismini verdikleri bu yazılım sayesinde Şifreli konuşmalar yani Chat yapmak mümkün hale geliyor. Messenger mantığınıda düşünebilirsiniz yazılımı.
Peki Bleep Nasıl Güvenlik Sağlıyor?
Yapımcısının dediğine göre olay aynı TOR trafiğinda ki Node noktalarından geçerken atılan Düğümlere benziyor dostlar. Siz Bleep üzerinden bir kişiyle sohbete başladığınız zaman arka planda metadata bilgisi, ip bilgisi vb aklınıza gelebilecek her türlü data ve bilgi bir Düğüm noktasına gidiyor ve şifreleniyor. Oradan başka bir düğüm noktasına geçerken yine şifreleniyor. Yani anlık sohbet trafiğiniz sürekli şifreli hale gelmiş durumda oluyor.
Bleep Yazılımının mantığında Mimariyi oluştururken iki önemli unsur var. Birisincisi Oturum Başlatma Protokolünün Şifrelenmesi İkincisi ise Bu Oturum başlatma katmanına eklenmiş ve Şifrelenmiş olan Peer-To-Peer metodu.
Bleep Hangi Ortamlarda Çalışıyor ?
Bleep yazılımı Desktop, Mobil, Email gibi her servis ve ortamda çalışıyor dostlar.
Bleep ‘i Nasıl Deneyebiliriz, Nasıl Bilgi alabiliriz ?
http://labs.bittorrent.com/experiments/bleep/ şuraya gidip daha fazla şeyler okuyabilir, Kayıt olabilir, İnceleyebilirsiniz.