Author Topic: php backdoor ++  (Read 4704 times)

0 Members and 1 Guest are viewing this topic.

Offline jay755

  • /dev/null
  • *
  • Posts: 9
  • Cookies: -1
    • View Profile
php backdoor ++
« on: February 19, 2013, 09:51:03 am »
Hi,

I am wanting to learn and work on a php backdoor. All c99 things get detected very fast and I want to make something easy and difficult to detect. Something which can go into existing files and work over POST so not to get in access logs with GET parameter.

Is there anybody who want to help and work together on it?

Jay

Offline DaNePaLI

  • Peasant
  • *
  • Posts: 55
  • Cookies: 12
  • Forever n00b
    • View Profile
Re: php backdoor ++
« Reply #1 on: February 19, 2013, 11:11:41 am »
Well I can't work together but I can surely give you some ideas that I have. First off, antivirii are dumb, chaning few streams (with all those IDEs, refactoring is an easy task) and adding/removing some data is enough to bypass most of the AVs I've seen.

Secondly, you know that you should use POST instead of GET so why not research on it? Its just like changing exec($_GET['cmd']); to exec($_POST['cmd']); (again refactoring can be employed here as well). Of course, you have to work on giving easier interface to process POST forms.

Moreover, most of the shells are likely to have the suspicious function calls such as eval(), system(), etc. These can be used to detect the presence of PHP based shells so there exist few methods to bypass such detections.

One idea is to use the php://input, which you can execute using the include() function. The data can be passed as POST data (check http://php.net/manual/en/wrappers.php.php ). From the PHP manual, php://input is a read-only stream that allows you to read raw data from the request body. In the case of POST requests, it is preferable to use php://input instead of $HTTP_RAW_POST_DATA as it does not depend on special php.ini directives. Hence you could exploit this feature to create undetectable web shells.

The other possibility is to pass both functions to be executed and argument to the function as the POST data and create the function call on the fly.

Yet other possibility is to hex edit some unsuspicious binary/image/mp3/etc file and insert the PHP backdoor in there. Your PHP script could then read the particular bytes from the binary file on the fly and execute them.

Just my ideas. If you didn't understand any, I am happy to write examples as well :)
« Last Edit: February 19, 2013, 11:12:58 am by DaNePaLI »

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: php backdoor ++
« Reply #2 on: February 19, 2013, 05:39:38 pm »
Moved
~Factionwars

Offline jay755

  • /dev/null
  • *
  • Posts: 9
  • Cookies: -1
    • View Profile
Re: php backdoor ++
« Reply #3 on: February 21, 2013, 09:33:24 am »

Secondly, you know that you should use POST instead of GET so why not research on it? Its just like changing exec($_GET['cmd']); to exec($_POST['cmd']); (again refactoring can be employed here as well). Of course, you have to work on giving easier interface to process POST forms.
Yes, I have done that, thank you for the suggestion.


One idea is to use the php://input, which you can execute using the include() function. The data can be passed as POST data (check http://php.net/manual/en/wrappers.php.php ). From the PHP manual, php://input is a read-only stream that allows you to read raw data from the request body. In the case of POST requests, it is preferable to use php://input instead of $HTTP_RAW_POST_DATA as it does not depend on special php.ini directives. Hence you could exploit this feature to create undetectable web shells.

Great, that sounds like a very good idea. Could you give a small example on how to use the php://input with the include function?


Yet other possibility is to hex edit some unsuspicious binary/image/mp3/etc file and insert the PHP backdoor in there. Your PHP script could then read the particular bytes from the binary file on the fly and execute them.
That sounds like a good idea as well. I will implement that too.

Thanks for your input, I will send you a pm when I have some code so you can look at it if you want?



Offline DaNePaLI

  • Peasant
  • *
  • Posts: 55
  • Cookies: 12
  • Forever n00b
    • View Profile
Re: php backdoor ++
« Reply #4 on: February 21, 2013, 07:25:29 pm »
Thanks for your input, I will send you a pm when I have some code so you can look at it if you want?

Well sir I'm out of reach from Internet for a while. PM me and I'll have a look on your script :)