Sha256: 7c4f176e44c2aa992138da99a6a55b1f3d667f9b4497b495b038aa69e1c98837
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
require 'spec_helper' require 'ronin/post_ex/sessions/reverse_shell' describe Ronin::PostEx::Sessions::ReverseShell do it "must inherit from Ronin::PostEx::Sessions::RemoteShellSession" do expect(described_class).to be < Ronin::PostEx::Sessions::RemoteShellSession end let(:host) { 'localhost' } let(:port) { 1337 } let(:addrinfo) { Addrinfo.tcp(host,port) } describe ".listen" do let(:server_socket) { double('TCPServer') } let(:client_socket) { double('TCPSocket') } before { allow(client_socket).to receive(:remote_address).and_return(addrinfo) } subject { described_class } it "must listen on a local port, accept a connection, return a #{described_class} object, and close the server socket" do expect(TCPServer).to receive(:new).with(port,nil).and_return(server_socket) expect(server_socket).to receive(:listen).with(1) expect(server_socket).to receive(:accept).and_return(client_socket) expect(server_socket).to receive(:close) reverse_shell = subject.listen(port) expect(reverse_shell).to be_kind_of(described_class) expect(reverse_shell.io).to be(client_socket) end context "and a host argument is given" do let(:host) { '127.0.0.1' } it "must listen on a local host and port, accept a connection, return a #{described_class} object, and close the server socket" do expect(TCPServer).to receive(:new).with(port,host).and_return(server_socket) expect(server_socket).to receive(:listen).with(1) expect(server_socket).to receive(:accept).and_return(client_socket) expect(server_socket).to receive(:close) allow(client_socket).to receive(:local_address).and_return(addrinfo) reverse_shell = subject.listen(host,port) expect(reverse_shell).to be_kind_of(described_class) expect(reverse_shell.io).to be(client_socket) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ronin-post_ex-0.1.0.beta1 | spec/sessions/reverse_shell_spec.rb |