Friday, February 29, 2008

Fake Cisco gear

Those industrious Chinese...

http://www.andovercg.com/services/cisco-counterfeit-wic-1dsu-t1.shtml

Solaris, Serial Consoles, Cisco Firewalls and TFTP

Using a serial console + tftp server on Solaris:

% screen /dev/term/b 9600
or
% cu -s 9600 -l /dev/term/b
or
% tip hardwire
Where you have hardwire defined in /etc/remote:
hardwire:\
:dv=/dev/term/b:br#9600:el=^C^S^Q^U^D:ie=%$:oe=^D:

Configuring a TFTPD server in Solaris 10:

# mkdir /tftpboot
# echo "tftp dgram udp6 wait root /usr/sbin/in.tftpd in.tftpd -s /tftpboot" > /etc/inetd.conf
# /usr/sbin/inetconv
# svcs network/tftp/udp6
# svcadm restart network/tftp/udp6
Now we can dump some new images in the ftpdir, and upgrade our firewall :-).

# copy tftp: flash:

Address or name of remote host []? 192.168.21.35

Source filename []? asa803-k8.bin

Destination filename [asa803-k8.bin]?

Accessing tftp://192.168.21.35/asa803-k8.bin

14635008 bytes copied in 32.260 secs (457344 bytes/sec)


# copy tftp: flash:

Address or name of remote host [192.168.21.35]?

Source filename [asa803-k8.bin]? asdm-603.bin

Destination filename [asdm-603.bin]?

Accessing tftp://192.168.21.35/asdm-603.bin

Tuesday, February 26, 2008

Can you say "death by server"?



http://www.flickr.com/photos/64856052@N00/894127714/sizes/o/

Saturday, February 23, 2008

SeamlessRDP - Seamless Remote Desktop Connection Shells for Terminal Services

SeamlessRDP is basically like VirtualBox or VMware Fusion Seamless Mode, but for Windows Applications. Or like doing ssh -X, but with Windows :-). Or Citrix or Tarantella (Sun Secure Global Desktop), etc.

It works with RDesktop/TSClientX.

Thursday, February 21, 2008

PowerShell, PowerTab, PSCX, Console, Terminus and Vim

Here's something for all you Powershell / WMIC / VB / cmd script monkeys :-).

You can, of course, script in ksh, Perl or Python if that's your thing. (ActiveState Perl / Python).

Powershell + PowerTab + PSCX + Console + Terminus Programmers Fonts + VIM + VIM PowerShell Syntax Highlighting.



Here's another PowerTab Theme and PSCX (PowerShell Community Extensions):



A cyan BackColor to match my prompt:



And of course, a good color scheme and PoSH syntax highlighting in VIM is also nice:

OpenMicrosoft

Hooray for open APIs
http://www.theregister.co.uk/2008/02/21/microsoft_goes_open/
http://blogs.cnet.com/8301-13505_1-9876027-16.html

Wednesday, February 20, 2008

Windows SteadyState - Free DeepFreeze alternative - now also for Vista

Microsoft Shared Computer Toolkit for Windows AKA Microsoft SteadyState helps manage shared computer systems for internet cafes, libraries, schools, etc. by preventing system changes (a reboot restores everything). It's very much similar to DeepFreeze.

It makes restricting computer access easy.

A SteadyState for Windows Vista version (2.5 beta) has also been released.

Monday, February 18, 2008

SMPlayer Vista Aero Integration - OpenGL

MPlayer is the best video player, ever. It's also open source, and more versatile than Video Lan Client (VLC). On Windows platforms, MPlayer for Windows - contains SMPlayer, MPUI, MPlayer and codecs in a convenient package.

The problem is it will revert to Aero basic when running on Vista. Here's how to fix that:

Open SMPlayer - go to Options - Preferences (Ctrl -P) - General - Output Drivers - Video - select GL:



Go to the Interface Tab and pick the "Windows Vista" style.



Go to the Advanced Tab - Check "Run MPlayer in it's own Window".



Enjoy:

NVIDIA Laptop Drivers and Vista SP1 x64

