Skip to content

Commit

Permalink
fix: fixed vm locking
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Apr 4, 2021
1 parent 3c20f2c commit 2b1ff7d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
60 changes: 31 additions & 29 deletions example.js
Expand Up @@ -4,43 +4,31 @@ var telegramChatId = 'put your telegram chat id here';

function sendMessage(message) {
var url = 'https://api.telegram.org/bot' + telegramToken +
'/sendMessage?chat_id=' + telegramChatId +
'&text=' + http.Encode(message);
'/sendMessage?chat_id=' + telegramChatId +
'&text=' + http.Encode(message);

var resp = http.Get(url, {});
if( resp.Error ) {
log("error while running sending telegram message: " + resp.Error.Error());
}
}

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" +
'GPS: lat=' + session.GPS.Latitude + " lon=" + session.GPS.Longitude + " updated_at=" + session.GPS.Updated.String() + "\n\n" +
'RSSI: ' + data.RSSI + "\n" +
'Reason: ' + data.Reason + "\n" +
'Address1: ' + data.Address1 + "\n" +
'Address2: ' + data.Address2 + "\n" +
'Address3: ' + data.Address3;
'Time: ' + event.Time.String() + "\n" +
'GPS: lat=' + session.GPS.Latitude + " lon=" + session.GPS.Longitude + " updated_at=" + session.GPS.Updated.String() + "\n\n" +
'RSSI: ' + data.RSSI + "\n" +
'Reason: ' + data.Reason + "\n" +
'Address1: ' + data.Address1 + "\n" +
'Address2: ' + data.Address2 + "\n" +
'Address3: ' + data.Address3;

// 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';

Expand All @@ -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);
3 changes: 1 addition & 2 deletions session/script.go
@@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions session/script_builtin_runtime.go
Expand Up @@ -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)
Expand Down

0 comments on commit 2b1ff7d

Please sign in to comment.