Sterling Hamilton

10 Oct, 2008

Server Scanner…woh

Posted by: Sterling Hamilton In: Code

So remember Joomla Scanner? OF COURSE YOU DO!

Anyway…I’ve extended it.
Now it detects the VirtueMart component and version…AND XCart.

With the way this script is going…I might just start writing a little program that is a little more robust.
Something that asks for what you want it to check for…and also has the ability to check for updates for installed packages…that would be FRIGGIN’ SWEET!

You’re excited…you know it.
Anyway - here’s a sample.

Example Output:

Retrieving Joomla Site List…
Detecting Joomla Versions…
[http://www.angelkissfoundation.org] -> [Joomla!] [1.0.15] -> [No VirtueMart Detected]
[http://www.florinanalytical.com] -> [Joomla!] [1.0.13] -> [No VirtueMart Detected]
[http://www.kcareno.com] -> [Joomla!] [1.0.13] -> [No VirtueMart Detected]
[http://www.itosbolivia.com] -> [Joomla!] [1.0.13] -> [No VirtueMart Detected]
[http://www.successdna.com] -> [Joomla!] [1.0.13] -> [VirtueMart] [1.0.13a.]
[http://www.computercorps.org] -> [Joomla!] [1.0.15] -> [No VirtueMart Detected]
[http://www.clarkcountybar.org] -> [Joomla!] [1.0.13] -> [VirtueMart] [1.0.15.]
[http://www.natewalker.org] -> [Joomla!] [1.0.11] -> [No VirtueMart Detected]
[http://hamptoninnreno.com] -> [Joomla!] [1.0.15] -> [No VirtueMart Detected]
[http://www.railwayreflections.org] -> [Joomla!] [1.0.13] -> [VirtueMart] [1.1.0.]
[http://www.nevadanla.com] -> [Joomla!] [1.0.15] -> [No VirtueMart Detected]
[http://www.southgatecoins.com] -> [Mambo] [4.5.4] -> [VirtueMart] [1.0.13a.]
[http://www.dailysoulutions.com] -> [Mambo] [4.5.4] -> [No VirtueMart Detected]
[http://www.wellbeingjournal.com] -> [Joomla!] [1.0.12] -> [VirtueMart] [1.0.13a.]
[http://www.commacoffee.com] -> [Joomla!] [1.0.12] -> [No VirtueMart Detected]

Retrieving X-Cart Site List…
[stusellcoins.com] -> [Version 4.1.10]
[www.pepsigifts.com] -> [Version 4.1.6]
[srv02.exyst.com] -> [Version 4.1.11]
[www.tigertransmission.com] -> [Version 4.1.5]
[www.CIPLASTQDP.com] -> [Version 4.1.8]
[srv02.exyst.com] -> [Version 4.1.11]
[www.pei-ups.com] -> [Version 4.1.10]
[www.cpsqdp.com] -> [Version 4.1.8]
[www.mckdev.com] -> [Version 4.1.7]
[www.arroyoqdp.com] -> [Version 4.1.8]
[www.mckernan.com] -> [Version 4.1.8]
[www.kkmprecision.com] -> [Version 4.1.4]
[www.rpprogram.com] -> [Version 4.1.8]
[www.casepakqdp.com] -> [Version 4.1.8]

Code:

#!/usr/local/bin/php -q
<?php
  /*  Project:  Sever Scanner
   *  Author:   Sterling Hamilton
   *  Date:     10.10.2008
   *  
   *  This is an extended version of the Joomla Scanner.
   *  Its current function is to find all Joomla websites and display the version of that install.
   *  Then it checks if VirtueMart is installed and if it is, it retrieves the version and displays it.
   *  
   *  It also scans for X-Cart websites and displays the version installed.
   *
   *  In the future I will extend this to detect component,module and other plugin versions and setup
   *  automatic notifications to be sent out if we have out of date installs.
   */
 
 
  echo "\033[32mRetrieving Joomla Site List...\033[0m\n";
  $strSiteList = shell_exec("find /home/virtual -maxdepth 6 -regex '.*/html/pathway.php'");
  $strSiteList = str_replace("/home/virtual/", NULL, $strSiteList);
  $strSiteList = str_replace("/fst/var/www/html/pathway.php", NULL, $strSiteList);
 
  $arySiteList = explode("\n",$strSiteList);
  $arySiteList = array_slice($arySiteList,0,count($arySiteList)-1);
 
  echo "\033[36mDetecting Joomla Versions...\033[0m\n";
  foreach($arySiteList as $strSite) {
    $strJoomlaDomain = shell_exec("grep '^\$mosConfig_live_site' /home/virtual/$strSite/fst/var/www/html/configuration.php");
    $strJoomlaDomain = str_replace('$mosConfig_live_site = \'',NULL,$strJoomlaDomain);
    $strJoomlaDomain = trim(str_replace('\';',NULL,$strJoomlaDomain));
 
    $strJoomlaProduct = trim(shell_exec("grep '\$PRODUCT' /home/virtual/$strSite/fst/var/www/html/includes/version.php"));
    $strJoomlaVersion  = trim(shell_exec("grep '\$RELEASE' /home/virtual/$strSite/fst/var/www/html/includes/version.php"));
    $strJoomlaSubVersion = trim(shell_exec("grep '\$DEV_LEVEL' /home/virtual/$strSite/fst/var/www/html/includes/version.php"));
 
    $strVirtueMart = "[\033[37mNo VirtueMart Detected\033[0m]";
    $strICanHazVirtueMart = shell_exec("ls /home/virtual/$strSite/fst/var/www/html/administrator/components | grep 'com_virtuemart'");
 
    if($strICanHazVirtueMart) {
      $strVirtueMartProduct = trim(shell_exec("grep '\$PRODUCT' /home/virtual/$strSite/fst/var/www/html/administrator/components/com_virtuemart/version.php"));
      $strVirtueMartVersion  = trim(shell_exec("grep '\$RELEASE' /home/virtual/$strSite/fst/var/www/html/administrator/components/com_virtuemart/version.php"));
      $strVirtueMartSubVersion = trim(shell_exec("grep '\$DEV_LEVEL' /home/virtual/$strSite/fst/var/www/html/administrator/components/com_virtuemart/version.php"));
 
      $strVirtueMartProduct = str_replace('var $PRODUCT',NULL,$strVirtueMartProduct);
      $strVirtueMartProduct = str_replace('= \'',NULL,trim($strVirtueMartProduct));
      $strVirtueMartProduct = str_replace('\';',NULL,$strVirtueMartProduct);
      $strVirtueMartVersion = str_replace('var $RELEASE',NULL,$strVirtueMartVersion);
      $strVirtueMartVersion = str_replace('= \'',NULL,trim($strVirtueMartVersion));
      $strVirtueMartVersion = str_replace('\';',NULL,$strVirtueMartVersion);
      $strVirtueMartSubVersion = str_replace('var $DEV_LEVEL',NULL,$strVirtueMartSubVersion);
      $strVirtueMartSubVersion = str_replace('= \'',NULL,trim($strVirtueMartSubVersion));
      $strVirtueMartSubVersion = str_replace('\';',NULL,$strVirtueMartSubVersion);
 
      $strVirtueMart = "[\033[36m$strVirtueMartProduct\033[0m] [\033[31m$strVirtueMartVersion.$strVirtueMartSubVersion\033[0m]";
    }
 
    $strJoomlaProduct = str_replace('var $PRODUCT',NULL,$strJoomlaProduct);
    $strJoomlaProduct = str_replace('= \'',NULL,trim($strJoomlaProduct));
    $strJoomlaProduct = str_replace('\';',NULL,$strJoomlaProduct);
    $strJoomlaVersion = str_replace('var $RELEASE',NULL,$strJoomlaVersion);
    $strJoomlaVersion = str_replace('= \'',NULL,trim($strJoomlaVersion));
    $strJoomlaVersion = str_replace('\';',NULL,$strJoomlaVersion);
    $strJoomlaSubVersion = str_replace('var $DEV_LEVEL',NULL,$strJoomlaSubVersion);
    $strJoomlaSubVersion = str_replace('= \'',NULL,trim($strJoomlaSubVersion));
    $strJoomlaSubVersion = str_replace('\';',NULL,$strJoomlaSubVersion);
 
    $strJoomla = "[\033[33m$strJoomlaProduct\033[0m] [\033[31m$strJoomlaVersion.$strJoomlaSubVersion\033[0m]";
    $strDomain = "[\033[35m$strJoomlaDomain\033[0m]";
 
    echo "$strDomain -> $strJoomla -> $strVirtueMart\n";
  }
 
  echo "\n\033[32mRetrieving X-Cart Site List...\033[0m\n";
  $strSiteList = shell_exec("find /home/virtual/ -maxdepth 7 -regex '.*/html/[^.]*/wysiwyg.php'");
  $strSiteList = str_replace("/home/virtual/", NULL, $strSiteList);
  $strSiteList = str_replace("/fst/var/www/html", "|", $strSiteList);
  $strSiteList = str_replace("wysiwyg.php", NULL, $strSiteList);
  $strSiteList = str_replace("/", NULL, $strSiteList);
 
  $arySiteList = (explode("\n",trim($strSiteList)));
 
  foreach($arySiteList as $strSiteStore) {
    $strSite = substr($strSiteStore, 0, strpos($strSiteStore, "|"));
    $strStore = substr(strstr($strSiteStore,"|"),1);
 
    $strXCartDomain = shell_exec('grep \'^$xcart_http_host\' /home/virtual/'.$strSite.'/fst/var/www/html/'.$strStore.'/config.php');
    $strXCartDomain = str_replace('$xcart_http_host ="', NULL, $strXCartDomain);
    $strXCartDomain = trim(str_replace('";', NULL, $strXCartDomain));
 
    $strXCartVersion = trim(shell_exec("grep '^Version' /home/virtual/$strSite/fst/var/www/html/$strStore/VERSION"));
 
    $strXCartDomain = "[\033[35m$strXCartDomain\033[0m]";
    $strXCartVersion = "[\033[33m$strXCartVersion\033[0m]";
 
    echo "$strXCartDomain -> $strXCartVersion\n";
  }
 
?>

No Responses to "Server Scanner…woh"

Comment Form

You must be logged in to post a comment.

Categories

Archives

About

Hi, You’ve found my website, well done!

I’m a web designer and an all round geek, hence the funky website. I live in Reno and work in Carson City with a great group of web developers.

I’d describe myself as quiet, shy and simply a nice guy - but I’d be lying. But one can try right? I like my music rocking, my tea hot, and my shoes custom, as well as my daily dose of caffeine, gaming and technology.

I rock green eyes, curly brown hair which I tend to keep on the long side, and a complexion that can be illustrated with a blank sheet of paper. I dress business casual most of the time or just casual and I drive the most generic car on the planet.