I've upgraded my laptop OS to Windows Vista SP1 Enterprise 64 bit, and I've had a hard time finding updated drivers from the manufacturer.

The trouble with NVIDIA laptop graphics adapters is that you need to use the vendor driver, instead of the one from NVIDIA.com.

I've got a 8600 GT mobile graphics adapter on this Acer 5920G laptop, and the Acer drivers are ancient (101.45), compared to 169.12 version currently available from laptop2go.

The good news is you can grab an updated copy from the LaptopVideo2Go website, copy the modified INF file, and enjoy :-).

Programmer Fonts and VIM Themes

A great collection of monospaced / fixed width programmer's fonts.

My favorite font is Terminus. It goes great with the "Slate" VIM theme.

Thursday, February 14, 2008

IBM security report for 2007

Read this.

Wednesday, February 13, 2008

VirtualBox on Solaris - Virtualization Software - Installing VirtualBox on Solaris 10

While qemu + kqemu was sufficient for most tasks on Solaris hosts, VirtualBox tends to be faster and simpler to use.

Sneak peak and what VirtualBox can do for you:



VBox in seamless mode.



You get mouse integration, seamless mode, snapshots, shared clipboard and folders, Alt-Tabbing to Windows apps... Virtualbox has it all.

Grab the VirtualBox-opensolaris-amd64-1.5.51-r28040-beta.gz package, gunzip it and install the package as root:

# pkgadd -d VirtualBox-opensolaris-amd64-1.5.51-r28040-beta1
Of course, you'll need to add some libraries to your LD_LIBRARY_PATH:
solaris% ldd /opt/VirtualBox/VirtualBox | grep not
VBoxKeyboard.so => (file not found)
libqt-mt.so.3 => (file not found)
VBoxRT.so => (file not found)
VBoxREM.so => (file not found)
VBoxVMM.so => (file not found)
libX11.so.4 (SUNW_1.1) => (version not found)
VBoxXPCOM.so => (file not found)
Just grep the installed package contents database for the proper path, and export LD_LIBRARY_PATH
solaris% grep VBoxKeyboard.so /var/sadm/install/contents
/opt/VirtualBox/VBoxKeyboard.so f none 0755 root bin 57552 64233 1202698345 INNOvbox
solaris% ldd * | grep "not found"
[...]
solaris% LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/VirtualBox:/opt/VirtualBox/qtgcc/lib:/lib:/opt/sfw/lib
solaris% export LD_LIBRARY_PATH



Problem 1: the VBox.sh script relies on /bin/bash, change to /usr/bin/bash or /usr/bin/ksh.
Problem 2: VBoxDD.so needs a 64 bit libdlpi.so, but that's only been updated in OpenSolaris:

On Solaris 10 u4:
solaris% file /lib/libdlpi.so.1
/lib/libdlpi.so.1: ELF 32-bit LSB dynamic lib 80386 Version 1, dynamically linked, not stripped, no debugging information available
solaris% grep libdlpi.so.1 /var/sadm/install/contents
/lib/libdlpi.so.1 f none 0755 root bin 49784 28431 1168280598 SUNWcslr
solaris% pkginfo | grep SUNWcslr
system SUNWcslr Core Solaris Libraries (Root)
Easy fix :-). We download it from Nexenta!

http://archive.nexenta.org/elatte-unstable/base/sunwcslr

solaris% /usr/xpg4/bin/ar x sunwcslr_5.11.82-1_solaris-i386.deb
So we file the libs in data.tar - 64 bit:

solaris% tar -tf data.tar | grep libdlpi.so
./lib/amd64/libdlpi.so.1
./lib/libdlpi.so.1
./lib/amd64/libdlpi.so symbolic link to libdlpi.so.1
./lib/libdlpi.so symbolic link to libdlpi.so.1
solaris% tar xvf data.tar

solaris% file ./lib/amd64/libdlpi.so.1
libdlpi.so.1: ELF 64-bit LSB dynamic lib AMD64 Version 1 [CMOV], dynamically linked, not stripped, no debugging

Now we can start VirtualBox and run Vista on Solaris using virtualization :-).




