Friday, December 01, 2006

Wargames Influenced Powershell Hack

As a child, I love the movie WarGames.  Looking back though, it does seem kind of corny and maybe even improbable.  No matter, I still think its a great movie.  The movie introduces concepts that we still deal with today.  Things like system security, artificial intelligence and the concept of futility.  You prabably know that I love lists, so here are my favorite things about the movie.

The five greatest things about WarGames the movie:

5. That scene where Matthew Broderick phreaked a pay phone by sticking a pull tab from a soda can in the receiver.  Through the eyes of a kid, this was awesome.

4. The extensive use of the acoustically coupled modem to hack the Government's most secure network.

3. The 8 inch floppy drive.  Which at it's prime could hold 1200 kb.

2. Barry Corbin.

1. The cool terminal that would talk to you, a.k.a. Joshua.

Its the terminal that inspired my personallized use of this hack.  Below is an excerpt from my Powershell profile.  You may recognize some of the code from a previous post.

function say($script)
{
$v = New-Object -ComObject "SAPI.spvoice"
$r = $v.Speak($script)
rv v
}

#Say Hello
$Greeting = "Hello " + $env:Username + ". Shall we play a game?"
write $Greeting
say $Greeting
rv Greeting

The first thing I do is create a function named "say".  Inside the function I create a instance of the SAPI.spvoice COM object.  SAPI is the Text to Speech API that is installed with Windows XP by default.  You can administer it by going into your control panel and opening the Speech option.  The spvoice object allows you to pass in some text and it will convert it into audible speech and send it out to your speakers.  So the "say" function takes some text and speaks it.  Note that I took the time to use "rv" to remove the variable.  Don't need to hold on to that COM object longer than I need to.


Next you see where I get the user name of the person logged on and print out a greeting right before I speak it.  I've seen some articles on using this technology in ASP.NET applications.  Think of the fun you could have.

4 comments:

Anonymous said...

$v.Speak("Look Dave, I can see you're really upset about this. I honestly think you ought to sit down calmly, take a stress pill, and think things over.")

http://www.imdb.com/title/tt0062622/quotes


Jeffrey Snover [MSFT]
Windows PowerShell/MMC Architect
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Anonymous said...

[array]$JeffreySnoverQuotes = "Blaah Blaah Blaah", "Using one CMDlets over another is like Bar Fighting...","Powershell Remoting - Mobile Object Model - Islands of optimization in a sea of Interoperability"

$v.Speak($JeffreySnoverQuotes)

or

$TheTimeNow = Get-Date

$v.Speak("Hello Dave, The current time is" $TheTimeNow)

Anonymous said...

Well I acquiesce in but I contemplate the post should prepare more info then it has.

Anonymous said...

i really adore all your writing choice, very helpful.
don't quit and keep creating in all honesty , because it just simply very well worth to look through it.
excited to looked over much more of your articles, have a good one!