Showing posts with label RANDOM. Show all posts
Showing posts with label RANDOM. Show all posts

Saturday, May 9, 2009

A Nice Linux ScreenSaver

Hey there,

Well, now that the sickness is abating, I'm back to working on the weekend ;)

Hope you enjoy this cool little screensaver script I found over at BloggEd

I included the basic code below, but you should check out the site for a good write-up and instruction on how to use and modify it for your system's kernel.

Enjoy :)



#!/bin/sh

file=phosphor-kernel-src.pl # script to create
linux_src_dir=/usr/src/linux # location of kernel src

cat << EOF > "$file"
#!/usr/bin/perl
srand;
rand(\$.) < 1 && (\$line = \$_) while <DATA>;
print \$line;
__DATA__
EOF
find -L "$linux_src_dir" -name \*.c >> $file
chmod 555 $file




, Mike




Discover the Free Ebook that shows you how to make 100% commissions on ClickBank!



Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Saturday, August 2, 2008

Absolute Nonsense - More Weekend Unix and Linux Levity

Hey there,

Another week has passed and it's time to laugh heartily before it all ends in tears ;) This week, I stumbled upon Two sites that had me working overtime trying not to laugh out loud at my desk. Nonsense humor isn't for everyone, but I find it the most enjoyable kind. It's goofy, it's random and once something gets me going I sound like I'm having a massive asthma attack while I'm trying to force myself to not laugh. Thank God I do this during my lunch break, when nobody cares to stop and see if I'm okay ;)

This is going to be a strange post, since there's not a whole lot I can put up here without directing you to another site. The one bad thing about random nonsense generation (no matter how controlled it may be) is that, once I cut and paste it into this editor, it will stop being random. Hopefully, it will remain nonsense ;)

The first one, called The Unity Of Multi is so heavy with references to the Illuminati, the numbers 23 and 5, discordianism and "fnords" that I was surprised I couldn't find a link to Robert Anton Wilson's Site (of whose writing I'm a great fan), but it may be in there somewhere. Possibly a link to Robert Shea as well, but I'm getting way off topic... Or maybe not. If you check out the about RAW page on Wilson's site, it's also re-loadable nonsense :)

Anyway, check out "Fun with randomness" near the bottom of the page. I personally enjoyed the Random Band Name and Random Goth Lyric generators the most. If the band generator link doesn't work for you, try hitting this Random Generator Site for pretty much the same thing, with a few extras.

The second site, which made me laugh harder for some reason, actually has a program you can download to customize and expand upon if you ever feel like it. It's appropriately titled Nonsense and links to a bundle you can download and install on your own PC or Unix/Linux box to start enjoying right away. You can put the form.html file anywhere and, if you accept the defaults, just dump everything else into your cgi-bin directory. Right out of the box, the form.html assumes everything is located at "localhost/cgi-bin" but editing it to suit your needs is pretty quick and easy.

Here are screen shots of the "fancy" form and one of my favorite pages (None of the "stupid laws" on the page are true, to my knowledge). All of the pages, it should be noted can be reloaded, until your fingers get tired, to come up with some fairly unique and amusing content. If you want to breeze through it, I'd recommend the "Stupid Laws," "College Courses," and "Mission Statements." Pretty much everything under the "data files" section is a good for a few laughs and the "Resume" builder under the "Templates" section can squeeze out some hilarious reading, too :) As always, click on the pics to make them larger.

Nonsense
Stupid Laws

And, just to clear the air and reassure the folks at Google, this page was not created with Blog-O-Matic. This is 100% original material fronting for 100% purposefully-random material on 100% original web-sites :)

Have a great Saturday!

, Mike

Thursday, January 17, 2008

Perl Random Password Generator For Linux and Unix

As we noted in yesterday's post, we took a look at how it's possible to use Perl on Linux and Unix to try and find whether or not any given password exists within a system's /etc/shadow file.