If you want sound, install OSS.





As you can see, apart from the poor graphical performance (as expected from Virtualization software), performance is very good. Especially disk I/O.



And for all the people who wish to convert their VMware and QEmu virtual machines to Solaris / VirtualBox, read this.

Expect a FreeBSD version of VirtualBox soon.

Running Windows 2008 Enterprise and Vista Ultimate on VirtualBox:




If you want VirtualBox Guest Additions, just download a debian package or whatever, and use ar -x to unpack it. Grab the ISO and mount it in the virtual machine. You need them for AMD PCNet drivers (networking) on Vista and 2008 for example.


And, once VBoxGuest Additions are installed, you can work in seamless mode. It basically means the host and the guest Windows both appear on the same host desktop:






Shared folders:



Want to have some fun? Use VirtualBox virtual machines on ZFS with compression and snapshots :-). You'll get at least 1.5x compression with virtually no performance hit (less data to transfer == faster with a minor hit on CPU for compression / decompression).

Note: VirtualBox also released a 32 bit package for 32 bit x86 Solaris systems.

Tuesday, February 12, 2008

Sun buys Innotek - makers of VirtualBox

First MySQL, now Virtualbox. Sun loves paying money for GPLware.
Sun grabs Innotek. Containers, xVM, LDOMS... virtualization hype ftw.
http://www.theregister.co.uk/2008/02/12/sun_innotek_virtualization/

Schwartz takes another spin on the strategy wheel...



Image from Ars Technica

Good news is you can now run VirtualBox on Solaris x86. There's a beta of Virtualbox for (Open)Solaris x86-64.

Saturday, February 09, 2008

Windows Performance Tracing Toolkit

Windows Performance Tools Kit, v.4.1.1 helps diagnostic application start time issues, boot issues, deferred procedure calls and interrupt activity (DPCs and ISRs), interrupt storms, application resource usage and system responsiveness issues.

The toolkit includes xperf - a trace capture tool, xperfview - a visualization tool (Performance Analyzer) and xbootmgr - a boot trace capture tool.

It works great along side sysinternals tools (Process Explorer and Process Monitor) and krview for kernel tracing and profiling and Performance Monitor (perfmon.msc).


Here's a VERY simple trace (xperf -on DiagEasy, xperf -d trace.etl, xperf trace.etl). There's hunderds of knobs you can turn. You can use it for everything from getting VERY detailed system information (xperf –i trace.etl –a sysconfig) to getting advanced disk I/O info or pinpointing Registry Access bottlenecks.

Tuesday, February 05, 2008

Solaris Package Companion - Cool Solaris Tool

Cool little ksh script to manage Solaris packages and (meta) clusters:
http://opensolaris.org/os/project/svr4_packaging/package_companion/

MySQL, Oracle, DB2, PgSQL and Firebird versus Leap Years and Division by Zero

Oracle first:


SQL> CREATE TABLE leaptest (thedate date);

Table created.

SQL> INSERT INTO leaptest VALUES ('28-feb-2008');

1 row created.

SQL> INSERT INTO leaptest VALUES ('29-feb-2008');

1 row created.

SQL> INSERT INTO leaptest VALUES ('30-feb-2008');
INSERT INTO leaptest VALUES ('30-feb-2008')
*
ERROR at line 1:
ORA-01830: date format picture ends before converting entire input string


SQL> INSERT INTO leaptest VALUES ('29-feb-2007');
INSERT INTO leaptest VALUES ('29-feb-2007')
*
ERROR at line 1:
ORA-01830: date format picture ends before converting entire input string

SQL> SELECT * from leaptest;

THEDATE
---------
28-FEB-08
29-FEB-08


As you can see, Oracle knows 2008 is a leap year, and that 2007 is not.

Let's try another good database, PostgreSQL:

