mirror of
https://github.com/bettercap/bettercap
synced 2025-07-12 08:07:00 -07:00
fix: fixed vm locking
This commit is contained in:
parent
3c20f2c9aa
commit
2b1ff7d59f
3 changed files with 35 additions and 31 deletions
42
example.js
42
example.js
|
@ -13,18 +13,7 @@ function sendMessage(message) {
|
|||
}
|
||||
}
|
||||
|
||||
log("session script loaded");
|
||||
|
||||
// enable recon and probing of new hosts
|
||||
run('net.recon on');
|
||||
run('net.probe on');
|
||||
|
||||
// enable wifi scanning
|
||||
run('set wifi.interface ' + wifiInterface);
|
||||
run('wifi.recon on');
|
||||
|
||||
// register for wifi.deauthentication events
|
||||
onEvent('wifi.deauthentication', function(event){
|
||||
function onDeauthentication(event) {
|
||||
var data = event.Data;
|
||||
var message = '🚨 Detected deauthentication frame:\n\n' +
|
||||
'Time: ' + event.Time.String() + "\n" +
|
||||
|
@ -37,10 +26,9 @@ onEvent('wifi.deauthentication', function(event){
|
|||
|
||||
// send to telegram bot
|
||||
sendMessage(message);
|
||||
});
|
||||
}
|
||||
|
||||
// register for wifi.client.handshake events
|
||||
onEvent('wifi.client.handshake', function(event){
|
||||
function onHandshake(event){
|
||||
var data = event.Data;
|
||||
var what = 'handshake';
|
||||
|
||||
|
@ -60,12 +48,26 @@ onEvent('wifi.client.handshake', function(event){
|
|||
|
||||
// send to telegram bot
|
||||
sendMessage(message);
|
||||
});
|
||||
}
|
||||
|
||||
// register for any event
|
||||
onEvent(function(event){
|
||||
function onAnyEvent(event){
|
||||
// if endpoint.new or endpoint.lost, clear the screen and show hosts
|
||||
if( event.Tag.indexOf('endpoint.') === 0 ) {
|
||||
run('clear; net.show');
|
||||
// run('clear; net.show');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
log("session script loaded");
|
||||
|
||||
// enable recon and probing of new hosts
|
||||
run('net.recon on');
|
||||
run('net.probe on');
|
||||
// enable wifi scanning
|
||||
run('set wifi.interface ' + wifiInterface);
|
||||
run('wifi.recon on');
|
||||
// register for wifi.deauthentication events
|
||||
onEvent('wifi.deauthentication', onDeauthentication);
|
||||
// register for wifi.client.handshake events
|
||||
onEvent('wifi.client.handshake', onHandshake);
|
||||
// register for any event
|
||||
onEvent(onAnyEvent);
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"github.com/evilsocket/islazy/plugin"
|
||||
|
||||
_ "github.com/bettercap/bettercap/js"
|
||||
"github.com/evilsocket/islazy/plugin"
|
||||
)
|
||||
|
||||
type Script struct {
|
||||
|
|
|
@ -56,9 +56,12 @@ func jsOnEventFunc(call otto.FunctionCall) otto.Value {
|
|||
|
||||
for event := range listener {
|
||||
if expr == "" || event.Tag == expr {
|
||||
// lock vm
|
||||
I.script.Lock()
|
||||
if _, err := cb.Call(otto.NullValue(), event); err != nil {
|
||||
I.Events.Log(log.ERROR, "error dispatching event %s: %v", event.Tag, err)
|
||||
}
|
||||
I.script.Unlock()
|
||||
}
|
||||
}
|
||||
}(filterExpr, cb)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue