Skip to content

Commit 0b886db

Browse files
committed
Script specs and remove unknown method
1 parent 0177e51 commit 0b886db

File tree

2 files changed

+49
-11
lines changed

2 files changed

+49
-11
lines changed

lib/rex/exploitation/powershell/script.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Powershell
99

1010
class Script
1111
attr_accessor :code
12-
attr_reader :functions
12+
attr_reader :functions, :rig
1313

1414
include Output
1515
include Parser
@@ -88,16 +88,6 @@ def self.to_byte_array(input_data,var_name = Rex::Text.rand_text_alpha(rand(3)+3
8888
return psh << lines.join("") + "\r\n"
8989
end
9090

91-
#
92-
# ?? RageLtMan
93-
#
94-
# @param dir [String] ?
95-
def self.psp_funcs(dir)
96-
scripts = Dir.glob(File.expand_path(dir) + '/**/*').select {|e| e =~ /ps1$|psm1$/}
97-
functions = scripts.map {|s| Script.new(s).functions}
98-
return functions.flatten
99-
end
100-
10191
#
10292
# Return list of code modifier methods
10393
#
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -*- coding:binary -*-
2+
require 'spec_helper'
3+
4+
require 'rex/exploitation/powershell'
5+
6+
describe Rex::Exploitation::Powershell::Output do
7+
8+
let(:example_script) do
9+
Rex::Text.rand_text_alpha(400)
10+
end
11+
12+
let(:subject) do
13+
Rex::Exploitation::Powershell::Script.new(example_script)
14+
end
15+
16+
describe "::initialize" do
17+
it 'should create a new script object' do
18+
subject.should be
19+
subject.should be_kind_of Rex::Exploitation::Powershell::Script
20+
subject.rig.should be
21+
subject.rig.should be_kind_of Rex::RandomIdentifierGenerator
22+
subject.code.should be
23+
subject.code.should be_kind_of String
24+
subject.code.empty?.should be_false
25+
subject.functions.empty?.should be_true
26+
end
27+
end
28+
29+
describe "::to_byte_array" do
30+
it 'should generate a powershell byte array' do
31+
byte_array = Rex::Exploitation::Powershell::Script.to_byte_array("parp")
32+
byte_array.should be
33+
byte_array.should be_kind_of String
34+
byte_array.include?('[Byte[]] $').should be_true
35+
end
36+
end
37+
38+
describe "::code_modifiers" do
39+
it 'should return an array of modifier methods' do
40+
mods = Rex::Exploitation::Powershell::Script.code_modifiers
41+
mods.should be
42+
mods.should be_kind_of Array
43+
mods.empty?.should be_false
44+
end
45+
end
46+
47+
end
48+

0 commit comments

Comments
 (0)