Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /usr/share/nmap/nselib/ |
Upload File : |
--- -- Pack and unpack binary data. -- -- A problem script authors often face is the necessity of encoding values -- into binary data. For example after analyzing a protocol the starting -- point to write a script could be a hex dump, which serves as a preamble -- to every sent packet. Although it is possible to work with the -- functionality Lua provides, it's not very convenient. Therefore NSE includes -- Binlib, based on lpack (http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/) -- by Luiz Henrique de Figueiredo. -- -- The Binlib functions take a format string to encode and decode binary -- data. Packing and unpacking are controlled by the following operator -- characters: -- * <code>H</code> hex string -- * <code>B</code> bit string -- * <code>x</code> null byte -- * <code>z</code> zero-terminated string -- * <code>p</code> string preceded by 1-byte integer length -- * <code>P</code> string preceded by 2-byte integer length -- * <code>a</code> string preceded by 4-byte integer length -- * <code>A</code> string -- * <code>f</code> float -- * <code>d</code> double -- * <code>n</code> Lua number -- * <code>c</code> char (1-byte integer) -- * <code>C</code> byte = unsigned char (1-byte unsigned integer) -- * <code>s</code> short (2-byte integer) -- * <code>S</code> unsigned short (2-byte unsigned integer) -- * <code>i</code> int (4-byte integer) -- * <code>I</code> unsigned int (4-byte unsigned integer) -- * <code>l</code> long (8-byte integer) -- * <code>L</code> unsigned long (8-byte unsigned integer) -- * <code><</code> little endian modifier -- * <code>></code> big endian modifier -- * <code>=</code> native endian modifier -- -- Note that the endian operators work as modifiers to all the -- characters following them in the format string. module "bin" --- Returns a binary packed string. -- -- The format string describes how the parameters (<code>p1</code>, -- <code>...</code>) will be interpreted. Numerical values following operators -- stand for operator repetitions and need an according amount of parameters. -- Operators expect appropriate parameter types. -- -- Note: on Windows packing of 64-bit values > 2^63 currently -- results in packing exactly 2^63. -- @param format Format string, used to pack following arguments. -- @param ... The values to pack. -- @return String containing packed data. function pack(format, ...) --- Returns values read from the binary packed data string. -- -- The first return value of this function is the position at which unpacking -- stopped. This can be used as the <code>init</code> value for subsequent -- calls. The following return values are the values according to the format -- string. Numerical values in the format string are interpreted as repetitions -- like in <code>pack</code>, except if used with <code>A</code>, -- <code>B</code>, or <code>H</code>, in which cases the number tells -- <code>unpack</code> how many bytes to read. <code>unpack</code> stops if -- either the format string or the binary data string are exhausted. -- @param format Format string, used to unpack values out of data string. -- @param data String containing packed data. -- @param init Optional starting position within the string. -- @return Position in the data string where unpacking stopped. -- @return All unpacked values. function unpack(format, data, init)