Add modules to repository

This commit is contained in:
Sebastian Kinne
2017-11-16 16:42:22 +11:00
commit d0aa1e38ef
707 changed files with 96750 additions and 0 deletions

21
Commander/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Marc
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,15 @@
[Network]
Server: irc.example.com
Port: 6667
Nickname: Commander
Channel: #commander
[Security]
Master: Foxtrot
Trigger: !
[Commands]
example: mkdir /test/ && touch /test/commander
[Other]
Debug: off

View File

@@ -0,0 +1,121 @@
#!/usr/bin/python
"""
Commander.py - Python Backend for the WiFi Pineapple Commander module.
Version 2 Codename: Electric Boogaloo
Thanks to: sebkinne & tesla
Foxtrot (C) 2016 <foxtrotnull@gmail.com>
"""
import os
import ConfigParser
import sys
import socket
import time
import string
import select
import errno
class Commander(object):
print "[*] WiFi Pineapple Commander Module"
def run(self):
while True:
self.fillBuffer()
self.parseCommands()
def parseConfig(self):
if os.path.exists('commander.conf'):
self.config = ConfigParser.RawConfigParser()
self.config.read('commander.conf')
if self.config.has_section('Network') and self.config.has_section('Security') and self.config.has_section('Commands') and self.config.has_section('Other'):
print "[*] Valid configuration file found!"
print ""
else:
print "[!] No valid configuration file found... Exiting!"
sys.exit(1)
self.server = self.config.get('Network', 'Server')
self.port = self.config.getint('Network', 'Port')
self.nick = self.config.get('Network', 'Nickname')
self.channel = self.config.get('Network', 'Channel')
self.master = self.config.get('Security', 'Master')
self.trigger = self.config.get('Security', 'Trigger')
self.commands = self.config.options('Commands')
self.debugmode = self.config.get('Other', 'Debug')
def printConfig(self):
print "[*] Using the following connection settings:"
print " %s" % self.server
print " %d" % self.port
print " %s" % self.nick
print " %s" % self.channel
print ""
print "[*] Using the following security settings:"
print " Master: %s" % self.master
print " Trigger: %s\n" % self.trigger
print "[*] Listing commands:"
for command in self.commands:
print " %s%s" % (self.trigger, command)
print ""
def connect(self):
self.sock = socket.socket()
print "[*] Connecting!"
self.sock.connect((self.server, self.port))
print "[*] Sending nick and user information"
self.sock.send('NICK %s\r\n' % self.nick)
self.sock.send('USER %s 8 * :%s\r\n' % (self.nick, self.nick))
time.sleep(2)
self.sock.send('JOIN %s\r\n' % self.channel)
self.sock.send('PRIVMSG %s :Connected.\r\n' % self.channel)
print "[*] Connected!\n"
def fillBuffer(self):
self.buff = ""
self.sock.setblocking(0)
readable, _, _ = select.select([self.sock], [], [])
if self.sock in readable:
self.buff = ""
cont = True
while cont:
try:
self.buff += self.sock.recv(1024)
except socket.error,e:
if e.errno != errno.EWOULDBLOCK:
sys.exit(1)
cont = False
def parseCommands(self):
for line in self.buff.split('\r\n'):
if self.debugmode.lower() == "on":
print line
line = line.split()
if 'PING' in line:
print "[*] Replying to ping\n"
self.sock.send('PONG ' + line.split()[1] + '\r\n')
for command in self.commands:
if line and line[0].lower().startswith(":" + self.master.lower() + "!"):
if ":" + self.trigger + command in line:
print "[*] Found command %s%s\n" % (self.trigger, command)
self.sock.send('PRIVMSG %s :Executing command %s\r\n' % (self.channel, command))
cmd = self.config.get('Commands', command)
os.system(cmd)
if __name__ == '__main__':
commander = Commander()
commander.parseConfig()
commander.printConfig()
commander.connect()
commander.run()

61
Commander/api/module.php Normal file
View File

@@ -0,0 +1,61 @@
<?php namespace pineapple;
class Commander extends Module
{
public function route()
{
switch ($this->request->action) {
case 'startCommander':
$this->startCommander();
break;
case 'stopCommander':
$this->stopCommander();
break;
case 'getConfiguration':
$this->getConfiguration();
break;
case 'saveConfiguration':
$this->saveConfiguration();
break;
case 'restoreDefaultConfiguration':
$this->restoreDefaultConfiguration();
break;
}
}
private function startCommander()
{
$this->execBackground('cd /pineapple/modules/Commander/Python && python commander.py');
$this->response = array("success" => true);
}
private function stopCommander()
{
exec('kill -9 $(pgrep -f commander)');
$this->response = array("success" => true);
}
private function getConfiguration()
{
$config = file_get_contents('/pineapple/modules/Commander/Python/commander.conf');
$this->response = array("CommanderConfiguration" => $config);
}
private function saveConfiguration()
{
$config = $this->request->CommanderConfiguration;
file_put_contents('/pineapple/modules/Commander/Python/commander.conf', $config);
$this->response = array("success" => true);
}
private function restoreDefaultConfiguration()
{
$defaultConfig = file_get_contents('/pineapple/modules/Commander/assets/default.conf');
file_put_contents('/pineapple/modules/Commander/Python/commander.conf', $defaultConfig);
$this->response = array("success" => true);
}
}

