mirror of
https://github.com/bettercap/bettercap
synced 2025-07-12 16:13:48 -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");
|
function onDeauthentication(event) {
|
||||||
|
|
||||||
// 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){
|
|
||||||
var data = event.Data;
|
var data = event.Data;
|
||||||
var message = '🚨 Detected deauthentication frame:\n\n' +
|
var message = '🚨 Detected deauthentication frame:\n\n' +
|
||||||
'Time: ' + event.Time.String() + "\n" +
|
'Time: ' + event.Time.String() + "\n" +
|
||||||
|
@ -37,10 +26,9 @@ onEvent('wifi.deauthentication', function(event){
|
||||||
|
|
||||||
// send to telegram bot
|
// send to telegram bot
|
||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
});
|
}
|
||||||
|
|
||||||
// register for wifi.client.handshake events
|
function onHandshake(event){
|
||||||
onEvent('wifi.client.handshake', function(event){
|
|
||||||
var data = event.Data;
|
var data = event.Data;
|
||||||
var what = 'handshake';
|
var what = 'handshake';
|
||||||
|
|
||||||
|
@ -60,12 +48,26 @@ onEvent('wifi.client.handshake', function(event){
|
||||||
|
|
||||||
// send to telegram bot
|
// send to telegram bot
|
||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
});
|
}
|
||||||
|
|
||||||
// register for any event
|
function onAnyEvent(event){
|
||||||
onEvent(function(event){
|
|
||||||
// if endpoint.new or endpoint.lost, clear the screen and show hosts
|
// if endpoint.new or endpoint.lost, clear the screen and show hosts
|
||||||
if( event.Tag.indexOf('endpoint.') === 0 ) {
|
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
|
package session
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/evilsocket/islazy/plugin"
|
|
||||||
|
|
||||||
_ "github.com/bettercap/bettercap/js"
|
_ "github.com/bettercap/bettercap/js"
|
||||||
|
"github.com/evilsocket/islazy/plugin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Script struct {
|
type Script struct {
|
||||||
|
|
|
@ -56,9 +56,12 @@ func jsOnEventFunc(call otto.FunctionCall) otto.Value {
|
||||||
|
|
||||||
for event := range listener {
|
for event := range listener {
|
||||||
if expr == "" || event.Tag == expr {
|
if expr == "" || event.Tag == expr {
|
||||||
|
// lock vm
|
||||||
|
I.script.Lock()
|
||||||
if _, err := cb.Call(otto.NullValue(), event); err != nil {
|
if _, err := cb.Call(otto.NullValue(), event); err != nil {
|
||||||
I.Events.Log(log.ERROR, "error dispatching event %s: %v", event.Tag, err)
|
I.Events.Log(log.ERROR, "error dispatching event %s: %v", event.Tag, err)
|
||||||
}
|
}
|
||||||
|
I.script.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(filterExpr, cb)
|
}(filterExpr, cb)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue