Browse Source

bubble_debug is not a mitm script, just an import. only import once.

tags/v1.1.4
Jonathan Cobb 4 years ago
parent
commit
e6c5966512
2 changed files with 21 additions and 15 deletions
  1. +21
    -14
      bubble-server/src/main/resources/packer/roles/mitmproxy/files/bubble_debug.py
  2. +0
    -1
      bubble-server/src/main/resources/packer/roles/mitmproxy/files/run_mitm.sh

+ 21
- 14
bubble-server/src/main/resources/packer/roles/mitmproxy/files/bubble_debug.py View File

@@ -20,25 +20,18 @@ if BUBBLE_PORT is None:
BUBBLE_LOG = '/var/log/bubble/mitmproxy_bubble.log' BUBBLE_LOG = '/var/log/bubble/mitmproxy_bubble.log'
BUBBLE_LOG_LEVEL_FILE = '/home/mitmproxy/bubble_log_level.txt' BUBBLE_LOG_LEVEL_FILE = '/home/mitmproxy/bubble_log_level.txt'
BUBBLE_LOG_LEVEL_ENV_VAR = 'BUBBLE_LOG_LEVEL' BUBBLE_LOG_LEVEL_ENV_VAR = 'BUBBLE_LOG_LEVEL'
DEFAULT_BUBBLE_LOG_LEVEL = 'WARNING'
DEFAULT_BUBBLE_LOG_LEVEL = 'INFO'
BUBBLE_LOG_LEVEL = None BUBBLE_LOG_LEVEL = None
try:
BUBBLE_LOG_LEVEL = Path(BUBBLE_LOG_LEVEL_FILE).read_text().strip()
except IOError:
print('error reading log level from '+BUBBLE_LOG_LEVEL_FILE+', checking env var '+BUBBLE_LOG_LEVEL_ENV_VAR, file=sys.stderr, flush=True)
BUBBLE_LOG_LEVEL = os.getenv(BUBBLE_LOG_LEVEL_ENV_VAR, DEFAULT_BUBBLE_LOG_LEVEL)


BUBBLE_NUMERIC_LOG_LEVEL = getattr(logging, BUBBLE_LOG_LEVEL.upper(), None)
if not isinstance(BUBBLE_NUMERIC_LOG_LEVEL, int):
print('Invalid log level: ' + BUBBLE_LOG_LEVEL + ' - using default '+DEFAULT_BUBBLE_LOG_LEVEL, file=sys.stderr, flush=True)
BUBBLE_NUMERIC_LOG_LEVEL = getattr(logging, DEFAULT_BUBBLE_LOG_LEVEL.upper(), None)
logging.basicConfig(format='[mitm'+BUBBLE_PORT+'] %(asctime)s - [%(module)s:%(lineno)d] - %(levelname)s: %(message)s', filename=BUBBLE_LOG, level=BUBBLE_NUMERIC_LOG_LEVEL)


bubble_log = logging.getLogger(__name__)
def get_stack(e=None):
if e is None:
e = ValueError()
return "".join(traceback.TracebackException.from_exception(e).format())




# Allow SIGUSR1 to print stack traces to stderr # Allow SIGUSR1 to print stack traces to stderr
def dumpstacks(signal, frame):
def dump_stacks(signal, frame):
id2name = dict([(th.ident, th.name) for th in threading.enumerate()]) id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
code = [] code = []
for threadId, stack in sys._current_frames().items(): for threadId, stack in sys._current_frames().items():
@@ -50,7 +43,21 @@ def dumpstacks(signal, frame):
print("\n------------------------------------- stack traces ------------------------------"+"\n".join(code), file=sys.stderr, flush=True) print("\n------------------------------------- stack traces ------------------------------"+"\n".join(code), file=sys.stderr, flush=True)




signal.signal(signal.SIGUSR1, dumpstacks)
signal.signal(signal.SIGUSR1, dump_stacks)

try:
BUBBLE_LOG_LEVEL = Path(BUBBLE_LOG_LEVEL_FILE).read_text().strip()
except IOError:
print('error reading log level from '+BUBBLE_LOG_LEVEL_FILE+', checking env var '+BUBBLE_LOG_LEVEL_ENV_VAR, file=sys.stderr, flush=True)
BUBBLE_LOG_LEVEL = os.getenv(BUBBLE_LOG_LEVEL_ENV_VAR, DEFAULT_BUBBLE_LOG_LEVEL)

BUBBLE_NUMERIC_LOG_LEVEL = getattr(logging, BUBBLE_LOG_LEVEL.upper(), None)
if not isinstance(BUBBLE_NUMERIC_LOG_LEVEL, int):
print('Invalid log level: ' + BUBBLE_LOG_LEVEL + ' - using default '+DEFAULT_BUBBLE_LOG_LEVEL, file=sys.stderr, flush=True)
BUBBLE_NUMERIC_LOG_LEVEL = getattr(logging, DEFAULT_BUBBLE_LOG_LEVEL.upper(), None)
logging.basicConfig(format='[mitm'+BUBBLE_PORT+'] %(asctime)s - [%(module)s:%(lineno)d] - %(levelname)s: %(message)s', filename=BUBBLE_LOG, level=BUBBLE_NUMERIC_LOG_LEVEL)

bubble_log = logging.getLogger(__name__)


if bubble_log.isEnabledFor(INFO): if bubble_log.isEnabledFor(INFO):
bubble_log.info('debug module initialized, default log level = '+logging.getLevelName(BUBBLE_NUMERIC_LOG_LEVEL)) bubble_log.info('debug module initialized, default log level = '+logging.getLevelName(BUBBLE_NUMERIC_LOG_LEVEL))

+ 0
- 1
bubble-server/src/main/resources/packer/roles/mitmproxy/files/run_mitm.sh View File

@@ -25,7 +25,6 @@ BUBBLE_PORT=${PORT} mitmdump \
--set flow_detail=0 \ --set flow_detail=0 \
--set stream_large_bodies=1 \ --set stream_large_bodies=1 \
--set keep_host_header \ --set keep_host_header \
-s ./bubble_debug.py \
-s ./bubble_conn_check.py \ -s ./bubble_conn_check.py \
-s ./bubble_request.py \ -s ./bubble_request.py \
-s ./bubble_modify.py \ -s ./bubble_modify.py \


Loading…
Cancel
Save