The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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:
    6
    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:
    1
    Location:
    india
  3. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    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:
    0
    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:
    6
    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:
    6
    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