Skip to content

Commit

Permalink
Merge pull request #218 from bmorcelli/main
Browse files Browse the repository at this point in the history
JavaScript Interpreter
  • Loading branch information
pr3y authored Aug 25, 2024
2 parents 6a9c399 + 49d9fb2 commit 4139f31
Show file tree
Hide file tree
Showing 13 changed files with 1,228 additions and 124 deletions.
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Also, [read our FAQ](https://github.com/pr3y/Bruce/wiki/FAQ)
### BLE
- [X] BLE Beacon
- [X] BLE Scan
- [X] NRF24 Jammer
- [X] AppleJuice
- [X] SwiftPair
- [X] Android Spam
Expand All @@ -62,15 +63,15 @@ Also, [read our FAQ](https://github.com/pr3y/Bruce/wiki/FAQ)
### RF
- [x] Scan/Copy
- [x] Custom SubGhz
- [x] Spectrum - @incursiohack
- [x] Jammer Full - @incursiohack
- [x] Jammer Intermittent - @incursiohack
- [x] Spectrum
- [x] Jammer Full (sends a full squared wave into output)
- [x] Jammer Intermittent (sends PWM signal into output)
- [x] Config
- [X] RF TX Pin
- [X] RF RX Pin
- [X] RF Module
- [X] RF Frequency
- [ ] Replay
- [x] Replay

### RFID
- [x] Read tag
Expand Down Expand Up @@ -104,6 +105,7 @@ Also, [read our FAQ](https://github.com/pr3y/Bruce/wiki/FAQ)
- [x] Megalodon
- [x] BADUsb (New features, SPIFFS and SDCard)
- [X] Openhaystack
- [X] JavaScript Interpreter (Credits to justinknight93)[https://github.com/justinknight93/Doolittle]

### Clock
- [X] Clock
Expand All @@ -117,6 +119,18 @@ Also, [read our FAQ](https://github.com/pr3y/Bruce/wiki/FAQ)
- [x] Sleep
- [x] Restart

## Specific functions per Device, the ones not mentioned here are available to all.
| Device | CC1101 | NRF24 | Interpreter | FMRadio | Mic_SPM1423 | BadUSB | RGB Led | Speaker | LITE_MODE |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Cardputer | :ok: | :ok: | :ok: | :x: | :ok: | :ok: | :ok: | NS4168 | :x: |
| StickCPlus2 | :ok: | :ok: | :ok: | :ok: | :ok: | :x: | :x: | Tone | :x: |
| StickCPlus 1.1 | :ok: | :ok: | :ok: | :x: | :ok: | :x: | :x: | Tone | :ok: |
| Core | :x: | :x: | :x: | :x: | :ok: | :x: | :x: | Tone | :x: |
| Core2 | :x: | :x: | :x: | :x: | :ok: | :x: | :x: | :x: | :x: |
| CoreSe/SE | :x: | :x: | :ok: | :x: | :x: | :ok: | :x: | :x: | :x: |

*LITE_MODE*: TelNet, SSH, DPWO, WireGuard, BLEBacon, BLEScan, FMRadio and OpenHaystack are NOT available for M5Launcher Compatibility

## :sparkles: Why and how does it look?

Bruce stems from a keen observation within the community focused on devices like Flipper Zero. While these devices offered a glimpse into the world of offensive security, there was a palpable sense that something more could be achieved without being that overpriced, particularly with the robust and modular hardware ecosystem provided by m5stack products.
Expand Down
247 changes: 247 additions & 0 deletions interpreter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
## Manual for Coding in JavaScript to Bruce

This secction was ported from (justinknight93/Doolittle)[https://github.com/justinknight93/Doolittle], who made a very nice job with its JavaScript interpreter

Some changes were made and some new functions were added, and more are to be add.

Bellow you can find some of the


## API Reference for Native Functions Accessible from JS

### `load(script: string)`

**Description**: Sets the script to be executed next when the current script ends.

**Parameters**:
- `script` (string): The JavaScript code as a string to be loaded.

**Returns**: `void`

---

### `print(message: string)`

**Description**: Prints the given message to the Serial monitor.

**Parameters**:
- `message` (string): The message to print.

**Returns**: `void`

---

### `now()`

**Description**: Returns the current time in milliseconds since the epoch.

**Returns**: `number`: The current timestamp in milliseconds.

---

### `delay(ms: number)`

**Description**: Pauses execution for the specified number of milliseconds.

**Parameters**:
- `ms` (number): The number of milliseconds to delay.

**Returns**: `void`

---

### `digitalWrite(pin: number, value: boolean)`

**Description**: Sets the digital value (HIGH or LOW) for a specified pin.

**Parameters**:
- `pin` (number): The pin number.
- `value` (boolean): The value to write (true for HIGH, false for LOW).

**Returns**: `void`

---

### `pinMode(pin: number, mode: number)`

**Description**: Configures the specified pin to behave as an input or an output.

**Parameters**:
- `pin` (number): The pin number.
- `mode` (number): The mode to set (INPUT, OUTPUT, etc.).

**Returns**: `void`

---
## Get some board information
### `getBattery`
**Description**: Get and integer from 0 to 100 relative to the battery level.

**Returns**: `number`: 0-100 battery level.

---
### `getBoard`
**Description**: Get and integer from 0 to 100 relative to the battery level.

**Returns**: `string[]`: "StickCPlus", "StickCPlus2", "Cardputer", "Core2", "Core", "CoreS3/SE".

---
## WiFi functions
### `wifiConnect`
**Description**: Open Bruce WiFi connection menu.

---
### `wifiDisconnect`
**Description**: Disconnect Wifi.

---
### `httpGet(url: string, headers: string[])`

**Description**: Performs an HTTP GET request to the specified URL. Optionally includes headers.

**Parameters**:
- `url` (string): The URL to send the GET request to.
- `headers` (string[]): An array of headers to include in the request. Headers should be provided as key-value pairs in the array. Example: `[
"Content-Type", "application/json",
"Authorization", "Bearer your_token_here",
"Accept", "application/json"
]`

**Returns**: `object`: An object with two properties:
- `response` (number): The HTTP response code.
- `body` (string): The response body.

---

## TFT Display Functions

### `color(r: number, g: number, b: number)`

**Description**: Creates a color from the given RGB values.

**Parameters**:
- `r` (number): The red component (0-255).
- `g` (number): The green component (0-255).
- `b` (number): The blue component (0-255).

**Returns**: `number`: The color value in 16-bit RGB format.

---

### `setTextColor(color: number)`

**Description**: Sets the text color for drawing operations.

**Parameters**:
- `color` (number): The color value in 16-bit RGB format.

**Returns**: `void`

---

### `setTextSize(size: number)`

**Description**: Sets the text size for drawing operations.

**Parameters**:
- `size` (number): The text size multiplier.

**Returns**: `void`

---

### `drawRect(x: number, y: number, width: number, height: number, color: number)`

**Description**: Draws a rectangle with the specified parameters.

**Parameters**:
- `x` (number): The x-coordinate of the top-left corner.
- `y` (number): The y-coordinate of the top-left corner.
- `width` (number): The width of the rectangle.
- `height` (number): The height of the rectangle.
- `color` (number): The color value in 16-bit RGB format.

**Returns**: `void`

---

### `drawFillRect(x: number, y: number, width: number, height: number, color: number)`

**Description**: Draws a filled rectangle with the specified parameters.

**Parameters**:
- `x` (number): The x-coordinate of the top-left corner.
- `y` (number): The y-coordinate of the top-left corner.
- `width` (number): The width of the rectangle.
- `height` (number): The height of the rectangle.
- `color` (number): The color value in 16-bit RGB format.

**Returns**: `void`

---

### `drawString(text: string, x: number, y: number)`

**Description**: Draws the specified text at the given coordinates.

**Parameters**:
- `text` (string): The text to draw.
- `x` (number): The x-coordinate where the text starts.
- `y` (number): The y-coordinate where the text starts.

**Returns**: `void`

---

### `width()`

**Description**: Returns the width of the display.

**Returns**: `number`: The width of the display in pixels.

---

### `height()`

**Description**: Returns the height of the display.

**Returns**: `number`: The height of the display in pixels.

---

## Keyboard Inputs

### `getPrevPress()`
**Description**: Return the current state of 'Previous' button;

**Returns**: `boolean`: Returns `true` if pressed and `false` if not pressed

---
### `getSelPress()`
**Description**: Return the current state of 'Select' button;

**Returns**: `boolean`: Returns `true` if pressed and `false` if not pressed

---
### `getNextPress()`
**Description**: Return the current state of 'Next' button;

**Returns**: `boolean`: Returns `true` if pressed and `false` if not pressed

---
### `getKeysPressed()`
**Restriction**: Works only in Cardputer

**Description**: Returns the current state of the keys pressed on the M5Cardputer.

**Returns**: `string[]`: An array of strings representing the pressed keys. Possible values include "Delete", "Enter", "Alt", "Tab", "Function", "Option", or the actual key character.

---
## ToDo
### Send IR command

### Send RF command

### Send BadUSB payload

###
Loading

0 comments on commit 4139f31

Please sign in to comment.