Exemple #1
0
#!/usr/bin/env python3
import logging
import json

from pineapple.modules import Module, Request

module = Module('ssidpooldb', logging.DEBUG)


@module.handles_action('GetSSIDSavedPool')
def GetSSIDSavedPool(request: Request):
    return [["coucou", "hello"], ["try", "waw"]]


@module.handles_action('SetSSIDSavedPool')
def AddSSIDSavedPool(request: Request):
    return "done"


if __name__ == '__main__':
    module.start()
Exemple #2
0
#!/usr/bin/env python3
import logging
from pineapple.modules import Module, Request
import subprocess

module = Module('Ping', logging.DEBUG)

@module.handles_action('ping')
def ping(request: Request):

    ip = request.Ip
    count = request.Count
    output = subprocess.getoutput("ping -c " + str(count) + " " + ip)

    return output
    # PING 8.8.8.8 (8.8.8.8):
    # 56 data bytes 64 bytes from 8.8.8.8:
    # seq=0 ttl=117 time=26.822 ms ---
    # 8.8.8.8 ping statistics ---
    # 1 packets transmitted, 1 packets received,
    # 0% packet loss round-trip min/avg/max = 26.822/26.822/26.822 ms
if __name__ == '__main__':
    module.start()
Exemple #3
0
#!/usr/bin/env python3

import logging
import subprocess  #Used to run airodump-ng for network and client scanning (w/ timeout)
import csv  #Used for reading files created by airodump-ng
import json  #Used for transmitting data back to JS nicely
import os  #Used to delete files after they have been processed
import configparser  #Used to handle configuration provided by user

from pineapple.modules import Module, Request

module = Module('CaptivePortalJumper', logging.DEBUG)

# Default Var Config
APScanInterface = "wlan2"
APScanTimeout = 5
ClientScanInterface = "wlan2"
ClientScanTimeout = 5


# Update global variables with user specified config
def getConfig():
    try:
        global APScanInterface, APScanTimeout, ClientScanInterface, ClientScanTimeout
        config = configparser.ConfigParser()
        config.read("config")
        APScanInterface = str(config["APScan"]["Interface"])
        APScanTimeout = int(config["APScan"]["Timeout"])
        ClientScanInterface = str(config["ClientScan"]["Interface"])
        ClientScanTimeout = int(config["ClientScan"]["Timeout"])
        return True
Exemple #4
0
#!/usr/bin/env python3

import logging
import time
import subprocess

from pineapple.modules import Module, Request

module = Module('speedtest', logging.DEBUG)

global process
process = subprocess.Popen("echo")


def _check_speedtest_running():
    if process.poll() == None:
        return 1
    else:
        return 0


