Friday, April 27, 2007

0x539 Haxxorz

I am not a hacker and the title is probably thus misleading. One of the things that I may do with this blog is to document my discoveries in Powershell. If you do not know what Powershell is then you can look here:

http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx

Basically it is the new scripting language from MS. I happen to think it is very good but I have no desire to engage in a scripting language religious war here.

In Powershell, it is a "promiscuously" typed language. That is not my term it comes from an excellent book "Windows PowerShell In Action by Bruce Payette". It is typed but it does an admirable job of handling the typing for you. I was reading the book and I came across this:

12:44:31 ( 44 ) C:\Temp PS>0xDeadBeef
-559038737

So Powershell automatically converts the Hex value of DeadBeef to an int of -559038737. For some reason this peeked my interest. I was curious about what the Hex value was of some decimal numbers. Unfortunately it is a little harder to get hex from dec. To find out that the hex for 15 is F, this is what you need to do:

12:40:55 ( 41 ) C:\Temp PS>"0x{0:x}" -f 15
0xf

Which lead me to:

12:43:49 ( 43 ) C:\Temp PS>"0x{0:x}" -f 1337
0x539

No comments: