From 8da8e19ca6e3609c4602619c961be3e934042560 Mon Sep 17 00:00:00 2001 From: Henry Pitcairn <735tesla@gmail.com> Date: Thu, 24 Mar 2016 19:31:37 -0400 Subject: [PATCH 01/51] Begin writing introduction --- api.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api.md b/api.md index 5feafcd..bf92874 100644 --- a/api.md +++ b/api.md @@ -1,3 +1,11 @@ # WiFi Pineapple Module API -Work in progress +## Introduction +Unlike the old web interface, the back end of the new interface has been decoupled from the front end. All requests to perform system actions are sent as POSTs to `/api/`. The content of the POST is JSON and contains a minimal of two parameters. +### The first parameter key must be either `system` or `module` +`system` is used for core system functions such as logging users in and performing system setup as well as managing notifications. `module` is used when sending a request to any of the default modules or to any user modules. The value is set to the module with which you are trying to communicate. For example, `"system": "notifications"` or `"module": "RandomRoll"`. +### The second parameter key `action` +This is set to the action you wish to perform. For instance, this could be `"action": "listNotifications"` or `"action": "getRandomRollRolls"`. +### Any other parameters are optional and are specific to the module and action you are requesting +Many actions do not require additional parameters. For instance, `{"system": "notifications", "action": "listNotifications"}` will return a list of all of the current unread notifications (as JSON). However, there are some functions, such as `addNotification`, that require additional parameters (in this case `message`). To create a new notifications, one would use the following request: +`{"system": "notifications", "action": "addNotification", "message": "Hello World!"}` From 0dffbbf0e6614105e13a8b826b41df14d420bfb2 Mon Sep 17 00:00:00 2001 From: Henry Pitcairn <735tesla@gmail.com> Date: Sun, 27 Mar 2016 09:04:26 -0400 Subject: [PATCH 02/51] Update api.md --- api.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/api.md b/api.md index bf92874..7fa5bb3 100644 --- a/api.md +++ b/api.md @@ -9,3 +9,24 @@ This is set to the action you wish to perform. For instance, this could be `"act ### Any other parameters are optional and are specific to the module and action you are requesting Many actions do not require additional parameters. For instance, `{"system": "notifications", "action": "listNotifications"}` will return a list of all of the current unread notifications (as JSON). However, there are some functions, such as `addNotification`, that require additional parameters (in this case `message`). To create a new notifications, one would use the following request: `{"system": "notifications", "action": "addNotification", "message": "Hello World!"}` + +## Authentication +There are a couple ways to authenticate with the pineapple. Requests sent via the web interface use a PHPSESSID cookie as well as an X-XSRF-TOKEN header. The pineapple will verify that the session is valid and logged in and that the XSRF token matches the one generated at the start of the session. If both of these conditions are met, the request is routed. An example of a request sent by chrom is as follows: +``` +POST /api/ HTTP/1.1 +Host: 172.16.42.1:1471 +Connection: keep-alive +Content-Length: 55 +Accept: application/json, text/plain, */* +Origin: http://172.16.42.1:1471 +X-XSRF-TOKEN: b01c5046faa2f8ffbed6f2fdd90a5605e6c505e3 +User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 +Content-Type: application/json;charset=UTF-8 +Referer: http://172.16.42.1:1471/ +Accept-Encoding: gzip, deflate +Accept-Language: en-US,en;q=0.8 +Cookie: PHPSESSID=cfd6b0bb983666362cae311c457d1d34; XSRF-TOKEN=b01c5046faa2f8ffbed6f2fdd90a5605e6c505e3 + +{"system":"notifications","action":"listNotifications"} +``` +This type of authentication is awkward and clumbsy to implement programmatically. Because of this, we have added a new way to authenticate with the WiFi Pineapple: API tokens. From 4a06a76e5c0bb8660960bcdd2638868cf4f58638 Mon Sep 17 00:00:00 2001 From: Henry Pitcairn <735tesla@gmail.com> Date: Sun, 27 Mar 2016 09:07:07 -0400 Subject: [PATCH 03/51] Update api.md --- api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api.md b/api.md index 7fa5bb3..46c079e 100644 --- a/api.md +++ b/api.md @@ -11,7 +11,7 @@ Many actions do not require additional parameters. For instance, `{"system": "no `{"system": "notifications", "action": "addNotification", "message": "Hello World!"}` ## Authentication -There are a couple ways to authenticate with the pineapple. Requests sent via the web interface use a PHPSESSID cookie as well as an X-XSRF-TOKEN header. The pineapple will verify that the session is valid and logged in and that the XSRF token matches the one generated at the start of the session. If both of these conditions are met, the request is routed. An example of a request sent by chrom is as follows: +There are a couple ways to authenticate with the pineapple. Requests sent via the web interface use a PHPSESSID cookie as well as an X-XSRF-TOKEN header. The pineapple will verify that the session is valid and logged in and that the XSRF token matches the one generated at the start of the session. If both of these conditions are met, the request is routed. An example of a request sent by chrome is as follows: ``` POST /api/ HTTP/1.1 Host: 172.16.42.1:1471 @@ -29,4 +29,4 @@ Cookie: PHPSESSID=cfd6b0bb983666362cae311c457d1d34; XSRF-TOKEN=b01c5046faa2f8ffb {"system":"notifications","action":"listNotifications"} ``` -This type of authentication is awkward and clumbsy to implement programmatically. Because of this, we have added a new way to authenticate with the WiFi Pineapple: API tokens. +This type of authentication is awkward and clumbsy to implement programmatically. Because of this, we have added a new way to authenticate with the WiFi Pineapple: API tokens. Though API tokens are supported by default, the pineapple is shipped without any valid tokens. The process of generating API tokens is simplified by the [API Tokens module](https://github.com/735tesla/Pineapple-API-Tokens-Module). From cbc36cfc7148a749ee7d316aa53dc43aa8dd189b Mon Sep 17 00:00:00 2001 From: Henry Pitcairn <735tesla@gmail.com> Date: Sun, 27 Mar 2016 09:16:56 -0400 Subject: [PATCH 04/51] Update api.md --- api.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/api.md b/api.md index 46c079e..3bf1214 100644 --- a/api.md +++ b/api.md @@ -8,7 +8,13 @@ Unlike the old web interface, the back end of the new interface has been decoupl This is set to the action you wish to perform. For instance, this could be `"action": "listNotifications"` or `"action": "getRandomRollRolls"`. ### Any other parameters are optional and are specific to the module and action you are requesting Many actions do not require additional parameters. For instance, `{"system": "notifications", "action": "listNotifications"}` will return a list of all of the current unread notifications (as JSON). However, there are some functions, such as `addNotification`, that require additional parameters (in this case `message`). To create a new notifications, one would use the following request: -`{"system": "notifications", "action": "addNotification", "message": "Hello World!"}` +``` +{ + "system": "notifications", + "action": "addNotification", + "message": "Hello World!" +} +``` ## Authentication There are a couple ways to authenticate with the pineapple. Requests sent via the web interface use a PHPSESSID cookie as well as an X-XSRF-TOKEN header. The pineapple will verify that the session is valid and logged in and that the XSRF token matches the one generated at the start of the session. If both of these conditions are met, the request is routed. An example of a request sent by chrome is as follows: @@ -29,4 +35,13 @@ Cookie: PHPSESSID=cfd6b0bb983666362cae311c457d1d34; XSRF-TOKEN=b01c5046faa2f8ffb {"system":"notifications","action":"listNotifications"} ``` -This type of authentication is awkward and clumbsy to implement programmatically. Because of this, we have added a new way to authenticate with the WiFi Pineapple: API tokens. Though API tokens are supported by default, the pineapple is shipped without any valid tokens. The process of generating API tokens is simplified by the [API Tokens module](https://github.com/735tesla/Pineapple-API-Tokens-Module). +This type of authentication is awkward and clumbsy to implement programmatically. Because of this, we have added a new way to authenticate with the WiFi Pineapple: API tokens. Though API tokens are supported by default, the pineapple is shipped without any valid tokens. The process of generating API tokens is simplified by the [API Tokens module](https://github.com/735tesla/Pineapple-API-Tokens-Module). After a token has been generated, it can be sent as an additional parameter. To use an API token, simply add an additional `apiToken` key to the request body. For example, to add a notification, one could send the following JSON request: +``` +{ + "system": "notifications", + "action": "addNotification", + "message": "Hello World!", + "apiToken": "7365626b696e6e652063616e7420636f6465202724ef6b5d7ac0b800cc83d474e8e007" +} +``` +If the `apiToken` parameter is valid, the request will be route; otherwise an error will be returned. From b4eaf4fb417cb6d634332e73c7f9daccca277740 Mon Sep 17 00:00:00 2001 From: Henry Pitcairn <735tesla@gmail.com> Date: Sun, 27 Mar 2016 09:18:06 -0400 Subject: [PATCH 05/51] Update api.md --- api.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api.md b/api.md index 3bf1214..1e5610f 100644 --- a/api.md +++ b/api.md @@ -2,11 +2,11 @@ ## Introduction Unlike the old web interface, the back end of the new interface has been decoupled from the front end. All requests to perform system actions are sent as POSTs to `/api/`. The content of the POST is JSON and contains a minimal of two parameters. -### The first parameter key must be either `system` or `module` +#### The first parameter key must be either `system` or `module` `system` is used for core system functions such as logging users in and performing system setup as well as managing notifications. `module` is used when sending a request to any of the default modules or to any user modules. The value is set to the module with which you are trying to communicate. For example, `"system": "notifications"` or `"module": "RandomRoll"`. -### The second parameter key `action` +#### The second parameter key `action` This is set to the action you wish to perform. For instance, this could be `"action": "listNotifications"` or `"action": "getRandomRollRolls"`. -### Any other parameters are optional and are specific to the module and action you are requesting +#### Any other parameters are optional and are specific to the module and action you are requesting Many actions do not require additional parameters. For instance, `{"system": "notifications", "action": "listNotifications"}` will return a list of all of the current unread notifications (as JSON). However, there are some functions, such as `addNotification`, that require additional parameters (in this case `message`). To create a new notifications, one would use the following request: ``` { From 2fbe092d4d40ce5b1fea60dbfc705bd9c7724c24 Mon Sep 17 00:00:00 2001 From: Henry Pitcairn <735tesla@gmail.com> Date: Sun, 27 Mar 2016 09:23:12 -0400 Subject: [PATCH 06/51] Update api.md --- api.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/api.md b/api.md index 1e5610f..184223b 100644 --- a/api.md +++ b/api.md @@ -45,3 +45,45 @@ This type of authentication is awkward and clumbsy to implement programmatically } ``` If the `apiToken` parameter is valid, the request will be route; otherwise an error will be returned. + +## Modules +### Advanced +#### Description +#### Supported Actions +### Clients +#### Description +#### Supported Actions +### Configuration +#### Description +#### Supported Actions +### Dashboard +#### Description +#### Supported Actions +### Filters +#### Description +#### Supported Actions +### Logging +#### Description +#### Supported Actions +### ModuleManager +#### Description +#### Supported Actions +### Networking +#### Description +#### Supported Actions +### PineAP +#### Description +#### Supported Actions +### Recon +#### Description +#### Supported Actions +### Reporting +#### Description +#### Supported Actions +### Tracking +#### Description +#### Supported Actions + +## Community Python API + +## Further Information From ab493fa656d0dfaa811c65fb8812a20ceec84444 Mon Sep 17 00:00:00 2001 From: Henry Pitcairn <735tesla@gmail.com> Date: Mon, 4 Apr 2016 13:03:43 -0400 Subject: [PATCH 07/51] Update api.md --- api.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/api.md b/api.md index 184223b..f4be1ff 100644 --- a/api.md +++ b/api.md @@ -50,6 +50,20 @@ If the `apiToken` parameter is valid, the request will be route; otherwise an er ### Advanced #### Description #### Supported Actions +Action|Description|Parameters +------|-----------|---------- +`getResources`|Returns a JSON array of disk and memory usage|_none_ +`dropCaches`|Clears system caches|_none_ +`getUSB`|Returns a list of USB devices connected ot the pineapple|_none +`getFstab`|Returns the contents of `/etc/config/fstab`|_none_ +`getCSS`|| +`saveFstab`|Overwrites `/etc/config/fstab` with a string| +`saveCSS`|| +`checkForUpgrade`|| +`downloadUpgrade`|| +`getDownloadStatus`|| +`performUpgrade`|| +`getCurrentVersion`|| ### Clients #### Description #### Supported Actions From cc5632146a097ed1905395b7d42891eaf039ae97 Mon Sep 17 00:00:00 2001 From: Henry Pitcairn <735tesla@gmail.com> Date: Mon, 4 Apr 2016 13:04:39 -0400 Subject: [PATCH 08/51] Update api.md --- api.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/api.md b/api.md index f4be1ff..db908c6 100644 --- a/api.md +++ b/api.md @@ -49,7 +49,6 @@ If the `apiToken` parameter is valid, the request will be route; otherwise an er ## Modules ### Advanced #### Description -#### Supported Actions Action|Description|Parameters ------|-----------|---------- `getResources`|Returns a JSON array of disk and memory usage|_none_ @@ -66,37 +65,26 @@ Action|Description|Parameters `getCurrentVersion`|| ### Clients #### Description -#### Supported Actions ### Configuration #### Description -#### Supported Actions ### Dashboard #### Description -#### Supported Actions ### Filters #### Description -#### Supported Actions ### Logging #### Description -#### Supported Actions ### ModuleManager #### Description -#### Supported Actions ### Networking #### Description -#### Supported Actions ### PineAP #### Description -#### Supported Actions ### Recon #### Description -#### Supported Actions ### Reporting #### Description -#### Supported Actions ### Tracking #### Description -#### Supported Actions ## Community Python API From cc5cbe84f8f7ed1c4e123e6636e0d0fb4bfcb2a8 Mon Sep 17 00:00:00 2001 From: Henry Pitcairn <735tesla@gmail.com> Date: Mon, 4 Apr 2016 13:08:33 -0400 Subject: [PATCH 09/51] Update api.md --- api.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api.md b/api.md index db908c6..ca65370 100644 --- a/api.md +++ b/api.md @@ -55,11 +55,11 @@ Action|Description|Parameters `dropCaches`|Clears system caches|_none_ `getUSB`|Returns a list of USB devices connected ot the pineapple|_none `getFstab`|Returns the contents of `/etc/config/fstab`|_none_ -`getCSS`|| +`getCSS`|Returns the contents of main.css|_none_ `saveFstab`|Overwrites `/etc/config/fstab` with a string| -`saveCSS`|| -`checkForUpgrade`|| -`downloadUpgrade`|| +`saveCSS`|Overwrites the contents of main.css with a string| +`checkForUpgrade`|Fetches the list of upgrades and the description of each|_none_ +`downloadUpgrade`|Upgrades the pineapple to a specified firmare version (see output of `checkForUpgrades`)| `getDownloadStatus`|| `performUpgrade`|| `getCurrentVersion`|| From 93887a573ec145b290cb90b030c1c34a1dc2d702 Mon Sep 17 00:00:00 2001 From: Henry Pitcairn <735tesla@gmail.com> Date: Mon, 4 Apr 2016 13:10:48 -0400 Subject: [PATCH 10/51] Update api.md --- api.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api.md b/api.md index ca65370..7b95c14 100644 --- a/api.md +++ b/api.md @@ -56,10 +56,10 @@ Action|Description|Parameters `getUSB`|Returns a list of USB devices connected ot the pineapple|_none `getFstab`|Returns the contents of `/etc/config/fstab`|_none_ `getCSS`|Returns the contents of main.css|_none_ -`saveFstab`|Overwrites `/etc/config/fstab` with a string| -`saveCSS`|Overwrites the contents of main.css with a string| +`saveFstab`|Overwrites `/etc/config/fstab` with a string| +`saveCSS`|Overwrites the contents of main.css with a string| `checkForUpgrade`|Fetches the list of upgrades and the description of each|_none_ -`downloadUpgrade`|Upgrades the pineapple to a specified firmare version (see output of `checkForUpgrades`)| +`downloadUpgrade`|Upgrades the pineapple to a specified firmare version (see output of `checkForUpgrades`)| `getDownloadStatus`|| `performUpgrade`|| `getCurrentVersion`|| From 444be5f4f21756c0765ba7c2d19f9e06ed51eecb Mon Sep 17 00:00:00 2001 From: Henry Pitcairn <735tesla@gmail.com> Date: Mon, 4 Apr 2016 13:14:16 -0400 Subject: [PATCH 11/51] Update api.md --- api.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api.md b/api.md index 7b95c14..ba5d121 100644 --- a/api.md +++ b/api.md @@ -53,16 +53,16 @@ Action|Description|Parameters ------|-----------|---------- `getResources`|Returns a JSON array of disk and memory usage|_none_ `dropCaches`|Clears system caches|_none_ -`getUSB`|Returns a list of USB devices connected ot the pineapple|_none +`getUSB`|Returns a list of USB devices connected ot the pineapple|_none_ `getFstab`|Returns the contents of `/etc/config/fstab`|_none_ `getCSS`|Returns the contents of main.css|_none_ `saveFstab`|Overwrites `/etc/config/fstab` with a string| `saveCSS`|Overwrites the contents of main.css with a string| `checkForUpgrade`|Fetches the list of upgrades and the description of each|_none_ -`downloadUpgrade`|Upgrades the pineapple to a specified firmare version (see output of `checkForUpgrades`)| -`getDownloadStatus`|| -`performUpgrade`|| -`getCurrentVersion`|| +`downloadUpgrade`|Upgrades the pineapple to a specified firmare version (see output of `checkForUpgrades` and `getCurrentVersion`)| +`getDownloadStatus`|Tells whether a firmware download is complete or in progress and how many bytes have been downloaded|_none +`performUpgrade`|Upgrades using the image in /tmp/upgrade.bin|_none_ +`getCurrentVersion`|Returns the current firmware version on the pineapple|_none_ ### Clients #### Description ### Configuration From b4c35b2ccdc96c694522294b89cdfdff28dcc45d Mon Sep 17 00:00:00 2001 From: Henry Pitcairn <735tesla@gmail.com> Date: Mon, 4 Apr 2016 13:21:56 -0400 Subject: [PATCH 12/51] Update api.md --- api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api.md b/api.md index ba5d121..b3f3129 100644 --- a/api.md +++ b/api.md @@ -60,7 +60,7 @@ Action|Description|Parameters `saveCSS`|Overwrites the contents of main.css with a string| `checkForUpgrade`|Fetches the list of upgrades and the description of each|_none_ `downloadUpgrade`|Upgrades the pineapple to a specified firmare version (see output of `checkForUpgrades` and `getCurrentVersion`)| -`getDownloadStatus`|Tells whether a firmware download is complete or in progress and how many bytes have been downloaded|_none +`getDownloadStatus`|Tells whether a firmware download is complete or in progress and how many bytes have been downloaded|_none_ `performUpgrade`|Upgrades using the image in /tmp/upgrade.bin|_none_ `getCurrentVersion`|Returns the current firmware version on the pineapple|_none_ ### Clients From 5dc895bb29ec3da05915a263ce274f071174007e Mon Sep 17 00:00:00 2001 From: Foxtrot Date: Mon, 4 Apr 2016 18:54:50 +0100 Subject: [PATCH 13/51] Start Networking section --- api.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api.md b/api.md index b3f3129..fcaafe3 100644 --- a/api.md +++ b/api.md @@ -77,6 +77,10 @@ Action|Description|Parameters #### Description ### Networking #### Description +Action|Description|Parameters +------|-----------|---------- +`getRoutingTable`|Returns the routing table of the Pineapple|_none_ +`restartDNS`|Restarts the DNS service on the Pineapple|_none_ ### PineAP #### Description ### Recon From afad9b463592fdae8bff0125d869834491299592 Mon Sep 17 00:00:00 2001 From: Foxtrot Date: Mon, 4 Apr 2016 19:06:20 +0100 Subject: [PATCH 14/51] Add more to table for Networking --- api.md | 1 + 1 file changed, 1 insertion(+) diff --git a/api.md b/api.md index fcaafe3..96c389c 100644 --- a/api.md +++ b/api.md @@ -81,6 +81,7 @@ Action|Description|Parameters ------|-----------|---------- `getRoutingTable`|Returns the routing table of the Pineapple|_none_ `restartDNS`|Restarts the DNS service on the Pineapple|_none_ +`updateRoute`|Updates the routing table|