Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace import * with explicit imports #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions mirage/core/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
from string import Template
from mirage.core import interpreter,loader,taskManager,module,config,templates
from mirage.libs import io,utils

from mirage.core import config, interpreter, loader, module, taskManager, templates
from mirage.libs import io, utils


class App(interpreter.Interpreter):
'''
Expand Down Expand Up @@ -280,7 +282,7 @@ def set(self,name:"!method:_autocompleteParameters",value):
if moduleName == module["name"] and (
module["module"].dynamicArgs or
argName in module["module"].args
):
):
module["module"].args[argName] = value
else:
io.warning("You must provide a module name !")
Expand Down
4 changes: 3 additions & 1 deletion mirage/core/argParser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from mirage.libs import io
import sys

from mirage.libs import io


class ArgParser:
'''
This class allows to easily parse parameters from command line.
Expand Down
3 changes: 3 additions & 0 deletions mirage/core/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import configparser

from mirage.libs import io


class Config:
'''
This class is used to parse and generate a configuration file in ".cfg" format.
Expand Down
16 changes: 12 additions & 4 deletions mirage/core/interpreter.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
from mirage.libs import io
import readline,shlex,re,inspect,glob,sys
import glob
import inspect
import os
import re
import readline
import shlex
import sys

import keyboard

from mirage.libs import io


class Interpreter:
'''
If a class inherits of this class, it becomes a tiny command interpreter.
Expand Down Expand Up @@ -229,8 +237,8 @@ def evaluateCommand(self,command):
len(inspect.getfullargspec(getattr(self,opcode)).args)-1 == len(arguments) or
(
inspect.getfullargspec(getattr(self,opcode)).defaults is not None and
len(inspect.getfullargspec(getattr(self,opcode)).args) - 1
- len(inspect.getfullargspec(getattr(self,opcode)).defaults) <= len(arguments) and
len(inspect.getfullargspec(getattr(self,opcode)).args) - 1
- len(inspect.getfullargspec(getattr(self,opcode)).defaults) <= len(arguments) and
len(arguments) <= len(inspect.getfullargspec(getattr(self,opcode)).defaults)
)
)
Expand Down
14 changes: 8 additions & 6 deletions mirage/core/module.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import keyboard

from mirage.core.scenario import scenarioSignal
from mirage.libs import io

'''
This submodule defines two main classes of the framework : Module & WirelessModule.
The modules defined in the framework inherits from these classes in order to
Expand Down Expand Up @@ -70,12 +72,12 @@ def init(self):
This method is an initialization method, called at the end of the constructor's execution.

It must be overloaded in order to define the parameters of module, especially :
- type : it defines the type of the module (e.g. "sniffing", "mitm" ...)
- technology : it defines the type of technology used by the module (e.g. "ble", "wifi", ...)
- description : a short string indicating the role of the module
- args : a dictionary of string describing the input parameters and their potential default values
- dependencies : an array of string indicating the dependencies of the module
- dynamicArgs : a boolean indicating if the user can provide input parameters not defined in the args dictionary
- type : it defines the type of the module (e.g. "sniffing", "mitm" ...)
- technology : it defines the type of technology used by the module (e.g. "ble", "wifi", ...)
- description : a short string indicating the role of the module
- args : a dictionary of string describing the input parameters and their potential default values
- dependencies : an array of string indicating the dependencies of the module
- dynamicArgs : a boolean indicating if the user can provide input parameters not defined in the args dictionary
'''
pass

Expand Down
6 changes: 4 additions & 2 deletions mirage/core/scenario.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import traceback
from mirage.core import module,app

from mirage.core import app
from mirage.libs import io


class Scenario:
'''
This class defines a scenario. A Scenario is a Mirage entity allowing to customize the behaviour of a module without
Expand Down Expand Up @@ -41,7 +43,7 @@ def receiveSignal(self,signal,*args, **kwargs):
else:
io.fail("An error occured in scenario "+self.name+" !")
if app.App.Instance.debugMode:
traceback.print_exception(type(e), e, e.__traceback__)
traceback.print_exception(type(e), e, e.__traceback__)
else:
return True

Expand Down
8 changes: 6 additions & 2 deletions mirage/core/task.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from mirage.libs import utils
import multiprocessing,os,sys
import multiprocessing
import os
import sys
from ctypes import c_char_p

from mirage.libs import utils


class Task(multiprocessing.Process):
'''
This class defines a background Task, it inherits from ``multiprocessing.Process``.
Expand Down
5 changes: 4 additions & 1 deletion mirage/core/taskManager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from .task import Task
from copy import copy

import psutil

from .task import Task


class TaskManager:
'''
This class is a manager allowing to easily manipulate background tasks (using multiprocessing).
Expand Down
Loading