Skip to content

Commit

Permalink
misc: small fix or general refactoring i did not bother commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Apr 8, 2021
1 parent 6393dc1 commit d5fb7b6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
31 changes: 19 additions & 12 deletions _example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ require("telegram")
var fakeESSID = random.String(16, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
var fakeBSSID = random.Mac()

function graph(who, where) {
// generates a .dot file with the graph for this mac
run('graph.to_dot ' + who);
// uses graphviz to make a png of it
run('!dot -Tpng bettergraph.dot > ' + where);
}

function onDeauthentication(event) {
var data = event.data;

run('graph.to_dot ' + data.address1);
run('!dot -Tpng bettergraph.dot > /tmp/graph_deauth.png')
graph(data.address1, '/tmp/graph_deauth.png');

var message = '🚨 Detected deauthentication frame:\n\n' +
'Time: ' + event.time + "\n" +
'GPS: lat=' + session.GPS.Latitude + " lon=" + session.GPS.Longitude + " updated_at=" + session.GPS.Updated.String() + "\n\n" +
// 'Time: ' + event.time + "\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" +
Expand All @@ -27,12 +34,12 @@ function onDeauthentication(event) {
function onNewAP(event){
var ap = event.data;
if(ap.hostname == fakeESSID) {
run('graph.to_dot ' + ap.mac);
run('!dot -Tpng bettergraph.dot > /tmp/graph_ap.png')
graph(ap.mac, '/tmp/graph_ap.png');

var message = '🚨 Detected possible rogue AP:\n\n' +
'Time: ' + event.time + "\n" +
'GPS: lat=' + session.GPS.Latitude + " lon=" + session.GPS.Longitude + " updated_at=" + session.GPS.Updated.String() + "\n\n" +
// 'Time: ' + event.time + "\n" +
// 'GPS: lat=' + session.GPS.Latitude + " lon=" + session.GPS.Longitude + " updated_at=" +
//session.GPS.Updated.String() + "\n\n" +
'AP: ' + ap.mac + ' (' + ap.vendor + ')';

// send to telegram bot
Expand All @@ -45,8 +52,7 @@ function onHandshake(event){
var data = event.data;
var what = 'handshake';

run('graph.to_dot ' + data.station);
run('!dot -Tpng bettergraph.dot > /tmp/graph_handshake.png')
graph(data.station, '/tmp/graph_handshake.png');

if(data.pmkid != null) {
what = "RSN PMKID";
Expand All @@ -57,8 +63,9 @@ function onHandshake(event){
}

var message = '💰 Captured ' + what + ':\n\n' +
'Time: ' + event.time + "\n" +
'GPS: lat=' + session.GPS.Latitude + " lon=" + session.GPS.Longitude + " updated_at=" + session.GPS.Updated.String() + "\n\n" +
//'Time: ' + event.time + "\n" +
//'GPS: lat=' + session.GPS.Latitude + " lon=" + session.GPS.Longitude + " updated_at=" +
//session.GPS.Updated.String() + "\n\n" +
'Station: ' + data.station + "\n" +
'AP: ' + data.ap;

Expand Down
2 changes: 1 addition & 1 deletion _example/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ function sendMessage(message) {

function sendPhoto(path) {
var url = 'https://api.telegram.org/bot' + telegramToken + '/sendPhoto';
var cmd = 'curl -s -X POST "' + url + '" -F chat_id=' + telegramChatId + ' -F photo="@' + path + '"';
var cmd = 'curl -s -X POST "' + url + '" -F chat_id=' + telegramChatId + ' -F photo="@' + path + '" > /dev/null';
run("!"+cmd);
}
3 changes: 3 additions & 0 deletions modules/graph/dot.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
)

func (mod *Module) generateDotGraph(bssid string) error {
mod.wLock.Lock()
defer mod.wLock.Unlock()

start := time.Now()
if err := mod.updateSettings(); err != nil {
return err
Expand Down
3 changes: 3 additions & 0 deletions modules/graph/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
)

func (mod *Module) generateJSONGraph(bssid string) error {
mod.wLock.Lock()
defer mod.wLock.Unlock()

start := time.Now()
if err := mod.updateSettings(); err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions modules/graph/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"path/filepath"
"regexp"
"sync"
"time"
)

Expand Down Expand Up @@ -46,6 +47,7 @@ type Module struct {
gw *Node
iface *Node
eventBus session.EventBus
wLock sync.Mutex
}

func NewModule(s *session.Session) *Module {
Expand Down

0 comments on commit d5fb7b6

Please sign in to comment.