ホームページ  >  記事  >  バックエンド開発  >  PHP が Webshel​​l 処理関数を妨げる_PHP チュートリアル

PHP が Webshel​​l 処理関数を妨げる_PHP チュートリアル

WBOY
WBOYオリジナル
2016-07-13 17:09:561040ブラウズ


OSをインポート
システムをインポートします
輸入再
輸入時間
def listdir(dirs,liston='0'):
flog = open(os.getcwd()+"/check_php教程_shell.log","a+")
そうでない場合は os.path.isdir(dirs):
print "ディレクトリ %s は存在しません"% (dirs)
戻る
リスト = os.listdir(dirs)
リスト内のリストの場合:
ファイルパス = os.path.join(dirs,list)
os.path.isdir(ファイルパス)の場合:
リストン == '1' の場合:
listdir(ファイルパス,'1')
elif os.path.isfile(ファイルパス):
ファイル名 = os.path.basename(ファイルパス)
if re.search(r".(?:php|inc|html?)$", ファイル名, re.ignorecase):
i = 0
イネーム = 0
f = オープン(ファイルパス)
一方、f:
file_contents = f.readline()
file_contents でない場合:
休憩
私 += 1
match = re.search(r'''(?pb(?:include|require)(?:_once)?b)s*(?s*["'](?p[^ ;]*(? 一致する場合:
関数 = match.group("関数")
ファイル名 = match.group("ファイル名")
iname == 0の場合:
info = 'n[%s] :n'% (ファイルパス)
その他:
情報 = ''
info += 't|-- [%s] - [%s] 行 [%d] n'% (関数,ファイル名,i)
flog.write(情報)
印刷情報
イネーム += 1
match = re.search(r'b(?peval|proc_open|popen|shell_exec|exec|passthru|system|assert|fwrite|create_function)bs*(', file_contents, re.ignorecase| re.multiline)
一致する場合:
関数 = match.group("関数")
iname == 0の場合:
info = 'n[%s] :n'% (ファイルパス)
その他:
情報 = ''
info += 't|-- [%s] 行 [%d] n'% (関数,i)
flog.write(情報)
印刷情報
イネーム += 1
match = re.search(r'(^|(?<=;))s*`(?p[^`]+)`s*;', file_contents, re.ignorecase)
一致する場合:
シェル = match.group("シェル")
iname == 0の場合:
info = 'n[%s] :n'% (ファイルパス)
その他:
情報 = ''
info += 't|-- [``] コマンドは [%d] 行目の [%s] n'% (shell,i)
flog.write(情報)
印刷情報
イネーム += 1
match = re.search(r'(?p$_(?:pos|ge|reques)t)s*[[^]]+]s*(', file_contents, re.ignorecase)
一致する場合:
シェル = match.group("シェル")
iname == 0の場合:
info = 'n[%s] :n'% (ファイルパス)
その他:
情報 = ''
info += 't|-- [``] コマンドは [%d] 行目の [%s] n'% (shell,i)
flog.write(情報)
印刷情報
イネーム += 1
f.close()
flog.close()
if '__main__' == __name__:
argvnum = len(sys.argv)
リストン = '0'
argvnum == 1の場合:
アクション = os.path.basename(sys.argv[0])
print "コマンドは次のとおりです:n %s d:wwwroot n %s d:wwwroot 1 -- サブフォルダーを再帰します"% (アクション,アクション)
やめます()
elif argvnum == 2:
パス = os.path.realpath(sys.argv[1])
listdir(パス,リストン)
その他:
リストン = sys.argv[2]
パス = os.path.realpath(sys.argv[1])
listdir(パス,リストン)
flog = open(os.getcwd()+"/check_php_shell.log","a+")
isotimeformat='%y-%m-%d %x'
now_time = time.strftime(isotimeformat,time.localtime())
flog.write("n----------%s がチェックされました ------------------- --n"% (現時点))
flog.close()

www.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/629713.html技術記事 import os import sys import re import time def listdir(dirs,liston='0'): flog = open(os.getcwd()+/check_php教程_shell.log,a+) if not os.path.isdir(dirs) : 印刷ディレクトリ %s はありません...
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。