Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/spec/lib/rex/proto/x11.rb
Views: 15996
# -*- coding: binary -*-12require 'spec_helper'34RSpec.describe Rex::Proto::X11 do5subject do6mod = ::Msf::Exploit.new7mod.extend described_class89mod.send(:initialize)10mod11end1213let(:get_property_resp) do14"\x01\x08\x04\x00\x1f\x00\x00\x00\x1f\x00\x00\x00\x00\x00\x00\x00" \15"\x79\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \16"\x58\x66\x74\x2e\x64\x70\x69\x3a\x09\x39\x36\x0a\x58\x66\x74\x2e" \17"\x61\x6e\x74\x69\x61\x6c\x69\x61\x73\x3a\x09\x31\x0a\x58\x66\x74" \18"\x2e\x68\x69\x6e\x74\x69\x6e\x67\x3a\x09\x31\x0a\x58\x66\x74\x2e" \19"\x68\x69\x6e\x74\x73\x74\x79\x6c\x65\x3a\x09\x68\x69\x6e\x74\x73" \20"\x6c\x69\x67\x68\x74\x0a\x58\x66\x74\x2e\x72\x67\x62\x61\x3a\x09" \21"\x72\x67\x62\x0a\x58\x63\x75\x72\x73\x6f\x72\x2e\x73\x69\x7a\x65" \22"\x3a\x09\x32\x34\x0a\x58\x63\x75\x72\x73\x6f\x72\x2e\x74\x68\x65" \23"\x6d\x65\x3a\x09\x59\x61\x72\x75\x0a\x00\x00\x00"24end2526let(:get_property) do27"\x14\x00\x06\x00\x28\x05\x00\x00\x17\x00\x00\x00\x1f\x00\x00\x00" \28"\x00\x00\x00\x00\x00\xe1\xf5\x05"29end3031let(:creategc) do32"\x37\x00\x05\x00\x00\x00\x00\x01\x28\x05\x00\x00\x08\x00\x00\x00\xff\xff\xff\x00"33end3435let(:get_input_focus) do36"\x2b\x00\x01\x00"37end3839let(:free_gc) do40"\x3c\x01\x02\x00\x00\x00\x00\x02"41end4243let(:intern_atom_wait) do44"\x10\x00\x03\x00\x04\x00\x00\x00\x57\x61\x69\x74"45end4647let(:intern_atom_server_overlay_visuals) do48"\x10\x01\x08\x00\x16\x00\x00\x00\x53\x45\x52\x56\x45\x52\x5f\x4f" \49"\x56\x45\x52\x4c\x41\x59\x5f\x56\x49\x53\x55\x41\x4c\x53\x00\x00"50end5152describe 'X11GetPropertyResponseHeader' do53context '#read' do54it do55response = Rex::Proto::X11::X11GetPropertyResponseHeader.read(get_property_resp)56expect(response.get_property_type).to eq(31) # \x1f\x00\x00\x0057expect(response.sequence_number).to eq(4) # \x04\x0058expect(response.value_length).to eq(121)59end60end61end6263describe 'X11GetPropertyRequest' do64context '#initialize' do65it do66header = Rex::Proto::X11::X11RequestHeader.new(opcode: 20)67body = Rex::Proto::X11::X11GetPropertyRequestBody.new(window: 1320)68expect(header.to_binary_s + body.to_binary_s).to eq(get_property)69end70end7172context '#read' do73it do74request = Rex::Proto::X11::X11Request.read(get_property)75expect(request.header.opcode).to eq(20)76expect(request.body.content_length).to eq(100_000_000)77expect(request.body.window).to eq(1320)78end79end80end8182describe 'X11CreateGraphicalContextRequest' do83context '#initialize' do84it do85header = Rex::Proto::X11::X11RequestHeader.new(opcode: 55)86body = Rex::Proto::X11::X11CreateGraphicalContextRequestBody.new(87cid: 16777216,88drawable: 1320,89gc_value_mask_background: 190)91expect(header.to_binary_s + body.to_binary_s).to eq(creategc)92end93end9495context '#read' do96it do97request = Rex::Proto::X11::X11Request.read(creategc)98expect(request.header.opcode).to eq(55)99expect(request.body.request_length).to eq(5)100expect(request.body.cid).to eq(16777216)101expect(request.body.drawable).to eq(1320)102expect(request.body.gc_value_mask_background).to eq(1)103expect(request.body.background).to eq(16777215)104end105end106end107108describe 'X11GetInputFocusRequest' do109context '#initialize' do110it do111header = Rex::Proto::X11::X11RequestHeader.new(opcode: 43)112body = Rex::Proto::X11::X11GetInputFocusRequestBody.new113expect(header.to_binary_s + body.to_binary_s).to eq(get_input_focus)114end115end116context '#read' do117it do118request = Rex::Proto::X11::X11Request.read(get_input_focus)119expect(request.header.opcode).to eq(43)120end121end122end123124describe 'X11FreeGraphicalContextRequest' do125context '#initialize' do126it do127header = Rex::Proto::X11::X11RequestHeader.new(opcode: 60)128body = Rex::Proto::X11::X11FreeGraphicalContextRequestBody.new(129gc: 33554432130)131expect(header.to_binary_s + body.to_binary_s).to eq(free_gc)132end133end134context '#read' do135it do136request = Rex::Proto::X11::X11Request.read(free_gc)137expect(request.header.opcode).to eq(60)138expect(request.body.gc).to eq(33554432)139end140end141end142143describe 'X11InternAtomRequest' do144context '#initialize' do145it do146header = Rex::Proto::X11::X11RequestHeader.new(opcode: 16)147body = Rex::Proto::X11::X11InternAtomRequestBody.new(148name: 'Wait'149)150expect(header.to_binary_s + body.to_binary_s).to eq(intern_atom_wait)151expect(header.opcode).to eq(16)152expect(body.request_length).to eq(3)153expect(body.name).to eq('Wait')154expect(body.only_if_exists).to eq(0)155156header = Rex::Proto::X11::X11RequestHeader.new(opcode: 16)157body = Rex::Proto::X11::X11InternAtomRequestBody.new(158name: "SERVER_OVERLAY_VISUALS\x00\x00", only_if_exists: 1159)160expect(header.to_binary_s + body.to_binary_s).to eq(intern_atom_server_overlay_visuals)161expect(header.opcode).to eq(16)162expect(body.request_length).to eq(8)163expect(body.name).to eq('SERVER_OVERLAY_VISUALS')164expect(body.only_if_exists).to eq(1)165end166end167end168end169170171