From 3ae8c3ff46f25bdc6aa6190c32c552509fce713f Mon Sep 17 00:00:00 2001 From: Meatballs Date: Fri, 25 Apr 2014 18:14:39 +0100 Subject: [PATCH] Basic specs --- spec/lib/rex/exploitation/powershell_spec.rb | 33 +++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/spec/lib/rex/exploitation/powershell_spec.rb b/spec/lib/rex/exploitation/powershell_spec.rb index 2ea36a4816..6885691963 100644 --- a/spec/lib/rex/exploitation/powershell_spec.rb +++ b/spec/lib/rex/exploitation/powershell_spec.rb @@ -5,12 +5,43 @@ require 'rex/exploitation/powershell' describe Rex::Exploitation::Powershell do + let(:example_script) do + """function DumpHashes +{ + LoadApi + $bootkey = Get-BootKey; + $hbootKey = Get-HBootKey $bootkey; + Get-UserKeys | %{ + $hashes = Get-UserHashes $_ $hBootKey; + \"{0}:{1}:{2}:{3}:::\" -f ($_.UserName,$_.Rid, + [BitConverter]::ToString($hashes[0]).Replace(\"-\",\"\").ToLower(), + [BitConverter]::ToString($hashes[1]).Replace(\"-\",\"\").ToLower()); + } +} +DumpHashes""" + end + describe "::read_script" do it 'should create a script from a string input' do - script = described_class.read_script("parp") + script = described_class.read_script(example_script) script.should be_a_kind_of Rex::Exploitation::Powershell::Script end end + describe "::process_subs" do + it 'should create an array of substitutions to process' do + subs = described_class.process_subs("BitConverter,ParpConverter;$bootkey,$parpkey;") + subs.should eq [['BitConverter','ParpConverter'],['$bootkey','$parpkey']] + end + end + + describe "::make_subs" do + it 'should substitute values in script' do + script = described_class.make_subs(example_script,[['BitConverter','ParpConverter']]) + script.include?('BitConverter').should be_false + script.include?('ParpConverter').should be_true + end + end + end