class Object

Constants

NASL_EMU_ENCODING
NASL_EMU_IPV6

Public Instance Methods

base64(str) click to toggle source
# File lib/nasl_emu.rb, line 51
def base64(str)
        return Base64.encode64(str)
end
crap(num, str='X') click to toggle source
# File lib/nasl_emu.rb, line 38
def crap(num, str='X')
        times=num/str.length+1
        return (str*times)[0..num-1]
end
display(*arg) click to toggle source
# File lib/nasl_emu.rb, line 9
def display(*arg)
        arg.each do |a|
                tmpstr = a.to_s
                print tmpstr
        end
end
hex2raw(str) click to toggle source
# File lib/nasl_emu.rb, line 34
def hex2raw(str)
        return str.scan(/../).map(&:hex).pack('C*').force_encoding(NASL_EMU_ENCODING)
end
raw_string(*arg) click to toggle source
# File lib/nasl_emu.rb, line 25
def raw_string(*arg)
        str = ''
        arg.each do |i|
                tmpstr = i.to_s
                str << tmpstr.scan(/../).map(&:hex).pack('C*').force_encoding(NASL_EMU_ENCODING)
        end
        return str
end
string(*arg) click to toggle source
# File lib/nasl_emu.rb, line 16
def string(*arg)
        str = ''
        arg.each do |a|
                tmpstr = a.to_s
                str << tmpstr
        end
        return str
end
strlen(str) click to toggle source
# File lib/nasl_emu.rb, line 43
def strlen(str)
        return str.length
end
this_host() click to toggle source
# File lib/nasl_emu.rb, line 55
def this_host
        ip='127.0.0.1'
        addr_infos = Socket.ip_address_list
        addr_infos.each do |adr|
                if adr.ip_address != '127.0.0.1' then
                        if NASL_EMU_IPV6 then
                                ip = adr.ip_address
                        else
                                if not adr.ip_address.include?(':') then
                                        ip = adr.ip_address
                                end
                        end
                end
        end
        return ip
end
tolower(str) click to toggle source
# File lib/nasl_emu.rb, line 47
def tolower(str)
        return str.downcase
end