Skip to content

Instantly share code, notes, and snippets.

@ricardojba
Forked from mgeeky/php-egrep-sast-scan.sh
Created September 3, 2019 10:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricardojba/6aac5203b6ec8e7d95ea1c7ad3a977a9 to your computer and use it in GitHub Desktop.
Save ricardojba/6aac5203b6ec8e7d95ea1c7ad3a977a9 to your computer and use it in GitHub Desktop.
egrep expression to scan PHP sources for invocation of potentially dangerous functions.
#!/bin/bash
P="*"
if [ -n "$1" ]; then
P="$1"
fi
grep -E "\spassthru\(|\sexec\(|\spnctl_exec\(|\sproc_open\(|\spopen\(|\ssystem\(|\sshell_exec\(|\sregister_shutdown_function\(|\sregister_tick_function\(|\seval\(|\sexpect_popen\(|\sapache_child_terminate\(|\slink\(|\sposix_kill\(|\sposix_mkfifo\(|\sposix_setpgid\(|\sposix_setsid\(|\sposix_setuid\(|\sproc_close\(|\sproc_get_status\(|\sproc_nice\(|\sproc_terminate\(|\sputenv\(|\stouch\(|\salter_ini\(|\shighlight_file\(|\sshow_source\(|\sini_alter\(|\sfgetcsv\(|\sfputcsv\(|\sfpassthru\(|\sini_get_all\(|\sopenlog\(|\ssyslog\(|\srename\(|\sparse_ini_file\(|\sftp_connect\(|\sftp_ssl_connect\(|\sfsockopen\(|\spfsockopen\(|\ssocket_bind\(|\ssocket_connect\(|\ssocket_listen\(|\ssocket_create_listen\(|\ssocket_accept\(|\ssocket_getpeername\(|\ssocket_send\(|\sapache_get_modules\(|\sapache_get_version\(|\sapache_getenc\(|\sapache_note\(|\sapache_setenv\(|\sapache_request_headers\(|\sdiskfreespace\(|\sdisk_free_space\(|\sget_current_user\(|\sgetmypid\(|\sgetmyuid\(|\sgetrusage\(|\sset_time_limit\(|\sshow_source\(|\ssymlink\(|\stmpfile\(|\svirtual\(|\sphpinfo\(|\smax_execution_time\(|\sset_include_path\(|\sescapeshellcmd\(|\sescapeshellarg" -R $P
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment