nuclei-templates/file/php/php-scanner.yaml

313 lines
6.6 KiB
YAML
Raw Permalink Normal View History

2021-08-05 00:18:37 +00:00
id: php-scanner
info:
name: PHP Scanner
author: geeknik
severity: info
tags: php,file
file:
- extensions:
- html
- htm
2021-08-05 00:18:37 +00:00
- phtml
- php
- php3
- php4
- php5
- phps
- cgi
- inc
- tpl
- test
- module
- plugin
2021-08-05 00:18:37 +00:00
extractors:
- type: regex
# Investigate for possible SQL Injection
# Likely vulnerable: $dbConn->GetRow("SELECT * FROM users WHERE id = $user_id");
# Likely not Vulnerable: $dbConn->GetRow("SELECT * FROM users WHERE id = ?", array('$user_id'));
2021-08-05 00:18:37 +00:00
regex:
- '(?i)getone|getrow|getall|getcol|getassoc|execute|replace'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Warn when var_dump is found
regex:
- 'var_dump'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Warn when display_errors is enabled manually
regex:
- 'display_errors'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Avoid the use of eval()
regex:
- 'eval'
- 'eval\((base64|eval|\$_|\$\$|\$[A-Za-z_0-9\{]*(\(|\{|\[))'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Avoid the use of exit or die()
regex:
- 'exit'
- 'die'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Avoid the use of logical operators (ex. using and over &&)
regex:
- 'and'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Avoid the use of the ereg* functions (now deprecated)
regex:
- 'ereg'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Ensure that the second parameter of extract is set to not overwrite (not EXTR_OVERWRITE)
regex:
- 'extract'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Checking output methods (echo, print, printf, print_r, vprintf, sprintf) that use variables in their options
regex:
- 'echo'
- 'print'
- 'printf'
- 'print_r'
- 'vprintf'
- 'sprintf'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Ensuring you're not using echo with file_get_contents
regex:
- 'file_get_contents'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Testing for the system execution functions and shell exec (backticks)
regex:
- '\\`'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Use of readfile, readlink and readgzfile
regex:
- 'readfile'
- 'readlink'
- 'readgzfile'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Using parse_str or mb_parse_str (writes values to the local scope)
regex:
- 'parse_st'
- 'mb_parse_str'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Using session_regenerate_id either without a parameter or using false
regex:
- 'session_regenerate'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Avoid use of $_REQUEST (know where your data is coming from)
regex:
- '\\$_REQUEST'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Don't use mysql_real_escape_string
regex:
- 'mysql_real_escape_string'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Avoiding use of import_request_variables
regex:
- 'import_request_variables'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Avoid use of GLOBALS
2021-08-05 00:18:37 +00:00
regex:
- 'GLOBALS'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
regex:
- '_GET'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
regex:
- '_POST'
2023-10-14 11:27:55 +00:00
- type: regex
regex:
- '_COOKIE'
2023-10-14 11:27:55 +00:00
- type: regex
regex:
- '_SESSION'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Ensure the use of type checking validating against booleans (===)
regex:
- '\\=\\=\\='
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Ensure that the /e modifier isn't used in regular expressions (execute)
regex:
- '\\/e'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Using concatenation in header() calls
regex:
- 'header'
2023-10-14 11:27:55 +00:00
2021-08-05 00:18:37 +00:00
- type: regex
# Avoiding the use of $http_raw_post_data
regex:
- '\\$http_raw_post_data'
2023-10-14 11:27:55 +00:00
- type: regex
# interesting functions for POP/Unserialize
regex:
- "__autoload"
- "__destruct"
- "__wakeup"
- "__toString"
- "__call"
- "__callStatic"
- "__get"
- "__set"
- "__isset"
- "__unset"
2023-10-14 11:27:55 +00:00
2021-08-27 14:17:57 +00:00
- type: regex
# phpinfo detected
regex:
- "phpinfo"
2023-10-14 11:27:55 +00:00
- type: regex
# registerPHPFunctions() allows code exec in XML
regex:
- "registerPHPFunctions"
2023-10-14 11:27:55 +00:00
- type: regex
regex:
- "session_start"
2023-10-14 11:27:55 +00:00
- type: regex
# dBase DBMS
regex:
- "dbase_open"
2023-10-14 11:27:55 +00:00
- type: regex
# DB++ DBMS
regex:
- "dbplus_open"
- "dbplus_ropen"
2023-10-14 11:27:55 +00:00
- type: regex
# Frontbase DBMS
regex:
- "fbsql_connect"
2023-10-14 11:27:55 +00:00
- type: regex
# Informix DBMS
regex:
- "ifx_connect"
2023-10-14 11:27:55 +00:00
- type: regex
# IBM DB2 DBMS
regex:
- "db2_(p?)connect"
2023-10-14 11:27:55 +00:00
- type: regex
# FTP server
regex:
- "ftp_(ssl_)?connect"
2023-10-14 11:27:55 +00:00
- type: regex
# Ingres DBMS
regex:
- "ingres_(p?)connect"
2023-10-14 11:27:55 +00:00
- type: regex
# LDAP server
regex:
- "ldap_connect"
2023-10-14 11:27:55 +00:00
- type: regex
# msession server
regex:
- "msession_connect"
2023-10-14 11:27:55 +00:00
- type: regex
# mSQL DBMS
regex:
- "msql_(p?)connect"
2023-10-14 11:27:55 +00:00
- type: regex
# MsSQL DBMS
regex:
- "mssql_(p?)connect"
2023-10-14 11:27:55 +00:00
- type: regex
# MySQL DBMS
regex:
- "mysql_(p?)connect"
2023-10-14 11:27:55 +00:00
- type: regex
# MySQLi Extension
regex:
- "mysqli((_real)?_connect)?|_query"
2023-10-14 11:27:55 +00:00
- type: regex
# Oracle OCI8 DBMS
regex:
- "oci|(_new?)|_connect|(n?|p?)logon"
2023-10-14 11:27:55 +00:00
- type: regex
# Oracle DBMS
regex:
- "ora_(p?)connect"
2023-10-14 11:27:55 +00:00
- type: regex
# Ovrimos SQL DBMS
regex:
- "ovrimos_connect"
2023-10-14 11:27:55 +00:00
- type: regex
# PostgreSQL DBMS
regex:
- "pg_(p?)connect"
2023-10-14 11:27:55 +00:00
- type: regex
# SQLite DBMS
regex:
- "sqlite_(p?)open"
2023-10-14 11:27:55 +00:00
- type: regex
# SQLite3 DBMS
regex:
- "SQLite3"
2023-10-14 11:27:55 +00:00
- type: regex
# Sybase DBMS
regex:
- "sybase_(p?)connect"
2023-10-14 11:27:55 +00:00
- type: regex
# TokyoTyrant DBMS
regex:
- "TokyoTyrant"
2023-10-14 11:27:55 +00:00
- type: regex
# XML document
regex:
- "x(ptr|path)_new_context"
2023-10-14 11:27:55 +00:00
2021-09-30 22:58:15 +00:00
- type: regex
# Investigate if GetTableFields is called safely
regex:
- "GetTableFields"
2023-10-14 11:27:55 +00:00
2021-09-30 22:58:15 +00:00
- type: regex
regex:
- "ini_get.*magic_quotes_gpc.*"
# digest: 4a0a00473045022100cdc04b80c9479b1a4fe8a4dd836ca51e473d21b6dfee8a10d4766eab8980dd66022002ed5ea70b600f04f8842ba1b24b70122656832d5769131b53c765c8f678a62a:922c64590222798bb761d5b6d8e72950