zoukankan      html  css  js  c++  java
  • 检测php网站是否已经被攻破

    from :http://www.gregfreeman.org/2013/how-to-tell-if-your-php-site-has-been-compromised/

    http://drops.wooyun.org/web/2718

    0x01 查看访问日志
    PREMOVED - - [01/Mar/2013:06:16:48 -0600] "POST/uploads/monthly_10_2012/view.php HTTP/1.1" 200 36 "-" "Mozilla/5.0"
    IPREMOVED - - [01/Mar/2013:06:12:58 -0600] "POST/public/style_images/master/profile/blog.php HTTP/1.1" 200 36 "-" "Mozilla/5.0"

    nginx默认记录的日志格式为:
    access_log logs/access.log
    access_log logs/access.log combined;

    nginx默认记录日志的位置为:
    nginx安装目录/log/

    0x02 查找含有恶意php代码的文件

    2.1 查找最近发生变化的php文件
    find . -type f -name '*.php' -mtime -7
    -type f 表示搜索正常的一般文件 -mtime -7 表示7*24小时内修改的文件

    2.2 查找文件中是否存在疑似代码
    find . -type f -name '*.php' | xargs grep -l "eval *(" --color
    (*代表任意个空格)

    find . -type f -name '*.php' | xargs grep -l "base64_decode *(" --color
    find . -type f -name '*.php' | xargs grep -l "gzinflate *(" --color
    find . -type f -name '*.php' | xargs grep -l "eval *(str_rot13 *(base64_decode *(" --color

    0x03 比较代码文件
    diff -r wordpress-clean/ wordpress-compromised/ -x wp-content
    上面的例子是比较wordpress-clean/ 和wordpress-comprised/两个目录,并且目录里面的wp-content/子目录不比较

    0x04 搜寻可写的目录
    看这个目录里面是否有可疑文件,如下脚本查找权限为777的目录是否存在php文件
    search_dir=$(pwd)
    writable_dirs=$(find $search_dir -type d -perm 0777)
    for dir in $writable_dirs
    do
    #echo $dir
    find $dir -type f -name '*.php'
    done

    黑客经常在jpg文件中插入php代码,因此在查询这些目录的时候也要查询jpg文件:
    find wp-content/uploads -type f -iname '*.jpg' | xargs grep -i php
    注意:-iname 表示文件名不区分大小写 grep -i 也表示不区分大小写

    0x05 检测iframe标签
    grep -i '

    0x06 查找数据库中是否存在敏感字符串
    包括%base64_%、%eval(%<等上面提到的一些关键词

    0x07 检查.htaccess文件
    是否包含了auto_prepend_file和auto_append_file,使用如下命令
    find . -type f -name '.htaccess' | xargs grep -i auto_prepend_file
    find . -type f -name '.htaccess' | xargs grep -i auto_append_file

  • 相关阅读:
    Maximum sum-动态规划
    Ubuntu14下Hadoop开发&lt;1&gt; 基础环境安装
    POJ 3252 Round Numbers 数学题解
    ubuntu环境 rake aborted!
    oracle decode函数用法
    Android多线程研究(1)——线程基础及源码剖析
    2014冬去春来
    Android中的动画详解系列【4】——Activity之间切换动画
    JavaScript你所不知道的困惑(3)
    研发人员技术定级的一些思考
  • 原文地址:https://www.cnblogs.com/lly-lly/p/5390846.html
Copyright © 2011-2022 走看看