PHP Classes

Bad PHP Code Scan: Scan PHP code files to find malicious code

Recommend this page to a friend!
  Info   Example   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (9 months ago) RSS 2.0 feedStarStarStar 52%Total: 505 All time: 5,792 This week: 38Up
Version License PHP version Categories
bad-code-scan 1.10GNU General Publi...5.3PHP 5, Files and Folders, Security
Description 

Author

This class can scan PHP code files to find malicious code.

It can traverse a given directory recursively to find files with a given file name extension that defaults to .php .

The class can scan the found files to determine if they contain code using eval and base64_decode function calls, which is a sign that the code may be hidding malicious code.

The class return an array with all potentially infected files, or list them in a HTML table.

Picture of Max Stemplevski
  Performance   Level  
Name: Max Stemplevski <contact>
Classes: 12 packages by
Country: Belarus Belarus
Age: 36
All time rank: 19418 in Belarus Belarus
Week rank: 44 Up1 in Belarus Belarus Up
Innovation award
Innovation award
Nominee: 5x

Example

<?php
require_once('badcodescan.php'); // include class

$ex_code_scan = new BadCodeScan; // create new object of BadCodeScan class

#Sample #1
$ex_code_scan->searchBadCode(); // search bad code by default mask and parameters ($path = '.', $mask = 'eval(base64_decode', $ext = '*.php')
$ex_code_scan->showResultTable(); // show result table (optional)


#Sample #2
$ex_code_scan = new BadCodeScan; // create new object of BadCodeScan class (optional: you can collect multiple results by other masks)
$ex_code_scan->searchBadCode( '.', 'system(', '*.txt' ); // search bad code by custom mask and parameters.
$ex_code_scan->showResultTable(); // show result table (optional)

#Sample #3
$ex_code_scan = new BadCodeScan;
$ex_code_scan->searchBadCode( '.', ',""); /\*');
$ex_code_scan->showResultTable();


Details

badcode_search

BadCodeScan class for searching bad commands in files on your server.


Screenshots (1)  
  • results
  Files folder image Files (8)  
File Role Description
Files folder imagetest_folder (2 files, 1 directory)
Plain text file badcodescan.php Class Class source
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file README.md Data Auxiliary data

  Files folder image Files (8)  /  test_folder  
File Role Description
Files folder imagetest_subfolder (2 files)
  Accessible without login Plain text file infected.html Data Auxiliary data
  Accessible without login Plain text file infected.php Test Unit test script

  Files folder image Files (8)  /  test_folder  /  test_subfolder  
File Role Description
  Accessible without login Plain text file infected.php Test Unit test script
  Accessible without login Plain text file infected.txt Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 87%
Total:505
This week:0
All time:5,792
This week:38Up
User Ratings User Comments (1)
 All time
Utility:58%StarStarStar
Consistency:83%StarStarStarStarStar
Documentation:-
Examples:91%StarStarStarStarStar
Tests:58%StarStarStar
Videos:-
Overall:52%StarStarStar
Rank:2421
 
Will not be as useful than a simple grep/sort line.
10 years ago (Ludovic Bellière)
27%StarStar