Library sslv2

A library providing functions for doing SSLv2 communications

Authors:

  • Bertrand Bonnefoy-Claudet
  • Daniel Miller

Source: https://svn.nmap.org/nmap/nselib/sslv2.lua

Functions

client_hello (ciphers)

Build a client_hello message

record_buffer (sock, buffer, i)

Get an entire record into a buffer

record_read (buffer, i)

Read a SSLv2 record

ssl_record (payload, pad_length)

Wrap a payload in an SSLv2 record header

Tables

SSL_CIPHER_CODES

Another table of ciphers

SSL_CIPHERS

SSLv2 ciphers, keyed by cipher code as a string of 3 bytes.

Functions

client_hello (ciphers)

Build a client_hello message

The ciphers parameter can contain cipher names or raw 3-byte cipher codes.

Parameters

ciphers
Table of cipher names

Return value:

The client_hello record as a string
record_buffer (sock, buffer, i)

Get an entire record into a buffer

Caller is responsible for closing the socket if necessary.

Parameters

sock
The socket to read additional data from
buffer
The string buffer holding any previously-read data (default: "")
i
The position in the buffer where the record should start (default: 1)

Return values:

  1. status Socket status
  2. Buffer containing at least 1 record if status is true
  3. Error text if there was an error
record_read (buffer, i)

Read a SSLv2 record

Parameters

buffer
The read buffer
i
The position in the buffer to start reading

Return values:

  1. The current position in the buffer
  2. The record that was read, as a table
ssl_record (payload, pad_length)

Wrap a payload in an SSLv2 record header

Parameters

payload
The padded payload to send
pad_length
The length of the padding. If the payload is not padded, set to 0

Return value:

An SSLv2 record containing the payload

Tables

SSL_CIPHER_CODES

Another table of ciphers

Unlike SSL_CIPHERS, this one is keyed by cipher name and the values are the cipher code as a 3-byte string.

SSL_CIPHERS

SSLv2 ciphers, keyed by cipher code as a string of 3 bytes.

Fields

str
The cipher name as a string
key_length
The length of the cipher's key
encrypted_key_length
How much of the key is encrypted in the handshake (effective key strength)