pax_global_header00006660000000000000000000000064147055210030014507gustar00rootroot0000000000000052 comment=152dec43e243d132f96112514516ecb3012b02e3 cmsscanner-0.1.2/000077500000000000000000000000001470552100300136435ustar00rootroot00000000000000cmsscanner-0.1.2/.gitignore000066400000000000000000000000231470552100300156260ustar00rootroot00000000000000debian/cmsscanner/ cmsscanner-0.1.2/README.md000066400000000000000000000024461470552100300151300ustar00rootroot00000000000000# CMS Scanner This is a small php program that scans a folder and its subfolders for any known PHP program. It just echoes the software + version + path found. (next, you can use the [cmschecker](https://octoforge.fr/octopuce/cmschecker) micro-service to check the checksums of files for the program.) # Usage: ``` cmsscanner ``` This will scan (which must be a directory that the current Linux user can access). the output is ``` software name version path where it has been found. ``` If a sub directory can't be opened or has been removed while scanning, the first word on the line will be "ERROR:" # Known software: The currently recognized software are in src/softs/ folder, and are the following : Dokuwiki Dolibarr Drupal Joomla Nextcloud Phpmyadmin Prestashop Roundcube Spip Wordpress # Developpment: If you want to add another free software (ideally we'd like to focus on PHP-based software, mostly used in shared hosting), feel free to send a pull-request. Please note that the scanner will, by default, not cross filesystem boundaries. Typically, if your server has a NFS share mounted in a folder below the scanned , it will not be scanned inside the NFS. The License for this software is GPL v3+. Please see debian/Copyright cmsscanner-0.1.2/debian/000077500000000000000000000000001470552100300150655ustar00rootroot00000000000000cmsscanner-0.1.2/debian/.debhelper/000077500000000000000000000000001470552100300170755ustar00rootroot00000000000000cmsscanner-0.1.2/debian/.debhelper/generated/000077500000000000000000000000001470552100300210335ustar00rootroot00000000000000cmsscanner-0.1.2/debian/.debhelper/generated/cmsscanner/000077500000000000000000000000001470552100300231675ustar00rootroot00000000000000cmsscanner-0.1.2/debian/.debhelper/generated/cmsscanner/dh_installchangelogs.dch.trimmed000066400000000000000000000002641470552100300314650ustar00rootroot00000000000000cmsscanner (0.1) stable; urgency=low * Initial project: scan folders and subfolders for a known CMS -- Benjamin Sonntag Wed, 16 Oct 2024 15:48:00 +0200 cmsscanner-0.1.2/debian/.debhelper/generated/cmsscanner/installed-by-dh_install000066400000000000000000000000361470552100300276170ustar00rootroot00000000000000./src/scanner.php ./src/softs cmsscanner-0.1.2/debian/.debhelper/generated/cmsscanner/installed-by-dh_installdocs000066400000000000000000000000001470552100300304570ustar00rootroot00000000000000cmsscanner-0.1.2/debian/changelog000066400000000000000000000010301470552100300167310ustar00rootroot00000000000000cmsscanner (0.1.2) buster bullseye bookworm; urgency=low * fix: little bug in Drupal.php -- Benjamin Sonntag Mon, 21 Oct 2024 20:46:00 +0200 cmsscanner (0.1.1) buster bullseye bookworm; urgency=low * Set available package from buster to bookworm -- Camille Lafitte Mon, 21 Oct 2024 17:00:00 +0200 cmsscanner (0.1) stable; urgency=low * Initial project: scan folders and subfolders for a known CMS -- Benjamin Sonntag Wed, 16 Oct 2024 15:48:00 +0200 cmsscanner-0.1.2/debian/cmsscanner.debhelper.log000066400000000000000000000000131470552100300216470ustar00rootroot00000000000000dh_install cmsscanner-0.1.2/debian/cmsscanner.substvars000066400000000000000000000000401470552100300211710ustar00rootroot00000000000000misc:Depends= misc:Pre-Depends= cmsscanner-0.1.2/debian/cmsscanner/000077500000000000000000000000001470552100300172215ustar00rootroot00000000000000cmsscanner-0.1.2/debian/cmsscanner/DEBIAN/000077500000000000000000000000001470552100300201435ustar00rootroot00000000000000cmsscanner-0.1.2/debian/cmsscanner/DEBIAN/control000066400000000000000000000005551470552100300215530ustar00rootroot00000000000000Package: cmsscanner Version: 0.1 Architecture: all Maintainer: Benjamin Sonntag Installed-Size: 32 Depends: php-cli Section: admin Priority: optional Description: Scan CMS hosted on a server This package scan a folder and its subfolder and search for known PHP applications there. it echoes the list of detected programs and their version. cmsscanner-0.1.2/debian/cmsscanner/DEBIAN/md5sums000066400000000000000000000016351470552100300214700ustar00rootroot000000000000007ff36a5619f84df989f6ea1fc30b5613 usr/lib/cmsscanner/scanner.php abd1018a324b68199dbc4eed9516f396 usr/lib/cmsscanner/softs/Dokuwiki.php 64ee7d776d6fdc2c9693717718e2f6e2 usr/lib/cmsscanner/softs/Dolibarr.php 71fe98bb44c891dde2b7e982e23dab86 usr/lib/cmsscanner/softs/Drupal.php 81d6c1fe5a729d2a1d17417b1ea7b843 usr/lib/cmsscanner/softs/Joomla.php ac73a05710c7fb9469f39ae80aa39dd8 usr/lib/cmsscanner/softs/Nextcloud.php c08e4914c9a33128d85e881982edbd05 usr/lib/cmsscanner/softs/Phpmyadmin.php 0270b2e1ae57b635d6aac709f3600f67 usr/lib/cmsscanner/softs/Prestashop.php 83b6e189cdef607e533e2ed5d10058d8 usr/lib/cmsscanner/softs/Roundcube.php dead35fad4a2197559e208bdf9a26e0c usr/lib/cmsscanner/softs/Spip.php 5cc4c442d9cc389477ad234f71ae758e usr/lib/cmsscanner/softs/Wordpress.php c055e402b163c07927eaca3ba7224411 usr/share/doc/cmsscanner/changelog.gz 23f1fe493c2067e30c0d8fe0df9d2c49 usr/share/doc/cmsscanner/copyright cmsscanner-0.1.2/debian/cmsscanner/usr/000077500000000000000000000000001470552100300200325ustar00rootroot00000000000000cmsscanner-0.1.2/debian/cmsscanner/usr/bin/000077500000000000000000000000001470552100300206025ustar00rootroot00000000000000cmsscanner-0.1.2/debian/cmsscanner/usr/bin/cmsscanner000077700000000000000000000000001470552100300301332../lib/cmsscanner/scanner.phpustar00rootroot00000000000000cmsscanner-0.1.2/debian/cmsscanner/usr/lib/000077500000000000000000000000001470552100300206005ustar00rootroot00000000000000cmsscanner-0.1.2/debian/cmsscanner/usr/lib/cmsscanner/000077500000000000000000000000001470552100300227345ustar00rootroot00000000000000cmsscanner-0.1.2/debian/cmsscanner/usr/lib/cmsscanner/scanner.php000077500000000000000000000033121470552100300251000ustar00rootroot00000000000000#!/usr/bin/php \n"; exit(); } $root=realpath($argv[1]); if (!$root || !is_dir($root)) { echo "FATAL: $root is not a directory or can't be opened\n"; } $t=stat($root); $fs=$t["dev"]; // we don't cross filesystems. $d=@opendir(__DIR__."/softs"); if (!$d) die("FATAL: Can't open softs/ folder in the code."); while (($c=readdir($d))!==false) { if (substr($c,-4)==".php") { require_once(__DIR__."/softs/".$c); $classname=substr($c,0,-4); $classes[strtolower($classname)]=new $classname(); } } closedir($d); scanner($root); function scanner($root,$level=0) { global $fs,$classes; foreach($classes as $class=>$object) { if ($version = $object->search($root)) { echo "$class $version $root\n"; } } $d=@opendir($root); if (!$d) { echo "ERROR: Can't open folder $root (deleted or permission denied)\n"; return; } $root=rtrim($root,"/"); while (($c=readdir($d))!==false) { if ($c=="." || $c=="..") continue; if (is_link($root."/".$c)) continue; if (is_dir($root."/".$c)) { $t=stat($root."/".$c); if ($t["dev"]!=$fs) continue; // we skip subfolders in OTHER filesystems (nfs, crossmounts ...) scanner($root."/".$c,$level+1); // recursive call. } } closedir($d); } cmsscanner-0.1.2/debian/cmsscanner/usr/lib/cmsscanner/softs/000077500000000000000000000000001470552100300240725ustar00rootroot00000000000000cmsscanner-0.1.2/debian/cmsscanner/usr/lib/cmsscanner/softs/Dokuwiki.php000066400000000000000000000012611470552100300263710ustar00rootroot00000000000000parseversion($root."/includes/version.php"); if ($v) return $v; } if (is_file($root."/libraries/joomla/version.php")) { $v=$this->parseversion($root."/libraries/joomla/version.php"); if ($v) return $v; } if (is_file($root."/libraries/cms/version/version.php")) { $v=$this->parseversion($root."/libraries/cms/version/version.php"); if ($v) return $v; } if (is_file($root."/libraries/src/Version.php")) { $version=false; $minor=false; $patch=false; $f=fopen($root."/libraries/src/Version.php","rb"); if (!$f) return false; while($s=fgets($f,1024)) { if (preg_match('#const\s+MAJOR_VERSION\s+=\s+([0-9]+);#',$s,$mat)) { $version=$mat[1]; } if (preg_match('#const\s+MINOR_VERSION\s+=\s+([0-9]+);#',$s,$mat)) { $minor=$mat[1]; } if (preg_match('#const\s+PATCH_VERSION\s+=\s+([0-9]+);#',$s,$mat)) { $patch=$mat[1]; } } fclose($f); if ($version && $minor && $patch) return $version.".".$minor.".".$patch; } return false; } // search function parseversion($file) { $version=false; $patch=false; $f=fopen($file,"rb"); if (!$f) return false; while($s=fgets($f,1024)) { if (preg_match('#var\s+\$RELEASE\s+=\s+\'([^\']+)\';#',$s,$mat)) { $version=$mat[1]; } if (preg_match('#var\s+\$DEV_LEVEL\s+=\s+\'([^\']+)\';#',$s,$mat)) { $patch=$mat[1]; } } fclose($f); if ($version && $patch) return $version.".".$patch; return false; } } // class Joomla cmsscanner-0.1.2/debian/cmsscanner/usr/lib/cmsscanner/softs/Nextcloud.php000066400000000000000000000024171470552100300265540ustar00rootroot00000000000000set('PMA_VERSION', '2.11.11'); $f=fopen($root."/libraries/Config.class.php","rb"); if (!$f) return false; while($s=fgets($f,1024)) { if (preg_match('#\$this->set\([\'"]PMA_VERSION[\'"],\s*[\'"](.*)[\'"]\);#',$s,$mat)) { fclose($f); return $mat[1]; } } fclose($f); return false; } if (is_dir($root."/libraries") && is_file($root."/package.json") && filesize($root."/package.json")<100000) { $f=json_decode(file_get_contents($root."/package.json"),true); if (!$f) return false; if ($f["name"]=="phpmyadmin") return $f["version"]; } return false; } // search } // class Phpmyadmin cmsscanner-0.1.2/debian/cmsscanner/usr/lib/cmsscanner/softs/Prestashop.php000066400000000000000000000032211470552100300267310ustar00rootroot00000000000000=8 if (is_file($root."/app/metadata.json") && filesize($root."/app/metadata.json")<1048576) { $f=json_decode(file_get_contents($root."/app/metadata.json"),true); if (isset($f["version"])) return $f["version"]; } // <8 if (is_file($root."/app/AppKernel.php")) { $f=fopen($root."/app/AppKernel.php","rb"); if (!$f) return false; while($s=fgets($f,1024)) { if (preg_match('#const VERSION\s*=\s*[\'"](.*)[\'"];#',$s,$mat)) { fclose($f); return $mat[1]; } } fclose($f); } // VERY old ~1.6.1.9 if (is_file($root."/install/install_version.php")) { $f=fopen($root."/install/install_version.php","rb"); if (!$f) return false; while($s=fgets($f,1024)) { if (preg_match('#define\(\'_PS_INSTALL_VERSION_\',\s*[\'"](.*)[\'"]\);#',$s,$mat)) { fclose($f); return $mat[1]; } } fclose($f); } } return false; } // search } // class Prestashop cmsscanner-0.1.2/debian/cmsscanner/usr/lib/cmsscanner/softs/Roundcube.php000066400000000000000000000017721470552100300265400ustar00rootroot00000000000000jkv ~X[8]!qQ2Jv{ W,G,u!""z2==cmsscanner-0.1.2/debian/cmsscanner/usr/share/doc/cmsscanner/copyright000066400000000000000000000020741470552100300257730ustar00rootroot00000000000000 Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: cmsscanner Source: https://octoforge.fr/octopuce/cmsscanner Files: * Copyright: Copyright 2022-2024 Benjamin Sonntag License: GPL-3 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA . On Debian systems, the full text of the GNU General Public License version 3 can be found in the file `/usr/share/common-licenses/GPL-3'. cmsscanner-0.1.2/debian/compat000066400000000000000000000000031470552100300162640ustar00rootroot0000000000000012 cmsscanner-0.1.2/debian/control000066400000000000000000000006661470552100300165000ustar00rootroot00000000000000Source: cmsscanner Section: admin Priority: optional Maintainer: Benjamin Sonntag Build-Depends: debhelper (>= 12), devscripts Standards-Version: 4.3.0 Package: cmsscanner Architecture: all Depends: php-cli Description: Scan CMS hosted on a server This package scan a folder and its subfolder and search for known PHP applications there. it echoes the list of detected programs and their version. cmsscanner-0.1.2/debian/copyright000066400000000000000000000020741470552100300170230ustar00rootroot00000000000000 Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: cmsscanner Source: https://octoforge.fr/octopuce/cmsscanner Files: * Copyright: Copyright 2022-2024 Benjamin Sonntag License: GPL-3 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA . On Debian systems, the full text of the GNU General Public License version 3 can be found in the file `/usr/share/common-licenses/GPL-3'. cmsscanner-0.1.2/debian/debhelper-build-stamp000066400000000000000000000000131470552100300211530ustar00rootroot00000000000000cmsscanner cmsscanner-0.1.2/debian/dirs000066400000000000000000000000331470552100300157450ustar00rootroot00000000000000usr/bin usr/lib/cmsscanner cmsscanner-0.1.2/debian/files000066400000000000000000000001241470552100300161070ustar00rootroot00000000000000cmsscanner_0.1_all.deb admin optional cmsscanner_0.1_amd64.buildinfo admin optional cmsscanner-0.1.2/debian/install000066400000000000000000000000321470552100300164510ustar00rootroot00000000000000src/* usr/lib/cmsscanner/ cmsscanner-0.1.2/debian/rules000077500000000000000000000003641470552100300161500ustar00rootroot00000000000000#!/usr/bin/make -f #export DH_VERBOSE = 1 %: dh $@ override_dh_install: dh_install ln -s /usr/lib/cmsscanner/scanner.php $(CURDIR)/debian/cmsscanner/usr/bin/cmsscanner chmod a+x $(CURDIR)/debian/cmsscanner/usr/lib/cmsscanner/scanner.php cmsscanner-0.1.2/src/000077500000000000000000000000001470552100300144325ustar00rootroot00000000000000cmsscanner-0.1.2/src/scanner.php000066400000000000000000000033121470552100300165730ustar00rootroot00000000000000#!/usr/bin/php \n"; exit(); } $root=realpath($argv[1]); if (!$root || !is_dir($root)) { echo "FATAL: $root is not a directory or can't be opened\n"; } $t=stat($root); $fs=$t["dev"]; // we don't cross filesystems. $d=@opendir(__DIR__."/softs"); if (!$d) die("FATAL: Can't open softs/ folder in the code."); while (($c=readdir($d))!==false) { if (substr($c,-4)==".php") { require_once(__DIR__."/softs/".$c); $classname=substr($c,0,-4); $classes[strtolower($classname)]=new $classname(); } } closedir($d); scanner($root); function scanner($root,$level=0) { global $fs,$classes; foreach($classes as $class=>$object) { if ($version = $object->search($root)) { echo "$class $version $root\n"; } } $d=@opendir($root); if (!$d) { echo "ERROR: Can't open folder $root (deleted or permission denied)\n"; return; } $root=rtrim($root,"/"); while (($c=readdir($d))!==false) { if ($c=="." || $c=="..") continue; if (is_link($root."/".$c)) continue; if (is_dir($root."/".$c)) { $t=stat($root."/".$c); if ($t["dev"]!=$fs) continue; // we skip subfolders in OTHER filesystems (nfs, crossmounts ...) scanner($root."/".$c,$level+1); // recursive call. } } closedir($d); } cmsscanner-0.1.2/src/softs/000077500000000000000000000000001470552100300155705ustar00rootroot00000000000000cmsscanner-0.1.2/src/softs/Dokuwiki.php000066400000000000000000000012611470552100300200670ustar00rootroot00000000000000parseversion($root."/includes/version.php"); if ($v) return $v; } if (is_file($root."/libraries/joomla/version.php")) { $v=$this->parseversion($root."/libraries/joomla/version.php"); if ($v) return $v; } if (is_file($root."/libraries/cms/version/version.php")) { $v=$this->parseversion($root."/libraries/cms/version/version.php"); if ($v) return $v; } if (is_file($root."/libraries/src/Version.php")) { $version=false; $minor=false; $patch=false; $f=fopen($root."/libraries/src/Version.php","rb"); if (!$f) return false; while($s=fgets($f,1024)) { if (preg_match('#const\s+MAJOR_VERSION\s+=\s+([0-9]+);#',$s,$mat)) { $version=$mat[1]; } if (preg_match('#const\s+MINOR_VERSION\s+=\s+([0-9]+);#',$s,$mat)) { $minor=$mat[1]; } if (preg_match('#const\s+PATCH_VERSION\s+=\s+([0-9]+);#',$s,$mat)) { $patch=$mat[1]; } } fclose($f); if ($version && $minor && $patch) return $version.".".$minor.".".$patch; } return false; } // search function parseversion($file) { $version=false; $patch=false; $f=fopen($file,"rb"); if (!$f) return false; while($s=fgets($f,1024)) { if (preg_match('#var\s+\$RELEASE\s+=\s+\'([^\']+)\';#',$s,$mat)) { $version=$mat[1]; } if (preg_match('#var\s+\$DEV_LEVEL\s+=\s+\'([^\']+)\';#',$s,$mat)) { $patch=$mat[1]; } } fclose($f); if ($version && $patch) return $version.".".$patch; return false; } } // class Joomla cmsscanner-0.1.2/src/softs/Nextcloud.php000066400000000000000000000024171470552100300202520ustar00rootroot00000000000000set('PMA_VERSION', '2.11.11'); $f=fopen($root."/libraries/Config.class.php","rb"); if (!$f) return false; while($s=fgets($f,1024)) { if (preg_match('#\$this->set\([\'"]PMA_VERSION[\'"],\s*[\'"](.*)[\'"]\);#',$s,$mat)) { fclose($f); return $mat[1]; } } fclose($f); return false; } if (is_dir($root."/libraries") && is_file($root."/package.json") && filesize($root."/package.json")<100000) { $f=json_decode(file_get_contents($root."/package.json"),true); if (!$f) return false; if ($f["name"]=="phpmyadmin") return $f["version"]; } return false; } // search } // class Phpmyadmin cmsscanner-0.1.2/src/softs/Prestashop.php000066400000000000000000000032211470552100300204270ustar00rootroot00000000000000=8 if (is_file($root."/app/metadata.json") && filesize($root."/app/metadata.json")<1048576) { $f=json_decode(file_get_contents($root."/app/metadata.json"),true); if (isset($f["version"])) return $f["version"]; } // <8 if (is_file($root."/app/AppKernel.php")) { $f=fopen($root."/app/AppKernel.php","rb"); if (!$f) return false; while($s=fgets($f,1024)) { if (preg_match('#const VERSION\s*=\s*[\'"](.*)[\'"];#',$s,$mat)) { fclose($f); return $mat[1]; } } fclose($f); } // VERY old ~1.6.1.9 if (is_file($root."/install/install_version.php")) { $f=fopen($root."/install/install_version.php","rb"); if (!$f) return false; while($s=fgets($f,1024)) { if (preg_match('#define\(\'_PS_INSTALL_VERSION_\',\s*[\'"](.*)[\'"]\);#',$s,$mat)) { fclose($f); return $mat[1]; } } fclose($f); } } return false; } // search } // class Prestashop cmsscanner-0.1.2/src/softs/Roundcube.php000066400000000000000000000017721470552100300202360ustar00rootroot00000000000000