Wednesday, May 21, 2008

Creating an Encrypted DVD with Debian Linux

As a network security professional, I occasionally need to save data relating to an investigation to a DVD. The data is often sensitive and requires encryption.

I found great tutorials at HOWTO Burn Encrypted DVDs and HOWTO Compile an aespipe Program

Below is my brief step-by-step guide. (Detailed information can be found at the above links.)

Note: Requirements aespipe (I use Debian Linux, which would loop-aes-modules)

Step 1:
Create a directory with the files you want to save on CD (or DVD).
In this example, we'll create a directory named WALDO.

Step 2 (you will be prompted to enter a passphrase):

$ yes "" dd of=image.iso bs=512 count=16
$ head -c 2925 /dev/random uuencode -m - head -n 66 tail -n 65 \
gpg --symmetric -a dd of=image.iso conv=notrunc

Step 3:
$ mkisofs -quiet -r WALDO aespipe -K WALDO.iso -O 16 >> WALDO.iso

Step 4: Test it by mounting on loopback

$ mount -t iso9660 WALDO.iso /cdrom -o \
loop,encryption=AES128,gpgkey=WALDO.iso,offset=8192

Step 5: Burn the iso (k3b works fine)

Step 6: mount the cd via fstab entry or:
$ mount -t iso9660 /dev/cdrom /cdrom -o \
loop,encryption=AES128,gpgkey=/dev/cdrom,offset=8192

Post provided by Mary M. Chaddock

Sunday, May 18, 2008

Perform Elementary Encryption with tr Command

Reading the "Stars and Stripes" newspaper today, I ran across the popularly syndicated JUMBLE puzzle, which is a scrambled word game. Interestingly enough, the versatile UNIX tr command came to mind again. By providing a jumbled alphabet key, the UNIX tr command can perform an elementary encryption operation. Here is a simple example.

To "encrypt" the contents of mysysad.txt in uppercase.
# sh
# cat mysysad.txt | tr '[a-z]' '[A-Z]' | tr '[A-Z]' "PETRUSCMANFXZJOIVKBGWHDYLQ" > mysys.txt

# more mysys.txt
GMU GKPJBXPGU WGAXAGL IKOHARUB HUKBPGAXGL DAGMAJ WJAY.

To "decrypt" the contents of mysys.txt in lowercase (original state)
# cat mysys.txt | tr "PETRUSCMANFXZJOIVKBGWHDYLQ" '[a-z]'

Or use the echo command per Denis' (commenter) suggestion
# echo "GMU GKPJBXPGU WGAXAGL IKOHARUB HUKBPGAXGL DAGMAJ WJAY." | tr 'PETRUSCMANFXZJOIVKBGWHDYLQ' '[a-z]'

Friday, May 16, 2008

Using XAMPP From Apache Friends

Several months ago, I installed the latest and greatest version of Apache web server. In addition, I installed PHP and MySQL. Well, I found that effort a little trickier to tackle on my box. Fortunately, an acquaintance recommended using XAMPP from Apache Friends.

I found XAMPP easy to install, a time saver, and to use - just download, extract and start.

Available for the following platforms:

XAMPP for Linux
The distribution for Linux systems (tested for SuSE, RedHat, Mandrake and Debian) contains: Apache, MySQL, PHP & PEAR, Perl, ProFTPD, phpMyAdmin, OpenSSL, GD, Freetype2, libjpeg, libpng, gdbm, zlib, expat, Sablotron, libxml, Ming, Webalizer, pdf class, ncurses, mod_perl, FreeTDS, gettext, mcrypt, mhash, eAccelerator, SQLite and IMAP C-Client.

XAMPP for Windows
The distribution for Windows 98, NT, 2000, 2003, XP and Vista. This version contains: Apache, MySQL, PHP + PEAR, Perl, mod_php, mod_perl, mod_ssl, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, JpGraph, FileZilla FTP Server, mcrypt, eAccelerator, SQLite, and WEB-DAV + mod_auth_mysql.

XAMPP for Mac OS X
The distribution for Mac OS X contains: Apache, MySQL, PHP & PEAR, SQLite, Perl, ProFTPD, phpMyAdmin, OpenSSL, GD, Freetype2, libjpeg, libpng, zlib, Ming, Webalizer, mod_perl, eAccelerator, phpSQLiteAdmin.
WARNING: This version of XAMPP is still in the first steps of development. Use at you own risk!

XAMPP for Solaris
The distribution for Solaris (developed and tested with Solaris 8, tested with Solaris 9) contains: Apache, MySQL, PHP & PEAR, Perl, ProFTPD, phpMyAdmin, OpenSSL, Freetype2, libjpeg, libpng, zlib, expat, Ming, Webalizer, pdf class.
WARNING: This version of XAMPP is still in the first steps of development. Use at you own risk!

Here is the download link for XAMPP and it is free of charge.

Thursday, May 15, 2008

UNIX From Command Prints Mailbox Header Lines

The /usr/ucb/from UNIX command prints out the mail header lines in your mailbox file. It shows you who the mail is from. Here is an example run for this command.

Display mail header lines in your mailbox file
# /usr/ucb/from
From root Sun Mar 16 03:15:01 2008
From root Sun Mar 23 03:15:00 2008
From root Sun Mar 30 03:15:01 2008
From root Sun Apr 6 03:15:01 2008
From root Sun Apr 13 03:15:01 2008
From esoft Thu May 15 19:50:10 2008

Display mail header for mail sent by sender
# /usr/ucb/from -s esoft
From esoft Thu May 15 19:50:10 2008

Display mail header lines for a user's mailbox file
# /usr/ucb/from soft
From soft Sun Feb 10 03:10:41 2008
From soft Sun Feb 10 03:15:01 2008
From soft Sun Feb 17 03:10:41 2008
From soft Sun Feb 17 03:15:01 2008
From soft Sun Feb 24 03:10:41 2008

Saturday, May 10, 2008

Protect your Site Against Questionable Redirects and Frames

After reviewing statistics for my topsite blog directory, I observed traffic from a website that uses redirects and frames to exploit my website with questionable advertisements (porn). Here is the format: http://????????.com/go/?/301??/http://www.topbloglists.com. I inserted the "?" as substitutes.

Obviously, I felt my site was being hijacked and I was miffed. But this was not the first time this happened to me.

Approximately two months ago, I emailed the webmaster three times requesting their members NOT be allowed to employ links that use frames to create banner-like ads above my pages. I never received a response to my emails, but the activity did stop until today.

Luckily, I found this script to deal with the issue. Place it within the <_head>. Here is the script's source along with a post on questionable linking.

Friday, May 09, 2008

Shell Based Random Number Generator

I observed a a few searches in my metadata stats for a shell based random generator. I know Korn, Bash, and Z Shell shells support a RANDOM variable. Depending on the shell, I will use a print and/or echo command to output its value. The pseudo-random generator outputs an integer between 0 and 32767 - yes, a very limited range. Here are a few examples for these three different shells.

Korn Shell
# ksh
# echo $RANDOM
23508
# echo $RANDOM
22618
# echo $RANDOM
1864
# echo $RANDOM $RANDOM
4958 29989
# print $RANDOM
30418
# print $RANDOM
4992
# print $RANDOM $RANDOM $RANDOM
29436 27342 12946

Seed the sequence of numbers
# RANDOM=100
# print $RANDOM
12662
# echo $RANDOM
23392
# RANDOM=100
# echo $RANDOM
12662
# echo $RANDOM
23392

Bash Shell
# bash
# echo $RANDOM
3107
# echo $RANDOM
7897

Z Shell
# zsh
# print $RANDOM
32274
# for i in {1..10}
for> do
for> print $RANDOM
for> done
10740
12659
9498
2798
3541
10384
21216
15221
22157
15198

Seed the sequence of numbers
# RANDOM=`date '+%H%S'`
# echo $RANDOM
12488
# echo $RANDOM
5266

Friday, May 02, 2008

Insightful Quotes by the Revered Physicist Albert Einstein

Here are some insightful quotes by the revered physicist Albert Einstein. I used an echo statement to act as a delimiter, especially towards the bottom of the list. I do not know who Kevin Harris is but it must have taken him awhile to compile this list.

