Configure plugins via config.yml
This commit is contained in:
parent
65c2a45665
commit
a99c21bbc5
sdcard/rootfs/root/pwnagotchi
config.yml
scripts/pwnagotchi/plugins
@ -6,8 +6,21 @@ main:
|
|||||||
custom_plugins:
|
custom_plugins:
|
||||||
# which plugins to load and enable
|
# which plugins to load and enable
|
||||||
plugins:
|
plugins:
|
||||||
- gps
|
gps:
|
||||||
- twitter
|
enabled: false
|
||||||
|
twitter:
|
||||||
|
enabled: false
|
||||||
|
consumer_key: aaa
|
||||||
|
consumer_secret: aaa
|
||||||
|
access_token_key: aaa
|
||||||
|
access_token_secret: aaa
|
||||||
|
onlinehashcrack:
|
||||||
|
enabled: false
|
||||||
|
email: ~
|
||||||
|
wpa-sec:
|
||||||
|
enabled: false
|
||||||
|
api_key: ~
|
||||||
|
|
||||||
# monitor interface to use
|
# monitor interface to use
|
||||||
iface: mon0
|
iface: mon0
|
||||||
# command to run to bring the mon interface up in case it's not up already
|
# command to run to bring the mon interface up in case it's not up already
|
||||||
@ -114,13 +127,6 @@ ui:
|
|||||||
address: '10.0.0.2'
|
address: '10.0.0.2'
|
||||||
port: 8080
|
port: 8080
|
||||||
|
|
||||||
# twitter bot data
|
|
||||||
twitter:
|
|
||||||
enabled: false
|
|
||||||
consumer_key: aaa
|
|
||||||
consumer_secret: aaa
|
|
||||||
access_token_key: aaa
|
|
||||||
access_token_secret: aaa
|
|
||||||
|
|
||||||
# bettercap rest api configuration
|
# bettercap rest api configuration
|
||||||
bettercap:
|
bettercap:
|
||||||
|
@ -43,12 +43,18 @@ def load_from_path(path, enabled=()):
|
|||||||
|
|
||||||
|
|
||||||
def load(config):
|
def load(config):
|
||||||
enabled = config['main']['plugins']
|
enabled = [name for name, options in config['main']['plugins'].items() if 'enabled' in options and options['enabled']]
|
||||||
custom_path = config['main']['custom_plugins'] if 'custom_plugins' in config['main'] else None
|
custom_path = config['main']['custom_plugins'] if 'custom_plugins' in config['main'] else None
|
||||||
# load default plugins
|
# load default plugins
|
||||||
load_from_path(default_path, enabled=enabled)
|
loaded = load_from_path(default_path, enabled=enabled)
|
||||||
|
# set the options
|
||||||
|
for name, plugin in loaded.items():
|
||||||
|
plugin.__dict__['OPTIONS'] = config['main']['plugins'][name]
|
||||||
# load custom ones
|
# load custom ones
|
||||||
if custom_path is not None:
|
if custom_path is not None:
|
||||||
load_from_path(custom_path, enabled=enabled)
|
loaded = load_from_path(custom_path, enabled=enabled)
|
||||||
|
# set the options
|
||||||
|
for name, plugin in loaded.items():
|
||||||
|
plugin.__dict__['OPTIONS'] = config['main']['plugins'][name]
|
||||||
|
|
||||||
on('loaded')
|
on('loaded')
|
||||||
|
@ -11,6 +11,9 @@ from pwnagotchi.ui.view import BLACK
|
|||||||
import pwnagotchi.ui.fonts as fonts
|
import pwnagotchi.ui.fonts as fonts
|
||||||
|
|
||||||
|
|
||||||
|
# Will be set with the options in config.yml config['main']['plugins'][__name__]
|
||||||
|
OPTIONS = dict()
|
||||||
|
|
||||||
# called when the plugin is loaded
|
# called when the plugin is loaded
|
||||||
def on_loaded():
|
def on_loaded():
|
||||||
logging.warning("WARNING: plugin %s should be disabled!" % __name__)
|
logging.warning("WARNING: plugin %s should be disabled!" % __name__)
|
||||||
|
@ -9,8 +9,8 @@ import logging
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
READY = False
|
READY = False
|
||||||
EMAIL = None
|
|
||||||
ALREADY_UPLOADED = None
|
ALREADY_UPLOADED = None
|
||||||
|
OPTIONS = dict()
|
||||||
|
|
||||||
|
|
||||||
def on_loaded():
|
def on_loaded():
|
||||||
@ -21,8 +21,8 @@ def on_loaded():
|
|||||||
global EMAIL
|
global EMAIL
|
||||||
global ALREADY_UPLOADED
|
global ALREADY_UPLOADED
|
||||||
|
|
||||||
if not EMAIL:
|
if not 'email' in OPTIONS or ('email' in OPTIONS and OPTIONS['email'] is None):
|
||||||
logging.error("OHC: EMAIL isn't set. Can't upload to onlinehashcrack.com")
|
logging.error("OHC: Email isn't set. Can't upload to onlinehashcrack.com")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -40,7 +40,7 @@ def _upload_to_ohc(path, timeout=30):
|
|||||||
Uploads the file to onlinehashcrack.com
|
Uploads the file to onlinehashcrack.com
|
||||||
"""
|
"""
|
||||||
with open(path, 'rb') as file_to_upload:
|
with open(path, 'rb') as file_to_upload:
|
||||||
data = {'email': EMAIL}
|
data = {'email': OPTIONS['email']}
|
||||||
payload = {'file': file_to_upload}
|
payload = {'file': file_to_upload}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -7,6 +7,7 @@ __description__ = 'This plugin creates tweets about the recent activity of pwnag
|
|||||||
import logging
|
import logging
|
||||||
from pwnagotchi.voice import Voice
|
from pwnagotchi.voice import Voice
|
||||||
|
|
||||||
|
OPTIONS = dict()
|
||||||
|
|
||||||
def on_loaded():
|
def on_loaded():
|
||||||
logging.info("twitter plugin loaded.")
|
logging.info("twitter plugin loaded.")
|
||||||
@ -14,7 +15,7 @@ def on_loaded():
|
|||||||
|
|
||||||
# called in manual mode when there's internet connectivity
|
# called in manual mode when there's internet connectivity
|
||||||
def on_internet_available(ui, config, log):
|
def on_internet_available(ui, config, log):
|
||||||
if config['twitter']['enabled'] and log.is_new() and log.handshakes > 0:
|
if log.is_new() and log.handshakes > 0:
|
||||||
try:
|
try:
|
||||||
import tweepy
|
import tweepy
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -32,8 +33,8 @@ def on_internet_available(ui, config, log):
|
|||||||
ui.update(force=True)
|
ui.update(force=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
auth = tweepy.OAuthHandler(config['twitter']['consumer_key'], config['twitter']['consumer_secret'])
|
auth = tweepy.OAuthHandler(OPTIONS['consumer_key'], OPTIONS['consumer_secret'])
|
||||||
auth.set_access_token(config['twitter']['access_token_key'], config['twitter']['access_token_secret'])
|
auth.set_access_token(OPTIONS['access_token_key'], OPTIONS['access_token_secret'])
|
||||||
api = tweepy.API(auth)
|
api = tweepy.API(auth)
|
||||||
|
|
||||||
tweet = Voice(lang=config['main']['lang']).on_log_tweet(log)
|
tweet = Voice(lang=config['main']['lang']).on_log_tweet(log)
|
||||||
|
@ -9,7 +9,6 @@ import logging
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
READY = False
|
READY = False
|
||||||
API_KEY = None
|
|
||||||
ALREADY_UPLOADED = None
|
ALREADY_UPLOADED = None
|
||||||
|
|
||||||
|
|
||||||
@ -21,7 +20,7 @@ def on_loaded():
|
|||||||
global API_KEY
|
global API_KEY
|
||||||
global ALREADY_UPLOADED
|
global ALREADY_UPLOADED
|
||||||
|
|
||||||
if not API_KEY:
|
if not 'api_key' in OPTIONS or ('api_key' in OPTIONS and OPTIONS['api_key'] is None):
|
||||||
logging.error("WPA_SEC: API-KEY isn't set. Can't upload to wpa-sec.stanev.org")
|
logging.error("WPA_SEC: API-KEY isn't set. Can't upload to wpa-sec.stanev.org")
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ def _upload_to_wpasec(path, timeout=30):
|
|||||||
Uploads the file to wpa-sec.stanev.org
|
Uploads the file to wpa-sec.stanev.org
|
||||||
"""
|
"""
|
||||||
with open(path, 'rb') as file_to_upload:
|
with open(path, 'rb') as file_to_upload:
|
||||||
headers = {'key': API_KEY}
|
headers = {'key': OPTIONS['api_key']}
|
||||||
payload = {'file': file_to_upload}
|
payload = {'file': file_to_upload}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user