-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
57 lines (44 loc) · 1.74 KB
/
__init__.py
File metadata and controls
57 lines (44 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from mycroft import MycroftSkill, intent_file_handler, intent_handler
from os.path import join
from os import mkdir
class ExecBash(MycroftSkill):
def __init__(self):
self.hosts = ["127.0.0.1"] # TODO: Swap with better store
self.target = "127.0.0.1" # TODO: Load from target file
self.safety = "on"
MycroftSkill.__init__(self)
# hello world
def initialize(self):
self.register_entity_file('scantype.entity')
self.register_entity_file('onoff.entity')
self.register_entity_file('path.entity')
# TODO: Make output dir automatically
@intent_file_handler('set.safety.intent')
def handle_set_safety(self, message):
onoff = message.data.get("onoff")
self.safety = onoff
self.speak(f"ok, safety is {onoff}")
@intent_file_handler('check.safety.intent')
def handle_check_safety(self, message):
self.speak(f"safety is {self.safety}")
@intent_file_handler('exec.nmap.intent')
def handle_exec_nmap(self, message):
scantype = message.data.get('scantype')
if scantype is None:
scantype = "syn"
# TODO: improve
target = self.target
with self.file_system.open("/tmp/a.txt", "w") as myfile:
myfile.write("Hello world, file io working")
if self.safety == "off":
self.speak(f"Ok, running {scantype} scan against {target}")
else:
self.speak(f"Ok, preparing to run {scantype} scan against {target}.")
# Prompt
@intent_file_handler('bash.exec.intent')
def handle_bash_exec(self, message):
self.speak_dialog('bash.exec')
def shutdown(self):
self.speak_dialog('shutdown')
def create_skill():
return ExecBash()