Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/mitmproxy/contentviews/__init__.py b/mitmproxy/contentviews/__init__.py
index f5c31eef..72ad44a8 100644
--- a/mitmproxy/contentviews/__init__.py
+++ b/mitmproxy/contentviews/__init__.py
@@ -22,7 +22,7 @@ from mitmproxy.net import http
from mitmproxy.utils import strutils
from . import (
auto, raw, hex, json, xml_html, wbxml, javascript, css,
- urlencoded, multipart, image, query, protobuf
+ urlencoded, multipart, image, query, protobuf, wasm
)
from .base import View, KEY_MAX, format_text, format_dict, TViewResult
@@ -175,6 +175,7 @@ add(multipart.ViewMultipart())
add(image.ViewImage())
add(query.ViewQuery())
add(protobuf.ViewProtobuf())
+add(wasm.ViewWASM())
__all__ = [
"View", "KEY_MAX", "format_text", "format_dict", "TViewResult",
diff --git a/mitmproxy/contentviews/wasm.py b/mitmproxy/contentviews/wasm.py
new file mode 100644
index 00000000..e8f21a0e
--- /dev/null
+++ b/mitmproxy/contentviews/wasm.py
@@ -0,0 +1,20 @@
+from . import base
+import wasamole
+
+class ViewWASM(base.View):
+ """Human friendly view of WebAssembly
+ The view uses the protoc compiler to decode the binary
+ """
+
+ name = "WASM"
+ content_types = [
+ "application/wasm",
+ ]
+
+ def __call__(self, data, **metadata):
+ try:
+ module = wasamole.io.from_bytes(data)
+ except Exception:
+ raise ValueError("Failed to parse input.")
+
+ return "WASM", base.format_text(wasamole.io.to_text_string(module))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment