( ~~~ )
  ))^ ^((
 ((* - *))
   _) (_
 / '--' \     ^
//(_  _)\\   /_\
\\ )__( //   .'
 (( v  ))   (
   \| /\     '-.
    K(  \       )
    |\\  '-._.-'
    ||\\
  *_-P/,P
     '-
Want your PHP application manually audited? Check out Xxor AB's PHP Security Auditing Service

Friday, July 8, 2011

phpMyAdmin 3.x preg_replace RCE POC

I'm flooded with requests for a POC and many doubt that these vulnerabilities are exploitable. And since this vulnerability is rather technically interesting I believe many could learn from it.

The POC uses the session manipulation vulnerability in combination with the remote code execution in preg_replace as detailed in my last blogpost. It will only confirm if the instance is exploitable or not and you need to have valid credentials to the database. Use responsibly.

Download here


Edit:As 0x6a616d6573 reminded me of, blogger removes "%00" if not carefully encoded. The code posted where messed up due to this. (The downloadable file where still fine)
Now it's fixed. I also added the "//" as suggested.

45 comments:

  1. It doesn't Work It show me
    [i] Running...
    [*] Contacting server to authenticate.
    [i] Cookie:pma_mcrypt_iv=6usxi8fDjxY%3D; phpMyAdmin=83f941377c2ad368cb065ae3511c114b6ce908d7; pmaUser-1=K6%2BMQV0L8oo%3D; pmaPass-1=C7ohzD7vwAc%3D
    [i] Token:e498413730bbb8c51ce127b807160bf8
    [*] Contacting server to poison some _SESSION variables.
    [*] Contacting server to execute command.
    [!] Authentication error. Wrong password maby.
    [*] Exiting...

    I use PMA V 3.4.3 PHP 5.3.5 On OSX

    ReplyDelete
  2. @Anonymous

    I'll debug tomorrow. It would be helpfull if you edited the code and changed $debug to true and emailed me the output to h@xxor.se

    ReplyDelete
  3. @Mango: I appreciate the PoC, and I did learn something. I learned I should have spent more time trying to exploit this bug. lol :] Nice work!

    Also, to get the PoC working reliably, I simply added a uri encoded null byte at the end of the regex string, and a comment delimiter at the end of the injected PHP code (The null is not needed there BTW):

    '&_SESSION[src_uncommon_tables][0]=||/e'.

    Becomes

    '&_SESSION[src_uncommon_tables][0]=||/e'.

    And

    '\`.eval($_POST["comm"]);'."\x00" :

    Becomes

    '\`.eval($_POST["comm"]);//'."\x00" :

    ReplyDelete
  4. Apparently blogger eats url encoded nulls for breakfast, but I think you know what I mean from the description.

    ReplyDelete
  5. Just tested with version 3.3.9.2 (Unsuccessful) and Tried 0x6a616d6573's ['\`.eval($_POST["comm"]);//'."\x00" :]

    Result of execution:
    [i] Running...
    [*] Contacting server to authenticate.
    [!] Fail. request returned 401. The host is not vulnerable or there is a problem with the supplied url.
    [*] Exiting...
    -------------

    Being that -u is set to https

    ReplyDelete
  6. @Anon: Try echo'ing out the $result variable to see if that can give you some insight into how the 401 error is happening. Also, the null at the end of the php code isn't necessary. I don't know if that's the problem, but give it a go, and let us know how it works?

    @Mango: Have you looked into the possibility of authentication bypass since $_SESSION variables can apparently be overwritten? I realize the authentication within phpMyAdmin happens on two different layers, (Application, and SQL) but bypassing phpMyAdmin application specific authentication should suffice for a preauth remote code execution condition. What do you think?

    ReplyDelete
  7. @0x6a616d6573
    As I remember, the authentication can be bypassed without modifying the session. But I came to the conclusion that the code inevitably comes to some place where it needs a valid connection to the database before it hits any funny pieces of code.

    But please, if you can find something, tell me. =D

    ReplyDelete
  8. Last Anon.

    Debug = 1

    http://www.pastie.org/private/66hsny5mrc8xw27dgsuitw

    ReplyDelete
  9. @Anonymous

    Your server uses basic authentication. Use an url like this:
    https://user:pass@db.xxxxxxxxxx.com:443/phpmyadmin

    I don't know if these credentials are the same as your db credentials.

    ReplyDelete
  10. Can u show me LFI Bug PoC

    ReplyDelete
  11. great work man!
    it took me a while to fully understand all this, but now it's clear!:)
    Congrats for the hard work!

    ReplyDelete
  12. Download link does not work anymore :-(

    ReplyDelete
  13. I enjoy, result in I found exactly what I used to be looking for. You’ve ended my 4 day long hunt! God Bless you man. Have a nice day. Bye
    Regards too from Young Entrepreneur
    Tangki Fiberglass
    Jual Septic Tank

    ReplyDelete
  14. I will always support your website, hopefully more advanced. keep the spirit… thanks

    ReplyDelete
  15. Wow what a Great Information about World Day its exceptionally pleasant educational post. a debt of gratitude is in order for the post.
    data science course in India

    ReplyDelete
  16. Are you also searching for spanish nursing writing services we are the best solution for you. We are best known for delivering the best services to students.  

    ReplyDelete
  17. cool blog, cool post, very interesting, it would be cool if a large number of people have to find out, and it will help to increase coverage in social networks https://soclikes.com/

    ReplyDelete
  18. Thanks for sharing this.,
    Leanpitch provides online training in Scrum Master, everyone can use it wisely.
    Join Leanpitch 2 Days CSM Certification Workshop in different cities.

    certified scrum master
    Scrum master

    ReplyDelete
  19. Thanks for sharing this.,
    Leanpitch provides online training in Scrum Master, everyone can use it wisely.
    Join Leanpitch 2 Days CSM Certification Workshop in different cities.

    Scrum master certification

    csm certification cost

    ReplyDelete
  20. This comment has been removed by the author.

    ReplyDelete
  21. The next stop is AtozTopNews. This website is up-to-date with the latest tech news, reviews of the most modern consumer technology, and advice on purchasing technology. There's also a distinctive "How To" section which includes blog posts written to consumers with their purchases, such as "How do you watch Star Wars movies in order '' We love it.

    ReplyDelete
  22. We visit, play, use and play on each casino we promote and share our findings and experiences with you. We sort out the best from the rest and only feature fully licensed UK casino operators in regulated markets across the United Kingdom. All featured casinos on E-Vegas.com are remotely licensed with either MGA ( Malta Gaming Authority ) or ( AGCC ) Alderney Gambling Control Commission or appropriate UK governing body.UK Live Casino

    ReplyDelete
  23. I feel very grateful that I read this. It is very helpful and very informative and I learned a lot from it.
    For hand grip strengthener please contact with squegg.

    ReplyDelete
  24. Thank you for another informative blog. Where else could I get that type of info written in such a perfect approach? I have an undertaking that I’m simply now working on, and I’ve been on the lookout for such information.

    ReplyDelete
  25. D&P PERFUMUM IMPORT EXPORT INDUSTRY AND TRADE LIMITED COMPANY WERE ESTABLISHED IN ANKARA IN 1999 AND STILL 40+CONTINUES ITS ACTIVITIES AS D&P PERFUME SHOP. IMPORT EXPORT INDUSTRY AND JOINT STOCK COMPANY. UNITED STATES THE BEST ONLINE PERFUME STORE IN TEXAS SAN ANTONIO OUR COMPANY, WHOSE MAIN FIELD OF ACTIVITY IS Best Perfume Collection, WORKS INTENSIVELY ON PERFUME IN PARALLEL WITH ITS IDENTITY AS “THE PERFUMER OF THE COUNTRY.”

    ReplyDelete
  26. Ignition Casino’s slot machines are truly mind-blowing, boasting selection of|quite so much of|a wide range of} options where they’ve chosen to give attention to} quality quite than quantity. You stand an opportunity to win it massive with their progressive slots and jackpots too. Super Slots is your finest guess if you’re in search of a 카지노사이트.online bit of recreation selection and a fantastic choice of on-line slot machines from the leading software providers within the business. This web site options over a hundred and twenty actual cash slot video games you could play for free if you nonetheless wish to test them out. To spare you the difficulty, we’ve narrowed down a listing of exciting on-line slot machines and essentially the most best on-line casinos where you'll find every of them.

    ReplyDelete
  27. AM
    Thank you for sharing such good information. It's very useful to click here - Lungeklinikken i Lillestrøm

    ReplyDelete
  28. Wow, Haxxor Security looks amazing! I'm so impressed with the level of security and protection they offer. It's great to see a company dedicated to keeping our devices and data safe. I'm definitely planning on researching Haxxor Security more as I think it would be an invaluable asset to help safeguard my network. Highly recommended!

    ReplyDelete
  29. This one is very good for PHP user. You share such a great information in this article. I hope you will share more good updates. Now it's time to avail shutter repair service for more information.

    ReplyDelete
  30. We have more than 70 Varients of Antiviruses, Microsoft Windows & Microsoft Offices products available

    click here - MACbook Microsoft Office

    ReplyDelete

  31. great blog this is thanks for this great blog this is so useful for us
    click here :- methane capture from air

    ReplyDelete
  32. Haxxor Security" appears to be a term associated with hacking or cybersecurity culture, often used humorously or colloquially. It may denote a fictional or playful reference to individuals or entities claiming expertise in hacking or security-related matters. It's important to note that the term is not likely associated with legitimate cybersecurity organizations but rather used in informal contexts.
    virginia beach personal injury attorney
    motorcycle accident virginia

    ReplyDelete
  33. I recently came across the phpMyAdmin 3.x preg_replace RCE POC, and I must say it's quite a significant discovery in the realm of web security. The proof-of-concept (POC) sheds light on a potential remote code execution vulnerability related to preg_replace in phpMyAdmin version 3.x. This finding highlights the importance of staying vigilant when it comes to securing web applications.

    The POC seems to pinpoint a specific weakness in phpMyAdmin's implementation, specifically in how it handles regular expressions. It serves as a wake-up call for developers and administrators to thoroughly review and fortify their codebase against such vulnerabilities. Security should always be a top priority, and this discovery emphasizes the need for regular audits and updates to ensure the safety of web applications.

    In the ever-evolving landscape of cybersecurity, staying informed about potential risks and vulnerabilities is crucial. Kudos to the researchers and contributors who unveiled this POC, as their efforts contribute to the collective goal of creating a more secure online environment. This discovery encourages a proactive approach to security, prompting developers to patch and update their systems promptly. Most students are drawn to these types of articles and information, but they are unable to prepare for their exams, If you have been struggling with your exams and want assistance, students can take my online class for me - take my class for me and get higher grades on their examinations by providing them with the best available resources, including quality academic services.

    ReplyDelete
  34. This proof of concept for the PHPMyAdmin vulnerability is both alarming and eye-opening. Developers must stay informed and proactive about security measures! Visit our link for ISO Certification In Philippines

    ReplyDelete