CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/lib/rex/post/meterpreter/packet_parser_spec.rb
Views: 11788
1
# -*- coding:binary -*-
2
require 'rex/post/meterpreter/packet'
3
require 'rex/post/meterpreter/packet_parser'
4
require 'stringio'
5
6
RSpec.describe Rex::Post::Meterpreter::PacketParser do
7
subject(:parser){
8
Rex::Post::Meterpreter::PacketParser.new
9
}
10
before(:example) do
11
@request_packet = Rex::Post::Meterpreter::Packet.create_request(31337)
12
@sock = StringIO.new(@request_packet.to_r)
13
end
14
15
it "should parse valid raw data into a packet object" do
16
begin
17
parsed_packet = parser.recv(@sock)
18
end while parsed_packet.nil?
19
parsed_packet.from_r
20
expect(parsed_packet).to be_a Rex::Post::Meterpreter::Packet
21
expect(parsed_packet.type).to eq Rex::Post::Meterpreter::PACKET_TYPE_REQUEST
22
expect(parsed_packet.method?(31337)).to eq true
23
end
24
25
end
26
27