@module.handles_action('run_test')
def run_test(request: Request):
    # debug, we may need job control bc timeout is 6 secs
    sleep(2)
    return "nice"
    downloadCMD = "wget -O /dev/null http://cachefly.cachefly.net/50mb.test"
    downloadCMD = downloadCMD.split(" ")
    startTime = time.time()
    global process
    process = subprocess.Popen(downloadCMD,
Exemple #5
0
#!/usr/bin/env python3

import logging

from pineapple.modules import Module, Request

import json
import urllib.request

module = Module('locate', logging.DEBUG)

API_LINK = f"https://ipwhois.app/json/"

@module.handles_action('locate_ip')
def locate_ip(request: Request):
    ip = request.user_input
    module.logger.debug(f"{ip} address is valid.")
    module.logger.debug(f"{API_LINK}{ip}")
    response = urllib.request.urlopen(f"{API_LINK}/{ip}")
    data = response.read()
    output_json = json.loads(data)
    if output_json['success'] == False:
        error_code = output_json['message']
        return error_code,False

    module.logger.debug(output_json)
    lookup_ip = output_json['ip']
    city = output_json['city']
    region = output_json['region']
    country = output_json['country']
    country_capital = output_json['country_capital']
Exemple #6
0
#!/usr/bin/env python3

import logging

from pineapple.modules import Module, Request

module = Module('hashcrackutils', logging.DEBUG)


@module.handles_action('hello_world')
def hello_world(request: Request):
    return 'You said: {}'.format(request.user_input)


if __name__ == '__main__':
    module.start()
Exemple #7
0
from typing import Tuple, List, Optional
from datetime import datetime
from time import sleep
import logging
import pathlib
import subprocess
import os
import json

from pineapple.modules import Module, Request
from pineapple.jobs import Job, JobManager
from pineapple.helpers.opkg_helpers import OpkgJob
import pineapple.helpers.notification_helpers as notifier
import pineapple.helpers.opkg_helpers as opkg

module = Module('nmap', logging.DEBUG)
job_manager = JobManager(name='nmap', module=module, log_level=logging.DEBUG)

history_directory_path = '/root/.nmap'
history_directory = pathlib.Path(history_directory_path)


class ScanJob(Job[bool]):

    def __init__(self, command: List[str], file_name: str):
        super().__init__()
        self.command = command
        self.file_name = file_name
        self.output_file = f'{history_directory_path}/{file_name}'

    def do_work(self, logger: logging.Logger) -> bool:
Exemple #8
0
import logging
import os
import pathlib
import subprocess
from datetime import datetime
from logging import Logger
from typing import List, Optional, Union, Tuple

from pineapple.modules import Module, Request
from pineapple.helpers.opkg_helpers import OpkgJob
from pineapple.helpers import opkg_helpers as opkg
import pineapple.helpers.notification_helpers as notifier
from pineapple.helpers import network_helpers as net
from pineapple.jobs import JobManager, Job

module = Module('tcpdump', logging.DEBUG)
job_manager = JobManager(name='tcpdump',
                         module=module,
                         log_level=logging.DEBUG)

PCAP_DIRECTORY_PATH = '/root/.tcpdump'
PCAP_DIRECTORY = pathlib.Path(PCAP_DIRECTORY_PATH)


class PcapJob(Job[bool]):
    def __init__(self, command: List[str], file_name: str):
        super().__init__()
        self.file_name = file_name
        self.command = command
        self.pcap_file = f'{PCAP_DIRECTORY_PATH}/{file_name}'
        self.proc = None
Exemple #9
0
from typing import Dict, Tuple, List, Union, Optional
import json
import subprocess
import logging
import pathlib
import tarfile
import os

from pineapple.modules import Module, Request
from pineapple.jobs import JobManager
from pineapple.helpers.opkg_helpers import OpkgJob
import pineapple.helpers.command_helpers as cmd
import pineapple.helpers.opkg_helpers as opkg


module = Module('evilportal', logging.DEBUG)
manager = JobManager('evilportal', log_level=logging.DEBUG, module=module)

# CONSTANTS
_DEPENDENCIES = ['php7-mod-curl', 'php7-mod-json', 'php7-fpm', 'php7-mod-sqlite3', 'php7', 'nginx']
_MODULE_PATH = '/pineapple/ui/modules/evilportal'
_ASSETS_PATH = f'{_MODULE_PATH}/assets'
_PORTAL_PATH = f'/root/portals'
_CLIENTS_FILE = f'/tmp/EVILPORTAL_CLIENTS.txt'
# CONSTANTS


def _post_install(job: OpkgJob):
    if not job.install:
        return
    elif not job.was_successful:
Exemple #10
0
#!/usr/bin/env python3

from typing import Optional
from pineapple.modules import Module, Request
import json
import subprocess
import logging
from pineapple.jobs import Job, JobManager
import pathlib
from pineapple.helpers.opkg_helpers import OpkgJob
import pineapple.helpers.notification_helpers as notifier
import pineapple.helpers.opkg_helpers as opkg

module = Module('mtr', logging.DEBUG)
job_manager = JobManager(name="mtr", module=module, log_level=logging.DEBUG)

root_folder = "/root/.mtr"
json_file = f"{root_folder}/report.json"


class MTRJob(Job[bool]):
    def __init__(self, user_input: str):
        super().__init__()
        self.user_input = user_input

    def do_work(self, logger: logging.Logger) -> bool:
        logger.debug("MTR job started.")
        module.logger.debug(self.user_input)
        result = subprocess.check_output(["mtr", "-j", self.user_input],
                                         encoding='UTF-8')
        json_data = json.loads(result)
Exemple #11
0
#!/usr/bin/env python3

import logging
import os
import subprocess
from logging import Logger
from time import sleep

from pineapple.jobs.job import TResult
from pineapple.modules import Module, Request
from pineapple.jobs import JobManager, Job

module = Module('httpeek', logging.DEBUG)
job_manager = JobManager('httpeek', logging.DEBUG, module=module)


class SnifferJob(Job[bool]):
    def __init__(self):
        super().__init__()
        self.proc = None

    def do_work(self, logger: Logger) -> TResult:
        logger.debug('Starting sniffer handler...')
        self.proc = subprocess.Popen(['python3', 'sniffer_handler.py'],
                                     cwd='/pineapple/modules/httpeek/assets/')

        while True:
            sleep(0.5)
            value = self.proc.poll()
            if value is not None:
                logger.debug(f'Proc returned value {value}')
Exemple #12
0
from typing import List, Tuple, Optional, Union

from pineapple.helpers.opkg_helpers import OpkgJob
from pineapple.modules import Module, Request
from pineapple.helpers import network_helpers as net
from pineapple.helpers import opkg_helpers as opkg
import pineapple.helpers.notification_helpers as notifier
from pineapple.jobs import Job, JobManager

# CONSTANTS
_HISTORY_DIRECTORY_PATH = '/root/.mdk4'
_HISTORY_DIRECTORY = pathlib.Path(_HISTORY_DIRECTORY_PATH)
# CONSTANTS

module = Module('mdk4', logging.DEBUG)
job_manager = JobManager(name='mdk4', module=module, log_level=logging.DEBUG)


class Mdk4Job(Job[bool]):
    def __init__(self, command: List[str], file_name: str,
                 input_interface: str, output_interface: str):
        super().__init__()
        self.file_name = file_name
        self.command = command
        self.mdk4_file = f'{_HISTORY_DIRECTORY_PATH}/{file_name}'
        self.input_interface = input_interface
        self.output_interface = output_interface
        self.monitor_input_iface = None
        self.monitor_output_iface = None
Exemple #13
0
#!/usr/bin/env python3

from typing import List
import logging
import pathlib
import os

from pineapple.modules import Module, Request

module = Module('cabinet', logging.DEBUG)


def _get_directory_contents(directory: pathlib.Path) -> List[dict]:
    return [{
        'name': item.name,
        'path': str(item),
        'size': item.lstat().st_size,
        'permissions': oct(item.lstat().st_mode)[-3:],
        'is_directory': item.is_dir()
    } for item in sorted(directory.iterdir(), key=lambda i: not i.is_dir())]


def _delete_directory_tree(directory: pathlib.Path) -> bool:
    if not directory.is_dir():
        return False

    for item in directory.iterdir():
        module.logger.debug(f'DELETING ITEM: {str(item)}')
        if item.is_dir():
            _delete_directory_tree(item)
            item.rmdir()
Exemple #14
0
#!/usr/bin/env python3

from pineapple.modules import Module, Request
from pineapple.helpers.network_helpers import get_interfaces
import subprocess

module = Module('SecretSettings')


@module.handles_action('load_interfaces')
def load_interfaces(request: Request):
    return get_interfaces()


@module.handles_action('load_settings')
def load_settings(request: Request):
    return get_uci()


def get_uci(config: str = None,
            section: str = None,
            option: str = None) -> dict:
    opt = ''
    if config is not None:
        opt += config
        if section is not None:
            opt += '.%s' % section
            if option is not None:
                opt += '.%s' % option
    args = ['uci', 'show']
    if len(opt):