The Pineapple (since Mark IV) has introduced the idea of infusions; community written plugins that when approved become available on the Pineapple-Bar for all to use. Since the introduction of Interface 3.0/Mk4 or 1.0/Mk5 these infusions have changed to a more uniformed modular approach. This has the following benefits:
- easier to create
- modular design
- similar code-base (easier to review)
- generally more secure code
Now creating new plugins may seem daunting but it is actually quite easy. The MarkV even supports a nice create & manage plugins page called Bartender, that allows you to start from a clean plugin template on the Pineapple or the sd-card.
Create a Plugin
Example: My first plugin
Create Plugin:
Manage Plugin:
SSH into the Pineapple, after creating a ‘Test’ sd-card infusion.
root@Pineapple:/sd/infusions/test# ls -l -rw-r--r-- 1 root root 0 Nov 3 08:56 functions.php -rw-r--r-- 1 root root 567 Nov 3 08:56 handler.php -rw-r--r-- 1 root root 0 Nov 3 08:56 large_tile.php -rw-r--r-- 1 root root 0 Nov 3 08:56 small_tile.php
- The ‘functions.php‘ is essentially the code where are your parameters get processed.
- The ‘handler.php‘ is essentially the helper module, that does not need to be manually edited; it contains the plugin name, version, author etc, and links to the other template files.
- The *_tile.php are the main display code for the tiles you see on the pineapple homepage.
The pineapples large_tile for infusion works in a Javascript popup type method, using regular HTML forms would cause this to break, so we use AJAX. This prevents the pineapple going to a new page. More information can be found in the example section below.
Example Infusion: Test
Large_tile.php
<form action="/components/infusions/test/functions.php" method="POST" onSubmit="$(this).AJAXifyForm(callback); return false;"> <input type="text" name="text" placeholder="Enter some meaningless text here..." /> <input type="submit" name="submit" value="Submit"> </form> <script type="text/javascript"> function callback(data){ popup(data); } </script>
Functions.php
<?php if(isset($_POST['submit'])){ echo "Hello World!: ".$_POST['text']; } ?>
You will end up with a blank small_tile.php, but when you click on it (to get the large_tile.php), you will be presented with a form. Once you click “submit”, the form details will be sent to functions.php, which will process the data; resulting in outputting your “text-box contents” onto the webpage.
You can use this very simple example to create more complex scripts that drive 3rd-party applications E.g. sslstrip, dnsspoof, urlsnarf etc. Remember the *_tiles.php, displays the forms, and any input/output. Functions.php actually drives the infusion, and operates any program calls.