echo "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction."
echo "Imagination is more important than knowledge."
echo "Gravitation is not responsible for people falling in love."
echo "I want to know God's thoughts; the rest are details."
echo "The hardest thing in the world to understand is the income tax."
echo "Reality is merely an illusion, albeit a very persistent one."
echo "The only real valuable thing is intuition."
echo "A person starts to live when he can live outside himself."
echo "I am convinced that He (God) does not play dice."
echo "God is subtle but he is not malicious."
echo "Weakness of attitude becomes weakness of character."
echo "I never think of the future. It comes soon enough."
echo "The eternal mystery of the world is its comprehensibility."
echo "Sometimes one pays most for the things one gets for nothing."
echo "Science without religion is lame. Religion without science is blind."
echo "Anyone who has never made a mistake has never tried anything new."
echo "Great spirits have often encountered violent opposition from weak minds."
echo "Everything should be made as simple as possible, but not simpler."
echo "Common sense is the collection of prejudices acquired by age eighteen."
echo "Science is a wonderful thing if one does not have to earn one's living at it."
echo "The secret to creativity is knowing how to hide your sources."
echo "The only thing that interferes with my learning is my education."
echo "God does not care about our mathematical difficulties. He integrates empirically."
echo "The whole of science is nothing more than a refinement of everyday thinking."
echo "Technological progress is like an axe in the hands of a pathological criminal."
echo "Peace cannot be kept by force. It can only be achieved by understanding."
echo "The most incomprehensible thing about the world is that it is comprehensible."
echo "We can't solve problems by using the same kind of thinking we used when we created them."
echo "Education is what remains after one has forgotten everything he learned in school."
echo "The important thing is not to stop questioning. Curiosity has its own reason for existing."
echo "Do not worry about your difficulties in Mathematics. I can assure you mine are still greater."
echo "Equations are more important to me, because politics is for the present, but an equation is something for eternity."
echo "If A is a success in life, then A equals x plus y plus z. Work is x; y is play; and z is keeping your mouth shut."
echo "Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."
echo "As far as the laws of mathematics refer to reality, they are not certain, as far as they are certain, they do not refer to reality."
echo "Whoever undertakes to set himself up as a judge of Truth and Knowledge is shipwrecked by the laughter of the gods."
echo "I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones."
echo "In order to form an immaculate member of a flock of sheep one must, above all, be a sheep."
echo "The fear of death is the most unjustified of all fears, for there's no risk of accident for someone who's dead."
echo "Too many of us look upon Americans as dollar chasers. This is a cruel libel, even if it is reiterated thoughtlessly by the Americans themselves."
echo "Heroism on command, senseless violence, and all the loathsome nonsense that goes by the name of patriotism -- how passionately I hate them!"
echo "No, this trick won't work...How on earth are you ever going to explain in terms of chemistry and physics so important a biological phenomenon as first love?"
echo "My religion consists of a humble admiration of the illimitable superior spirit who reveals himself in the slight details we are able to perceive with our frail and feeble mind."
echo "Yes, we have to divide up our time like that, between our politics and our equations. But to me our equations are far more important, for politics are only a matter of present concern. A mathematical equation stands forever."
echo "The release of atom power has changed everything except our way of thinking...the solution to this problem lies in the heart of mankind. If only I had known, I should have become a watchmaker."
echo "Great spirits have always found violent opposition from mediocrities. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence."
echo "The most beautiful thing we can experience is the mysterious. It is the source of all true art and all science. He to whom this emotion is a stranger, who can no longer pause to wonder and stand rapt in awe, is as good as dead: his eyes are closed."
echo "A man's ethical behavior should be based effectually on sympathy, education, and social ties; no religious basis is necessary. Man would indeeded be in a poor way if he had to be restrained by fear of punishment and hope of reward after death."
echo "The further the spiritual evolution of mankind advances, the more certain it seems to me that the path to genuine religiosity does not lie through the fear of life, and the fear of death, and blind faith, but through striving after rational knowledge."
echo "Now he has departed from this strange world a little ahead of me. That means nothing. People like us, who believe in physics, know that the distinction between past, present, and future is only a stubbornly persistent illusion."
echo "You see, wire telegraph is a kind of a very, very long cat. You pull his tail in New York and his head is meowing in Los Angeles. Do you understand this? And radio operates exactly the same way: you send signals here, they receive them there. The only difference is that there is no cat."
echo "One had to cram all this stuff into one's mind for the examinations, whether one liked it or not. This coercion had such a deterring effect on me that, after I had passed the final examination, I found the consideration of any scientific problems distasteful to me for an entire year."
echo "...one of the strongest motives that lead men to art and science is escape from everyday life with its painful crudity and hopeless dreariness, from the fetters of one's own ever-shifting desires. A finely tempered nature longs to escape from the personal life into the world of objective perception and thought."
echo "He who joyfully marches to music rank and file, has already earned my contempt. He has been given a large brain by mistake, since for him the spinal cord would surely suffice. This disgrace to civilization should be done away with at once. Heroism at command, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action. It is my conviction that killing under the cloak of war is nothing but an act of murder."
echo "A human being is a part of a whole, called by us _universe_, a part limited in time and space. He experiences himself, his thoughts and feelings as something separated from the rest... a kind of optical delusion of his consciousness. This delusion is a kind of prison for us, restricting us to our personal desires and to affection for a few persons nearest to us. Our task must be to free ourselves from this prison by widening our circle of compassion to embrace all living creatures and the whole of nature in its beauty."
echo "Not everything that counts can be counted, and not everything that can be counted counts." (Sign hanging in Einstein's office at Princeton)

Copyright: Kevin Harris 1995 (may be freely distributed with this acknowledgement)