goods=> CREATE TABLE leaptest (thedate date);
CREATE TABLE
goods=> INSERT INTO leaptest VALUES ('28-feb-2008');
INSERT 0 1
goods=> INSERT INTO leaptest VALUES ('29-feb-2008');
INSERT 0 1
goods=> INSERT INTO leaptest VALUES ('30-feb-2008');
ERROR: date/time field value out of range: "30-feb-2008"
goods=> INSERT INTO leaptest VALUES ('29-feb-2007');
ERROR: date/time field value out of range: "29-feb-2007"
goods=> SELECT * FROM leaptest;
thedate
------------
2008-02-28
2008-02-29
(2 rows)


No problems here either. What about IBM DB2?

db2 => CREATE TABLE leaptest (thedate date)
DB20000I The SQL command completed successfully.
db2 => INSERT INTO cmihai.leaptest VALUES ('2008-02-28')
DB20000I The SQL command completed successfully.
db2 => INSERT INTO cmihai.leaptest VALUES ('2008-02-29')
DB20000I The SQL command completed successfully.
db2 => INSERT INTO cmihai.leaptest VALUES ('2008-02-30')
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0181N The string representation of a datetime value is out of range.
SQLSTATE=22007
db2 => INSERT INTO cmihai.leaptest VALUES ('2007-02-29')
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0181N The string representation of a datetime value is out of range.
SQLSTATE=22007
db2 => SELECT * FROM cmihai.leaptest

THEDATE
----------
02/28/2008
02/29/2008

2 record(s) selected.


Let's even try Firebird:

SQL> CREATE TABLE leaptest (thedate date);
SQL> INSERT INTO leaptest VALUES ('28-feb-2008');
SQL> INSERT INTO leaptest VALUES ('29-feb-2008');
SQL> INSERT INTO leaptest VALUES ('30-feb-2008');
Statement failed, SQLCODE = -413
conversion error from string "30-feb-2008"
SQL> INSERT INTO leaptest VALUES ('29-feb-2007');
Statement failed, SQLCODE = -413
conversion error from string "29-feb-2007"
SQL> SELECT * FROM leaptest;

THEDATE
===========
2008-02-28
2008-02-29


Well now, let's try MySQL:

mysql> CREATE TABLE leaptest (thedate date);
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO leaptest VALUES ('28-feb-2008');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO leaptest VALUES ('29-feb-2008');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO leaptest VALUES ('30-feb-2008');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO leaptest VALUES ('29-feb-2007');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> SELECT * FROM leaptest;
+------------+
| thedate |
+------------+
| 0000-00-00 |
| 0000-00-00 |
| 0000-00-00 |
| 0000-00-00 |
+------------+
4 rows in set (0.00 sec)

As you can see, MySQL happily takes the input, but when we try to read it.. surprise surprise, your data isn't there! It should respond with an error code..

As Komal Shah points out, that's only due to an invalid date format, using ISO dates dates works fine.

INSERT INTO leaptest VALUES ('2008-02-28');

An invalid date will still generate a warning and a 0000-00-00 entry.

Here's another fine piece of MySQL behavior:
Division by 0:
Well, let's first see how Oracle and PgSQL handle this:

Oracle
SQL> SELECT 0/0 FROM dual;
SELECT 0/0 FROM dual
*
ERROR at line 1:
ORA-01476: divisor is equal to zero


PostgreSQL
goods=> SELECT 0/0;
ERROR: division by zero


IBM DB2:

db2 => SELECT 0/0 FROM cmihai.leaptest
SQL0801N Division by zero was attempted. SQLSTATE=22012


Firebird:

SQL> SELECT 0/0 FROM leaptest;

=====================
Statement failed, SQLCODE = -802
arithmetic exception, numeric overflow, or string truncation
SQL> SELECT 0/1 FROM leaptest;


=====================
0
0
SQL> SELECT 1+1 FROM leaptest;


=====================
2
2



MySQL
mysql> SELECT 0/0;
+------+
| 0/0 |
+------+
| NULL |
+------+
1 row in set (0.00 sec)

So there you have it, MySQL unexpected behavior.

If anyone cares, tested versions: DB2 9.5, Oracle 10g and 11g, PosgreSQL 8.2, 8.3 and Firebird 2. MySQL was 5.0.45.

Getting started with PostgreSQL - a Database Primer

A quick guide to getting started with the PostgreSQL database server:

