Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/lib/rex/proto/ntp/modes_spec.rb
Views: 11789
# -*- coding: binary -*-1#23RSpec.describe "Rex::Proto::NTP mode message handling" do4before do5@payload = 'R7' * 76end78describe Rex::Proto::NTP::NTPControl do9before do10@control_raw = "\x1e\x05\x12\x34\x12\x34\x12\x34\x00\x00\x00\x0e" + @payload11@control = Rex::Proto::NTP::NTPControl.new12@control.version = 313@control.response = 014@control.more = 015@control.operation = 516@control.sequence = 0x123417@control.association_id = 0x123418@control.status = 0x123419@control.payload_offset = 020@control.payload_size = 1421@control.payload = @payload22end2324it 'Generates control NTP messages correctly' do25expect(@control_raw).to eq @control.to_binary_s26end2728it 'Parses control NTP messages correctly' do29parsed_raw = Rex::Proto::NTP::NTPControl.new.read(@control_raw)30expect(@control).to eq parsed_raw31end32end3334describe Rex::Proto::NTP::NTPGeneric do35before do36@generic_raw = "\xcc\x12\x34\x56" + @payload37@generic = Rex::Proto::NTP::NTPGeneric.new38@generic.li = 339@generic.version = 140@generic.mode = 441@generic.stratum = 0x1242@generic.poll = 0x3443@generic.precision = 0x5644@generic.payload = @payload45end4647it 'Generates generic NTP messages correctly' do48expect(@generic_raw).to eq @generic.to_binary_s49end5051it 'Parses generic NTP messages correctly' do52parsed_raw = Rex::Proto::NTP::NTPGeneric.new.read(@generic_raw)53expect(@generic).to eq parsed_raw54end55end5657describe Rex::Proto::NTP::NTPPrivate do58before do59@private_raw = "\x1f\x5a\x01\x99\x00\x00\x00\x00" + @payload60@private = Rex::Proto::NTP::NTPPrivate.new61@private.response = 062@private.more = 063@private.version = 364@private.mode = 765@private.auth = 066@private.sequence = 9067@private.implementation = 168@private.request_code = 15369@private.payload = @payload70end7172it 'Generates private NTP messages correctly' do73expect(@private_raw).to eq @private.to_binary_s74end7576it 'Parses private NTP messages correctly' do77parsed_raw = Rex::Proto::NTP::NTPPrivate.new.read(@private_raw)78expect(@private).to eq parsed_raw79end80end81end828384