aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'libmproxy/contrib')
-rw-r--r--libmproxy/contrib/README14
-rw-r--r--libmproxy/contrib/__init__.py0
-rw-r--r--libmproxy/contrib/jsbeautifier/__init__.py1153
-rw-r--r--libmproxy/contrib/jsbeautifier/unpackers/README.specs.mkd25
-rw-r--r--libmproxy/contrib/jsbeautifier/unpackers/__init__.py66
-rw-r--r--libmproxy/contrib/jsbeautifier/unpackers/evalbased.py39
-rw-r--r--libmproxy/contrib/jsbeautifier/unpackers/javascriptobfuscator.py58
-rw-r--r--libmproxy/contrib/jsbeautifier/unpackers/myobfuscate.py86
-rw-r--r--libmproxy/contrib/jsbeautifier/unpackers/packer.py103
-rw-r--r--libmproxy/contrib/jsbeautifier/unpackers/urlencode.py34
-rw-r--r--libmproxy/contrib/tls/__init__.py5
-rw-r--r--libmproxy/contrib/tls/_constructs.py213
-rw-r--r--libmproxy/contrib/tls/utils.py26
-rw-r--r--libmproxy/contrib/wbxml/ASCommandResponse.py72
-rw-r--r--libmproxy/contrib/wbxml/ASWBXML.py903
-rw-r--r--libmproxy/contrib/wbxml/ASWBXMLByteQueue.py103
-rw-r--r--libmproxy/contrib/wbxml/ASWBXMLCodePage.py52
-rw-r--r--libmproxy/contrib/wbxml/GlobalTokens.py50
-rw-r--r--libmproxy/contrib/wbxml/InvalidDataException.py31
-rw-r--r--libmproxy/contrib/wbxml/__init__.py0
20 files changed, 0 insertions, 3033 deletions
diff --git a/libmproxy/contrib/README b/libmproxy/contrib/README
deleted file mode 100644
index e5ce11da..00000000
--- a/libmproxy/contrib/README
+++ /dev/null
@@ -1,14 +0,0 @@
-
-Contribs:
-
-jsbeautifier, git checkout 25/03/12, MIT license
- - Removed test directories
- - Disabled packers through a single-line modification (see "# CORTESI"
- comment)
-
-wbxml
- - https://github.com/davidpshaw/PyWBXMLDecoder
-
-tls, BSD license
- - https://github.com/mhils/tls/tree/mitmproxy
- - limited to required files. \ No newline at end of file
diff --git a/libmproxy/contrib/__init__.py b/libmproxy/contrib/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/libmproxy/contrib/__init__.py
+++ /dev/null
diff --git a/libmproxy/contrib/jsbeautifier/__init__.py b/libmproxy/contrib/jsbeautifier/__init__.py
deleted file mode 100644
index e319e8dd..00000000
--- a/libmproxy/contrib/jsbeautifier/__init__.py
+++ /dev/null
@@ -1,1153 +0,0 @@
-import sys
-import getopt
-import re
-import string
-
-#
-# Originally written by Einar Lielmanis et al.,
-# Conversion to python by Einar Lielmanis, einar@jsbeautifier.org,
-# MIT licence, enjoy.
-#
-# Python is not my native language, feel free to push things around.
-#
-# Use either from command line (script displays its usage when run
-# without any parameters),
-#
-#
-# or, alternatively, use it as a module:
-#
-# import jsbeautifier
-# res = jsbeautifier.beautify('your javascript string')
-# res = jsbeautifier.beautify_file('some_file.js')
-#
-# you may specify some options:
-#
-# opts = jsbeautifier.default_options()
-# opts.indent_size = 2
-# res = jsbeautifier.beautify('some javascript', opts)
-#
-#
-# Here are the available options: (read source)
-
-
-class BeautifierOptions:
- def __init__(self):
- self.indent_size = 4
- self.indent_char = ' '
- self.indent_with_tabs = False
- self.preserve_newlines = True
- self.max_preserve_newlines = 10.
- self.jslint_happy = False
- self.brace_style = 'collapse'
- self.keep_array_indentation = False
- self.keep_function_indentation = False
- self.eval_code = False
-
-
-
- def __repr__(self):
- return \
-"""indent_size = %d
-indent_char = [%s]
-preserve_newlines = %s
-max_preserve_newlines = %d
-jslint_happy = %s
-indent_with_tabs = %s
-brace_style = %s
-keep_array_indentation = %s
-eval_code = %s
-""" % ( self.indent_size,
- self.indent_char,
- self.preserve_newlines,
- self.max_preserve_newlines,
- self.jslint_happy,
- self.indent_with_tabs,
- self.brace_style,
- self.keep_array_indentation,
- self.eval_code,
- )
-
-
-class BeautifierFlags:
- def __init__(self, mode):
- self.previous_mode = 'BLOCK'
- self.mode = mode
- self.var_line = False
- self.var_line_tainted = False
- self.var_line_reindented = False
- self.in_html_comment = False
- self.if_line = False
- self.in_case = False
- self.eat_next_space = False
- self.indentation_baseline = -1
- self.indentation_level = 0
- self.ternary_depth = 0
-
-
-def default_options():
- return BeautifierOptions()
-
-
-def beautify(string, opts = default_options() ):
- b = Beautifier()
- return b.beautify(string, opts)
-
-def beautify_file(file_name, opts = default_options() ):
-
- if file_name == '-': # stdin
- f = sys.stdin
- else:
- try:
- f = open(file_name)
- except Exception as ex:
- return 'The file could not be opened'
-
- b = Beautifier()
- return b.beautify(''.join(f.readlines()), opts)
-
-
-def usage():
-
- print("""Javascript beautifier (http://jsbeautifier.org/)
-
-Usage: jsbeautifier.py [options] <infile>
-
- <infile> can be "-", which means stdin.
- <outfile> defaults to stdout
-
-Input options:
-
- -i, --stdin read input from stdin
-
-Output options:
-
- -s, --indent-size=NUMBER indentation size. (default 4).
- -c, --indent-char=CHAR character to indent with. (default space).
- -t, --indent-with-tabs Indent with tabs, overrides -s and -c
- -d, --disable-preserve-newlines do not preserve existing line breaks.
- -j, --jslint-happy more jslint-compatible output
- -b, --brace-style=collapse brace style (collapse, expand, end-expand)
- -k, --keep-array-indentation keep array indentation.
- -o, --outfile=FILE specify a file to output to (default stdout)
- -f, --keep-function-indentation Do not re-indent function bodies defined in var lines.
-
-Rarely needed options:
-
- --eval-code evaluate code if a JS interpreter is
- installed. May be useful with some obfuscated
- script but poses a potential security issue.
-
- -l, --indent-level=NUMBER initial indentation level. (default 0).
-
- -h, --help, --usage prints this help statement.
-
-""")
-
-
-
-
-
-
-class Beautifier:
-
- def __init__(self, opts = default_options() ):
-
- self.opts = opts
- self.blank_state()
-
- def blank_state(self):
-
- # internal flags
- self.flags = BeautifierFlags('BLOCK')
- self.flag_store = []
- self.wanted_newline = False
- self.just_added_newline = False
- self.do_block_just_closed = False
-
- if self.opts.indent_with_tabs:
- self.indent_string = "\t"
- else:
- self.indent_string = self.opts.indent_char * self.opts.indent_size
-
- self.preindent_string = ''
- self.last_word = '' # last TK_WORD seen
- self.last_type = 'TK_START_EXPR' # last token type
- self.last_text = '' # last token text
- self.last_last_text = '' # pre-last token text
-
- self.input = None
- self.output = [] # formatted javascript gets built here
-
- self.whitespace = ["\n", "\r", "\t", " "]
- self.wordchar = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$'
- self.digits = '0123456789'
- self.punct = '+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::'
- self.punct += ' <?= <? ?> <%= <% %>'
- self.punct = self.punct.split(' ')
-
-
- # Words which always should start on a new line
- self.line_starters = 'continue,try,throw,return,var,if,switch,case,default,for,while,break,function'.split(',')
- self.set_mode('BLOCK')
-
- global parser_pos
- parser_pos = 0
-
-
- def beautify(self, s, opts = None ):
-
- if opts != None:
- self.opts = opts
-
-
- if self.opts.brace_style not in ['expand', 'collapse', 'end-expand']:
- raise(Exception('opts.brace_style must be "expand", "collapse" or "end-expand".'))
-
- self.blank_state()
-
- while s and s[0] in [' ', '\t']:
- self.preindent_string += s[0]
- s = s[1:]
-
- #self.input = self.unpack(s, opts.eval_code)
- # CORTESI
- self.input = s
-
- parser_pos = 0
- while True:
- token_text, token_type = self.get_next_token()
- #print (token_text, token_type, self.flags.mode)
- if token_type == 'TK_EOF':
- break
-
- handlers = {
- 'TK_START_EXPR': self.handle_start_expr,
- 'TK_END_EXPR': self.handle_end_expr,
- 'TK_START_BLOCK': self.handle_start_block,
- 'TK_END_BLOCK': self.handle_end_block,
- 'TK_WORD': self.handle_word,
- 'TK_SEMICOLON': self.handle_semicolon,
- 'TK_STRING': self.handle_string,
- 'TK_EQUALS': self.handle_equals,
- 'TK_OPERATOR': self.handle_operator,
- 'TK_BLOCK_COMMENT': self.handle_block_comment,
- 'TK_INLINE_COMMENT': self.handle_inline_comment,
- 'TK_COMMENT': self.handle_comment,
- 'TK_UNKNOWN': self.handle_unknown,
- }
-
- handlers[token_type](token_text)
-
- self.last_last_text = self.last_text
- self.last_type = token_type
- self.last_text = token_text
-
- sweet_code = self.preindent_string + re.sub('[\n ]+$', '', ''.join(self.output))
- return sweet_code
-
- def unpack(self, source, evalcode=False):
- import jsbeautifier.unpackers as unpackers
- try:
- return unpackers.run(source, evalcode)
- except unpackers.UnpackingError as error:
- print('error:', error)
- return ''
-
- def trim_output(self, eat_newlines = False):
- while len(self.output) \
- and (
- self.output[-1] == ' '\
- or self.output[-1] == self.indent_string \
- or self.output[-1] == self.preindent_string \
- or (eat_newlines and self.output[-1] in ['\n', '\r'])):
- self.output.pop()
-
- def is_special_word(self, s):
- return s in ['case', 'return', 'do', 'if', 'throw', 'else'];
-
- def is_array(self, mode):
- return mode in ['[EXPRESSION]', '[INDENDED-EXPRESSION]']
-
-
- def is_expression(self, mode):
- return mode in ['[EXPRESSION]', '[INDENDED-EXPRESSION]', '(EXPRESSION)', '(FOR-EXPRESSION)', '(COND-EXPRESSION)']
-
-
- def append_newline_forced(self):
- old_array_indentation = self.opts.keep_array_indentation
- self.opts.keep_array_indentation = False
- self.append_newline()
- self.opts.keep_array_indentation = old_array_indentation
-
- def append_newline(self, ignore_repeated = True):
-
- self.flags.eat_next_space = False
-
- if self.opts.keep_array_indentation and self.is_array(self.flags.mode):
- return
-
- self.flags.if_line = False
- self.trim_output()
-
- if len(self.output) == 0:
- # no newline on start of file
- return
-
- if self.output[-1] != '\n' or not ignore_repeated:
- self.just_added_newline = True
- self.output.append('\n')
-
- if self.preindent_string:
- self.output.append(self.preindent_string)
-
- for i in range(self.flags.indentation_level):
- self.output.append(self.indent_string)
-
- if self.flags.var_line and self.flags.var_line_reindented:
- self.output.append(self.indent_string)
-
-
- def append(self, s):
- if s == ' ':
- # do not add just a single space after the // comment, ever
- if self.last_type == 'TK_COMMENT':
- return self.append_newline()
-
- # make sure only single space gets drawn
- if self.flags.eat_next_space:
- self.flags.eat_next_space = False
- elif len(self.output) and self.output[-1] not in [' ', '\n', self.indent_string]:
- self.output.append(' ')
- else:
- self.just_added_newline = False
- self.flags.eat_next_space = False
- self.output.append(s)
-
-
- def indent(self):
- self.flags.indentation_level = self.flags.indentation_level + 1
-
-
- def remove_indent(self):
- if len(self.output) and self.output[-1] in [self.indent_string, self.preindent_string]:
- self.output.pop()
-
-
- def set_mode(self, mode):
-
- prev = BeautifierFlags('BLOCK')
-
- if self.flags:
- self.flag_store.append(self.flags)
- prev = self.flags
-
- self.flags = BeautifierFlags(mode)
-
- if len(self.flag_store) == 1:
- self.flags.indentation_level = 0
- else:
- self.flags.indentation_level = prev.indentation_level
- if prev.var_line and prev.var_line_reindented:
- self.flags.indentation_level = self.flags.indentation_level + 1
- self.flags.previous_mode = prev.mode
-
-
- def restore_mode(self):
- self.do_block_just_closed = self.flags.mode == 'DO_BLOCK'
- if len(self.flag_store) > 0:
- mode = self.flags.mode
- self.flags = self.flag_store.pop()
- self.flags.previous_mode = mode
-
-
- def get_next_token(self):
-
- global parser_pos
-
- self.n_newlines = 0
-
- if parser_pos >= len(self.input):
- return '', 'TK_EOF'
-
- self.wanted_newline = False
- c = self.input[parser_pos]
- parser_pos += 1
-
- keep_whitespace = self.opts.keep_array_indentation and self.is_array(self.flags.mode)
-
- if keep_whitespace:
- # slight mess to allow nice preservation of array indentation and reindent that correctly
- # first time when we get to the arrays:
- # var a = [
- # ....'something'
- # we make note of whitespace_count = 4 into flags.indentation_baseline
- # so we know that 4 whitespaces in original source match indent_level of reindented source
- #
- # and afterwards, when we get to
- # 'something,
- # .......'something else'
- # we know that this should be indented to indent_level + (7 - indentation_baseline) spaces
-
- whitespace_count = 0
- while c in self.whitespace:
- if c == '\n':
- self.trim_output()
- self.output.append('\n')
- self.just_added_newline = True
- whitespace_count = 0
- elif c == '\t':
- whitespace_count += 4
- elif c == '\r':
- pass
- else:
- whitespace_count += 1
-
- if parser_pos >= len(self.input):
- return '', 'TK_EOF'
-
- c = self.input[parser_pos]
- parser_pos += 1
-
- if self.flags.indentation_baseline == -1:
-
- self.flags.indentation_baseline = whitespace_count
-
- if self.just_added_newline:
- for i in range(self.flags.indentation_level + 1):
- self.output.append(self.indent_string)
-
- if self.flags.indentation_baseline != -1:
- for i in range(whitespace_count - self.flags.indentation_baseline):
- self.output.append(' ')
-
- else: # not keep_whitespace
- while c in self.whitespace:
- if c == '\n':
- if self.opts.max_preserve_newlines == 0 or self.opts.max_preserve_newlines > self.n_newlines:
- self.n_newlines += 1
-
- if parser_pos >= len(self.input):
- return '', 'TK_EOF'
-
- c = self.input[parser_pos]
- parser_pos += 1
-
- if self.opts.preserve_newlines and self.n_newlines > 1:
- for i in range(self.n_newlines):
- self.append_newline(i == 0)
- self.just_added_newline = True
-
- self.wanted_newline = self.n_newlines > 0
-
-
- if c in self.wordchar:
- if parser_pos < len(self.input):
- while self.input[parser_pos] in self.wordchar:
- c = c + self.input[parser_pos]
- parser_pos += 1
- if parser_pos == len(self.input):
- break
-
- # small and surprisingly unugly hack for 1E-10 representation
- if parser_pos != len(self.input) and self.input[parser_pos] in '+-' \
- and re.match('^[0-9]+[Ee]$', c):
-
- sign = self.input[parser_pos]
- parser_pos += 1
- t = self.get_next_token()
- c += sign + t[0]
- return c, 'TK_WORD'
-
- if c == 'in': # in is an operator, need to hack
- return c, 'TK_OPERATOR'
-
- if self.wanted_newline and \
- self.last_type != 'TK_OPERATOR' and\
- self.last_type != 'TK_EQUALS' and\
- not self.flags.if_line and \
- (self.opts.preserve_newlines or self.last_text != 'var'):
- self.append_newline()
-
- return c, 'TK_WORD'
-
- if c in '([':
- return c, 'TK_START_EXPR'
-
- if c in ')]':
- return c, 'TK_END_EXPR'
-
- if c == '{':
- return c, 'TK_START_BLOCK'
-
- if c == '}':
- return c, 'TK_END_BLOCK'
-
- if c == ';':
- return c, 'TK_SEMICOLON'
-
- if c == '/':
- comment = ''
- inline_comment = True
- comment_mode = 'TK_INLINE_COMMENT'
- if self.input[parser_pos] == '*': # peek /* .. */ comment
- parser_pos += 1
- if parser_pos < len(self.input):
- while not (self.input[parser_pos] == '*' and \
- parser_pos + 1 < len(self.input) and \
- self.input[parser_pos + 1] == '/')\
- and parser_pos < len(self.input):
- c = self.input[parser_pos]
- comment += c
- if c in '\r\n':
- comment_mode = 'TK_BLOCK_COMMENT'
- parser_pos += 1
- if parser_pos >= len(self.input):
- break
- parser_pos += 2
- return '/*' + comment + '*/', comment_mode
- if self.input[parser_pos] == '/': # peek // comment
- comment = c
- while self.input[parser_pos] not in '\r\n':
- comment += self.input[parser_pos]
- parser_pos += 1
- if parser_pos >= len(self.input):
- break
- parser_pos += 1
- if self.wanted_newline:
- self.append_newline()
- return comment, 'TK_COMMENT'
-
-
-
- if c == "'" or c == '"' or \
- (c == '/' and ((self.last_type == 'TK_WORD' and self.is_special_word(self.last_text)) or \
- (self.last_type == 'TK_END_EXPR' and self.flags.previous_mode in ['(FOR-EXPRESSION)', '(COND-EXPRESSION)']) or \
- (self.last_type in ['TK_COMMENT', 'TK_START_EXPR', 'TK_START_BLOCK', 'TK_END_BLOCK', 'TK_OPERATOR',
- 'TK_EQUALS', 'TK_EOF', 'TK_SEMICOLON']))):
- sep = c
- esc = False
- resulting_string = c
- in_char_class = False
-
- if parser_pos < len(self.input):
- if sep == '/':
- # handle regexp
- in_char_class = False
- while esc or in_char_class or self.input[parser_pos] != sep:
- resulting_string += self.input[parser_pos]
- if not esc:
- esc = self.input[parser_pos] == '\\'
- if self.input[parser_pos] == '[':
- in_char_class = True
- elif self.input[parser_pos] == ']':
- in_char_class = False
- else:
- esc = False
- parser_pos += 1
- if parser_pos >= len(self.input):
- # incomplete regex when end-of-file reached
- # bail out with what has received so far
- return resulting_string, 'TK_STRING'
- else:
- # handle string
- while esc or self.input[parser_pos] != sep:
- resulting_string += self.input[parser_pos]
- if not esc:
- esc = self.input[parser_pos] == '\\'
- else:
- esc = False
- parser_pos += 1
- if parser_pos >= len(self.input):
- # incomplete string when end-of-file reached
- # bail out with what has received so far
- return resulting_string, 'TK_STRING'
-
-
- parser_pos += 1
- resulting_string += sep
- if sep == '/':
- # regexps may have modifiers /regexp/MOD, so fetch those too
- while parser_pos < len(self.input) and self.input[parser_pos] in self.wordchar:
- resulting_string += self.input[parser_pos]
- parser_pos += 1
- return resulting_string, 'TK_STRING'
-
- if c == '#':
-
- # she-bang
- if len(self.output) == 0 and len(self.input) > 1 and self.input[parser_pos] == '!':
- resulting_string = c
- while parser_pos < len(self.input) and c != '\n':
- c = self.input[parser_pos]
- resulting_string += c
- parser_pos += 1
- self.output.append(resulting_string.strip() + "\n")
- self.append_newline()
- return self.get_next_token()
-
-
- # Spidermonkey-specific sharp variables for circular references
- # https://developer.mozilla.org/En/Sharp_variables_in_JavaScript
- # http://mxr.mozilla.org/mozilla-central/source/js/src/jsscan.cpp around line 1935
- sharp = '#'
- if parser_pos < len(self.input) and self.input[parser_pos] in self.digits:
- while True:
- c = self.input[parser_pos]
- sharp += c
- parser_pos += 1
- if parser_pos >= len(self.input) or c == '#' or c == '=':
- break
- if c == '#' or parser_pos >= len(self.input):
- pass
- elif self.input[parser_pos] == '[' and self.input[parser_pos + 1] == ']':
- sharp += '[]'
- parser_pos += 2
- elif self.input[parser_pos] == '{' and self.input[parser_pos + 1] == '}':
- sharp += '{}'
- parser_pos += 2
- return sharp, 'TK_WORD'
-
- if c == '<' and self.input[parser_pos - 1 : parser_pos + 3] == '<!--':
- parser_pos += 3
- c = '<!--'
- while parser_pos < len(self.input) and self.input[parser_pos] != '\n':
- c += self.input[parser_pos]
- parser_pos += 1
- self.flags.in_html_comment = True
- return c, 'TK_COMMENT'
-
- if c == '-' and self.flags.in_html_comment and self.input[parser_pos - 1 : parser_pos + 2] == '-->':
- self.flags.in_html_comment = False
- parser_pos += 2
- if self.wanted_newline:
- self.append_newline()
- return '-->', 'TK_COMMENT'
-
- if c in self.punct:
- while parser_pos < len(self.input) and c + self.input[parser_pos] in self.punct:
- c += self.input[parser_pos]
- parser_pos += 1
- if parser_pos >= len(self.input):
- break
- if c == '=':
- return c, 'TK_EQUALS'
- else:
- return c, 'TK_OPERATOR'
- return c, 'TK_UNKNOWN'
-
-
-
- def handle_start_expr(self, token_text):
- if token_text == '[':
- if self.last_type == 'TK_WORD' or self.last_text == ')':
- if self.last_text in self.line_starters:
- self.append(' ')
- self.set_mode('(EXPRESSION)')
- self.append(token_text)
- return
-
- if self.flags.mode in ['[EXPRESSION]', '[INDENTED-EXPRESSION]']:
- if self.last_last_text == ']' and self.last_text == ',':
- # ], [ goes to a new line
- if self.flags.mode == '[EXPRESSION]':
- self.flags.mode = '[INDENTED-EXPRESSION]'
- if not self.opts.keep_array_indentation:
- self.indent()
- self.set_mode('[EXPRESSION]')
- if not self.opts.keep_array_indentation:
- self.append_newline()
- elif self.last_text == '[':
- if self.flags.mode == '[EXPRESSION]':
- self.flags.mode = '[INDENTED-EXPRESSION]'
- if not self.opts.keep_array_indentation:
- self.indent()
- self.set_mode('[EXPRESSION]')
-
- if not self.opts.keep_array_indentation:
- self.append_newline()
- else:
- self.set_mode('[EXPRESSION]')
- else:
- self.set_mode('[EXPRESSION]')
- else:
- if self.last_text == 'for':
- self.set_mode('(FOR-EXPRESSION)')
- elif self.last_text in ['if', 'while']:
- self.set_mode('(COND-EXPRESSION)')
- else:
- self.set_mode('(EXPRESSION)')
-
-
- if self.last_text == ';' or self.last_type == 'TK_START_BLOCK':
- self.append_newline()
- elif self.last_type in ['TK_END_EXPR', 'TK_START_EXPR', 'TK_END_BLOCK'] or self.last_text == '.':
- # do nothing on (( and )( and ][ and ]( and .(
- if self.wanted_newline:
- self.append_newline();
- elif self.last_type not in ['TK_WORD', 'TK_OPERATOR']:
- self.append(' ')
- elif self.last_word == 'function' or self.last_word == 'typeof':
- # function() vs function (), typeof() vs typeof ()
- if self.opts.jslint_happy:
- self.append(' ')
- elif self.last_text in self.line_starters or self.last_text == 'catch':
- self.append(' ')
-
- self.append(token_text)
-
-
- def handle_end_expr(self, token_text):
- if token_text == ']':
- if self.opts.keep_array_indentation:
- if self.last_text == '}':
- self.remove_indent()
- self.append(token_text)
- self.restore_mode()
- return
- else:
- if self.flags.mode == '[INDENTED-EXPRESSION]':
- if self.last_text == ']':
- self.restore_mode()
- self.append_newline()
- self.append(token_text)
- return
- self.restore_mode()
- self.append(token_text)
-
-
- def handle_start_block(self, token_text):
- if self.last_word == 'do':
- self.set_mode('DO_BLOCK')
- else:
- self.set_mode('BLOCK')
-
- if self.opts.brace_style == 'expand':
- if self.last_type != 'TK_OPERATOR':
- if self.last_text == '=' or (self.is_special_word(self.last_text) and self.last_text != 'else'):
- self.append(' ')
- else:
- self.append_newline(True)
-
- self.append(token_text)
- self.indent()
- else:
- if self.last_type not in ['TK_OPERATOR', 'TK_START_EXPR']:
- if self.last_type == 'TK_START_BLOCK':
- self.append_newline()
- else:
- self.append(' ')
- else:
- # if TK_OPERATOR or TK_START_EXPR
- if self.is_array(self.flags.previous_mode) and self.last_text == ',':
- if self.last_last_text == '}':
- self.append(' ')
- else:
- self.append_newline()
- self.indent()
- self.append(token_text)
-
-
- def handle_end_block(self, token_text):
- self.restore_mode()
- if self.opts.brace_style == 'expand':
- if self.last_text != '{':
- self.append_newline()
- else:
- if self.last_type == 'TK_START_BLOCK':
- if self.just_added_newline:
- self.remove_indent()
- else:
- # {}
- self.trim_output()
- else:
- if self.is_array(self.flags.mode) and self.opts.keep_array_indentation:
- self.opts.keep_array_indentation = False
- self.append_newline()
- self.opts.keep_array_indentation = True
- else:
- self.append_newline()
-
- self.append(token_text)
-
-
- def handle_word(self, token_text):
- if self.do_block_just_closed:
- self.append(' ')
- self.append(token_text)
- self.append(' ')
- self.do_block_just_closed = False
- return
-
- if token_text == 'function':
-
- if self.flags.var_line:
- self.flags.var_line_reindented = not self.opts.keep_function_indentation
- if (self.just_added_newline or self.last_text == ';') and self.last_text != '{':
- # make sure there is a nice clean space of at least one blank line
- # before a new function definition
- have_newlines = self.n_newlines
- if not self.just_added_newline:
- have_newlines = 0
- if not self.opts.preserve_newlines:
- have_newlines = 1
- for i in range(2 - have_newlines):
- self.append_newline(False)
-
- if token_text in ['case', 'default']:
- if self.last_text == ':':
- self.remove_indent()
- else:
- self.flags.indentation_level -= 1
- self.append_newline()
- self.flags.indentation_level += 1
- self.append(token_text)
- self.flags.in_case = True
- return
-
- prefix = 'NONE'
-
- if self.last_type == 'TK_END_BLOCK':
- if token_text not in ['else', 'catch', 'finally']:
- prefix = 'NEWLINE'
- else:
- if self.opts.brace_style in ['expand', 'end-expand']:
- prefix = 'NEWLINE'
- else:
- prefix = 'SPACE'
- self.append(' ')
- elif self.last_type == 'TK_SEMICOLON' and self.flags.mode in ['BLOCK', 'DO_BLOCK']:
- prefix = 'NEWLINE'
- elif self.last_type == 'TK_SEMICOLON' and self.is_expression(self.flags.mode):
- prefix = 'SPACE'
- elif self.last_type == 'TK_STRING':
- prefix = 'NEWLINE'
- elif self.last_type == 'TK_WORD':
- if self.last_text == 'else':
- # eat newlines between ...else *** some_op...
- # won't preserve extra newlines in this place (if any), but don't care that much
- self.trim_output(True)
- prefix = 'SPACE'
- elif self.last_type == 'TK_START_BLOCK':
- prefix = 'NEWLINE'
- elif self.last_type == 'TK_END_EXPR':
- self.append(' ')
- prefix = 'NEWLINE'
-
- if self.flags.if_line and self.last_type == 'TK_END_EXPR':
- self.flags.if_line = False
-
- if token_text in self.line_starters:
- if self.last_text == 'else':
- prefix = 'SPACE'
- else:
- prefix = 'NEWLINE'
-
- if token_text == 'function' and self.last_text in ['get', 'set']:
- prefix = 'SPACE'
-
- if token_text in ['else', 'catch', 'finally']:
- if self.last_type != 'TK_END_BLOCK' \
- or self.opts.brace_style == 'expand' \
- or self.opts.brace_style == 'end-expand':
- self.append_newline()
- else:
- self.trim_output(True)
- self.append(' ')
- elif prefix == 'NEWLINE':
- if token_text == 'function' and (self.last_type == 'TK_START_EXPR' or self.last_text in '=,'):
- # no need to force newline on "function" -
- # (function...
- pass
- elif token_text == 'function' and self.last_text == 'new':
- self.append(' ')
- elif self.is_special_word(self.last_text):
- # no newline between return nnn
- self.append(' ')
- elif self.last_type != 'TK_END_EXPR':
- if (self.last_type != 'TK_START_EXPR' or token_text != 'var') and self.last_text != ':':
- # no need to force newline on VAR -
- # for (var x = 0...
- if token_text == 'if' and self.last_word == 'else' and self.last_text != '{':
- self.append(' ')
- else:
- self.flags.var_line = False
- self.flags.var_line_reindented = False
- self.append_newline()
- elif token_text in self.line_starters and self.last_text != ')':
- self.flags.var_line = False
- self.flags.var_line_reindented = False
- self.append_newline()
- elif self.is_array(self.flags.mode) and self.last_text == ',' and self.last_last_text == '}':
- self.append_newline() # }, in lists get a newline
- elif prefix == 'SPACE':
- self.append(' ')
-
-
- self.append(token_text)
- self.last_word = token_text
-
- if token_text == 'var':
- self.flags.var_line = True
- self.flags.var_line_reindented = False
- self.flags.var_line_tainted = False
-
-
- if token_text == 'if':
- self.flags.if_line = True
-
- if token_text == 'else':
- self.flags.if_line = False
-
-
- def handle_semicolon(self, token_text):
- self.append(token_text)
- self.flags.var_line = False
- self.flags.var_line_reindented = False
- if self.flags.mode == 'OBJECT':
- # OBJECT mode is weird and doesn't get reset too well.
- self.flags.mode = 'BLOCK'
-
-
- def handle_string(self, token_text):
- if self.last_type == 'TK_END_EXPR' and self.flags.previous_mode in ['(COND-EXPRESSION)', '(FOR-EXPRESSION)']:
- self.append(' ')
- if self.last_type in ['TK_STRING', 'TK_START_BLOCK', 'TK_END_BLOCK', 'TK_SEMICOLON']:
- self.append_newline()
- elif self.last_type == 'TK_WORD':
- self.append(' ')
-
- # Try to replace readable \x-encoded characters with their equivalent,
- # if it is possible (e.g. '\x41\x42\x43\x01' becomes 'ABC\x01').
- def unescape(match):
- block, code = match.group(0, 1)
- char = chr(int(code, 16))
- if block.count('\\') == 1 and char in string.printable:
- return char
- return block
-
- token_text = re.sub(r'\\{1,2}x([a-fA-F0-9]{2})', unescape, token_text)
-
- self.append(token_text)
-
- def handle_equals(self, token_text):
- if self.flags.var_line:
- # just got an '=' in a var-line, different line breaking rules will apply
- self.flags.var_line_tainted = True
-
- self.append(' ')
- self.append(token_text)
- self.append(' ')
-
-
- def handle_operator(self, token_text):
- space_before = True
- space_after = True
-
- if self.flags.var_line and token_text == ',' and self.is_expression(self.flags.mode):
- # do not break on comma, for ( var a = 1, b = 2
- self.flags.var_line_tainted = False
-
- if self.flags.var_line and token_text == ',':
- if self.flags.var_line_tainted:
- self.append(token_text)
- self.flags.var_line_reindented = True
- self.flags.var_line_tainted = False
- self.append_newline()
- return
- else:
- self.flags.var_line_tainted = False
-
- if self.is_special_word(self.last_text):
- # return had a special handling in TK_WORD
- self.append(' ')
- self.append(token_text)
- return
-
- if token_text == ':' and self.flags.in_case:
- self.append(token_text)
- self.append_newline()
- self.flags.in_case = False
- return
-
- if token_text == '::':
- # no spaces around the exotic namespacing syntax operator
- self.append(token_text)
- return
-
- if token_text == ',':
- if self.flags.var_line:
- if self.flags.var_line_tainted:
- # This never happens, as it's handled previously, right?
- self.append(token_text)
- self.append_newline()
- self.flags.var_line_tainted = False
- else:
- self.append(token_text)
- self.append(' ')
- elif self.last_type == 'TK_END_BLOCK' and self.flags.mode != '(EXPRESSION)':
- self.append(token_text)
- if self.flags.mode == 'OBJECT' and self.last_text == '}':
- self.append_newline()
- else:
- self.append(' ')
- else:
- if self.flags.mode == 'OBJECT':
- self.append(token_text)
- self.append_newline()
- else:
- # EXPR or DO_BLOCK
- self.append(token_text)
- self.append(' ')
- # comma handled
- return
- elif token_text in ['--', '++', '!'] \
- or (token_text in ['+', '-'] \
- and self.last_type in ['TK_START_BLOCK', 'TK_START_EXPR', 'TK_EQUALS', 'TK_OPERATOR']) \
- or self.last_text in self.line_starters:
-
- space_before = False
- space_after = False
-
- if self.last_text == ';' and self.is_expression(self.flags.mode):
- # for (;; ++i)
- # ^^
- space_before = True
-
- if self.last_type == 'TK_WORD' and self.last_text in self.line_starters:
- space_before = True
-
- if self.flags.mode == 'BLOCK' and self.last_text in ['{', ';']:
- # { foo: --i }
- # foo(): --bar
- self.append_newline()
-
- elif token_text == '.':
- # decimal digits or object.property
- space_before = False
-
- elif token_text == ':':
- if self.flags.ternary_depth == 0:
- self.flags.mode = 'OBJECT'
- space_before = False
- else:
- self.flags.ternary_depth -= 1
- elif token_text == '?':
- self.flags.ternary_depth += 1
-
- if space_before:
- self.append(' ')
-
- self.append(token_text)
-
- if space_after:
- self.append(' ')
-
-
-
- def handle_block_comment(self, token_text):
-
- lines = token_text.replace('\x0d', '').split('\x0a')
- # all lines start with an asterisk? that's a proper box comment
- if not any(l for l in lines[1:] if ( l.strip() == '' or (l.lstrip())[0] != '*')):
- self.append_newline()
- self.append(lines[0])
- for line in lines[1:]:
- self.append_newline()
- self.append(' ' + line.strip())
- else:
- # simple block comment: leave intact
- if len(lines) > 1:
- # multiline comment starts on a new line
- self.append_newline()
- else:
- # single line /* ... */ comment stays on the same line
- self.append(' ')
- for line in lines:
- self.append(line)
- self.append('\n')
- self.append_newline()
-
-
- def handle_inline_comment(self, token_text):
- self.append(' ')
- self.append(token_text)
- if self.is_expression(self.flags.mode):
- self.append(' ')
- else:
- self.append_newline_forced()
-
-
- def handle_comment(self, token_text):
- if self.wanted_newline:
- self.append_newline()
- else:
- self.append(' ')
-
- self.append(token_text)
- self.append_newline_forced()
-
-
- def handle_unknown(self, token_text):
- if self.last_text in ['return', 'throw']:
- self.append(' ')
-
- self.append(token_text)
-
-
-
-
-
-def main():
-
- argv = sys.argv[1:]
-
- try:
- opts, args = getopt.getopt(argv, "s:c:o:djbkil:htf", ['indent-size=','indent-char=','outfile=', 'disable-preserve-newlines',
- 'jslint-happy', 'brace-style=',
- 'keep-array-indentation', 'indent-level=', 'help',
- 'usage', 'stdin', 'eval-code', 'indent-with-tabs', 'keep-function-indentation'])
- except getopt.GetoptError:
- return usage()
-
- js_options = default_options()
-
- file = None
- outfile = 'stdout'
- if len(args) == 1:
- file = args[0]
-
- for opt, arg in opts:
- if opt in ('--keep-array-indentation', '-k'):
- js_options.keep_array_indentation = True
- if opt in ('--keep-function-indentation','-f'):
- js_options.keep_function_indentation = True
- elif opt in ('--outfile', '-o'):
- outfile = arg
- elif opt in ('--indent-size', '-s'):
- js_options.indent_size = int(arg)
- elif opt in ('--indent-char', '-c'):
- js_options.indent_char = arg
- elif opt in ('--indent-with-tabs', '-t'):
- js_options.indent_with_tabs = True
- elif opt in ('--disable-preserve_newlines', '-d'):
- js_options.preserve_newlines = False
- elif opt in ('--jslint-happy', '-j'):
- js_options.jslint_happy = True
- elif opt in ('--eval-code'):
- js_options.eval_code = True
- elif opt in ('--brace-style', '-b'):
- js_options.brace_style = arg
- elif opt in ('--stdin', '-i'):
- file = '-'
- elif opt in ('--help', '--usage', '-h'):
- return usage()
-
- if not file:
- return usage()
- else:
- if outfile == 'stdout':
- print(beautify_file(file, js_options))
- else:
- with open(outfile, 'w') as f:
- f.write(beautify_file(file, js_options) + '\n')
-
diff --git a/libmproxy/contrib/jsbeautifier/unpackers/README.specs.mkd b/libmproxy/contrib/jsbeautifier/unpackers/README.specs.mkd
deleted file mode 100644
index e937b762..00000000
--- a/libmproxy/contrib/jsbeautifier/unpackers/README.specs.mkd
+++ /dev/null
@@ -1,25 +0,0 @@
-# UNPACKERS SPECIFICATIONS
-
-Nothing very difficult: an unpacker is a submodule placed in the directory
-where this file was found. Each unpacker must define three symbols:
-
- * `PRIORITY` : integer number expressing the priority in applying this
- unpacker. Lower number means higher priority.
- Makes sense only if a source file has been packed with
- more than one packer.
- * `detect(source)` : returns `True` if source is packed, otherwise, `False`.
- * `unpack(source)` : takes a `source` string and unpacks it. Must always return
- valid JavaScript. That is to say, your code should look
- like:
-
-```
-if detect(source):
- return do_your_fancy_things_with(source)
-else:
- return source
-```
-
-*You can safely define any other symbol in your module, as it will be ignored.*
-
-`__init__` code will automatically load new unpackers, without any further step
-to be accomplished. Simply drop it in this directory.
diff --git a/libmproxy/contrib/jsbeautifier/unpackers/__init__.py b/libmproxy/contrib/jsbeautifier/unpackers/__init__.py
deleted file mode 100644
index fcb5b07a..00000000
--- a/libmproxy/contrib/jsbeautifier/unpackers/__init__.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# General code for JSBeautifier unpackers infrastructure. See README.specs
-# written by Stefano Sanfilippo <a.little.coder@gmail.com>
-#
-
-"""General code for JSBeautifier unpackers infrastructure."""
-
-import pkgutil
-import re
-from . import evalbased
-
-# NOTE: AT THE MOMENT, IT IS DEACTIVATED FOR YOUR SECURITY: it runs js!
-BLACKLIST = ['jsbeautifier.unpackers.evalbased']
-
-class UnpackingError(Exception):
- """Badly packed source or general error. Argument is a
- meaningful description."""
-
-def getunpackers():
- """Scans the unpackers dir, finds unpackers and add them to UNPACKERS list.
- An unpacker will be loaded only if it is a valid python module (name must
- adhere to naming conventions) and it is not blacklisted (i.e. inserted
- into BLACKLIST."""
- path = __path__
- prefix = __name__ + '.'
- unpackers = []
- interface = ['unpack', 'detect', 'PRIORITY']
- for _importer, modname, _ispkg in pkgutil.iter_modules(path, prefix):
- if 'tests' not in modname and modname not in BLACKLIST:
- try:
- module = __import__(modname, fromlist=interface)
- except ImportError:
- raise UnpackingError('Bad unpacker: %s' % modname)
- else:
- unpackers.append(module)
-
- return sorted(unpackers, key = lambda mod: mod.PRIORITY)
-
-UNPACKERS = getunpackers()
-
-def run(source, evalcode=False):
- """Runs the applicable unpackers and return unpacked source as a string."""
- for unpacker in [mod for mod in UNPACKERS if mod.detect(source)]:
- source = unpacker.unpack(source)
- if evalcode and evalbased.detect(source):
- source = evalbased.unpack(source)
- return source
-
-def filtercomments(source):
- """NOT USED: strips trailing comments and put them at the top."""
- trailing_comments = []
- comment = True
-
- while comment:
- if re.search(r'^\s*\/\*', source):
- comment = source[0, source.index('*/') + 2]
- elif re.search(r'^\s*\/\/', source):
- comment = re.search(r'^\s*\/\/', source).group(0)
- else:
- comment = None
-
- if comment:
- source = re.sub(r'^\s+', '', source[len(comment):])
- trailing_comments.append(comment)
-
- return '\n'.join(trailing_comments) + source
diff --git a/libmproxy/contrib/jsbeautifier/unpackers/evalbased.py b/libmproxy/contrib/jsbeautifier/unpackers/evalbased.py
deleted file mode 100644
index b17d926e..00000000
--- a/libmproxy/contrib/jsbeautifier/unpackers/evalbased.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Unpacker for eval() based packers, a part of javascript beautifier
-# by Einar Lielmanis <einar@jsbeautifier.org>
-#
-# written by Stefano Sanfilippo <a.little.coder@gmail.com>
-#
-# usage:
-#
-# if detect(some_string):
-# unpacked = unpack(some_string)
-#
-
-"""Unpacker for eval() based packers: runs JS code and returns result.
-Works only if a JS interpreter (e.g. Mozilla's Rhino) is installed and
-properly set up on host."""
-
-from subprocess import PIPE, Popen
-
-PRIORITY = 3
-
-def detect(source):
- """Detects if source is likely to be eval() packed."""
- return source.strip().lower().startswith('eval(function(')
-
-def unpack(source):
- """Runs source and return resulting code."""
- return jseval('print %s;' % source[4:]) if detect(source) else source
-
-# In case of failure, we'll just return the original, without crashing on user.
-def jseval(script):
- """Run code in the JS interpreter and return output."""
- try:
- interpreter = Popen(['js'], stdin=PIPE, stdout=PIPE)
- except OSError:
- return script
- result, errors = interpreter.communicate(script)
- if interpreter.poll() or errors:
- return script
- return result
diff --git a/libmproxy/contrib/jsbeautifier/unpackers/javascriptobfuscator.py b/libmproxy/contrib/jsbeautifier/unpackers/javascriptobfuscator.py
deleted file mode 100644
index aa4344a3..00000000
--- a/libmproxy/contrib/jsbeautifier/unpackers/javascriptobfuscator.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# simple unpacker/deobfuscator for scripts messed up with
-# javascriptobfuscator.com
-#
-# written by Einar Lielmanis <einar@jsbeautifier.org>
-# rewritten in Python by Stefano Sanfilippo <a.little.coder@gmail.com>
-#
-# Will always return valid javascript: if `detect()` is false, `code` is
-# returned, unmodified.
-#
-# usage:
-#
-# if javascriptobfuscator.detect(some_string):
-# some_string = javascriptobfuscator.unpack(some_string)
-#
-
-"""deobfuscator for scripts messed up with JavascriptObfuscator.com"""
-
-import re
-
-PRIORITY = 1
-
-def smartsplit(code):
- """Split `code` at " symbol, only if it is not escaped."""
- strings = []
- pos = 0
- while pos < len(code):
- if code[pos] == '"':
- word = '' # new word
- pos += 1
- while pos < len(code):
- if code[pos] == '"':
- break
- if code[pos] == '\\':
- word += '\\'
- pos += 1
- word += code[pos]
- pos += 1
- strings.append('"%s"' % word)
- pos += 1
- return strings
-
-def detect(code):
- """Detects if `code` is JavascriptObfuscator.com packed."""
- # prefer `is not` idiom, so that a true boolean is returned
- return (re.search(r'^var _0x[a-f0-9]+ ?\= ?\[', code) is not None)
-
-def unpack(code):
- """Unpacks JavascriptObfuscator.com packed code."""
- if detect(code):
- matches = re.search(r'var (_0x[a-f\d]+) ?\= ?\[(.*?)\];', code)
- if matches:
- variable = matches.group(1)
- dictionary = smartsplit(matches.group(2))
- code = code[len(matches.group(0)):]
- for key, value in enumerate(dictionary):
- code = code.replace(r'%s[%s]' % (variable, key), value)
- return code
diff --git a/libmproxy/contrib/jsbeautifier/unpackers/myobfuscate.py b/libmproxy/contrib/jsbeautifier/unpackers/myobfuscate.py
deleted file mode 100644
index 9893f95f..00000000
--- a/libmproxy/contrib/jsbeautifier/unpackers/myobfuscate.py
+++ /dev/null
@@ -1,86 +0,0 @@
-#
-# deobfuscator for scripts messed up with myobfuscate.com
-# by Einar Lielmanis <einar@jsbeautifier.org>
-#
-# written by Stefano Sanfilippo <a.little.coder@gmail.com>
-#
-# usage:
-#
-# if detect(some_string):
-# unpacked = unpack(some_string)
-#
-
-# CAVEAT by Einar Lielmanis
-
-#
-# You really don't want to obfuscate your scripts there: they're tracking
-# your unpackings, your script gets turned into something like this,
-# as of 2011-08-26:
-#
-# var _escape = 'your_script_escaped';
-# var _111 = document.createElement('script');
-# _111.src = 'http://api.www.myobfuscate.com/?getsrc=ok' +
-# '&ref=' + encodeURIComponent(document.referrer) +
-# '&url=' + encodeURIComponent(document.URL);
-# var 000 = document.getElementsByTagName('head')[0];
-# 000.appendChild(_111);
-# document.write(unescape(_escape));
-#
-
-"""Deobfuscator for scripts messed up with MyObfuscate.com"""
-
-import re
-import base64
-
-# Python 2 retrocompatibility
-# pylint: disable=F0401
-# pylint: disable=E0611
-try:
- from urllib import unquote
-except ImportError:
- from urllib.parse import unquote
-
-from . import UnpackingError
-
-PRIORITY = 1
-
-CAVEAT = """//
-// Unpacker warning: be careful when using myobfuscate.com for your projects:
-// scripts obfuscated by the free online version call back home.
-//
-
-"""
-
-SIGNATURE = (r'["\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F'
- r'\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x61\x62\x63\x64\x65'
- r'\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75'
- r'\x76\x77\x78\x79\x7A\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x2B'
- r'\x2F\x3D","","\x63\x68\x61\x72\x41\x74","\x69\x6E\x64\x65\x78'
- r'\x4F\x66","\x66\x72\x6F\x6D\x43\x68\x61\x72\x43\x6F\x64\x65","'
- r'\x6C\x65\x6E\x67\x74\x68"]')
-
-def detect(source):
- """Detects MyObfuscate.com packer."""
- return SIGNATURE in source
-
-def unpack(source):
- """Unpacks js code packed with MyObfuscate.com"""
- if not detect(source):
- return source
- payload = unquote(_filter(source))
- match = re.search(r"^var _escape\='<script>(.*)<\/script>'",
- payload, re.DOTALL)
- polished = match.group(1) if match else source
- return CAVEAT + polished
-
-def _filter(source):
- """Extracts and decode payload (original file) from `source`"""
- try:
- varname = re.search(r'eval\(\w+\(\w+\((\w+)\)\)\);', source).group(1)
- reverse = re.search(r"var +%s *\= *'(.*)';" % varname, source).group(1)
- except AttributeError:
- raise UnpackingError('Malformed MyObfuscate data.')
- try:
- return base64.b64decode(reverse[::-1].encode('utf8')).decode('utf8')
- except TypeError:
- raise UnpackingError('MyObfuscate payload is not base64-encoded.')
diff --git a/libmproxy/contrib/jsbeautifier/unpackers/packer.py b/libmproxy/contrib/jsbeautifier/unpackers/packer.py
deleted file mode 100644
index 4ada669e..00000000
--- a/libmproxy/contrib/jsbeautifier/unpackers/packer.py
+++ /dev/null
@@ -1,103 +0,0 @@
-#
-# Unpacker for Dean Edward's p.a.c.k.e.r, a part of javascript beautifier
-# by Einar Lielmanis <einar@jsbeautifier.org>
-#
-# written by Stefano Sanfilippo <a.little.coder@gmail.com>
-#
-# usage:
-#
-# if detect(some_string):
-# unpacked = unpack(some_string)
-#
-
-"""Unpacker for Dean Edward's p.a.c.k.e.r"""
-
-import re
-from . import UnpackingError
-
-PRIORITY = 1
-
-def detect(source):
- """Detects whether `source` is P.A.C.K.E.R. coded."""
- return source.replace(' ', '').startswith('eval(function(p,a,c,k,e,r')
-
-def unpack(source):
- """Unpacks P.A.C.K.E.R. packed js code."""
- payload, symtab, radix, count = _filterargs(source)
-
- if count != len(symtab):
- raise UnpackingError('Malformed p.a.c.k.e.r. symtab.')
-
- try:
- unbase = Unbaser(radix)
- except TypeError:
- raise UnpackingError('Unknown p.a.c.k.e.r. encoding.')
-
- def lookup(match):
- """Look up symbols in the synthetic symtab."""
- word = match.group(0)
- return symtab[unbase(word)] or word
-
- source = re.sub(r'\b\w+\b', lookup, payload)
- return _replacestrings(source)
-
-def _filterargs(source):
- """Juice from a source file the four args needed by decoder."""
- argsregex = (r"}\('(.*)', *(\d+), *(\d+), *'(.*)'\."
- r"split\('\|'\), *(\d+), *(.*)\)\)")
- args = re.search(argsregex, source, re.DOTALL).groups()
-
- try:
- return args[0], args[3].split('|'), int(args[1]), int(args[2])
- except ValueError:
- raise UnpackingError('Corrupted p.a.c.k.e.r. data.')
-
-def _replacestrings(source):
- """Strip string lookup table (list) and replace values in source."""
- match = re.search(r'var *(_\w+)\=\["(.*?)"\];', source, re.DOTALL)
-
- if match:
- varname, strings = match.groups()
- startpoint = len(match.group(0))
- lookup = strings.split('","')
- variable = '%s[%%d]' % varname
- for index, value in enumerate(lookup):
- source = source.replace(variable % index, '"%s"' % value)
- return source[startpoint:]
- return source
-
-
-class Unbaser(object):
- """Functor for a given base. Will efficiently convert
- strings to natural numbers."""
- ALPHABET = {
- 62 : '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
- 95 : (' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- '[\]^_`abcdefghijklmnopqrstuvwxyz{|}~')
- }
-
- def __init__(self, base):
- self.base = base
-
- # If base can be handled by int() builtin, let it do it for us
- if 2 <= base <= 36:
- self.unbase = lambda string: int(string, base)
- else:
- # Build conversion dictionary cache
- try:
- self.dictionary = dict((cipher, index) for
- index, cipher in enumerate(self.ALPHABET[base]))
- except KeyError:
- raise TypeError('Unsupported base encoding.')
-
- self.unbase = self._dictunbaser
-
- def __call__(self, string):
- return self.unbase(string)
-
- def _dictunbaser(self, string):
- """Decodes a value to an integer."""
- ret = 0
- for index, cipher in enumerate(string[::-1]):
- ret += (self.base ** index) * self.dictionary[cipher]
- return ret
diff --git a/libmproxy/contrib/jsbeautifier/unpackers/urlencode.py b/libmproxy/contrib/jsbeautifier/unpackers/urlencode.py
deleted file mode 100644
index 72d2bd1c..00000000
--- a/libmproxy/contrib/jsbeautifier/unpackers/urlencode.py
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Trivial bookmarklet/escaped script detector for the javascript beautifier
-# written by Einar Lielmanis <einar@jsbeautifier.org>
-# rewritten in Python by Stefano Sanfilippo <a.little.coder@gmail.com>
-#
-# Will always return valid javascript: if `detect()` is false, `code` is
-# returned, unmodified.
-#
-# usage:
-#
-# some_string = urlencode.unpack(some_string)
-#
-
-"""Bookmarklet/escaped script unpacker."""
-
-# Python 2 retrocompatibility
-# pylint: disable=F0401
-# pylint: disable=E0611
-try:
- from urllib import unquote_plus
-except ImportError:
- from urllib.parse import unquote_plus
-
-PRIORITY = 0
-
-def detect(code):
- """Detects if a scriptlet is urlencoded."""
- # the fact that script doesn't contain any space, but has %20 instead
- # should be sufficient check for now.
- return ' ' not in code and ('%20' in code or code.count('%') > 3)
-
-def unpack(code):
- """URL decode `code` source string."""
- return unquote_plus(code) if detect(code) else code
diff --git a/libmproxy/contrib/tls/__init__.py b/libmproxy/contrib/tls/__init__.py
deleted file mode 100644
index 4b540884..00000000
--- a/libmproxy/contrib/tls/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-# This file is dual licensed under the terms of the Apache License, Version
-# 2.0, and the BSD License. See the LICENSE file in the root of this repository
-# for complete details.
-
-from __future__ import absolute_import, division, print_function
diff --git a/libmproxy/contrib/tls/_constructs.py b/libmproxy/contrib/tls/_constructs.py
deleted file mode 100644
index 4cb7d382..00000000
--- a/libmproxy/contrib/tls/_constructs.py
+++ /dev/null
@@ -1,213 +0,0 @@
-# This file is dual licensed under the terms of the Apache License, Version
-# 2.0, and the BSD License. See the LICENSE file in the root of this repository
-# for complete details.
-
-from __future__ import absolute_import, division, print_function
-
-from construct import (Array, Bytes, Struct, UBInt16, UBInt32, UBInt8, PascalString, Embed, TunnelAdapter, GreedyRange,
- Switch, OptionalGreedyRange, Optional)
-
-from .utils import UBInt24
-
-ProtocolVersion = Struct(
- "version",
- UBInt8("major"),
- UBInt8("minor"),
-)
-
-TLSPlaintext = Struct(
- "TLSPlaintext",
- UBInt8("type"),
- ProtocolVersion,
- UBInt16("length"), # TODO: Reject packets with length > 2 ** 14
- Bytes("fragment", lambda ctx: ctx.length),
-)
-
-TLSCompressed = Struct(
- "TLSCompressed",
- UBInt8("type"),
- ProtocolVersion,
- UBInt16("length"), # TODO: Reject packets with length > 2 ** 14 + 1024
- Bytes("fragment", lambda ctx: ctx.length),
-)
-
-TLSCiphertext = Struct(
- "TLSCiphertext",
- UBInt8("type"),
- ProtocolVersion,
- UBInt16("length"), # TODO: Reject packets with length > 2 ** 14 + 2048
- Bytes("fragment", lambda ctx: ctx.length),
-)
-
-Random = Struct(
- "random",
- UBInt32("gmt_unix_time"),
- Bytes("random_bytes", 28),
-)
-
-SessionID = Struct(
- "session_id",
- UBInt8("length"),
- Bytes("session_id", lambda ctx: ctx.length),
-)
-
-CipherSuites = Struct(
- "cipher_suites",
- UBInt16("length"), # TODO: Reject packets of length 0
- Array(lambda ctx: ctx.length // 2, UBInt16("cipher_suites")),
-)
-
-CompressionMethods = Struct(
- "compression_methods",
- UBInt8("length"), # TODO: Reject packets of length 0
- Array(lambda ctx: ctx.length, UBInt8("compression_methods")),
-)
-
-ServerName = Struct(
- "",
- UBInt8("type"),
- PascalString("name", length_field=UBInt16("length")),
-)
-
-SNIExtension = Struct(
- "",
- TunnelAdapter(
- PascalString("server_names", length_field=UBInt16("length")),
- TunnelAdapter(
- PascalString("", length_field=UBInt16("length")),
- GreedyRange(ServerName)
- ),
- ),
-)
-
-ALPNExtension = Struct(
- "",
- TunnelAdapter(
- PascalString("alpn_protocols", length_field=UBInt16("length")),
- TunnelAdapter(
- PascalString("", length_field=UBInt16("length")),
- GreedyRange(PascalString("name"))
- ),
- ),
-)
-
-UnknownExtension = Struct(
- "",
- PascalString("bytes", length_field=UBInt16("extensions_length"))
-)
-
-Extension = Struct(
- "Extension",
- UBInt16("type"),
- Embed(
- Switch(
- "", lambda ctx: ctx.type,
- {
- 0x00: SNIExtension,
- 0x10: ALPNExtension
- },
- default=UnknownExtension
- )
- )
-)
-
-extensions = TunnelAdapter(
- Optional(PascalString("extensions", length_field=UBInt16("extensions_length"))),
- OptionalGreedyRange(Extension)
-)
-
-ClientHello = Struct(
- "ClientHello",
- ProtocolVersion,
- Random,
- SessionID,
- CipherSuites,
- CompressionMethods,
- extensions,
-)
-
-ServerHello = Struct(
- "ServerHello",
- ProtocolVersion,
- Random,
- SessionID,
- Bytes("cipher_suite", 2),
- UBInt8("compression_method"),
- extensions,
-)
-
-ClientCertificateType = Struct(
- "certificate_types",
- UBInt8("length"), # TODO: Reject packets of length 0
- Array(lambda ctx: ctx.length, UBInt8("certificate_types")),
-)
-
-SignatureAndHashAlgorithm = Struct(
- "algorithms",
- UBInt8("hash"),
- UBInt8("signature"),
-)
-
-SupportedSignatureAlgorithms = Struct(
- "supported_signature_algorithms",
- UBInt16("supported_signature_algorithms_length"),
- # TODO: Reject packets of length 0
- Array(
- lambda ctx: ctx.supported_signature_algorithms_length / 2,
- SignatureAndHashAlgorithm,
- ),
-)
-
-DistinguishedName = Struct(
- "certificate_authorities",
- UBInt16("length"),
- Bytes("certificate_authorities", lambda ctx: ctx.length),
-)
-
-CertificateRequest = Struct(
- "CertificateRequest",
- ClientCertificateType,
- SupportedSignatureAlgorithms,
- DistinguishedName,
-)
-
-ServerDHParams = Struct(
- "ServerDHParams",
- UBInt16("dh_p_length"),
- Bytes("dh_p", lambda ctx: ctx.dh_p_length),
- UBInt16("dh_g_length"),
- Bytes("dh_g", lambda ctx: ctx.dh_g_length),
- UBInt16("dh_Ys_length"),
- Bytes("dh_Ys", lambda ctx: ctx.dh_Ys_length),
-)
-
-PreMasterSecret = Struct(
- "pre_master_secret",
- ProtocolVersion,
- Bytes("random_bytes", 46),
-)
-
-ASN1Cert = Struct(
- "ASN1Cert",
- UBInt32("length"), # TODO: Reject packets with length not in 1..2^24-1
- Bytes("asn1_cert", lambda ctx: ctx.length),
-)
-
-Certificate = Struct(
- "Certificate", # TODO: Reject packets with length > 2 ** 24 - 1
- UBInt32("certificates_length"),
- Bytes("certificates_bytes", lambda ctx: ctx.certificates_length),
-)
-
-Handshake = Struct(
- "Handshake",
- UBInt8("msg_type"),
- UBInt24("length"),
- Bytes("body", lambda ctx: ctx.length),
-)
-
-Alert = Struct(
- "Alert",
- UBInt8("level"),
- UBInt8("description"),
-)
diff --git a/libmproxy/contrib/tls/utils.py b/libmproxy/contrib/tls/utils.py
deleted file mode 100644
index 4c917303..00000000
--- a/libmproxy/contrib/tls/utils.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# This file is dual licensed under the terms of the Apache License, Version
-# 2.0, and the BSD License. See the LICENSE file in the root of this repository
-# for complete details.
-
-from __future__ import absolute_import, division, print_function
-
-import construct
-
-import six
-
-
-class _UBInt24(construct.Adapter):
- def _encode(self, obj, context):
- return (
- six.int2byte((obj & 0xFF0000) >> 16) +
- six.int2byte((obj & 0x00FF00) >> 8) +
- six.int2byte(obj & 0x0000FF)
- )
-
- def _decode(self, obj, context):
- obj = bytearray(obj)
- return (obj[0] << 16 | obj[1] << 8 | obj[2])
-
-
-def UBInt24(name): # noqa
- return _UBInt24(construct.Bytes(name, 3))
diff --git a/libmproxy/contrib/wbxml/ASCommandResponse.py b/libmproxy/contrib/wbxml/ASCommandResponse.py
deleted file mode 100644
index 08d03445..00000000
--- a/libmproxy/contrib/wbxml/ASCommandResponse.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env python
-'''
-@author: David Shaw, david.shaw.aw@gmail.com
-
-Inspired by EAS Inspector for Fiddler
-https://easinspectorforfiddler.codeplex.com
-
------ The MIT License (MIT) -----
-Filename: ASCommandResponse.py
-Copyright (c) 2014, David P. Shaw
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-'''
-from ASWBXML import ASWBXML
-import logging
-
-class ASCommandResponse:
-
- def __init__(self, response):
- self.wbxmlBody = response
- try:
- if ( len(response) > 0):
- self.xmlString = self.decodeWBXML(self.wbxmlBody)
- else:
- raise ValueError("Empty WBXML body passed")
- except Exception as e:
- self.xmlString = None
- raise ValueError("Error: {0}".format(e.message))
-
- def getWBXMLBytes(self):
- return self.wbxmlBytes
-
- def getXMLString(self):
- return self.xmlString
-
- def decodeWBXML(self, body):
- self.instance = ASWBXML()
- self.instance.loadBytes(body)
- return self.instance.getXml()
-
-if __name__ == "__main__":
- import os
- logging.basicConfig(level=logging.INFO)
-
- projectDir = os.path.dirname(os.path.realpath("."))
- samplesDir = os.path.join(projectDir, "Samples/")
- listOfSamples = os.listdir(samplesDir)
-
- for filename in listOfSamples:
- byteWBXML = open(samplesDir + os.sep + filename, "rb").read()
-
- logging.info("-"*100)
- logging.info(filename)
- logging.info("-"*100)
- instance = ASCommandResponse(byteWBXML)
- logging.info(instance.xmlString)
diff --git a/libmproxy/contrib/wbxml/ASWBXML.py b/libmproxy/contrib/wbxml/ASWBXML.py
deleted file mode 100644
index 926d18c0..00000000
--- a/libmproxy/contrib/wbxml/ASWBXML.py
+++ /dev/null
@@ -1,903 +0,0 @@
-#!/usr/bin/env python
-'''
-@author: David Shaw, david.shaw.aw@gmail.com
-
-Inspired by EAS Inspector for Fiddler
-https://easinspectorforfiddler.codeplex.com
-
------ The MIT License (MIT) -----
-Filename: ASWBXML.py
-Copyright (c) 2014, David P. Shaw
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-'''
-import xml.dom.minidom
-import logging
-
-from ASWBXMLCodePage import ASWBXMLCodePage
-from ASWBXMLByteQueue import ASWBXMLByteQueue
-from GlobalTokens import GlobalTokens
-from InvalidDataException import InvalidDataException
-
-class ASWBXML:
- versionByte = 0x03
- publicIdentifierByte = 0x01
- characterSetByte = 0x6A
- stringTableLengthByte = 0x00
-
- def __init__(self):
-
- # empty on init
- self.xmlDoc = xml.dom.minidom.Document()
- self.currentCodePage = 0
- self.defaultCodePage = -1
-
- # Load up code pages
- # Currently there are 25 code pages as per MS-ASWBXML
- self.codePages = []
-
- # region Code Page Initialization
- # Code Page 0: AirSync
- # region AirSync Code Page
- page = ASWBXMLCodePage()
- page.namespace = "AirSync:"
- page.xmlns = "airsync"
-
- page.addToken(0x05, "Sync")
- page.addToken(0x06, "Responses")
- page.addToken(0x07, "Add")
- page.addToken(0x08, "Change")
- page.addToken(0x09, "Delete")
- page.addToken(0x0A, "Fetch")
- page.addToken(0x0B, "SyncKey")
- page.addToken(0x0C, "ClientId")
- page.addToken(0x0D, "ServerId")
- page.addToken(0x0E, "Status")
- page.addToken(0x0F, "Collection")
- page.addToken(0x10, "Class")
- page.addToken(0x12, "CollectionId")
- page.addToken(0x13, "GetChanges")
- page.addToken(0x14, "MoreAvailable")
- page.addToken(0x15, "WindowSize")
- page.addToken(0x16, "Commands")
- page.addToken(0x17, "Options")
- page.addToken(0x18, "FilterType")
- page.addToken(0x1B, "Conflict")
- page.addToken(0x1C, "Collections")
- page.addToken(0x1D, "ApplicationData")
- page.addToken(0x1E, "DeletesAsMoves")
- page.addToken(0x20, "Supported")
- page.addToken(0x21, "SoftDelete")
- page.addToken(0x22, "MIMESupport")
- page.addToken(0x23, "MIMETruncation")
- page.addToken(0x24, "Wait")
- page.addToken(0x25, "Limit")
- page.addToken(0x26, "Partial")
- page.addToken(0x27, "ConversationMode")
- page.addToken(0x28, "MaxItems")
- page.addToken(0x29, "HeartbeatInterval")
- self.codePages.append(page)
- # endregion
-
- # Code Page 1: Contacts
- # region Contacts Code Page
- page = ASWBXMLCodePage()
- page.namespace = "Contacts:"
- page.xmlns = "contacts"
-
- page.addToken(0x05, "Anniversary")
- page.addToken(0x06, "AssistantName")
- page.addToken(0x07, "AssistantTelephoneNumber")
- page.addToken(0x08, "Birthday")
- page.addToken(0x0C, "Business2PhoneNumber")
- page.addToken(0x0D, "BusinessCity")
- page.addToken(0x0E, "BusinessCountry")
- page.addToken(0x0F, "BusinessPostalCode")
- page.addToken(0x10, "BusinessState")
- page.addToken(0x11, "BusinessStreet")
- page.addToken(0x12, "BusinessFaxNumber")
- page.addToken(0x13, "BusinessPhoneNumber")
- page.addToken(0x14, "CarPhoneNumber")
- page.addToken(0x15, "Categories")
- page.addToken(0x16, "Category")
- page.addToken(0x17, "Children")
- page.addToken(0x18, "Child")
- page.addToken(0x19, "CompanyName")
- page.addToken(0x1A, "Department")
- page.addToken(0x1B, "Email1Address")
- page.addToken(0x1C, "Email2Address")
- page.addToken(0x1D, "Email3Address")
- page.addToken(0x1E, "FileAs")
- page.addToken(0x1F, "FirstName")
- page.addToken(0x20, "Home2PhoneNumber")
- page.addToken(0x21, "HomeCity")
- page.addToken(0x22, "HomeCountry")
- page.addToken(0x23, "HomePostalCode")
- page.addToken(0x24, "HomeState")
- page.addToken(0x25, "HomeStreet")
- page.addToken(0x26, "HomeFaxNumber")
- page.addToken(0x27, "HomePhoneNumber")
- page.addToken(0x28, "JobTitle")
- page.addToken(0x29, "LastName")
- page.addToken(0x2A, "MiddleName")
- page.addToken(0x2B, "MobilePhoneNumber")
- page.addToken(0x2C, "OfficeLocation")
- page.addToken(0x2D, "OtherCity")
- page.addToken(0x2E, "OtherCountry")
- page.addToken(0x2F, "OtherPostalCode")
- page.addToken(0x30, "OtherState")
- page.addToken(0x31, "OtherStreet")
- page.addToken(0x32, "PagerNumber")
- page.addToken(0x33, "RadioPhoneNumber")
- page.addToken(0x34, "Spouse")
- page.addToken(0x35, "Suffix")
- page.addToken(0x36, "Title")
- page.addToken(0x37, "Webpage")
- page.addToken(0x38, "YomiCompanyName")
- page.addToken(0x39, "YomiFirstName")
- page.addToken(0x3A, "YomiLastName")
- page.addToken(0x3C, "Picture")
- page.addToken(0x3D, "Alias")
- page.addToken(0x3E, "WeightedRank")
- self.codePages.append(page)
- # endregion
-
- # Code Page 2: Email
- # region Email Code Page
- page = ASWBXMLCodePage()
- page.namespace = "Email:"
- page.xmlns = "email"
-
- page.addToken(0x0F, "DateReceived")
- page.addToken(0x11, "DisplayTo")
- page.addToken(0x12, "Importance")
- page.addToken(0x13, "MessageClass")
- page.addToken(0x14, "Subject")
- page.addToken(0x15, "Read")
- page.addToken(0x16, "To")
- page.addToken(0x17, "CC")
- page.addToken(0x18, "From")
- page.addToken(0x19, "ReplyTo")
- page.addToken(0x1A, "AllDayEvent")
- page.addToken(0x1B, "Categories")
- page.addToken(0x1C, "Category")
- page.addToken(0x1D, "DTStamp")
- page.addToken(0x1E, "EndTime")
- page.addToken(0x1F, "InstanceType")
- page.addToken(0x20, "BusyStatus")
- page.addToken(0x21, "Location")
- page.addToken(0x22, "MeetingRequest")
- page.addToken(0x23, "Organizer")
- page.addToken(0x24, "RecurrenceId")
- page.addToken(0x25, "Reminder")
- page.addToken(0x26, "ResponseRequested")
- page.addToken(0x27, "Recurrences")
- page.addToken(0x28, "Recurrence")
- page.addToken(0x29, "Recurrence_Type")
- page.addToken(0x2A, "Recurrence_Until")
- page.addToken(0x2B, "Recurrence_Occurrences")
- page.addToken(0x2C, "Recurrence_Interval")
- page.addToken(0x2D, "Recurrence_DayOfWeek")
- page.addToken(0x2E, "Recurrence_DayOfMonth")
- page.addToken(0x2F, "Recurrence_WeekOfMonth")
- page.addToken(0x30, "Recurrence_MonthOfYear")
- page.addToken(0x31, "StartTime")
- page.addToken(0x32, "Sensitivity")
- page.addToken(0x33, "TimeZone")
- page.addToken(0x34, "GlobalObjId")
- page.addToken(0x35, "ThreadTopic")
- page.addToken(0x39, "InternetCPID")
- page.addToken(0x3A, "Flag")
- page.addToken(0x3B, "FlagStatus")
- page.addToken(0x3C, "ContentClass")
- page.addToken(0x3D, "FlagType")
- page.addToken(0x3E, "CompleteTime")
- page.addToken(0x3F, "DisallowNewTimeProposal")
- self.codePages.append(page)
- # endregion
-
- # Code Page 3: AirNotify - retired
- # region AirNotify Code Page
- page = ASWBXMLCodePage()
- page.namespace = ""
- page.xmlns = ""
- self.codePages.append(page)
- # endregion
-
- # Code Page 4: Calendar
- # region Calendar Code Page
- page = ASWBXMLCodePage()
- page.namespace = "Calendar:"
- page.xmlns = "calendar"
-
- page.addToken(0x05, "TimeZone")
- page.addToken(0x06, "AllDayEvent")
- page.addToken(0x07, "Attendees")
- page.addToken(0x08, "Attendee")
- page.addToken(0x09, "Attendee_Email")
- page.addToken(0x0A, "Attendee_Name")
- page.addToken(0x0D, "BusyStatus")
- page.addToken(0x0E, "Categories")
- page.addToken(0x0F, "Category")
- page.addToken(0x11, "DTStamp")
- page.addToken(0x12, "EndTime")
- page.addToken(0x13, "Exception")
- page.addToken(0x14, "Exceptions")
- page.addToken(0x15, "Exception_Deleted")
- page.addToken(0x16, "Exception_StartTime")
- page.addToken(0x17, "Location")
- page.addToken(0x18, "MeetingStatus")
- page.addToken(0x19, "Organizer_Email")
- page.addToken(0x1A, "Organizer_Name")
- page.addToken(0x1B, "Recurrence")
- page.addToken(0x1C, "Recurrence_Type")
- page.addToken(0x1D, "Recurrence_Until")
- page.addToken(0x1E, "Recurrence_Occurrences")
- page.addToken(0x1F, "Recurrence_Interval")
- page.addToken(0x20, "Recurrence_DayOfWeek")
- page.addToken(0x21, "Recurrence_DayOfMonth")
- page.addToken(0x22, "Recurrence_WeekOfMonth")
- page.addToken(0x23, "Recurrence_MonthOfYear")
- page.addToken(0x24, "Reminder")
- page.addToken(0x25, "Sensitivity")
- page.addToken(0x26, "Subject")
- page.addToken(0x27, "StartTime")
- page.addToken(0x28, "UID")
- page.addToken(0x29, "Attendee_Status")
- page.addToken(0x2A, "Attendee_Type")
- page.addToken(0x33, "DisallowNewTimeProposal")
- page.addToken(0x34, "ResponseRequested")
- page.addToken(0x35, "AppointmentReplyTime")
- page.addToken(0x36, "ResponseType")
- page.addToken(0x37, "CalendarType")
- page.addToken(0x38, "IsLeapMonth")
- page.addToken(0x39, "FirstDayOfWeek")
- page.addToken(0x3A, "OnlineMeetingConfLink")
- page.addToken(0x3B, "OnlineMeetingExternalLink")
- self.codePages.append(page)
- # endregion
-
- # Code Page 5: Move
- # region Move Code Page
- page = ASWBXMLCodePage()
- page.namespace = "Move:"
- page.xmlns = "move"
-
- page.addToken(0x05, "MoveItems")
- page.addToken(0x06, "Move")
- page.addToken(0x07, "SrcMsgId")
- page.addToken(0x08, "SrcFldId")
- page.addToken(0x09, "DstFldId")
- page.addToken(0x0A, "Response")
- page.addToken(0x0B, "Status")
- page.addToken(0x0C, "DstMsgId")
- self.codePages.append(page)
- # endregion
-
- # Code Page 6: ItemEstimate
- # region ItemEstimate Code Page
- page = ASWBXMLCodePage()
- page.namespace = "GetItemEstimate:"
- page.xmlns = "getitemestimate"
-
- page.addToken(0x05, "GetItemEstimate")
- page.addToken(0x06, "Version")
- page.addToken(0x07, "Collections")
- page.addToken(0x08, "Collection")
- page.addToken(0x09, "Class")
- page.addToken(0x0A, "CollectionId")
- page.addToken(0x0B, "DateTime")
- page.addToken(0x0C, "Estimate")
- page.addToken(0x0D, "Response")
- page.addToken(0x0E, "Status")
- self.codePages.append(page)
- # endregion
-
- # Code Page 7: FolderHierarchy
- # region FolderHierarchy Code Page
- page = ASWBXMLCodePage()
- page.namespace = "FolderHierarchy:"
- page.xmlns = "folderhierarchy"
-
- page.addToken(0x07, "DisplayName")
- page.addToken(0x08, "ServerId")
- page.addToken(0x09, "ParentId")
- page.addToken(0x0A, "Type")
- page.addToken(0x0C, "Status")
- page.addToken(0x0E, "Changes")
- page.addToken(0x0F, "Add")
- page.addToken(0x10, "Delete")
- page.addToken(0x11, "Update")
- page.addToken(0x12, "SyncKey")
- page.addToken(0x13, "FolderCreate")
- page.addToken(0x14, "FolderDelete")
- page.addToken(0x15, "FolderUpdate")
- page.addToken(0x16, "FolderSync")
- page.addToken(0x17, "Count")
-
- self.codePages.append(page)
- # endregion
-
- # Code Page 8: MeetingResponse
- # region MeetingResponse Code Page
- page = ASWBXMLCodePage()
- page.namespace = "MeetingResponse:"
- page.xmlns = "meetingresponse"
-
- page.addToken(0x05, "CalendarId")
- page.addToken(0x06, "CollectionId")
- page.addToken(0x07, "MeetingResponse")
- page.addToken(0x08, "RequestId")
- page.addToken(0x09, "Request")
- page.addToken(0x0A, "Result")
- page.addToken(0x0B, "Status")
- page.addToken(0x0C, "UserResponse")
- page.addToken(0x0E, "InstanceId")
- self.codePages.append(page)
- # endregion
-
- # Code Page 9: Tasks
- # region Tasks Code Page
- page = ASWBXMLCodePage()
- page.namespace = "Tasks:"
- page.xmlns = "tasks"
-
- page.addToken(0x08, "Categories")
- page.addToken(0x09, "Category")
- page.addToken(0x0A, "Complete")
- page.addToken(0x0B, "DateCompleted")
- page.addToken(0x0C, "DueDate")
- page.addToken(0x0D, "UTCDueDate")
- page.addToken(0x0E, "Importance")
- page.addToken(0x0F, "Recurrence")
- page.addToken(0x10, "Recurrence_Type")
- page.addToken(0x11, "Recurrence_Start")
- page.addToken(0x12, "Recurrence_Until")
- page.addToken(0x13, "Recurrence_Occurrences")
- page.addToken(0x14, "Recurrence_Interval")
- page.addToken(0x15, "Recurrence_DayOfMonth")
- page.addToken(0x16, "Recurrence_DayOfWeek")
- page.addToken(0x17, "Recurrence_WeekOfMonth")
- page.addToken(0x18, "Recurrence_MonthOfYear")
- page.addToken(0x19, "Recurrence_Regenerate")
- page.addToken(0x1A, "Recurrence_DeadOccur")
- page.addToken(0x1B, "ReminderSet")
- page.addToken(0x1C, "ReminderTime")
- page.addToken(0x1D, "Sensitivity")
- page.addToken(0x1E, "StartDate")
- page.addToken(0x1F, "UTCStartDate")
- page.addToken(0x20, "Subject")
- page.addToken(0x22, "OrdinalDate")
- page.addToken(0x23, "SubOrdinalDate")
- page.addToken(0x24, "CalendarType")
- page.addToken(0x25, "IsLeapMonth")
- page.addToken(0x26, "FirstDayOfWeek")
- self.codePages.append(page)
- # endregion
-
- # Code Page 10: ResolveRecipients
- # region ResolveRecipients Code Page
- page = ASWBXMLCodePage()
- page.namespace = "ResolveRecipients:"
- page.xmlns = "resolverecipients"
-
- page.addToken(0x05, "ResolveRecipients")
- page.addToken(0x06, "Response")
- page.addToken(0x07, "Status")
- page.addToken(0x08, "Type")
- page.addToken(0x09, "Recipient")
- page.addToken(0x0A, "DisplayName")
- page.addToken(0x0B, "EmailAddress")
- page.addToken(0x0C, "Certificates")
- page.addToken(0x0D, "Certificate")
- page.addToken(0x0E, "MiniCertificate")
- page.addToken(0x0F, "Options")
- page.addToken(0x10, "To")
- page.addToken(0x11, "CertificateRetrieval")
- page.addToken(0x12, "RecipientCount")
- page.addToken(0x13, "MaxCertificates")
- page.addToken(0x14, "MaxAmbiguousRecipients")
- page.addToken(0x15, "CertificateCount")
- page.addToken(0x16, "Availability")
- page.addToken(0x17, "StartTime")
- page.addToken(0x18, "EndTime")
- page.addToken(0x19, "MergedFreeBusy")
- page.addToken(0x1A, "Picture")
- page.addToken(0x1B, "MaxSize")
- page.addToken(0x1C, "Data")
- page.addToken(0x1D, "MaxPictures")
- self.codePages.append(page)
- # endregion
-
- # Code Page 11: ValidateCert
- # region ValidateCert Code Page
- page = ASWBXMLCodePage()
- page.namespace = "ValidateCert:"
- page.xmlns = "validatecert"
-
- page.addToken(0x05, "ValidateCert")
- page.addToken(0x06, "Certificates")
- page.addToken(0x07, "Certificate")
- page.addToken(0x08, "CertificateChain")
- page.addToken(0x09, "CheckCRL")
- page.addToken(0x0A, "Status")
- self.codePages.append(page)
- # endregion
-
- # Code Page 12: Contacts2
- # region Contacts2 Code Page
- page = ASWBXMLCodePage()
- page.namespace = "Contacts2:"
- page.xmlns = "contacts2"
-
- page.addToken(0x05, "CustomerId")
- page.addToken(0x06, "GovernmentId")
- page.addToken(0x07, "IMAddress")
- page.addToken(0x08, "IMAddress2")
- page.addToken(0x09, "IMAddress3")
- page.addToken(0x0A, "ManagerName")
- page.addToken(0x0B, "CompanyMainPhone")
- page.addToken(0x0C, "AccountName")
- page.addToken(0x0D, "NickName")
- page.addToken(0x0E, "MMS")
- self.codePages.append(page)
- # endregion
-
- # Code Page 13: Ping
- # region Ping Code Page
- page = ASWBXMLCodePage()
- page.namespace = "Ping:"
- page.xmlns = "ping"
-
- page.addToken(0x05, "Ping")
- page.addToken(0x06, "AutdState") # Per MS-ASWBXML, this tag is not used by protocol
- page.addToken(0x07, "Status")
- page.addToken(0x08, "HeartbeatInterval")
- page.addToken(0x09, "Folders")
- page.addToken(0x0A, "Folder")
- page.addToken(0x0B, "Id")
- page.addToken(0x0C, "Class")
- page.addToken(0x0D, "MaxFolders")
- self.codePages.append(page)
- # endregion
-
- # Code Page 14: Provision
- # region Provision Code Page
- page = ASWBXMLCodePage()
- page.namespace = "Provision:"
- page.xmlns = "provision"
-
- page.addToken(0x05, "Provision")
- page.addToken(0x06, "Policies")
- page.addToken(0x07, "Policy")
- page.addToken(0x08, "PolicyType")
- page.addToken(0x09, "PolicyKey")
- page.addToken(0x0A, "Data")
- page.addToken(0x0B, "Status")
- page.addToken(0x0C, "RemoteWipe")
- page.addToken(0x0D, "EASProvisionDoc")
- page.addToken(0x0E, "DevicePasswordEnabled")
- page.addToken(0x0F, "AlphanumericDevicePasswordRequired")
- page.addToken(0x10, "RequireStorageCardEncryption")
- page.addToken(0x11, "PasswordRecoveryEnabled")
- page.addToken(0x13, "AttachmentsEnabled")
- page.addToken(0x14, "MinDevicePasswordLength")
- page.addToken(0x15, "MaxInactivityTimeDeviceLock")
- page.addToken(0x16, "MaxDevicePasswordFailedAttempts")
- page.addToken(0x17, "MaxAttachmentSize")
- page.addToken(0x18, "AllowSimpleDevicePassword")
- page.addToken(0x19, "DevicePasswordExpiration")
- page.addToken(0x1A, "DevicePasswordHistory")
- page.addToken(0x1B, "AllowStorageCard")
- page.addToken(0x1C, "AllowCamera")
- page.addToken(0x1D, "RequireDeviceEncryption")
- page.addToken(0x1E, "AllowUnsignedApplications")
- page.addToken(0x1F, "AllowUnsignedInstallationPackages")
- page.addToken(0x20, "MinDevicePasswordComplexCharacters")
- page.addToken(0x21, "AllowWiFi")
- page.addToken(0x22, "AllowTextMessaging")
- page.addToken(0x23, "AllowPOPIMAPEmail")
- page.addToken(0x24, "AllowBluetooth")
- page.addToken(0x25, "AllowIrDA")
- page.addToken(0x26, "RequireManualSyncWhenRoaming")
- page.addToken(0x27, "AllowDesktopSync")
- page.addToken(0x28, "MaxCalendarAgeFilter")
- page.addToken(0x29, "AllowHTMLEmail")
- page.addToken(0x2A, "MaxEmailAgeFilter")
- page.addToken(0x2B, "MaxEmailBodyTruncationSize")
- page.addToken(0x2C, "MaxEmailHTMLBodyTruncationSize")
- page.addToken(0x2D, "RequireSignedSMIMEMessages")
- page.addToken(0x2E, "RequireEncryptedSMIMEMessages")
- page.addToken(0x2F, "RequireSignedSMIMEAlgorithm")
- page.addToken(0x30, "RequireEncryptionSMIMEAlgorithm")
- page.addToken(0x31, "AllowSMIMEEncryptionAlgorithmNegotiation")
- page.addToken(0x32, "AllowSMIMESoftCerts")
- page.addToken(0x33, "AllowBrowser")
- page.addToken(0x34, "AllowConsumerEmail")
- page.addToken(0x35, "AllowRemoteDesktop")
- page.addToken(0x36, "AllowInternetSharing")
- page.addToken(0x37, "UnapprovedInROMApplicationList")
- page.addToken(0x38, "ApplicationName")
- page.addToken(0x39, "ApprovedApplicationList")
- page.addToken(0x3A, "Hash")
- self.codePages.append(page)
- # endregion
-
- # Code Page 15: Search
- # region Search Code Page
- page = ASWBXMLCodePage()
- page.namespace = "Search:"
- page.xmlns = "search"
-
- page.addToken(0x05, "Search")
- page.addToken(0x07, "Store")
- page.addToken(0x08, "Name")
- page.addToken(0x09, "Query")
- page.addToken(0x0A, "Options")
- page.addToken(0x0B, "Range")
- page.addToken(0x0C, "Status")
- page.addToken(0x0D, "Response")
- page.addToken(0x0E, "Result")
- page.addToken(0x0F, "Properties")
- page.addToken(0x10, "Total")
- page.addToken(0x11, "EqualTo")
- page.addToken(0x12, "Value")
- page.addToken(0x13, "And")
- page.addToken(0x14, "Or")
- page.addToken(0x15, "FreeText")
- page.addToken(0x17, "DeepTraversal")
- page.addToken(0x18, "LongId")
- page.addToken(0x19, "RebuildResults")
- page.addToken(0x1A, "LessThan")
- page.addToken(0x1B, "GreaterThan")
- page.addToken(0x1E, "UserName")
- page.addToken(0x1F, "Password")
- page.addToken(0x20, "ConversationId")
- page.addToken(0x21, "Picture")
- page.addToken(0x22, "MaxSize")
- page.addToken(0x23, "MaxPictures")
- self.codePages.append(page)
- # endregion
-
- # Code Page 16: GAL
- # region GAL Code Page
- page = ASWBXMLCodePage()
- page.namespace = "GAL:"
- page.xmlns = "gal"
-
- page.addToken(0x05, "DisplayName")
- page.addToken(0x06, "Phone")
- page.addToken(0x07, "Office")
- page.addToken(0x08, "Title")
- page.addToken(0x09, "Company")
- page.addToken(0x0A, "Alias")
- page.addToken(0x0B, "FirstName")
- page.addToken(0x0C, "LastName")
- page.addToken(0x0D, "HomePhone")
- page.addToken(0x0E, "MobilePhone")
- page.addToken(0x0F, "EmailAddress")
- page.addToken(0x10, "Picture")
- page.addToken(0x11, "Status")
- page.addToken(0x12, "Data")
- self.codePages.append(page)
- # endregion
-
- # Code Page 17: AirSyncBase
- # region AirSyncBase Code Page
- page = ASWBXMLCodePage()
- page.namespace = "AirSyncBase:"
- page.xmlns = "airsyncbase"
-
- page.addToken(0x05, "BodyPreference")
- page.addToken(0x06, "Type")
- page.addToken(0x07, "TruncationSize")
- page.addToken(0x08, "AllOrNone")
- page.addToken(0x0A, "Body")
- page.addToken(0x0B, "Data")
- page.addToken(0x0C, "EstimatedDataSize")
- page.addToken(0x0D, "Truncated")
- page.addToken(0x0E, "Attachments")
- page.addToken(0x0F, "Attachment")
- page.addToken(0x10, "DisplayName")
- page.addToken(0x11, "FileReference")
- page.addToken(0x12, "Method")
- page.addToken(0x13, "ContentId")
- page.addToken(0x14, "ContentLocation")
- page.addToken(0x15, "IsInline")
- page.addToken(0x16, "NativeBodyType")
- page.addToken(0x17, "ContentType")
- page.addToken(0x18, "Preview")
- page.addToken(0x19, "BodyPartPreference")
- page.addToken(0x1A, "BodyPart")
- page.addToken(0x1B, "Status")
- self.codePages.append(page)
- # endregion
-
- # Code Page 18: Settings
- # region Settings Code Page
- page = ASWBXMLCodePage()
- page.namespace = "Settings:"
- page.xmlns = "settings"
-
- page.addToken(0x05, "Settings")
- page.addToken(0x06, "Status")
- page.addToken(0x07, "Get")
- page.addToken(0x08, "Set")
- page.addToken(0x09, "Oof")
- page.addToken(0x0A, "OofState")
- page.addToken(0x0B, "StartTime")
- page.addToken(0x0C, "EndTime")
- page.addToken(0x0D, "OofMessage")
- page.addToken(0x0E, "AppliesToInternal")
- page.addToken(0x0F, "AppliesToExternalKnown")
- page.addToken(0x10, "AppliesToExternalUnknown")
- page.addToken(0x11, "Enabled")
- page.addToken(0x12, "ReplyMessage")
- page.addToken(0x13, "BodyType")
- page.addToken(0x14, "DevicePassword")
- page.addToken(0x15, "Password")
- page.addToken(0x16, "DeviceInformation")
- page.addToken(0x17, "Model")
- page.addToken(0x18, "IMEI")
- page.addToken(0x19, "FriendlyName")
- page.addToken(0x1A, "OS")
- page.addToken(0x1B, "OSLanguage")
- page.addToken(0x1C, "PhoneNumber")
- page.addToken(0x1D, "UserInformation")
- page.addToken(0x1E, "EmailAddresses")
- page.addToken(0x1F, "SmtpAddress")
- page.addToken(0x20, "UserAgent")
- page.addToken(0x21, "EnableOutboundSMS")
- page.addToken(0x22, "MobileOperator")
- page.addToken(0x23, "PrimarySmtpAddress")
- page.addToken(0x24, "Accounts")
- page.addToken(0x25, "Account")
- page.addToken(0x26, "AccountId")
- page.addToken(0x27, "AccountName")
- page.addToken(0x28, "UserDisplayName")
- page.addToken(0x29, "SendDisabled")
- page.addToken(0x2B, "RightsManagementInformation")
- self.codePages.append(page)
- # endregion
-
- # Code Page 19: DocumentLibrary
- # region DocumentLibrary Code Page
- page = ASWBXMLCodePage()
- page.namespace = "DocumentLibrary:"
- page.xmlns = "documentlibrary"
-
- page.addToken(0x05, "LinkId")
- page.addToken(0x06, "DisplayName")
- page.addToken(0x07, "IsFolder")
- page.addToken(0x08, "CreationDate")
- page.addToken(0x09, "LastModifiedDate")
- page.addToken(0x0A, "IsHidden")
- page.addToken(0x0B, "ContentLength")
- page.addToken(0x0C, "ContentType")
- self.codePages.append(page)
- # endregion
-
- # Code Page 20: ItemOperations
- # region ItemOperations Code Page
- page = ASWBXMLCodePage()
- page.namespace = "ItemOperations:"
- page.xmlns = "itemoperations"
-
- page.addToken(0x05, "ItemOperations")
- page.addToken(0x06, "Fetch")
- page.addToken(0x07, "Store")
- page.addToken(0x08, "Options")
- page.addToken(0x09, "Range")
- page.addToken(0x0A, "Total")
- page.addToken(0x0B, "Properties")
- page.addToken(0x0C, "Data")
- page.addToken(0x0D, "Status")
- page.addToken(0x0E, "Response")
- page.addToken(0x0F, "Version")
- page.addToken(0x10, "Schema")
- page.addToken(0x11, "Part")
- page.addToken(0x12, "EmptyFolderContents")
- page.addToken(0x13, "DeleteSubFolders")
- page.addToken(0x14, "UserName")
- page.addToken(0x15, "Password")
- page.addToken(0x16, "Move")
- page.addToken(0x17, "DstFldId")
- page.addToken(0x18, "ConversationId")
- page.addToken(0x19, "MoveAlways")
- self.codePages.append(page)
- # endregion
-
- # Code Page 21: ComposeMail
- # region ComposeMail Code Page
- page = ASWBXMLCodePage()
- page.namespace = "ComposeMail:"
- page.xmlns = "composemail"
-
- page.addToken(0x05, "SendMail")
- page.addToken(0x06, "SmartForward")
- page.addToken(0x07, "SmartReply")
- page.addToken(0x08, "SaveInSentItems")
- page.addToken(0x09, "ReplaceMime")
- page.addToken(0x0B, "Source")
- page.addToken(0x0C, "FolderId")
- page.addToken(0x0D, "ItemId")
- page.addToken(0x0E, "LongId")
- page.addToken(0x0F, "InstanceId")
- page.addToken(0x10, "MIME")
- page.addToken(0x11, "ClientId")
- page.addToken(0x12, "Status")
- page.addToken(0x13, "AccountId")
- self.codePages.append(page)
- # endregion
-
- # Code Page 22: Email2
- # region Email2 Code Page
- page = ASWBXMLCodePage()
- page.namespace = "Email2:"
- page.xmlns = "email2"
-
- page.addToken(0x05, "UmCallerID")
- page.addToken(0x06, "UmUserNotes")
- page.addToken(0x07, "UmAttDuration")
- page.addToken(0x08, "UmAttOrder")
- page.addToken(0x09, "ConversationId")
- page.addToken(0x0A, "ConversationIndex")
- page.addToken(0x0B, "LastVerbExecuted")
- page.addToken(0x0C, "LastVerbExecutionTime")
- page.addToken(0x0D, "ReceivedAsBcc")
- page.addToken(0x0E, "Sender")
- page.addToken(0x0F, "CalendarType")
- page.addToken(0x10, "IsLeapMonth")
- page.addToken(0x11, "AccountId")
- page.addToken(0x12, "FirstDayOfWeek")
- page.addToken(0x13, "MeetingMessageType")
- self.codePages.append(page)
- # endregion
-
- # Code Page 23: Notes
- # region Notes Code Page
- page = ASWBXMLCodePage()
- page.namespace = "Notes:"
- page.xmlns = "notes"
-
- page.addToken(0x05, "Subject")
- page.addToken(0x06, "MessageClass")
- page.addToken(0x07, "LastModifiedDate")
- page.addToken(0x08, "Categories")
- page.addToken(0x09, "Category")
- self.codePages.append(page)
- # endregion
-
- # Code Page 24: RightsManagement
- # region RightsManagement Code Page
- page = ASWBXMLCodePage()
- page.namespace = "RightsManagement:"
- page.xmlns = "rightsmanagement"
-
- page.addToken(0x05, "RightsManagementSupport")
- page.addToken(0x06, "RightsManagementTemplates")
- page.addToken(0x07, "RightsManagementTemplate")
- page.addToken(0x08, "RightsManagementLicense")
- page.addToken(0x09, "EditAllowed")
- page.addToken(0x0A, "ReplyAllowed")
- page.addToken(0x0B, "ReplyAllAllowed")
- page.addToken(0x0C, "ForwardAllowed")
- page.addToken(0x0D, "ModifyRecipientsAllowed")
- page.addToken(0x0E, "ExtractAllowed")
- page.addToken(0x0F, "PrintAllowed")
- page.addToken(0x10, "ExportAllowed")
- page.addToken(0x11, "ProgrammaticAccessAllowed")
- page.addToken(0x12, "RMOwner")
- page.addToken(0x13, "ContentExpiryDate")
- page.addToken(0x14, "TemplateID")
- page.addToken(0x15, "TemplateName")
- page.addToken(0x16, "TemplateDescription")
- page.addToken(0x17, "ContentOwner")
- page.addToken(0x18, "RemoveRightsManagementDistribution")
- self.codePages.append(page)
- # endregion
- # endregion
-
- def loadXml(self, strXML):
- # note xmlDoc has .childNodes and .parentNode
- self.xmlDoc = xml.dom.minidom.parseString(strXML)
-
- def getXml(self):
- if (self.xmlDoc != None):
- try:
- return self.xmlDoc.toprettyxml(indent=" ", newl="\n")
- except:
- return self.xmlDoc.toxml()
-
- def loadBytes(self, byteWBXML):
-
- currentNode = self.xmlDoc
-
- wbXMLBytes = ASWBXMLByteQueue(byteWBXML)
- # Version is ignored
- version = wbXMLBytes.dequeueAndLog()
-
- # Public Identifier is ignored
- publicId = wbXMLBytes.dequeueMultibyteInt()
-
- logging.debug("Version: %d, Public Identifier: %d" % (version, publicId))
-
- # Character set
- # Currently only UTF-8 is supported, throw if something else
- charset = wbXMLBytes.dequeueMultibyteInt()
- if (charset != 0x6A):
- raise InvalidDataException("ASWBXML only supports UTF-8 encoded XML.")
-
- # String table length
- # This should be 0, MS-ASWBXML does not use string tables
- stringTableLength = wbXMLBytes.dequeueMultibyteInt()
- if (stringTableLength != 0):
- raise InvalidDataException("WBXML data contains a string table.")
-
- # Now we should be at the body of the data.
- # Add the declaration
- unusedArray = [GlobalTokens.ENTITY, GlobalTokens.EXT_0, GlobalTokens.EXT_1, GlobalTokens.EXT_2, GlobalTokens.EXT_I_0, GlobalTokens.EXT_I_1, GlobalTokens.EXT_I_2, GlobalTokens.EXT_T_0, GlobalTokens.EXT_T_1, GlobalTokens.EXT_T_2, GlobalTokens.LITERAL, GlobalTokens.LITERAL_A, GlobalTokens.LITERAL_AC, GlobalTokens.LITERAL_C, GlobalTokens.PI, GlobalTokens.STR_T]
-
- while ( wbXMLBytes.qsize() > 0):
- currentByte = wbXMLBytes.dequeueAndLog()
- if ( currentByte == GlobalTokens.SWITCH_PAGE ):
- newCodePage = wbXMLBytes.dequeueAndLog()
- if (newCodePage >= 0 and newCodePage < 25):
- self.currentCodePage = newCodePage
- else:
- raise InvalidDataException("Unknown code page ID 0x{0:X} encountered in WBXML".format(currentByte))
- elif ( currentByte == GlobalTokens.END ):
- if (currentNode != None and currentNode.parentNode != None):
- currentNode = currentNode.parentNode
- else:
- raise InvalidDataException("END global token encountered out of sequence")
- break
- elif ( currentByte == GlobalTokens.OPAQUE ):
- CDATALength = wbXMLBytes.dequeueMultibyteInt()
- newOpaqueNode = self.xmlDoc.createCDATASection(wbXMLBytes.dequeueString(CDATALength))
- currentNode.appendChild(newOpaqueNode)
-
- elif ( currentByte == GlobalTokens.STR_I ):
- newTextNode = self.xmlDoc.createTextNode(wbXMLBytes.dequeueString())
- currentNode.appendChild(newTextNode)
-
- elif ( currentByte in unusedArray):
- raise InvalidDataException("Encountered unknown global token 0x{0:X}.".format(currentByte))
- else:
- hasAttributes = (currentByte & 0x80) > 0
- hasContent = (currentByte & 0x40) > 0
-
- token = currentByte & 0x3F
- if (hasAttributes):
- raise InvalidDataException("Token 0x{0:X} has attributes.".format(token))
-
- strTag = self.codePages[self.currentCodePage].getTag(token)
- if (strTag == None):
- strTag = "UNKNOWN_TAG_{0,2:X}".format(token)
-
- newNode = self.xmlDoc.createElement(strTag)
- # not sure if this should be set on every node or not
- #newNode.setAttribute("xmlns", self.codePages[self.currentCodePage].xmlns)
-
- currentNode.appendChild(newNode)
-
- if (hasContent):
- currentNode = newNode
-
- logging.debug("Total bytes dequeued: %d" % wbXMLBytes.bytesDequeued)
diff --git a/libmproxy/contrib/wbxml/ASWBXMLByteQueue.py b/libmproxy/contrib/wbxml/ASWBXMLByteQueue.py
deleted file mode 100644
index c7a9e0a5..00000000
--- a/libmproxy/contrib/wbxml/ASWBXMLByteQueue.py
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/usr/bin/env python
-'''
-@author: David Shaw, david.shaw.aw@gmail.com
-
-Inspired by EAS Inspector for Fiddler
-https://easinspectorforfiddler.codeplex.com
-
------ The MIT License (MIT) -----
-Filename: ASWBXMLByteQueue.py
-Copyright (c) 2014, David P. Shaw
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-'''
-from Queue import Queue
-import logging
-
-class ASWBXMLByteQueue(Queue):
-
- def __init__(self, wbxmlBytes):
-
- self.bytesDequeued = 0
- self.bytesEnqueued = 0
-
- Queue.__init__(self)
-
- for byte in wbxmlBytes:
- self.put(ord(byte))
- self.bytesEnqueued += 1
-
-
- logging.debug("Array byte count: %d, enqueued: %d" % (self.qsize(), self.bytesEnqueued))
-
- """
- Created to debug the dequeueing of bytes
- """
- def dequeueAndLog(self):
- singleByte = self.get()
- self.bytesDequeued += 1
- logging.debug("Dequeued byte 0x{0:X} ({1} total)".format(singleByte, self.bytesDequeued))
- return singleByte
-
- """
- Return true if the continuation bit is set in the byte
- """
- def checkContinuationBit(self, byteval):
- continuationBitmask = 0x80
- return (continuationBitmask & byteval) != 0
-
- def dequeueMultibyteInt(self):
- iReturn = 0
- singleByte = 0xFF
-
- while True:
- iReturn <<= 7
- if (self.qsize() == 0):
- break
- else:
- singleByte = self.dequeueAndLog()
- iReturn += int(singleByte & 0x7F)
- if not self.checkContinuationBit(singleByte):
- return iReturn
-
- def dequeueString(self, length=None):
- if ( length != None):
- currentByte = 0x00
- strReturn = ""
- for i in range(0, length):
- # TODO: Improve this handling. We are technically UTF-8, meaning
- # that characters could be more than one byte long. This will fail if we have
- # characters outside of the US-ASCII range
- if ( self.qsize() == 0 ):
- break
- currentByte = self.dequeueAndLog()
- strReturn += chr(currentByte)
-
- else:
- currentByte = 0x00
- strReturn = ""
- while True:
- currentByte = self.dequeueAndLog()
- if (currentByte != 0x00):
- strReturn += chr(currentByte)
- else:
- break
-
- return strReturn
-
diff --git a/libmproxy/contrib/wbxml/ASWBXMLCodePage.py b/libmproxy/contrib/wbxml/ASWBXMLCodePage.py
deleted file mode 100644
index 2f9d8717..00000000
--- a/libmproxy/contrib/wbxml/ASWBXMLCodePage.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/env python
-'''
-@author: David Shaw, david.shaw.aw@gmail.com
-
-Inspired by EAS Inspector for Fiddler
-https://easinspectorforfiddler.codeplex.com
-
------ The MIT License (MIT) -----
-Filename: ASWBXMLCodePage.py
-Copyright (c) 2014, David P. Shaw
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-'''
-class ASWBXMLCodePage:
- def __init__(self):
- self.namespace = ""
- self.xmlns = ""
- self.tokenLookup = {}
- self.tagLookup = {}
-
- def addToken(self, token, tag):
- self.tokenLookup[token] = tag
- self.tagLookup[tag] = token
-
- def getToken(self, tag):
- if self.tagLookup.has_key(tag):
- return self.tagLookup[tag]
- return 0xFF
-
- def getTag(self, token):
- if self.tokenLookup.has_key(token):
- return self.tokenLookup[token]
- return None
-
- def __repr__(self):
- return str(self.tokenLookup) \ No newline at end of file
diff --git a/libmproxy/contrib/wbxml/GlobalTokens.py b/libmproxy/contrib/wbxml/GlobalTokens.py
deleted file mode 100644
index 41310fb1..00000000
--- a/libmproxy/contrib/wbxml/GlobalTokens.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env python
-'''
-@author: David Shaw, david.shaw.aw@gmail.com
-
-Inspired by EAS Inspector for Fiddler
-https://easinspectorforfiddler.codeplex.com
-
------ The MIT License (MIT) -----
-Filename: GlobalTokens.py
-Copyright (c) 2014, David P. Shaw
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-'''
-class GlobalTokens:
- SWITCH_PAGE = 0x00
- END = 0x01
- ENTITY = 0x02
- STR_I = 0x03
- LITERAL = 0x04
- EXT_I_0 = 0x40
- EXT_I_1 = 0x41
- EXT_I_2 = 0x42
- PI = 0x43
- LITERAL_C = 0x44
- EXT_T_0 = 0x80
- EXT_T_1 = 0x81
- EXT_T_2 = 0x82
- STR_T = 0x83
- LITERAL_A = 0x84
- EXT_0 = 0xC0
- EXT_1 = 0xC1
- EXT_2 = 0xC2
- OPAQUE = 0xC3
- LITERAL_AC = 0xC4 \ No newline at end of file
diff --git a/libmproxy/contrib/wbxml/InvalidDataException.py b/libmproxy/contrib/wbxml/InvalidDataException.py
deleted file mode 100644
index 67f8ea93..00000000
--- a/libmproxy/contrib/wbxml/InvalidDataException.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/env python
-'''
-@author: David Shaw, david.shaw.aw@gmail.com
-
-Inspired by EAS Inspector for Fiddler
-https://easinspectorforfiddler.codeplex.com
-
------ The MIT License (MIT) -----
-Filename: InvalidDataException.py
-Copyright (c) 2014, David P. Shaw
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-'''
-class InvalidDataException(Exception):
- pass \ No newline at end of file
diff --git a/libmproxy/contrib/wbxml/__init__.py b/libmproxy/contrib/wbxml/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/libmproxy/contrib/wbxml/__init__.py
+++ /dev/null