~# mkdir ~/tmp && cd ~/tmp
~# apt-get install dpkg-dev
~# apt-get source lighttpd
~# apt-get build-dep lighttpd
~# wget http://www.linux.com.cn/modcache/lighttpd-1.4.19.modcache.v.1.6.0.patch
~# cd lighttpd-1.4.19
~# patch -p0 < ../lighttpd-1.4.19.modcache.v.1.6.0.patch
~# echo debian/tmp/usr/lib/lighttpd/mod_cache.so > debian/lighttpd.install
~# dpkg-buildpackage  -uc -b
~# ls -l ../*.deb

Install the debian packages with dpkg and enjoy :-)

Reference Links:
- APT HOWTO – Working with source packages

Tags: , ,

~ $ cat example.txt
first line
second line
third line
another line

~ $ sed -n ‘/second/{n;p;}’ < example.txt
third line

~ $ sed -n ‘/second/{n;p;n;p;}’ < example.txt
third line
another line

Tags: ,

This version includes some enhancements and fixes.

In evidence the capability to lock a host or a system so to lock all jobs at once such as the possibility to receive notification on job event (i.e. start and end).

In addition the File Watch plugin was added and the Service Check plugin now is able to check multiple services at once allowing to select the most commonly used service directly from a default list.

Help and comments are always welcome, see http://www.ortro.net for full changelog and details.

Ortro 1.3.3 and the plugins may be downloaded as usual from:
http://www.ortro.net/download

Tags: , , ,

This version includes some enhancements and fixes.

Now the Pear::Auth package is used for authentication and the timeout for long running jobs was added.
The memory free and mysql database table check plugins were added.
In addition the installer was improved and FCKeditor library was updated.

Help and comments are always welcome, see http://www.ortro.net for full changelog and details.

Tags: , , , ,

Install the ThinkFinger utilities and the relative PAM module:

~$ sudo apt-get install thinkfinger-tools libpam-thinkfinger

Acquire and test your fingerprint:

~$ sudo tf-tool --acquire
~$ sudo tf-tool --verify

Enable the PAM module:

~$ sudo /usr/lib/pam-thinkfinger/pam-thinkfinger-enable

Enjoy :-)

Resources
- wiki.ubuntu.com/ThinkFinger
- Bug #203973 in thinkfinger (Ubuntu)

Tags: ,

Requirements:

- PHP5
- PEAR::Net_Nmap
- nmap

<?php

/**
 * Scan network to retrieve hosts and services information.
 */

require_once 'Net/Nmap.php';

//Define the target to scan
$target = array('127.0.0.1','www.yourserver.com');

$options = array('nmap_binary' => '/usr/local/bin/nmap');

try {
    $nmap = new Net_Nmap($options);

    //Enable nmap options
    $nmap_options = array('os_detection' => true,
                          'service_info' => true,
                          'port_ranges' => 'U:53,111,137,T:21-25,80,139,8080',//to scan only specified ports
                          );

    $nmap->enableOptions($nmap_options);

    //Scan target
    $res = $nmap->scan($target);

    //Get failed hosts
    $failed_to_resolve = $nmap->getFailedToResolveHosts();

    if (count($failed_to_resolve) > 0) {
        echo 'Failed to resolve given hostname/IP: ' .
             implode (', ', $failed_to_resolve) .
             "\n";
    }

    //Parse XML Output to retrieve Hosts Object
    $hosts = $nmap->parseXMLOutput();

    //Print results
    foreach ($hosts as $key => $host) {
        echo 'Hostname: ' . $host->getHostname() . "\n";
        echo 'Address: ' . $host->getAddress() . "\n";
        echo 'OS: ' . $host->getOS() . "\n";
        echo 'Status: ' . $host->getStatus . "\n";
        $services = $host->getServices();
        echo 'Number of discovered services: ' . count($services) . "\n";
        foreach ($services as $key => $service) {
            echo "\n";
            echo 'Service Name: ' . $service->name . "\n";
            echo 'Port: ' . $service->port . "\n";
            echo 'Protocol: ' . $service->protocol . "\n";
            echo 'Product information: ' . $service->product . "\n";
            echo 'Product version: ' . $service->version . "\n";
            echo 'Product additional info: ' . $service->extrainfo . "\n";
        }
    }
} catch (Net_Nmap_Exception $ne) {
    echo $ne->getMessage();
}
?>

Tags: , , ,

The code below allows to retrieve and execute all SQL statements defined in a SQL script file removing all comments.

<?php
$sql_file = 'test.sql';

$contents = file_get_contents($sql_file);

// Remove C style and inline comments
$comment_patterns = array('/\/\*.*(\n)*.*(\*\/)?/', //C comments
                          '/\s*--.*\n/', //inline comments start with --
                          '/\s*#.*\n/', //inline comments start with #
                          );
$contents = preg_replace($comment_patterns, "\n", $contents);

//Retrieve sql statements
$statements = explode(";\n", $contents);
$statements = preg_replace("/\s/", ' ', $statements);

require_once 'MDB2.php';

$mdb2 =& MDB2::connect('mysql://usr:pw@localhost/dbnam');

foreach ($statements as $query) {
    if (trim($query) != '') {
        echo 'Executing query: ' . $query . "\n";
        $res = $mdb2->exec($query);

        if (PEAR::isError($res)) {
            die($res->getMessage());
        }
    }
}
?>

I have used Pear::MDB2 abstraction layer to interact with the database but the code above should work with any other db abstraction layer or PHP built-in functions.

Tags: , ,

This version includes some enhancements, and one very important security fix, a cross-site scripting (XSS) vulnerability allows remote attackers to inject arbitrary web script or HTML.

We recommend everyone update immediately.

In addition to the security fix, the Net_Nmap library was updated making the autodiscovery without OS detection more faster, the capability to upload files for plugins and the Web Service Test Plugin using SoapUI were added.

The SimpleTest and FCKeditor libraries were updated.

Help and comments are always welcome, see http://www.ortro.net for full changelog and details.

Ortro 1.3.1 and the plugins may be downloaded as usual from:
http://www.ortro.net/download

Tags: , , ,

The Net_Nmap Pear package is a simple interface for Nmap, the free and open source utility for network exploration or security auditing.

Net_Nmap can be used to auto discovery hosts and services in your network or simply to parse Nmap XML output.

You may install it on your system simply typing:

$ pear install Net_Nmap

or if prefer download it from the Pear web site.

Tags: , ,

On Linux or Unix systems perform recursively a command on items might contain white space, quote marks, or backslashes can be a problem when using find | xargs combination.

To solve this you may use:

find -type d -print0 | xargs -0 <command>
find -type f -print0 | xargs -0 <command>

For example to fix recursively permission:

find -type d -print0 | xargs -0 chmod 755
find -type f -print0 | xargs -0 chmod 644

Tags: , ,

« Older entries § Newer entries »