M. Donald MacLaren

13 papers Journal 10Unranked 3
YearRankTypeTitle / Venue / Authors
1984 conf
SIGPLAN Symposium on Compiler Construction
M. Donald MacLaren
1977 conf
Language Design for Reliable Software
M. Donald MacLaren
1973 conf
SIGPLAN-SIGOPS Interface Meeting
M. Donald MacLaren
1970 J jnl
ACM SIGPLAN Notices
M. Donald MacLaren
1970 J jnl
ACM SIGPLAN Notices
M. Donald MacLaren
1969 J jnl
ACM SIGPLAN Notices
M. Donald MacLaren
1968 J jnl
Commun. ACM
M. Donald MacLaren
1967 J jnl
Commun. ACM
M. Donald MacLaren
1966 J jnl
J. ACM
M. Donald MacLaren
1965 J jnl
Commun. ACM
M. Donald MacLaren
1965 J jnl
J. ACM
M. Donald MacLaren, George Marsaglia
1964 J jnl
Commun. ACM
M. Donald MacLaren, George Marsaglia, T. A. Bray
1964 J jnl
Commun. ACM
George Marsaglia, M. Donald MacLaren, T. A. Bray
redb/extractors/decompiler/bninja/analysis/strings.py
← Index redb/extractors/decompiler/bninja/analysis/strings.py python
from collections import Counter
import math

class StringAnalysis:
    def __init__(self, bv, functions):
        self.bv = bv
        self.functions = functions

    def entropy(self, s: str) -> float:
        """Compute Shannon entropy of a string."""
        if not s:
            return 0.0
        freq = Counter(s)
        length = len(s)
        return -sum((count / length) * math.log2(count / length) for count in freq.values())

    def analyze(self):
        """
        Extract unique strings from the binary.

        Deduplicates by (string, encoding) within the same binary, keeping the
        first occurrence (lowest offset). Cross-binary deduplication and
        aggregation is handled by ClickHouse materialized views.
        """
        strings = {}

        # Sort strings by their starting address
        sorted_entries = sorted(self.bv.strings, key=lambda e: e.start)

        for entry in sorted_entries:
            # Key is the string and its encoding
            key = (entry.value, entry.type.name)

            # Skip if this string (value + encoding) was already added.
            # Because entries are sorted by address, the first one is always kept.
            if key in strings:
                continue

            # Store only the first occurrence with schema-matching field names
            # entry.length is the raw byte length, len(entry.value) is decoded string length
            string_entry = {
                "string": entry.value,
                "string_raw": entry.raw,
                "string_encoding": entry.type.name,
                "string_offset": entry.start,
                "string_length": len(entry.value),
                "string_raw_length": entry.length,
                "string_entropy": self.entropy(entry.value),
            }

            strings[key] = string_entry

        # Return as list for export compatibility
        return list(strings.values())