扫描目录下的php文件,是不是含有木马特征
扫描目录下的php文件,是否含有木马特征
shell_checkl
#!/usr/bin/python#-*- encoding:UTF-8 -*-##### @package## @desc 扫描目录下的php文件,是否含有木马特征,注意,不是“木马扫描”## @useage python shell_check.py /your/web/path/ 1=是否递归###import osimport sysimport reimport timedef listdir(dirs,liston='0'): flog = open(os.getcwd()+"/check_php_shell.log","a+") if not os.path.isdir(dirs): print "directory %s is not exist"% (dirs) return lists = os.listdir(dirs) for list in lists: filepath = os.path.join(dirs,list) if os.path.isdir(filepath): if liston == '1': listdir(filepath,'1') elif os.path.isfile(filepath): filename = os.path.basename(filepath) if re.search(r"\.(?:php|inc|html?)$", filename, re.IGNORECASE): i = 0 iname = 0 f = open(filepath) while f: file_contents = f.readline() if not file_contents: break i += 1 match = re.search(r'''(?P<function>\b(?:include|require)(?:_once)?\b)\s*\(?\s*["'](?P<filename>.*?(?eval|proc_open|popen|shell_exec|exec|passthru|system)\b\s*\(', file_contents, re.IGNORECASE| re.MULTILINE) if match: function = match.group("function") if iname == 0: info = '\n[%s] :\n'% (filepath) else: info = '' info += '\t|-- [%s] line [%d] \n'% (function,i) flog.write(info) print info iname += 1 match = re.findall(r'(\$[a-z0-9_]*?\s*?\(.*?\))', file_contents, re.IGNORECASE) if match: if iname == 0: info = '\n[%s] :\n'% (filepath) else: info = '' info += '\t|-- [%s] line [%d] \n'% (match[0],i) flog.write(info) print info iname += 1 f.close() flog.close()if '__main__' == __name__: argvnum = len(sys.argv) liston = '0' if argvnum == 1: action = os.path.basename(sys.argv[0]) print "Command is like:\n %s D:\wwwroot\ \n %s D:\wwwroot\ 1 -- recurse subfolders"% (action,action) quit() elif argvnum == 2: path = os.path.realpath(sys.argv[1]) listdir(path,liston) else: liston = sys.argv[2] path = os.path.realpath(sys.argv[1]) listdir(path,liston) 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 checked ---------------------\n"% (now_time)) flog.close()</filename></function>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to set the PATH environment variable in Linux systems In Linux systems, the PATH environment variable is used to specify the path where the system searches for executable files on the command line. Correctly setting the PATH environment variable allows us to execute system commands and custom commands at any location. This article will introduce how to set the PATH environment variable in a Linux system and provide detailed code examples. View the current PATH environment variable. Execute the following command in the terminal to view the current PATH environment variable: echo$P

Function means function. It is a reusable code block with specific functions. It is one of the basic components of a program. It can accept input parameters, perform specific operations, and return results. Its purpose is to encapsulate a reusable block of code. code to improve code reusability and maintainability.

Method to set the path environment variable: 1. Windows system, open "System Properties", click the "Properties" option, click "Advanced System Settings", in the "System Properties" window, select the "Advanced" tab, and then click "Environment Variables" " button, find and click "Path" to edit and save; 2. For Linux systems, open the terminal, open your bash configuration file, add "export PATH=$PATH: file path" at the end of the file and save it; 3. For MacOS system, the operation is the same as above.

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

In golang, filepath.Abs is a very commonly used library. Its function is to obtain the absolute path of a relative path. However, in some cases, we will find that we will encounter an "undefined: filepath.Abs" error when using filepath.Abs, which means that we did not introduce the filepath library correctly or wrote the wrong syntax. This article explains how to resolve this error. First, we need to understand

Detailed explanation of the role and function of the MySQL.proc table. MySQL is a popular relational database management system. When developers use MySQL, they often involve the creation and management of stored procedures (StoredProcedure). The MySQL.proc table is a very important system table. It stores information related to all stored procedures in the database, including the name, definition, parameters, etc. of the stored procedures. In this article, we will explain in detail the role and functionality of the MySQL.proc table

In this article, we will learn about enumerate() function and the purpose of “enumerate()” function in Python. What is the enumerate() function? Python's enumerate() function accepts a data collection as a parameter and returns an enumeration object. Enumeration objects are returned as key-value pairs. The key is the index corresponding to each item, and the value is the items. Syntax enumerate(iterable,start) Parameters iterable - The passed in data collection can be returned as an enumeration object, called iterablestart - As the name suggests, the starting index of the enumeration object is defined by start. if we ignore

How to correctly set the PATH environment variable in Linux In the Linux operating system, environment variables are one of the important mechanisms used to store system-level configuration information. Among them, the PATH environment variable is used to specify the directories in which the system searches for executable files. Correctly setting the PATH environment variable is a key step to ensure the normal operation of the system. This article will introduce how to correctly set the PATH environment variable in Linux and provide specific code examples. 1. Check the current PATH environment variable and enter the following command in the terminal
