mirror of
https://github.com/bettercap/bettercap
synced 2025-07-30 19:50:06 -07:00
new: new -script allows to run JS code to instrument session
This commit is contained in:
parent
d5e5abcb9b
commit
40727063ec
13 changed files with 610 additions and 312 deletions
38
js/init.go
Normal file
38
js/init.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package js
|
||||
|
||||
import (
|
||||
"github.com/evilsocket/islazy/log"
|
||||
"github.com/evilsocket/islazy/plugin"
|
||||
|
||||
"github.com/robertkrimen/otto"
|
||||
)
|
||||
|
||||
var NullValue = otto.Value{}
|
||||
|
||||
func ReportError(format string, args ...interface{}) otto.Value {
|
||||
log.Error(format, args...)
|
||||
return NullValue
|
||||
}
|
||||
|
||||
func init() {
|
||||
// TODO: refactor this in packages
|
||||
|
||||
plugin.Defines["readDir"] = readDir
|
||||
plugin.Defines["readFile"] = readFile
|
||||
plugin.Defines["writeFile"] = writeFile
|
||||
|
||||
plugin.Defines["log"] = flog
|
||||
plugin.Defines["log_debug"] = log_debug
|
||||
plugin.Defines["log_info"] = log_info
|
||||
plugin.Defines["log_warn"] = log_warn
|
||||
plugin.Defines["log_error"] = log_error
|
||||
plugin.Defines["log_fatal"] = log_fatal
|
||||
|
||||
plugin.Defines["btoa"] = btoa
|
||||
plugin.Defines["atob"] = atob
|
||||
plugin.Defines["gzipCompress"] = gzipCompress
|
||||
plugin.Defines["gzipDecompress"] = gzipDecompress
|
||||
|
||||
plugin.Defines["httpRequest"] = httpRequest
|
||||
plugin.Defines["http"] = httpPackage{}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue