• Stars
    star
    239
  • Rank 168,763 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

One-stop TLS traffic inspection and manipulation using dynamic instrumentation

hallucinate

Author: Moritz Bechler [email protected]
Project Repository: https://github.com/SySS-Research/hallucinate
License: MIT

Originally inspired by Echo Mirage Intercept clear-text TLS network traffic by instrumenting the target process. Binary instrumentation based on Frida, Java integration on a custom agent.

Intercepted traffic can be:

  • logged, also in PCAP format for convenient protocol analysis
  • edited interactively or programmatically using external tools
  • analyzed/modified using python scripts

Supported Libraries/APIs:

  • Native network IO (POSIX/BSD/Winsock) - disabled by default
  • OpenSSL
  • GnuTLS
  • SChannel
  • low-level Windows NCrypt APIs (SslEncryptPacket/SslDecryptPacket) - disabled by default
  • Java JSSE
  • NSS

Ideas for future integration:

  • Java +BouncyCastle, RSA
  • BoringSSL
  • Mobile Platforms: Android, iOS

BUILD/INSTALL

Using setuptools

#> python setup.py install

Java/Maven is required to build the Java Agent JAR file required to attach to Java Applications. It is recommended to choose the oldest targeted Java version SDK. The Java Agent may also be version dependent and should be built with a JDK version similar to the targeted applications JVM.

USAGE

usage: hallucinate [-h] [--verbose] [--process PROCESS] [--disable DISABLE]
                   [--enable ENABLE] [--dump-script DUMPSCRIPT]
                   [--mapfile MAPFILE] [--force-replace-buffer] [--log]
                   [--pcap PCAP] [--editor EDITOR] [--script SCRIPT]
                   [--java-vm JAVAVM] [--agent-jar AGENTJAR]
                   [--inject-agent-startup] [--java-server-host JAVAAGENTHOST]
                   [--java-server-port JAVAAGENTPORT]
                   [--java-server-key JAVAAGENTKEY]
                   [cmd [cmd ...]]

Instrument processes to intercept (encrypted) network communication

positional arguments:
  cmd                   Command to execute

optional arguments:
  -h, --help            show this help message and exit
  --verbose, -v
  --process PROCESS, -p PROCESS
                        Attach to existing process (by name or PID)
  --disable DISABLE, -d DISABLE
                        Disable default module (gnutls.js, java.js, nss.js,
                        openssl.js, schannel.js)
  --enable ENABLE, -e ENABLE
                        Enable optional module (raw.js, ncrypt.js)
  --dump-script DUMPSCRIPT
                        Dump complete frida script to file for debugging
  --mapfile MAPFILE     JSON configuration to manually override library names
                        and function addresses
  --force-replace-buffer
                        Replace application buffers, even if this likely
                        breaks the application (SChannel only)

handlers:
  Options for processing the intercepted traffic

  --log                 Log clear-text packet data
  --pcap PCAP           Write clear-text communication to a dump file in PCAP
                        format
  --editor EDITOR       Specify a system command to edit individual packet
                        data,{in} and {out} are replaced with temporary
                        files,if only {in} is specified in-place editing is
                        expected
  --script SCRIPT       Python script to load, functions recv/send(data,props)
                        will be called

java:
  Options relating to the Java agent, re(attaching) to a Java process
  multiple times is unreliable

  --java-vm JAVAVM      Java binary to use when injecting the agent. This
                        should match the target application's Java version
  --agent-jar AGENTJAR  Override agent JAR file to inject (typically bundled
                        with hallucinate)
  --inject-agent-startup
                        Inject Java agent via VM argument. Not usable when
                        attaching to a running process
  --java-server-host JAVAAGENTHOST
                        Bind address for Java agent server
  --java-server-port JAVAAGENTPORT
                        Port for Java agent server (random by default)
  --java-server-key JAVAAGENTKEY
                        Secret authentication key for Java agent server
                        connection (random by default)

Usage Examples

Launch the target process through the script

#> hallucinate  --log -- /usr/bin/curl -k https://localhost

Different options for logging, interactive or automated modification of the intercepted traffic are available, see the application help.

For example the clear-text HTTP request/response of a CURL call could be modified in an editor of your choice:

#> hallucinate --disable raw.js  --editor '/usr/bin/gedit {in}' -- /usr/bin/curl -k https://localhost

Or, attach to a running process by specify it's PID, or, if unique, process name

#> hallucinate --log -p <pid|procname>

Java Usage

Java processes are automatically detected by hallucinate when attaching. However, as an agent is injected into these processes and no reloading is supported, (re-)attaching multiple times to the same process is unreliable (there may be room for future improvement). Also, make sure to specify a Java runtime version compatible with the target application as --java-vm.

An alternative is to inject the agent during VM startup by specifying the full Java command line for the target program, e.g. java -cp myjar.jar my.Application as the command to run and the --inject-agent-startup option. This automatically adds the necessary agent parameters to the VM invocation.

Scripting

hallucinate allows python scripting to process/analyze/modify the intercepted traffic. A python script can be specified using the --script parameter. From this file the functions send and recv will be called on each intercepted send/recv. If these functions return data the sent/received data is be replaced, otherwise it passes as-is.

Example: test.py

