local_spec.rb 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. require 'spec_helper'
  2. require 'rex/post/meterpreter/extensions/stdapi/sys/config'
  3. RSpec.describe Msf::Exploit::Local do
  4. describe '#exploit_type' do
  5. it 'indicates that the exploit is local' do
  6. expect(subject.exploit_type).to eq 'local'
  7. end
  8. end
  9. describe '#sysinfo' do
  10. before(:each) do
  11. allow(subject).to receive(:session).and_return(session)
  12. end
  13. context 'when the session is nil' do
  14. let(:session) { nil }
  15. it 'returns nil' do
  16. expect(subject.sysinfo).to eq nil
  17. end
  18. end
  19. context 'when the session is not Meterpreter' do
  20. let(:session) do
  21. connection = nil
  22. Msf::Sessions::CommandShell.new(connection)
  23. end
  24. it 'returns nil' do
  25. expect(subject.sysinfo).to eq nil
  26. end
  27. end
  28. context 'when the session is Meterpreter' do
  29. let(:session) do
  30. connection = nil
  31. session = Msf::Sessions::Meterpreter_x86_Win.new(connection)
  32. session.register_extension_alias(
  33. 'sys',
  34. Rex::Post::Meterpreter::ObjectAliases.new(
  35. 'config' => instance_double(
  36. ::Rex::Post::Meterpreter::Extensions::Stdapi::Sys::Config,
  37. sysinfo: { 'Computer' => 'FooComputer' }
  38. )
  39. )
  40. )
  41. session
  42. end
  43. it 'returns the sysinfo object' do
  44. expect(subject.sysinfo).to eq({ 'Computer' => 'FooComputer' })
  45. end
  46. end
  47. end
  48. end