|
343 | 343 | subject.has_tlv?(Rex::Post::Meterpreter::TLV_TYPE_BOOL).should == false
|
344 | 344 | end
|
345 | 345 | end
|
| 346 | + end |
| 347 | +end |
| 348 | + |
| 349 | +describe Rex::Post::Meterpreter::Packet do |
| 350 | + context "Request Packet" do |
| 351 | + subject{Rex::Post::Meterpreter::Packet.new(Rex::Post::Meterpreter::PACKET_TYPE_REQUEST, "test_method")} |
346 | 352 |
|
347 |
| - |
| 353 | + it "should respond to created_at" do |
| 354 | + subject.should respond_to :created_at |
| 355 | + end |
| 356 | + |
| 357 | + it "should respond to response?" do |
| 358 | + subject.should respond_to :response? |
| 359 | + end |
348 | 360 |
|
| 361 | + it "should respond to method?" do |
| 362 | + subject.should respond_to :method? |
| 363 | + end |
| 364 | + |
| 365 | + it "should respond to method" do |
| 366 | + subject.should respond_to :method |
| 367 | + end |
| 368 | + |
| 369 | + it "should respond to result?" do |
| 370 | + subject.should respond_to :result? |
| 371 | + end |
| 372 | + |
| 373 | + it "should respond to result=" do |
| 374 | + subject.should respond_to :result= |
| 375 | + end |
| 376 | + |
| 377 | + it "should respond to result" do |
| 378 | + subject.should respond_to :result |
| 379 | + end |
| 380 | + |
| 381 | + it "should respond to rid" do |
| 382 | + subject.should respond_to :rid |
| 383 | + end |
| 384 | + |
| 385 | + it "should return false for response?" do |
| 386 | + subject.response?.should == false |
| 387 | + end |
| 388 | + |
| 389 | + it "should evaluate the method correctly" do |
| 390 | + subject.method?("test_method").should == true |
| 391 | + subject.method?("blah").should == false |
| 392 | + end |
| 393 | + |
| 394 | + it "should accept new methods" do |
| 395 | + subject.method= "test_method2" |
| 396 | + subject.method?("test_method2").should == true |
| 397 | + end |
| 398 | + |
| 399 | + it "should return the correct method" do |
| 400 | + subject.method.should == "test_method" |
| 401 | + end |
| 402 | + |
| 403 | + it "should not have a result" do |
| 404 | + subject.result.should == nil |
| 405 | + end |
| 406 | + |
| 407 | + it "should return a valid request id" do |
| 408 | + subject.rid.should =~ /\A\d{32}\Z/ |
| 409 | + end |
| 410 | + |
| 411 | + it "should be created when Packet.create_request is called" do |
| 412 | + req = Rex::Post::Meterpreter::Packet.create_request("test_method") |
| 413 | + req.class.should == Rex::Post::Meterpreter::Packet |
| 414 | + req.response?.should == false |
| 415 | + req.method?("test_method").should == true |
| 416 | + end |
349 | 417 | end
|
350 | 418 |
|
| 419 | + context "a response packet" do |
| 420 | + subject{Rex::Post::Meterpreter::Packet.new(Rex::Post::Meterpreter::PACKET_TYPE_RESPONSE, "test_method")} |
| 421 | + before(:all) do |
| 422 | + subject.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_RESULT, "a-ok") |
| 423 | + end |
| 424 | + |
| 425 | + it "should return the correct result" do |
| 426 | + subject.result.should == "a-ok" |
| 427 | + end |
| 428 | + |
| 429 | + it "should evaluate result correctly" do |
| 430 | + subject.result?("a-ok").should == true |
| 431 | + subject.result?("5by5").should == false |
| 432 | + end |
351 | 433 |
|
| 434 | + it "should accept a new result" do |
| 435 | + subject.result= "test2" |
| 436 | + subject.result.should == "test2" |
| 437 | + end |
| 438 | + |
| 439 | + it "should be created when Packet.create_response is called" do |
| 440 | + resp = Rex::Post::Meterpreter::Packet.create_response |
| 441 | + resp.class.should == Rex::Post::Meterpreter::Packet |
| 442 | + resp.response?.should == true |
| 443 | + end |
| 444 | + |
| 445 | + end |
352 | 446 | end
|
0 commit comments