Monday, October 29, 2012

Way Back Machine

Fancy to glimpse at a web site appearance some years ago?
I mean: how it was looking some months, or years ago?

Then head to http://archive.org and enter the web site to play with into the address bar,



click on the "Take Me Back" button. You will then be presented with a timeline on the upper part of the window, and a calendar below.


On the timeline, every vertical bar means that a snapshot has been taken. Click on a year, then chose which date you want to get back to.

On the displayed page, there is an area near the top of the window that you can use to scroll between snapshots.

Not only the first page (the home page) is archived, but all the site's content, except "attached" files (e.g.,  a PDf document that the visitor had to manually download).

Funny to flight back in the past and seeing how a site improved its design over time.

Tuesday, October 23, 2012

FreeBSD Ports and Packages Tips & Tricks

Listing installed ports

pkg_info
pkg_info | grep -i foo

What files are installed by a given port

pkg_info -L foo.1.1 | less

Show me duplicate ports or packages

pkg_info | sort | sed -e 's/-[0-9].*$//' | uniq -c | grep -v '^[[:space:]]*1 

Corrupted ports DB

Sometimes, the ports DB can be corrupted. It may happen following an upgrade to RELEASE-pxx and a kernel recompilation (make buildinstall and so on).
Everything is looking fine but after the last mergmaster and reboot to multi-user mode it's now time to recompile all installed ports. To do so, it usually mean that you have first to upgrade portupgrade ( portversion | grep 'needs updating' ).

portupgrade -R -r -O portupgrade

And suddenly comes troubles; even portversion is fucked up!

portversion -l '<'
[Updating the pkgdb <format:bdb_btree> in /var/db/pkg ... /var/db/pkg/pkgdb.db: unexpected file type or format -- Invalid argument; rebuild needed] [Rebuilding the pkgdb <format:bdb_btree> in /var/db/pkg ... [Updating the pkgdb <format:bdb_btree> in /var/db/pkg ... /var/db/pkg/pkgdb.db: unexpected file type or format -- Invalid argument; rebuild needed] [Rebuilding the pkgdb <format:bdb_btree> in /var/db/pkg ... /var/db/pkg/pkgdb.db: unexpected file type or format -- Invalid argument: Cannot update the pkgdb!]: Cannot update the pkgdb!]

Command failed [exit code 1]: /usr/local/sbin/pkgdb -aFQ 

Trying to repair with portsdb will not make it

portsdb -uU 
 Updating the ports index ... Generating INDEX.tmp - please wait..Warning: Duplicate INDEX entry: mod_rpaf-0.5 Done. done [Updating the portsdb <format:bdb_btree> in /usr/ports ... - 16318 port entries found portsdb:

/usr/ports/INDEX-6.db: unexpected file type or format -- Invalid argument: Cannot update the portsdb! (/usr/ports/INDEX-6.db)]
The solution is to rebuild the DB

mv /var/db/pkg/pkgdb.db /var/db/pkg/pkgdb.db_Corrupted
portsdb -ufU 
Updating the ports index ... Generating INDEX.tmp - please wait..Warning: Duplicate INDEX entry: mod_rpaf-0.5 Done. done [Updating the portsdb <format:bdb_btree> in /usr/ports ... - 16318 port entries found

.........1000.........2000.........3000.........4000.........5000.........6000.........7000.........8000...... ...9000.........10000.........11000.........12000.........13000.........14000.........15000.........16000... ..... done]

pkgdb -u && pkgdb -F

It should now be fixed.

Disregard (accept the default [no] by pressing ENTER) for linux-base, if any such message is displayed during the process.

Linux: Short on Virtual Memory?

If your Linux box is short on RAM, you can create additional swap space on the fly without even rebooting.

Within one of your partition (assuming enough hard disk space), e.g., into /var, create a new file of the desired swap space size - here: 100MB

You ought better be logged in as root in order to perform such manipulation.
Mind that such a partition will be less effective (read: swift) than a real swap partition as accessing the file system induces a latency.

dd if=/dev/zero of=/var/swap bs=1025k count=1000
mkswap /var/swap
swapon /var/swap

That's it! 




For a more permanent change, amend /etc/fstab


/var/swap   none   swap   sw 0 0


Saturday, October 20, 2012

SEC4INTERNET


As IT Security practitioner, I am interested in Network & Security, Systems hardening, Audits & Compliance, and many more...