def send(data,p):
    if b'HTTP/1.1' in data:
        print("Replacing HTTP version")
        return data.replace(b'HTTP/1.1', b'HTTP/1.0')
    print("Not touching: " + repr(data))

def recv(data,p):
    print("Not touching: " + repr(data))
#> hallucinate -d raw.js --script test.py -- /usr/bin/curl -s -o /dev/null -k https://localhost
INFO:root:Starting ['/usr/bin/curl', '-s', '-o', '/dev/null', '-k', 'https://localhost']
INFO:root:Injected script, resuming execution of 22096
Replacing HTTP version
Not touching: b'HTTP/1.1 200 OK

Mapfile

A mapfile can be used to manually override the hooked target module and function addresses, e.g. statically linked library copies. It is a JSON formatted nested dictionary, lookup is based on the module name on the first nesting level, function name on the second. The special name @lib can be used to specify/override the target module name.

Example: test.json

{
        "openssl":{
                "@lib" : "test.so",
                "SSL_read_ex" : "0x24235235"
        }
}

KNOWN LIMITATIONS

  • Receive calls generally must use the application allocated buffers, therefore modified data cannot exceed the length of the buffers provided by the application.
  • The same is true for SChannel send calls, therefore the length is limited in this case as well. The option --force-replace-buffer to replace the buffers nevertheless is provided, but must be expected to break most applications.
  • Statically linked (without symbols)/inlined library instances won't be detected, hooking may be possible using manually identified function addresses and a mapfile.
  • No connection/address information is available for SChannel
  • Hooking of calls in runtime loaded libraries may not be working properly (room for future improvement?)
  • Hooking may not cover all relevant APIs of the respective libraries (let me know)
  • Attaching to processes may be limited on Linux, either launch the target process as a child or set sys.kernel.yama.ptrace_scope=0

More Repositories

1

Seth

Perform a MitM attack and extract clear text credentials from RDP connections
Python
1,390
star
2

WireBug

WireBug is a toolset for Voice-over-IP penetration testing
Python
170
star
3

smbcrawler

smbcrawler is no-nonsense tool that takes credentials and a list of hosts and 'crawls' (or 'spiders') through those shares
Python
143
star
4

outis

outis is a custom Remote Administration Tool (RAT) or something like that. It was build to support various transport methods (like DNS) and platforms (like Powershell).
Python
123
star
5

hashcathelper

Convenience tool for hashcat
Python
109
star
6

dns-mitm

A minimal DNS service that can provide spoofed replies
Python
98
star
7

clone-cert

Simple shell script to "clone" X.509 certificates
Shell
97
star
8

nrf24-playset

Software tools for Nordic Semiconductor nRF24-based devices like wireless keyboards, mice, and presenters
Python
89
star
9

radio-hackbox

PoC tool to demonstrate vulnerabilities in wireless input devices
Python
85
star
10

azurenum

Enumerate Microsoft Entra ID (Azure AD) fast
Python
85
star
11

icestick-lpc-tpm-sniffer

FPGA-based LPC bus sniffing tool for Lattice iCEstick Evaluation Kit
Verilog
75
star
12

nand-dump-tools

Simple software tools for encoding and decoding dumps of NAND memory chips using implemented error correcting codes (ECC)
Python
75
star
13

icestick-glitcher

Simple voltage glitcher implementation for the Lattice iCEstick Evaluation Kit
Verilog
55
star
14

MAT

This tool, programmed in C#, allows for the fast discovery and exploitation of vulnerabilities in MSSQL servers
C#
54
star
15

bluetooth-keyboard-emulator

Simple proof-of-concept software tool for emulating Bluetooth BR/EDR (a.k.a. Bluetooth Classic) keyboards
Python
52
star
16

ldap-swak

LDAP Swiss Army Knife
Java
43
star
17

slig

Siemens LOGO!8 PLC Password Hacking Proof-of-Concept-Tool
Lua
41
star
18

ldif2bloodhound

Convert an LDIF file to JSON files ingestible by BloodHound
Python
38
star
19

Lauschgeraet

Gets in the way of your victim's traffic and out of yours
Python
27
star
20

netns.sh

A simple script to make network namespaces more usable
Shell
20
star
21

icebreaker-glitcher

Simple voltage glitcher implementation for the iCEBreaker FPGA board
Verilog
13
star
22

biometricks

Fun with biometrics
C#
8
star
23

burp-extender-json-api

A Burp extension that provides an API to build other extensions in any programming language
Java
7
star
24

Single-User-BloodHound

Run BloodHound CE in a single-user setup with podman
Shell
7
star
25

radio-hackbox2

PoC tool to demonstrate vulnerabilities in wireless input devices
Python
5
star
26

protectimus-slim-proxmark3

Proxmark3 Lua script for attacking vulnerable Protectimus SLIM NFC TOTP hardware tokens
Lua
4
star
27

syss-crc

Simple Python CRC implementation for playing around with cyclic redundancy checks
Python
4
star
28

logic2-atecc508-extension

Logic 2 High Level Protocol Analyzer for the Microchip ATECC508A I2C communication with support for I2C encryption
Python
3
star
29

invoke-lsaparse

PowerShell implementation for parsing LSA (Local Security Authority) process memory dumps
PowerShell
1
star