Download and install PostgreSQL. If you're using some kind of BSD or Linux, it's probably already in the ports / packages repository. You may need to use initdb to create a new database cluster, and edit pg_hba.conf to grant your users / machines connect privileges to the server. If you're in a UNIX-like OS, you'll need to "su - postgres". After that:

Connect as postgres:

psql -U postgres

Create a role:

CREATE ROLE testuser LOGIN PASSWORD 'test123';

Create a database:

CREATE DATABASE testdb;


Note that the database is created in the cluster ENCODING. If you want to specify a different encoding (not recommended) you can use something like:

CREATE DATABASE testdb OWNER = testuser ENCODING = 'UTF8';

List databases, groups, users, quit:

\l+ \dg+ \du+ \q

Connect as the new user to the new database:

psql -U testuser testdb

Create a table:

CREATE TABLE test (ID serial PRIMARY KEY, name varchar(25) NOT NULL UNIQUE);

List table, relations, schemas, describe table:

\d

\dt

\dn

\d test

Insert some data:

INSER INTO test VALUES (default, 'quux');

Do a query:

SELECT * FROM test;

\q

Delete a database:

psql -U postgres

DROP DATABASE testdb;

Once you've got the hang of things, you can use \? and \h for help:
\?
\h
\h CREATE DATABASE

You can now delete the testuser role:
psql -U postgres
DROP ROLE testuser;


Create your new username and database, and connect to it. Create a simple database schema.

Here's a fun PostgreSQL feature: HTML output. \H turns it on, \H again turns it of:

We have a very simple table with 3 entries:

goods=> \d countries;
Table "public.countries"
Column | Type | Modifiers
---------+-----------------------+-----------
country | character varying(50) | not null
Indexes:
"countries_pkey" PRIMARY KEY, btree (country)

goods=> SELECT * FROM countries;
country
---------
A
B
C
(3 rows)

\H
goods=> \H
Output format is html.
goods=> SELECT * FROM countries;


We can use \o to redirect the output to a file:
goods=> \o countries.html
goods=> SELECT * FROM countries;
\q and view the file in your web browser :-).



Now that you've got the feel of psql, you can use PgAdmin III (or PHPPgAdmin or whatever interface you like, like OpenOffice.Org Base or Microsoft Office Access). PgAdmin III also shows the SQL commands it's going to run, so it's a good way to learn SQL.




Use this for a tutorial and this for reference.

Monday, February 04, 2008

Using OpenOffice.org Base to access PostgreSQL databases

Just like Access can connect to a PostgreSQL database via ODBC or JDBC, so can OpenOffice.org Base. But the good news is we don't need to use ODBC or JDBC, as there is a native PostgreSQL SDBC driver for OpenOffice.

Download the postgresql-sdbc-ver.zip file, start OpenOffice (if you start writer type Ctrl-W to close it) so you can access Tools - Extension Manager. Add the downloaded driver, then restart OpenOffice (you also need to exit the QuickStarter. Just right click the SystemTray icon - Exit).



Now you can start OpenOffice.org Base and connect to a PostgreSQL database:



In the Connections Setting type: "dbname=YourDBName host=YourDBServerIP"



Setup a username and password:



That's pretty much it for the database setup, now you can start creating your database. You can use data already available in the PostgreSQL server, or create new tables. You then build Queries, Forms and Reports based on those tables.

You can use the Table Design or Table Wizard to create tables:



You can use the Relationship Editor to create Foreign Key constraints:



You can use the Form Design and Form Wizard to create Forms and the Report Design / Wizard for Reports:



It's usually a good idea to take a look with psql every now and then. OpenOffice.org Base isn't exactly perfect when it comes to creating the database schema, and especially when it comes to constraints. Of course, neither is the SDBG drivers, so it's best to consider this "just for fun" for the moment.

Cracking the Kensington MicroSaver lock with toilet paper

I've seen plenty of "rip out the Kensington" or using a pen / screwdriver to crack the lock, but this is just ridiculous...

PostgreSQL 8.3 Released

PostgreSQL released version 8.3 of "the world's most advanced open source database".

Remember to dump/restore with pg_dump if you're planning to upgrade :-).

Here's a list of "What's new in 8.3".

Benchmarks also show a huge increase in performance from 8.2, some benchmarks even showing a 2.x performance boost from 8.2:

http://www.ajaxonomy.com/2007/sql/postgresql-83-vs-82-a-simple-benchmark

http://archives.postgresql.org/pgsql-general/2008-01/msg00417.php

Version  7.3.15 7.4.13  8.0.8   8.1.4   8.2.beta1 8.3beta1
tps 311 340 334 398 423 585

Improvements have also been done in terms of scalability.

Sunday, February 03, 2008

Accessing PostgreSQL and Oracle with Access and SQL Developer

Microsoft Office Access is a RDBMS that uses a GUI interface and RAD tools and a Jet Database Engine backend. It can also use external data stored in SQL servers such as MSSQL or Oracle, PostgreSQL, DB2, etc. via ODBC.

PostgreSQL is "the most advanced" open source database. It is a BSD-style licensed ORDBMS that supports advanced SQL features such as referential integrity constraints (foreign keys, column checks, etc), full ACID compliance, ANSI SQL compliance, views, rules, sub-selects, transactions, triggers, sequences, inheritance and has a built in language (PL/pgSQL) similar to Oracle PL/SQL. It also exhibits almost linear scalability up to 16 cores, being much more scalable then say, MySQL. As of version 8.3 it gets a performance and scalability boost too. The pgbench benchmark here shows an almost 50% performance boost (under certain workloads) from 8.1.

Using an ODBC connection you can use Access as a Rapid Application Development interface to develop Forms, Reports and Applications using PostgreSQL as a backend database, via PSQLODBC.

Install psqlodbc on your Access machine, and all you need to get started now is a PosgreSQL server (if you don't have one on your network you can install one on your Windows machine from:
http://www.postgresql.org/download/

Fire up Access and open up a database. We are going to create the ODBC connection and save the settings. First, let's export some table to the PostgreSQL database via ODBC. We can later link or import the table (in any database).



Create a new Data Source using the "PostgreSQL Unicode" driver. The goods database was created using "CREATE DATABASE goods OWNER cmihai ENCODING 'UTF8'" and we are planning on storing Unicode data.




Once you've selected a Server hostname (or IP), username, password and database (like the newly created "goods" database in your PostgreSQL server) you need to set some advanced options. Uncheck the "Bools as Char" box.



Check "True is -1":



Now we can Import a table using an external data source (it will import the structure and data of a Table in PostgreSQL as a table in Access. The tables will not be linked).

We can also Link tables using an external data source. This means that the data and structure of the table (schema) is only modified in the PostgreSQL database. We can link multiple applications to the same database (and tables). Just use Get External Data - Link to Data Source and select the PostgreSQL ODBC connection.




As you have noticed, PostgreSQL is case sensitive.

The linked tables are shown in the Table view with a sphere icon.



While you can use the Query Builder (in Design view or SQL view) to query data in the Access database (it can use both access tables and ODBC connected tables), there is an option to pass the SQL query directly to PostgreSQL, in Pass-Through mode.




SELECT public_clienti.nume, public_clienti.prenume, public_tari.tara
FROM public_clienti INNER JOIN public_tari ON public_clienti.tara = public_tari.tara
WHERE (((public_clienti.nume)="Gigi"))
ORDER BY public_clienti.nume, public_clienti.prenume;

The PostgreSQL query wouldn't use the public_clienti prefix, we can just do a simple Pass-Through query:



You can use Pass-Through queries in your Forms and Reports too.

Of course, you can also use Access with Microsoft SQL Server 2005 Express (freely available) or even the free Oracle 10g Express, using the SQL Developer Quick Migration tool to export MDB files to Oracle.



You can use the Quick Migration Wizzard:



Or the full blown "Oracle Migration Workbench Exporter for Access" to export your .mdb file for SQL Developer and Oracle Application Express.

Friday, February 01, 2008

Hibernation File Forensics

The Sandman Project is a C library that allows you to read the Windows hibernation file like a standard memory dump.