Results 1 to 7 of 7

Thread: PHP OOP over-ride resulting in memory choke up Share/Save - My123World.Com!

  1. #1

    Lightbulb PHP OOP over-ride resulting in memory choke up

    Hi Guys,

    It is interesting to write about real life stories that you come across when machines act as if they are machines with no intelligence :P

    here is mine.

    I was playing around with object oriented programming and was also studying about the infinite loops which causes denial of service or system crashes.

    I tried to create an infinite loop in php using simple object oriented functions

    A waits for B
    B waits for A
    and memory keeps increasing till it is exhausted.

    Fatal error eh!


    here is a code snippet:

    I have 3 files:
    index.php - to instantiate the objects of the classes
    class1.php - which inherits class2
    class2.php - which inherits class1

    class1 and class2 are created to create the forever loop and index to initialize that loop.

    index.php

    PHP Code:
    <?php
    /*

    */
    $var = new class1();
    $var2 = new class2();
    ?>





    class1.php

    PHP Code:
    <?php
        
    include 'class2.php';
        class 
    class1 extends class2
        
    {
            public function 
    __construct()
            {
                return 
    parent::__construct();
            }
        }
    ?>



    class2.php
    PHP Code:
    <?php
        
    include 'class1.php';
        class 
    class2 extends class1
        
    {
            public function 
    __construct()
            {
                return 
    parent::__construct();
            }
        }
    ?>

    Do not do dirty, if you are shared server, respect others business.

    This is intended just for information.


    Thanks to fb1h2s and b0nd for writing few articles recently that - fired my butt to write something here
    Last edited by keval_domadia; 12-18-2010 at 07:31 AM. Reason: Edited 3 lines, Just coz I remembered "never trust a scriptie" copy paste can be harmful.

  2. #2
    sorry to double post, but i have removed the 3 important lines tht could ACTUALLY cause harm. Smart ones need the logic not the script

  3. #3
    Security Researcher fb1h2s's Avatar
    Join Date
    Jul 2010
    Location
    India
    Posts
    616
    Blog Entries
    32
    Great... good to see you are back on track . Will check this thing some time . Keep posting
    Hacking Is a Matter of Time Knowledge and Patience

  4. #4
    Nice keep sharing bro

  5. #5
    Garage Member D4rk357's Avatar
    Join Date
    Jul 2010
    Location
    localhost@mumbai
    Posts
    153
    Blog Entries
    1
    Cool share keep 'em coming .. i am learning a lot from your posts
    Spirit was turned 2 ashes ,soul endured so much pain..
    now the darker time evanescence ,the fallen shall rise again.

  6. #6
    nice idea the script should cause a memory leak, but other hosts on the shared server would be immune since each virtual host has a limited resource and when you exceed it you would be cut off. have you come across any shared host otherwise ?

  7. #7
    Yes sandeep, I tried it on dollar2host provider and because of the first 3 lines (which I chucked off from here), it worked wonder...
    However, I also reported this to php.net and so far, there is no patch for it... hopefully, very soon

    "virtual host has a limited resource and when you exceed it you would be cut off"
    Yep, thats the whole point... U cannot allocate resources based on every single account, it is for ENTIRE apache
    31337 - 7H15 15 4n 4nn071ng!
    Study English - write Eleet

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •