Archives for June, 2008

Enabling fingerprint scanner on ThinkPad running Ubuntu Hardy in four steps


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)

Discovery hosts and services with PHP and Nmap


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,
[...]

Execute SQL script from a file using PHP


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
[...]