In today's post, we're going to look at another part of the password puzzle: Password generation. This is slightly different than sequential password generation (which we'll look at tomorrow), in that the passwords that are generated are intended to annoy ;) In other words, the probability that any of these passwords could be found in a shadow password file is highly unlikely. And, if you did find one, I don't know if it would be grounds for penalty. That user would have an unbelievable secure password under any other circumstance!

This code has been tested on Solaris Unix and RedHat Linux and works almost every time (I can't speak to the infinite, but it hasn't failed me yet ;)

This script makes use of Perl's built-in rand function, which works in much the same way as the standard Unix or Linux random function does. The rand function is fed some slightly random data (certainly not good enough to seed any viable encryption) and generates random ASCII characters.

I wrote this up so that it can be invoked simply by its name, like so:

./pwdgen

and requires no argument. This script will pump out 8 character garbage passwords, like this:

O[W291,A
21&V-*4Q
('$\9@:<
YU="M1A>
;<<WG@(>
...


and it will go on forever until you either kill it or it finds that it has created a duplicate. Check it out, enjoy it and feel free to improve upon it. A simple change can make it so it only spits out a certain number of random passwords.

If you use it creatively, you can incorporate it with other Linux and Unix shell scripts to provide input for password cracking programs. Although, as I mentioned above, if I found any of these passwords among my users' passwords, I certainly wouldn't complain ;) Tomorrow we'll look at a way to generate real passwords (kind of like JTR does) that can be fed to the script we looked at yesterday to do some in-house brute-force password cracking against your shadow database file. Again; this sort of shell scripting is only recommended for security enhancement!

Best Wishes,

#!/usr/bin/perl

#
# pwdgen - Create insane 8 character passwords to
# encourage users to beef up their password strength
#
# 2008 - Mike Golvach - eggi@comcast.net
#
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
#

for ( $i = 1; $i > 0 ; $i++ ) {
$random = rand('netstat -a'*10000);
$count=0;
$newpassword = "";
while ( $count < 8 ) {
$tester = rand('netstat -a')*100;
if ( $tester < 33 ) {
$tester += 33;
} elsif ( $tester > 93 ) {
$tester -= 7;
}
$newpassletter = sprintf("%c", $tester);
$newpassword .= $newpassletter;
$count++;
}
$newpassword =~ s/ ?//g;
if ( exists $passwords{$newpassword} ) {
print "Found a pattern on step $i with password $newpassword\n";
exit;
} else {
$passwords{$newpassword} = $i;
}
print "$newpassword\n";
}


, Mike




Friday, December 28, 2007

Using Your Shell To Generate RANDOMness For Security Software

Random number generation, or entropy gathering is something I've always found interesting, because it's so rarely used (to the extent that is possible) and the basic underlying principle is becoming so heavily depended upon. As we enter an age where encryption is becoming not only the standard for network security, but, at times, the only option, this seems insane. I've literally walked into dozens of security software "situations" where it had been agreed upon, all around, that an impasse had been reached, because prngd, egd or the /dev/random and/or /dev/urandom character special devices were no longer functioning correctly. There was simply nothing left to do but wait for vendor support to figure out the problem or, at the very best, wait while we re-installed such and such an OS or software package.

This is a huge problem when your security department has decided that, not only is Telnet no longer a safe connection method, but it's so unsafe that it shouldn't even be on the OS as a backup method for connection. You're left with three options: A secure connection, direct console connection or nothing!

Of course, in a situation like the one I'm describing above, when the security software (Let's say SSH) stops functioning (and no one has a lingering session), you'll need to do your work via the system console. But you should, theoretically, be able to get SSH back up on its feet and running in just slightly more time than it would take you to restart it, once you've logged into the console (hopefully from home :)

The main reason that I see SSH go down is a problem with whatever random number generator it was compiled to use. Of the few I mentioned above, the /dev/random and /dev/urandom character special devices are the most commonly built-in "randomness" generators for SSH. On some older setups (Or for those traditionalists), this is left open and/or set to read random informatiom from a straight file (like /etc/random, or whatever you decide to call it).

On the older versions (where the program reads from a file to "generate randomness") you almost never see this problem, because there's nothing convoluted about the process. We're assuming SSH is fine for all of these examples, and (unless you don't have read access to the file or the filesystem that its on is corrupted), there's almost no way straight-file reads to create randomness can go wrong.

When you're reading from a domain socket or a character special device (like /dev/urandom) is when you may end up having an issue. However you can get around this in your shell using a common variable called RANDOM (Not very cleverly named, but a good indicator of its actual function - available in ksh, bash and almost all shells). This variable produces a random number from between a range of 0 to 32767 (Actual results may vary depending on OS, bit strength of OS, etc) and its value changes every time it's invoked. For instance:

host # a=0;while [ $a -lt 5 ];do echo $RANDOM;let a=$a+1;done
17417
6453
11016
3054
8647


Now, to proceed. We're going to assume that the default file your SSH uses to generate randomness and transfer it to /dev/urandom is missing. Otherwise, you'd just have to fix that and this would be no fun at all ;) In order to incorporate this functionality into your downed SSH server, you'll need to, in effect, create your own /dev/urandom and move the other one out of the way (It's cooked anyway, right? ;)

host # mv /dev/random /dev/norandom
host # mv /dev/urandom /dev/nourandom


Then proceed to create your simple script (We're just going to script on the command line, here) which, while it won't be nearly as secure as the "real" /dev/random was, will keep you afloat until you get the fix in. Theoretically, you could make it really complicated and as secure as you like just as long as you just follow the general outline like this:

First recreate the two necessary random files:

host # mknod /dev/random c 1 8 &&
host # mknod /dev/urandom c 1 9 &&
host # chown root:root /dev/random /dev/urandom
host # chmod 0644 /dev/random /dev/urandom


Then create the random text file, like so (We only need 512 bytes):

host # a=0;while [ $a -lt 92160 ];do echo $RANDOM >>BING;let a=$a+1;done
host # cat BING >/dev/urandom


Note that the above command line (which dumps its output into the file named BING could be a full fledged shell script. It could be highly convoluted and as hard to comprehend as you prefer. The script doesn't even need to work as long as it dumps out enough error data and you're redirecting STDERR to STDOUT -- e.g. 2>&1)

If you want, you can save this output for later, but, hopefully, you won't be needing it. Just dd (disk to disk copy) it back to itself, like this:

host # dd if=/dev/urandom of=BING count=1 >/dev/null 2>&1

Now you should be able to startup your SSH Daemon and finally get back to work ;)

Cheers,

, Mike