README.md
It searches paths by priority, stops if it has found the file and push it to a map.
The parameter -d displays debug information.
libs = LoadLibs(["firstpath","secondpath","morepaths"],["crypto.so","metaxploit.so"])
lib = libs["typeOf"]
libs = LoadLibs([current_path,parent_path(launch_path),parent_path(program_path),"/lib"],["crypto.so","metaxploit.so"])
print("Available libraries:")
for lib in libs.indexes
if lib == "cryptoLib" then
print("* "+lib)
CrypTools = libs["cryptoLib"]
end if
if lib == "MetaxploitLib" then
print("* "+lib)
MetaTools = libs["MetaxploitLib"]
end if
end for
# Documentation
It searches paths by priority, stops if it has found the file and push it to a map.
## Usage
The parameter `-d` displays debug information.
```
libs = LoadLibs(["firstpath","secondpath","morepaths"],["crypto.so","metaxploit.so"])
lib = libs["typeOf"]
```
## Example
```
libs = LoadLibs([current_path,parent_path(launch_path),parent_path(program_path),"/lib"],["crypto.so","metaxploit.so"])
print("Available libraries:")
for lib in libs.indexes
if lib == "cryptoLib" then
print("* "+lib)
CrypTools = libs["cryptoLib"]
end if
if lib == "MetaxploitLib" then
print("* "+lib)
MetaTools = libs["MetaxploitLib"]
end if
end for
```
LoadLibs.src
LoadLibs = function(dirs,names)
tocolor = function(color)
return "<color="+color+">"+self.str+"</color>"
end function
convert = function(text)
obj = {}
obj.str = str(text)
obj.tocolor = @tocolor
return obj
end function
DateTime = function(param)
month = {}
month["Jan"] = "01"
month["Feb"] = "02"
month["Mar"] = "03"
month["Apr"] = "04"
month["May"] = "05"
month["Jun"] = "06"
month["Jul"] = "07"
month["Aug"] = "08"
month["Sep"] = "09"
month["Oct"] = "10"
month["Nov"] = "11"
month["Dec"] = "12"
string = current_date
for n in month.indexes
date = string.split(" ")[0]
if date.indexOf(n) then
date = date.replace(n,month[n])
break
end if
end for
d = date.split("/")[0]
m = date.split("/")[1]
y = date.split("/")[2]
date = y+m+d
time = string.split(" ")[2].replace(":","")
datetime = date+"+"+time
return datetime
end function
debug = function(msg)
if params.len == 1 and params[0] == "-d" then
print( convert("[DEBUG] "+DateTime+" - "+msg).tocolor("purple") )
end if
end function
obj = {}
for name in names
for dir in dirs
file = get_shell.host_computer.File(dir+"/"+name)
if typeof(file) != "null" then
if file.has_permission("r") then
if file.is_binary then
debug("Loaded "+file.path+" -> "+typeof(include_lib(file.path)))
obj.push( typeof( include_lib(file.path) ) )
obj[typeof( include_lib(file.path) )] = include_lib(file.path)
break
end if
if not file.is_binary then
debug(file.path+" is not a binary.")
end if
end if
if not file.has_permission("r") then
debug(file.path+" has no read permissions.")
end if
end if
if typeof(file) == "null" then
debug(dir+"/"+name+" does not exist.")
end if
end for
end for
return obj
end function
// Example
libs = LoadLibs([current_path,parent_path(launch_path),parent_path(program_path),"/lib"],["crypto.so","metaxploit.so"])
print("Available libraries:")
for lib in libs.indexes
if lib == "cryptoLib" then
print("* "+lib)
CrypTools = libs["cryptoLib"]
end if
if lib == "MetaxploitLib" then
print("* "+lib)
MetaTools = libs["MetaxploitLib"]
end if
end for