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/lib/rex/proto/apache_j_p.rb
Views: 11655
# -*- coding: binary -*-12require 'bindata'34# @see: https://tomcat.apache.org/connectors-doc/ajp/ajpv13a.html5module Rex::Proto::ApacheJP6class ApacheJPBoolean < BinData::Primitive7endian :big89uint8 :data1011def get12self.data != 013end1415def set(v)16self.data = v ? 1 : 017end18end1920class ApacheJPString < BinData::Primitive21endian :big2223uint16 :len, value: -> { data.length }24stringz :data2526def get27self.data28end2930def set(v)31self.data = v32end33end3435class ApacheJPHeaderName < BinData::Primitive36COMMON_HEADERS = []3738endian :big3940uint16 :len_or_code41stringz :data, onlyif: -> { len_or_code < 0xa000 }4243def get44if len_or_code >= 0xa00045self.class::COMMON_HEADERS[(len_or_code.to_i & 0xff) - 1]46else47self.data48end49end5051def set(v)52if (idx = self.class::COMMON_HEADERS.index(v))53self.len_or_code = 0xa000 | (idx + 1)54else55raise RuntimeError if v.length >= 0xa0005657self.len_or_code = v.length58self.data = v59end60end61end6263class ApacheJPReqHeaderName < ApacheJPHeaderName64COMMON_HEADERS = %w{ accept accept-charset accept-encoding accept-language authorization connection content-type content-length cookie cookie2 host pragma referer user-agent }65end6667class ApacheJPResHeaderName < ApacheJPHeaderName68COMMON_HEADERS = %w{ Content-Type Content-Language Content-Length Date Last-Modified Location Set-Cookie Set-Cookie2 Servlet-Engine Status WWW-Authentication }69end7071class ApacheJPRequestHeader < BinData::Record72endian :big7374apache_jp_req_header_name :header_name75apache_jp_string :header_value76end7778class ApacheJPResponseHeader < BinData::Record79endian :big8081apache_jp_res_header_name :header_name82apache_jp_string :header_value83end8485class ApacheJPRequestAttribute < BinData::Record86CODE_CONTEXT = 187CODE_SERVLET_PATH = 288CODE_REMOTE_USER = 389CODE_AUTH_TYPE = 490CODE_QUERY_STRING = 591CODE_JVM_ROUTE = 692CODE_SSL_CERT = 793CODE_SSL_CIPHER = 894CODE_SSL_SESSION = 995CODE_REQ_ATTRIBUTE = 1096CODE_TERMINATOR = 0xff9798endian :big99100uint8 :code101apache_jp_string :attribute_name, onlyif: -> { code == CODE_REQ_ATTRIBUTE }102apache_jp_string :attribute_value, onlyif: -> { code != CODE_TERMINATOR }103end104105class ApacheJPForwardRequest < BinData::Record106HTTP_METHOD_OPTIONS = 1107HTTP_METHOD_GET = 2108HTTP_METHOD_HEAD = 3109HTTP_METHOD_POST = 4110HTTP_METHOD_PUT = 5111HTTP_METHOD_DELETE = 6112HTTP_METHOD_TRACE = 7113HTTP_METHOD_PROPFIND = 8114HTTP_METHOD_PROPPATCH = 9115HTTP_METHOD_MKCOL = 10116HTTP_METHOD_COPY = 11117HTTP_METHOD_MOVE = 12118HTTP_METHOD_LOCK = 13119HTTP_METHOD_UNLOCK = 14120HTTP_METHOD_ACL = 15121HTTP_METHOD_REPORT = 16122HTTP_METHOD_VERSION_CONTROL = 17123HTTP_METHOD_CHECKIN = 18124HTTP_METHOD_CHECKOUT = 19125HTTP_METHOD_UNCHECKOUT = 20126HTTP_METHOD_SEARCH = 21127PREFIX_CODE = 2128129endian :big130131uint8 :prefix_code, value: PREFIX_CODE132uint8 :http_method133apache_jp_string :protocol, initial_value: 'HTTP/1.1'134apache_jp_string :req_uri135apache_jp_string :remote_addr136apache_jp_string :remote_host137apache_jp_string :server_name138uint16 :server_port, initial_value: -> { is_ssl ? 80 : 443 }139apache_jp_boolean :is_ssl, initial_value: false140uint16 :num_headers, initial_value: -> { headers.length }141array :headers, type: :apache_jp_request_header, initial_length: :num_headers142array :attributes, type: :apache_jp_request_attribute, read_until: -> { element.code == ApacheJPRequestAttribute::TERMINATOR }143end144145class ApacheJPSendBodyChunk < BinData::Record146PREFIX_CODE = 3147148endian :big149150uint8 :prefix_code, value: PREFIX_CODE151uint16 :body_chunk_length, initial_value: -> { body_chunk.length }152string :body_chunk, read_length: :body_chunk_length153end154155class ApacheJPSendHeaders < BinData::Record156PREFIX_CODE = 4157158endian :big159160uint8 :prefix_code, value: PREFIX_CODE161uint16 :http_status_code162apache_jp_string :http_status_msg163uint16 :num_headers, initial_value: -> { header.length }164array :headers, type: :apache_jp_response_header, initial_length: :num_headers165end166167class ApacheJPEndResponse < BinData::Record168PREFIX_CODE = 5169170endian :big171172uint8 :prefix_code, value: PREFIX_CODE173apache_jp_boolean :reuse174end175176class ApacheJPGetBodyChunk < BinData::Record177PREFIX_CODE = 6178179endian :big180181uint8 :prefix_code, value: PREFIX_CODE182uint16 :requested_length183end184end185186187