Skip to content

Commit

Permalink
Uses the updated version of optional btim module, btlejuice-proxy has…
Browse files Browse the repository at this point in the history
… some options. (#21)

* Integrated abilities to bring an interface up and spoof a MAC address.

* Fixed indentation.

* Removed a useless part which brought up an interface before attempting to spoof a MAC address.

* Added the possibility to list bluetooth interfaces.

* Renamed properties of an object describing an interface. Listing intetrfaces is more staightforward.

* The module btim became optional (dependent options are enabled if it's present), btlejuice-proxy brings up the specified interface and is able to list interfaces.
  • Loading branch information
narke authored and virtualabs committed Jul 3, 2017
1 parent faea355 commit 1cf99ac
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 52 deletions.
109 changes: 60 additions & 49 deletions bin/cmd_btlejuice.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var btim = require('btim');
* Command-line tool
**/
var parser = new argparse.ArgumentParser({
version: '1.1.5',
version: '1.1.6',
addHelp: true,
description: 'BtleJuice core & web interface'
});
Expand All @@ -53,16 +53,20 @@ parser.addArgument(['-s', '--web-port'], {
required: false,
default: 8080
});
parser.addArgument(['-m', '--mac'], {
help: 'Spoof the MAC address with a new one',
required: false,
});
parser.addArgument(['-l', '--list'], {
help: 'List bluetooth interfaces',
required: false,
action: 'storeTrue',
default: false
});

// Add additional options if the module btim is present.
if (btim != null) {
parser.addArgument(['-m', '--mac'], {
help: 'Spoof the MAC address with a new one',
required: false,
});
parser.addArgument(['-l', '--list'], {
help: 'List bluetooth interfaces',
required: false,
action: 'storeTrue',
default: false
});
}


args = parser.parseArgs();
Expand Down Expand Up @@ -114,7 +118,10 @@ if (args.iface != null) {
if (result != null) {
/* Keep the interface number. */
var iface = result[1];
btim.up(parseInt(iface));
/* Bring up an interace only if the module btim is present. */
if (btim != null) {
btim.up(parseInt(iface));
}
} else {
console.log(util.format('[!] Unknown interface %s', args.iface).red);
process.exit(-1);
Expand All @@ -128,53 +135,57 @@ if (args.iface != null) {
}
console.log(util.format('[i] Using interface hci%d', iface).bold);

if (args.mac != null && args.iface != null) {
var mac_regex = /^(([A-Fa-f0-9]{2}[:]){5}[A-Fa-f0-9]{2}[,]?)+$/;
if (mac_regex.test(args.mac)) {
// Add implemientation of additional options if the module btim is present.
if (btim != null) {
if (args.mac != null && args.iface != null) {
var mac_regex = /^(([A-Fa-f0-9]{2}[:]){5}[A-Fa-f0-9]{2}[,]?)+$/;
if (mac_regex.test(args.mac)) {
iface = parseInt(iface);
if (btim.spoof_mac(iface, args.mac) != 0) {
if (btim.spoof_mac(iface, args.mac) != 0) {
console.log(util.format('[!] The MAC address wasn\'t successfully spoofed: %s', args.mac).red);
process.exit(-1);
}
console.log(util.format('[i] MAC address successfully spoofed: %s', args.mac).bold);
} else {
}
console.log(util.format('[i] MAC address successfully spoofed: %s', args.mac).bold);
} else {
console.log(util.format('[!] The provided MAC address isn\t valid: %s', args.mac).red);
process.exit(-1);
}
}
}

if (args.list) {
function display_interface(item) {
for (property in item) {
console.log(util.format('%s\tType: %s Bus: %s BD Address: %s ' +
'ACL MTU: %s SCO MTU: %s\n\t%s\n\t' +
'RX: bytes: %s ACL: %s SCO: %s events: %s errors: %s\n\t' +
'TX: bytes: %s ACL: %s SCO: %s events: %s errors: %s\n',
property,
item[property]['Type'],
item[property]['Bus'],
item[property]['BD Address'],
item[property]['ACL MTU'],
item[property]['SCO MTU'],
item[property]['status'],
item[property]['RX']['bytes'],
item[property]['RX']['ACL'],
item[property]['RX']['SCO'],
item[property]['RX']['events'],
item[property]['RX']['errors'],
item[property]['TX']['bytes'],
item[property]['TX']['ACL'],
item[property]['TX']['SCO'],
item[property]['TX']['events'],
item[property]['TX']['errors']).bold);
if (args.list) {
function display_interface(item) {
for (property in item) {
console.log(util.format('%s\tType: %s Bus: %s BD Address: %s ' +
'ACL MTU: %s SCO MTU: %s\n\t%s\n\t' +
'RX: bytes: %s ACL: %s SCO: %s events: %s errors: %s\n\t' +
'TX: bytes: %s ACL: %s SCO: %s events: %s errors: %s\n',
property,
item[property]['type'],
item[property]['bus'],
item[property]['address'],
item[property]['acl_mtu'],
item[property]['sco_mtu'],
item[property]['status'],
item[property]['rx']['bytes'],
item[property]['rx']['acl'],
item[property]['rx']['sco'],
item[property]['rx']['events'],
item[property]['rx']['errors'],
item[property]['tx']['bytes'],
item[property]['tx']['acl'],
item[property]['tx']['sco'],
item[property]['tx']['events'],
item[property]['tx']['errors']).bold);
}
}
}

console.log(util.format('[info] Listing bluetooth interfaces...\n').green);
var interfaces = JSON.parse('[' + btim.list() + ']');
console.log(util.format('[info] Listing bluetooth interfaces...\n').green);
var interfaces = btim.list();

for (var i = 0; i < interfaces.length; i++) {
display_interface(interfaces[i]);
for (var i = 0; i < interfaces.length; i++) {
display_interface(interfaces[i]);
}
process.exit(0);
}
}

Expand Down
56 changes: 55 additions & 1 deletion bin/cmd_btlejuice_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ var argparse = require('argparse');
var proxy = require('../proxy');
const colors = require('colors');
const util = require('util');
var btim = require('btim');

/**
* Command-line tool
**/
var parser = new argparse.ArgumentParser({
version: '1.1.5',
version: '1.1.6',
addHelp: true,
description: 'BtleJuice proxy'
});
Expand All @@ -29,6 +30,16 @@ parser.addArgument(['-p', '--port'], {
help: 'BtleJuice proxy port (default: 8000)',
required: false,
});
// Add additional options if the module btim is present.
if (btim != null) {
parser.addArgument(['-l', '--list'], {
help: 'List bluetooth interfaces',
required: false,
action: 'storeTrue',
default: false
});
}

args = parser.parseArgs();


Expand All @@ -44,6 +55,10 @@ if (args.iface != null) {
if (result != null) {
/* Keep the interface number. */
var iface = result[1];
/* Bring up an interace only if the module btim is present. */
if (btim != null) {
btim.up(parseInt(iface));
}
} else {
console.log(util.format('[!] Unknown interface %s', args.iface).red);
process.exit(-1);
Expand All @@ -67,6 +82,45 @@ if (args.port != null) {
proxyPort = 8000;
}

// Add implemientation of additional options if the module btim is present.
if (btim != null) {
if (args.list) {
function display_interface(item) {
for (property in item) {
console.log(util.format('%s\tType: %s Bus: %s BD Address: %s ' +
'ACL MTU: %s SCO MTU: %s\n\t%s\n\t' +
'RX: bytes: %s ACL: %s SCO: %s events: %s errors: %s\n\t' +
'TX: bytes: %s ACL: %s SCO: %s events: %s errors: %s\n',
property,
item[property]['type'],
item[property]['bus'],
item[property]['address'],
item[property]['acl_mtu'],
item[property]['sco_mtu'],
item[property]['status'],
item[property]['rx']['bytes'],
item[property]['rx']['acl'],
item[property]['rx']['sco'],
item[property]['rx']['events'],
item[property]['rx']['errors'],
item[property]['tx']['bytes'],
item[property]['tx']['acl'],
item[property]['tx']['sco'],
item[property]['tx']['events'],
item[property]['tx']['errors']).bold);
}
}

console.log(util.format('[info] Listing bluetooth interfaces...\n').green);
var interfaces = btim.list();

for (var i = 0; i < interfaces.length; i++) {
display_interface(interfaces[i]);
}
process.exit(0);
}
}

/* Create our core. */
(new proxy({
port: proxyPort,
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "btlejuice",
"version": "1.1.5",
"version": "1.1.6",
"description": "Bluetooth Low-Energy spoofing and MitM framework",
"main": "index.js",
"bin": {
Expand All @@ -19,7 +19,10 @@
"socket.io": "^1.4.5",
"socket.io-client": "^1.4.5",
"winston": "^2.2.0",
"btim": "^1.0.1"
"optional": "^0.1.3"
},
"optionalDependencies": {
"btim": "^1.0.2"
},
"devDependencies": {},
"scripts": {
Expand Down

0 comments on commit 1cf99ac

Please sign in to comment.