View File

@@ -0,0 +1,15 @@
[Network]
Server: irc.example.com
Port: 6667
Nickname: Commander
Channel: #commander
[Security]
Master: Foxtrot
Trigger: !
[Commands]
example: mkdir /test/ && touch /test/commander
[Other]
Debug: off

67
Commander/js/module.js Normal file
View File

@@ -0,0 +1,67 @@
registerController('CommanderController', ['$api', '$scope', function($api, $scope) {
$scope.commanderRunning = false;
$scope.startCommander = (function() {
$api.request({
module: 'Commander',
action: 'startCommander'
}, function(response) {
if (response.success === true) {
$scope.commanderRunning = true;
}
});
});
$scope.stopCommander = (function() {
$api.request({
module: 'Commander',
action: 'stopCommander'
}, function(response){
if (response.success === true) {
$scope.commanderRunning = false;
}
});
});
}]);
registerController('CommanderManageController', ['$api', '$scope', '$timeout', function($api, $scope, $timeout) {
$scope.CommanderConfiguration = "";
$scope.getConfiguration = (function() {
$api.request({
module: 'Commander',
action: 'getConfiguration'
}, function(response) {
console.log(response);
if (response.error === undefined){
$scope.CommanderConfiguration = response.CommanderConfiguration;
}
});
});
$scope.saveConfiguration = (function() {
$api.request({
module: 'Commander',
action: 'saveConfiguration',
CommanderConfiguration: $scope.CommanderConfiguration
}, function(response) {
console.log(response);
if (response.success === true){
$scope.getConfiguration();
}
});
});
$scope.restoreDefaultConfiguration = (function() {
$api.request({
module: 'Commander',
action: 'restoreDefaultConfiguration'
}, function(response) {
if (response.success === true) {
$scope.getConfiguration();
}
});
});
$scope.getConfiguration();
}]);

62
Commander/module.html Normal file
View File

@@ -0,0 +1,62 @@
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Commander
<button type="button" class="close pull-right" data-toggle="modal" data-target="#information" aria-label="Close"><span aria-hidden="true">i</span></button></h3></h3>
</div>
</div>
</div>
<div id="information" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Information</h4>
</div>
<div class="modal-body">
<h3><center>Commander 1.0</center></h3>
<h5><center>Written by Foxtrot</center></h5>
<h5><center>This module allows you to control your WiFi Pineapple over IRC by acting as a client connecting to your specified server. You can then specify custom commands to execute by talking to it like it was a person.</center></h5>
<br/><br/>
<h5 class="text-danger"><center>Please use Responsibly!</center></h5>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-5" ng-controller="CommanderController">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Control</h3>
</div>
<div class="panel-body">
Status : <span class="text-success" ng-show="commanderRunning">Running</span> <span ng-hide="commanderRunning" class="text-danger">Not Running!</span>
<button class="btn btn-sm btn-primary pull-right" ng-click="startCommander()" ng-hide="commanderRunning">Start</button>
<button class="btn btn-sm btn-primary pull-right" ng-click="stopCommander()" ng-show="commanderRunning">Stop</button>
</div>
</div>
</div>
<div class="col-md-7" ng-controller="CommanderManageController">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Manage
<button type="button" ng-click="getConfiguration();" class="close pull-right"aria-label="Refresh"><span aria-hidden="true">&#8635;</span></button></h3>
</div>
<div class="panel-body">
<p>Edit configuration:</p>
<p>
<textarea class="form-control" rows="15" ng-model="CommanderConfiguration"></textarea>
</p>
<p class="well well-sm alert-success" ng-show="configSaved">Configuration Saved</p>
<button type="submit" class="btn btn-sm btn-primary" ng-click="saveConfiguration()">Save Configuration</button>
<button type="submit" class="btn btn-sm btn-warning" ng-click="restoreDefaultConfiguration()">Restore Defaults</button>
</div>
</div>
</div>
</div>

10
Commander/module.info Normal file
View File

@@ -0,0 +1,10 @@
{
"author": "Foxtrot",
"description": "Control the Pineapple via IRC",
"devices": [
"nano",
"tetra"
],
"title": "Commander",
"version": "2.0"
}