PHP Classes

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

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (4 days ago) RSS 2.0 feedNot enough user ratingsTotal: 502 This week: 5All time: 5,795 This week: 71Up
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
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  
  • results
  Files folder image Files  
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  /  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  /  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

 Version Control Unique User Downloads Download Rankings  
 87%
Total:502
This week:5
All time:5,795
This week:71Up
User Comments (1)
Will not be as useful than a simple grep/sort line.
9 years ago (Ludovic Bellière)
27%StarStar