Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Find PHP shell_exec

Discussion in 'General Discussion' started by rkm11, Oct 17, 2008.

  1. rkm11

    rkm11 Active Member

    Joined:
    May 30, 2007
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    156
    I am looking to secure my server, and I need to know how many scripts are using shell_exec before I block that command. Is there a way I can log the scripts that use this command?

    Thanks,
    Ryan
     
  2. anilg

    anilg Member

    Joined:
    Oct 15, 2008
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    51
    Location:
    india
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,216
    Likes Received:
    10
    Trophy Points:
    313
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    A grep on .php files for shell_exec may do the trick.

    If you're unfamiliar with how to do this, there's been quite a few quick shell scripts posted to these forums that make use of grep that could possibly be modified to suit your needs.
     
  4. forum17

    forum17 Active Member

    Joined:
    Mar 30, 2007
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    151
    If you want to locate all script from /home partition which are using shell_exec then try these commands

    cd /home
    find -type f | xargs grep -l shell_exec

    This command will give you list of all files which contains words shell_exec .

    Regards,
    Angelo S.
    http://midnight-cafe.co.uk
     
  5. rkm11

    rkm11 Active Member

    Joined:
    May 30, 2007
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    156
    Thanks, I didn't know how to use grep with searching directories while at the same time only .php files. What command in addition to this (find -type f | xargs grep -l shell_exec) would search only .php files?

    Thanks,
    Ryan
     
  6. rkm11

    rkm11 Active Member

    Joined:
    May 30, 2007
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    156
    I think I figured it out!

    find -type f -name '*.php' | xargs grep -l shell_exec

    Thanks for all the help!
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice