PoSH Challenge Part 3
I got stuck on Level 5 so I did a Google search :
http://www.google.nl/search?hl=en&q=peak+hell+sounds+familiar&btnG=Google+Search&meta=
again lucky the first entry got me going again without spoiling the rest, by naming the Python command that sounds like Peak Hell ,
http://www.pythonchallenge.com/forums/viewtopic.php?p=2265&sid=c683b414220a0238408881d8a84f5b6f
when I did look up the pickle command in Python, I did see that this was a thing PowerShell could not do, but hey !, I can host IronPython as I did before in former entries on this blog see IronPython series for more information, so now I can Provide the string to the Python runspace to translate it for me and then work with the results again in PowerShell :
$wc = New-Object System.Net.WebClient
$r = $wc.DownloadString("http://www.pythonchallenge.com/pc/def/banner.p")
# Use IronPython to load Python 2.5 to translate pickle string
[System.Reflection.Assembly]::LoadFile( 'C:\IronPython-1.1\IronPython.dll')
$ipe = new-object IronPython.Hosting.PythonEngine
$IPCode = @'
import clr
import System
import sys
sys.path.append(r'C:\Python25\Lib')
import pickle
t = pickle.loads(p)
'@
$ipe.Globals.Add("p",$r)
$ipe.Execute($IPCode)
$list = $ipe.Globals['t'] |% {$_}
Now we have the result in the list variable and can go on with the event.
If you not want to install IronPython and Python 2.5 Lib's you can also use the attached XML file, to finish the Level without using IronPython
* Readers Challenge *
this level was not suited for PoSH but PowerShell has also a way to serialize classes but then to XML,
I provided a Banner.XML as an attachment to this post , it is the $list variable seralized from PowerShell, ginving you back the objects you need for the rest of the level, you can see this file as the PowerShell equivalent of the banner.p file and complete the level with it.
I'm looking forward to the solutions for the last part you might come up with, and I will post my version after the weekend
Still a nice lever an a good opportunity to host and use the IronPython engine again.and how to get to Python 2.5 libs from there
Enjoy,
Greetings /\/\o\/\/