friTap


NamefriTap JSON
Version 1.2.3.0 PyPI version JSON
download
home_pagehttps://github.com/fkie-cad/friTap
SummaryDecrypts and logs a process's SSL/TLS traffic on all major platforms. Further it allows the TLS key extraction.
upload_time2024-10-30 14:52:47
maintainerNone
docs_urlNone
authorDaniel Baier, Francois Egner, Max Ufer
requires_python>=3.6
licenseGPL v3
keywords mobile instrumentation frida hook ssl decryption
VCS
bugtrack_url
requirements frida frida-tools AndroidFridaManager hexdump scapy watchdog click importlib-resources
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
    <img src="https://raw.githubusercontent.com/fkie-cad/friTap/main/assets/logo.png" alt="friTap logo" width="50%" height="50%"/>
</p>

# friTap
![version](https://img.shields.io/badge/version-1.2.3.0-blue) [![PyPI version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=py&r=r&ts=1683906897&type=6e&v=1.2.3.0&x2=0)](https://badge.fury.io/py/friTap)

The goal of this project is to help researchers to analyze traffic encapsulated in SSL or TLS. For details have a view into the [OSDFCon webinar slides](assets/friTapOSDFConwebinar.pdf) or in [this blog post](https://lolcads.github.io/posts/2022/08/fritap/).


This project was inspired by [SSL_Logger](https://github.com/google/ssl_logger ) and currently supports all major operating systems (Linux, Windows, Android). More platforms and libraries will be added in future releases.

## Installation


Installation is simply a matter of `pip3 install fritap`. This will give you the `friTap` command. You can update an existing `friTap` installation with `pip3 install --upgrade friTap`.

Alternatively just clone the repository and run the `friTap.py` file.


## Usage

On Linux/Windows/MacOS we can easily attach to a process by entering its name or its PID:

```bash
$ sudo fritap --pcap mycapture.pcap thunderbird
```

For mobile applications we just have to add the `-m` parameter to indicate that we are now attaching (or spawning) an Android or iOS app:

```bash
$ fritap -m --pcap mycapture.pcap com.example.app
```

Further ensure that the frida-server is running on the Android/iOS device. 


Remember when working with the pip installation you have to invoke the `friTap` command with sudo a little bit different. Either as module:
```bash
$ sudo -E python3 -m friTap.friTap --pcap mycapture.pcap thunderbird
```
or directly invoking the script:
```bash
$ which friTap
/home/daniel/.local/bin/friTap

$ sudo -E /home/daniel/.local/bin/friTap
```



More examples on using friTap can be found in the [USAGE.md](./USAGE.md). A detailed introduction using friTap on Android is under [EXAMPLE.md](./EXAMPLE.md) as well.

## Hooking Libraries Without Symbols

In certain scenarios, the library we want to hook offers no symbols or is statically linked with other libraries, making it challenging to directly hook functions. For example Cronet (`libcronet.so`) and Flutter (`libflutter.so`) are often statically linked with **BoringSSL**.

Despite the absence of symbols, we can still use friTap for parsing and hooking.

### Hooking by Byte Patterns

To solve this, we can use friTap with byte patterns to hook the desired functions. You can provide friTap with a JSON file that contains byte patterns for hooking specific functions, based on architecture and platform using the `--patterns <byte-pattern-file.json>` option.
In order to apply the apprioate hooks for the various byte patterns we distinguish between different hooking categories.
These categories include:

  -  Dump-Keys
  -  Install-Key-Log-Callback
  -  KeyLogCallback-Function
  -  SSL_Read
  -  SSL_Write

Each category has a primary and fallback byte pattern, allowing flexibility when the primary pattern fails.
For libraries like BoringSSL, where TLS functionality is often statically linked into other binaries, we developed a tool called [BoringSecretHunter](https://github.com/monkeywave/BoringSecretHunter). This tool automatically identifies the necessary byte patterns to hook BoringSSL by byte-pattern matching. Specifically, BoringSecretHunter focuses on identifying the byte patterns for functions in the Dump-Keys category, allowing you to extract encryption keys during TLS sessions with minimal effort. More about the different hooking categories can be found in [usage of byte-patterns in friTap](./USAGE.md#hooking-by-byte-patterns).

### Hooking by Offsets

Alternatively, you can use the `--offsets <offset-file.json>` option to hook functions using known offsets. friTap allows you to specify user-defined offsets (relative to the base address of the targeting SSL/socket library) or absolute virtual addresses for function resolution. This is done through a JSON file, which is passed using the `--offsets` parameter.

If the `--offsets` parameter is used, friTap will only overwrite the function addresses specified in the JSON file. For functions that are not specified, friTap will attempt to detect the addresses automatically (using symbols).


## Problems

The absence of traffic or incomplete traffic capture in the resulting pcap file (-p <your.pcap>) may stem from various causes. Before submitting a new issue, consider attempting the following solutions:

### Default Socket Information

There might be instances where friTap fails to retrieve socket information. In such scenarios, running friTap with default socket information (`--enable_default_fd`) could resolve the issue. This approach utilizes default socket information (127.0.0.1:1234 to 127.0.0.1:2345) for all traffic when the file descriptor (FD) cannot be used to obtain socket details:

```bash
fritap -m --enable_default_fd -p plaintext.pcap com.example.app
```

### Handling Subprocess Traffic

Traffic originating from a subprocess could be another contributing factor. To capture this traffic, friTap can leverage Frida's spawn gating feature, which intercepts newly spawned processes using the `--enable_spawn_gating` parameter:

```bash
fritap -m -p log.pcap --enable_spawn_gating com.example.app
```

### Library Support exist only for Key Extraction

In cases where the target library solely supports key extraction (cf. the table below), you can utilize the `-k <key.log>` parameter alongside full packet capture:

```bash
fritap -m -p log.pcap --full_capture -k keys.log com.example.app
```

### Seeking Further Assistance

If these approaches do not address your issue, please create a detailed issue report to aid in troubleshooting. To facilitate a more effective diagnosis, include the following information in your report:

- The operating system and its version
- The specific application encountering the issue or a comparable application that exhibits similar problems
- The output from executing friTap with the specified parameters, augmented with friTap's debug output:
```bash
fritap -do -v com.example.app
```


## Supported SSL/TLS implementations and corresponding logging capabilities

```markdown
| Library                   | Linux         | Windows       | MacOSX   | Android  | iOS          |
|---------------------------|---------------|---------------|----------|----------|--------------|
| OpenSSL                   |     Full      | R/W-Hook only |  TBI     |   Full   | TBI          |
| BoringSSL                 |     Full      | R/W-Hook only |  KeyEo   |   Full   | KeyEo        |
| NSS                       |     Full      | R/W-Hook only |  TBI     |   TBA    | TBI          |
| GnuTLS                    | R/W-Hook only | R/W-Hook only |  TBI     |   Full   | TBI          |
| WolfSSL                   | R/W-Hook only | R/W-Hook only |  TBI     |   Full   | TBI          |
| MbedTLS                   | R/W-Hook only | R/W-Hook only |  TBI     |   Full   | TBI          |
| Bouncycastle/Spongycastle |     TBA       |    TBA        |  TBA     |   Full   | TBA          |
| Conscrypt                 |     TBA       |    TBA        |  TBA     |   Full   | TBA          |
| S2n-tls                   |     Full      |    LibNO      |  TBA     |   Full   | LibNO        |
```
**R/W-Hook only** = Logging data sent and received by process<br>
**KeyEo** = Only the keying material can be extracted<br>
**Full** = Logging data send and received by process + Logging keys used for secure connection<br>
**TBA** = To be answered<br>
**TBI** = To be implemented<br>
**LibNO** = This library is not supported for this plattform<br>

**We verified the Windows implementations only for Windows 10**

## Dependencies

- [frida](https://frida.re)
- `>= python3.7`
- click (`python3 -m pip install click`)
- hexdump (`python3 -m pip install hexdump`)
- scapy (`python3 -m pip install scapy`)
- watchdog (`python3 -m pip install watchdog`)
- importlib.resources  (`python3 -m pip install importlib-resources`)
- for hooking on Android ensure that the `adb`-command is in your PATH

## Planned features

- [ ] add the capability to alter the decrypted payload
  - integration with https://github.com/mitmproxy/mitmproxy
  - integration with http://portswigger.net/burp/
- [ ] add wine support
- [ ] add Flutter support
- [ ] add further libraries (have a look at this [Wikipedia entry](https://en.wikipedia.org/wiki/Comparison_of_TLS_implementations)):
  - Botan (BSD license, Jack Lloyd)
  - LibreSSL (OpenBSD)
  - Cryptlib (Peter Gutmann)
  - JSSE (Java Secure Socket Extension, Oracle)
  - [MatrixSSL](https://github.com/matrixssl/matrixssl) 
  - ...
- [ ] Working with static linked libraries
- [ ] Add feature to prototype TLS-Read/Write/SSLKEY functions
- [ ] improve iOS/MacOS support (currently under development)
- [x] <strike>provide friTap as PyPI package</strike>

## Contribute

Contributions are always welcome. Just fork it and open a pull request!
More details can be found in the [CONTRIBUTION.md](./CONTRIBUTION.md).
___

## Changelog

See the wiki for [release notes](https://github.com/fkie-cad/friTap/wiki#news).

## Support

If you have any suggestions, or bug reports, please create an issue in the Issue Tracker.

In case you have any questions or other problems, feel free to send an email to:

[daniel.baier@fkie.fraunhofer.de](mailto:daniel.baier@fkie.fraunhofer.de).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/fkie-cad/friTap",
    "name": "friTap",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "mobile, instrumentation, frida, hook, SSL decryption",
    "author": "Daniel Baier, Francois Egner, Max Ufer",
    "author_email": "daniel.baier@fkie.fraunhofer.de",
    "download_url": "https://files.pythonhosted.org/packages/6b/79/cb7b275e15ef8a9eb4396f14a5d97c4a493a91348da878970ee04bc56fac/fritap-1.2.3.0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/fkie-cad/friTap/main/assets/logo.png\" alt=\"friTap logo\" width=\"50%\" height=\"50%\"/>\n</p>\n\n# friTap\n![version](https://img.shields.io/badge/version-1.2.3.0-blue) [![PyPI version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=py&r=r&ts=1683906897&type=6e&v=1.2.3.0&x2=0)](https://badge.fury.io/py/friTap)\n\nThe goal of this project is to help researchers to analyze traffic encapsulated in SSL or TLS. For details have a view into the [OSDFCon webinar slides](assets/friTapOSDFConwebinar.pdf) or in [this blog post](https://lolcads.github.io/posts/2022/08/fritap/).\n\n\nThis project was inspired by [SSL_Logger](https://github.com/google/ssl_logger ) and currently supports all major operating systems (Linux, Windows, Android). More platforms and libraries will be added in future releases.\n\n## Installation\n\n\nInstallation is simply a matter of `pip3 install fritap`. This will give you the `friTap` command. You can update an existing `friTap` installation with `pip3 install --upgrade friTap`.\n\nAlternatively just clone the repository and run the `friTap.py` file.\n\n\n## Usage\n\nOn Linux/Windows/MacOS we can easily attach to a process by entering its name or its PID:\n\n```bash\n$ sudo fritap --pcap mycapture.pcap thunderbird\n```\n\nFor mobile applications we just have to add the `-m` parameter to indicate that we are now attaching (or spawning) an Android or iOS app:\n\n```bash\n$ fritap -m --pcap mycapture.pcap com.example.app\n```\n\nFurther ensure that the frida-server is running on the Android/iOS device. \n\n\nRemember when working with the pip installation you have to invoke the `friTap` command with sudo a little bit different. Either as module:\n```bash\n$ sudo -E python3 -m friTap.friTap --pcap mycapture.pcap thunderbird\n```\nor directly invoking the script:\n```bash\n$ which friTap\n/home/daniel/.local/bin/friTap\n\n$ sudo -E /home/daniel/.local/bin/friTap\n```\n\n\n\nMore examples on using friTap can be found in the [USAGE.md](./USAGE.md). A detailed introduction using friTap on Android is under [EXAMPLE.md](./EXAMPLE.md) as well.\n\n## Hooking Libraries Without Symbols\n\nIn certain scenarios, the library we want to hook offers no symbols or is statically linked with other libraries, making it challenging to directly hook functions. For example Cronet (`libcronet.so`) and Flutter (`libflutter.so`) are often statically linked with **BoringSSL**.\n\nDespite the absence of symbols, we can still use friTap for parsing and hooking.\n\n### Hooking by Byte Patterns\n\nTo solve this, we can use friTap with byte patterns to hook the desired functions. You can provide friTap with a JSON file that contains byte patterns for hooking specific functions, based on architecture and platform using the `--patterns <byte-pattern-file.json>` option.\nIn order to apply the apprioate hooks for the various byte patterns we distinguish between different hooking categories.\nThese categories include:\n\n  -  Dump-Keys\n  -  Install-Key-Log-Callback\n  -  KeyLogCallback-Function\n  -  SSL_Read\n  -  SSL_Write\n\nEach category has a primary and fallback byte pattern, allowing flexibility when the primary pattern fails.\nFor libraries like BoringSSL, where TLS functionality is often statically linked into other binaries, we developed a tool called [BoringSecretHunter](https://github.com/monkeywave/BoringSecretHunter). This tool automatically identifies the necessary byte patterns to hook BoringSSL by byte-pattern matching. Specifically, BoringSecretHunter focuses on identifying the byte patterns for functions in the Dump-Keys category, allowing you to extract encryption keys during TLS sessions with minimal effort. More about the different hooking categories can be found in [usage of byte-patterns in friTap](./USAGE.md#hooking-by-byte-patterns).\n\n### Hooking by Offsets\n\nAlternatively, you can use the `--offsets <offset-file.json>` option to hook functions using known offsets. friTap allows you to specify user-defined offsets (relative to the base address of the targeting SSL/socket library) or absolute virtual addresses for function resolution. This is done through a JSON file, which is passed using the `--offsets` parameter.\n\nIf the `--offsets` parameter is used, friTap will only overwrite the function addresses specified in the JSON file. For functions that are not specified, friTap will attempt to detect the addresses automatically (using symbols).\n\n\n## Problems\n\nThe absence of traffic or incomplete traffic capture in the resulting pcap file (-p <your.pcap>) may stem from various causes. Before submitting a new issue, consider attempting the following solutions:\n\n### Default Socket Information\n\nThere might be instances where friTap fails to retrieve socket information. In such scenarios, running friTap with default socket information (`--enable_default_fd`) could resolve the issue. This approach utilizes default socket information (127.0.0.1:1234 to 127.0.0.1:2345) for all traffic when the file descriptor (FD) cannot be used to obtain socket details:\n\n```bash\nfritap -m --enable_default_fd -p plaintext.pcap com.example.app\n```\n\n### Handling Subprocess Traffic\n\nTraffic originating from a subprocess could be another contributing factor. To capture this traffic, friTap can leverage Frida's spawn gating feature, which intercepts newly spawned processes using the `--enable_spawn_gating` parameter:\n\n```bash\nfritap -m -p log.pcap --enable_spawn_gating com.example.app\n```\n\n### Library Support exist only for Key Extraction\n\nIn cases where the target library solely supports key extraction (cf. the table below), you can utilize the `-k <key.log>` parameter alongside full packet capture:\n\n```bash\nfritap -m -p log.pcap --full_capture -k keys.log com.example.app\n```\n\n### Seeking Further Assistance\n\nIf these approaches do not address your issue, please create a detailed issue report to aid in troubleshooting. To facilitate a more effective diagnosis, include the following information in your report:\n\n- The operating system and its version\n- The specific application encountering the issue or a comparable application that exhibits similar problems\n- The output from executing friTap with the specified parameters, augmented with friTap's debug output:\n```bash\nfritap -do -v com.example.app\n```\n\n\n## Supported SSL/TLS implementations and corresponding logging capabilities\n\n```markdown\n| Library                   | Linux         | Windows       | MacOSX   | Android  | iOS          |\n|---------------------------|---------------|---------------|----------|----------|--------------|\n| OpenSSL                   |     Full      | R/W-Hook only |  TBI     |   Full   | TBI          |\n| BoringSSL                 |     Full      | R/W-Hook only |  KeyEo   |   Full   | KeyEo        |\n| NSS                       |     Full      | R/W-Hook only |  TBI     |   TBA    | TBI          |\n| GnuTLS                    | R/W-Hook only | R/W-Hook only |  TBI     |   Full   | TBI          |\n| WolfSSL                   | R/W-Hook only | R/W-Hook only |  TBI     |   Full   | TBI          |\n| MbedTLS                   | R/W-Hook only | R/W-Hook only |  TBI     |   Full   | TBI          |\n| Bouncycastle/Spongycastle |     TBA       |    TBA        |  TBA     |   Full   | TBA          |\n| Conscrypt                 |     TBA       |    TBA        |  TBA     |   Full   | TBA          |\n| S2n-tls                   |     Full      |    LibNO      |  TBA     |   Full   | LibNO        |\n```\n**R/W-Hook only** = Logging data sent and received by process<br>\n**KeyEo** = Only the keying material can be extracted<br>\n**Full** = Logging data send and received by process + Logging keys used for secure connection<br>\n**TBA** = To be answered<br>\n**TBI** = To be implemented<br>\n**LibNO** = This library is not supported for this plattform<br>\n\n**We verified the Windows implementations only for Windows 10**\n\n## Dependencies\n\n- [frida](https://frida.re)\n- `>= python3.7`\n- click (`python3 -m pip install click`)\n- hexdump (`python3 -m pip install hexdump`)\n- scapy (`python3 -m pip install scapy`)\n- watchdog (`python3 -m pip install watchdog`)\n- importlib.resources  (`python3 -m pip install importlib-resources`)\n- for hooking on Android ensure that the `adb`-command is in your PATH\n\n## Planned features\n\n- [ ] add the capability to alter the decrypted payload\n  - integration with https://github.com/mitmproxy/mitmproxy\n  - integration with http://portswigger.net/burp/\n- [ ] add wine support\n- [ ] add Flutter support\n- [ ] add further libraries (have a look at this [Wikipedia entry](https://en.wikipedia.org/wiki/Comparison_of_TLS_implementations)):\n  - Botan (BSD license, Jack Lloyd)\n  - LibreSSL (OpenBSD)\n  - Cryptlib (Peter Gutmann)\n  - JSSE (Java Secure Socket Extension, Oracle)\n  - [MatrixSSL](https://github.com/matrixssl/matrixssl) \n  - ...\n- [ ] Working with static linked libraries\n- [ ] Add feature to prototype TLS-Read/Write/SSLKEY functions\n- [ ] improve iOS/MacOS support (currently under development)\n- [x] <strike>provide friTap as PyPI package</strike>\n\n## Contribute\n\nContributions are always welcome. Just fork it and open a pull request!\nMore details can be found in the [CONTRIBUTION.md](./CONTRIBUTION.md).\n___\n\n## Changelog\n\nSee the wiki for [release notes](https://github.com/fkie-cad/friTap/wiki#news).\n\n## Support\n\nIf you have any suggestions, or bug reports, please create an issue in the Issue Tracker.\n\nIn case you have any questions or other problems, feel free to send an email to:\n\n[daniel.baier@fkie.fraunhofer.de](mailto:daniel.baier@fkie.fraunhofer.de).\n",
    "bugtrack_url": null,
    "license": "GPL v3",
    "summary": "Decrypts and logs a process's SSL/TLS traffic on all major platforms. Further it allows the TLS key extraction.",
    "version": "1.2.3.0",
    "project_urls": {
        "Homepage": "https://github.com/fkie-cad/friTap"
    },
    "split_keywords": [
        "mobile",
        " instrumentation",
        " frida",
        " hook",
        " ssl decryption"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d7f2f82b654f6a1c27517f9584daaaf49d75e30c8af56d70f1cd7aacc727342d",
                "md5": "82fe819bc5b47618ebdfd735000133f2",
                "sha256": "058eb7da22f8b702942a9161d5968c6341fc042cd73ba42c3e144f778a48d620"
            },
            "downloads": -1,
            "filename": "friTap-1.2.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "82fe819bc5b47618ebdfd735000133f2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5371060,
            "upload_time": "2024-10-30T14:52:35",
            "upload_time_iso_8601": "2024-10-30T14:52:35.036441Z",
            "url": "https://files.pythonhosted.org/packages/d7/f2/f82b654f6a1c27517f9584daaaf49d75e30c8af56d70f1cd7aacc727342d/friTap-1.2.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6b79cb7b275e15ef8a9eb4396f14a5d97c4a493a91348da878970ee04bc56fac",
                "md5": "bc4f658459aa54fed8712aec7ae99412",
                "sha256": "ad58c075906901bdb3c83139e12c560db1654a9f36a5a7f5925782354a5e0562"
            },
            "downloads": -1,
            "filename": "fritap-1.2.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bc4f658459aa54fed8712aec7ae99412",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 5356964,
            "upload_time": "2024-10-30T14:52:47",
            "upload_time_iso_8601": "2024-10-30T14:52:47.226866Z",
            "url": "https://files.pythonhosted.org/packages/6b/79/cb7b275e15ef8a9eb4396f14a5d97c4a493a91348da878970ee04bc56fac/fritap-1.2.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-30 14:52:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fkie-cad",
    "github_project": "friTap",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "frida",
            "specs": [
                [
                    ">=",
                    "15.0.0"
                ]
            ]
        },
        {
            "name": "frida-tools",
            "specs": [
                [
                    ">=",
                    "10.0.0"
                ]
            ]
        },
        {
            "name": "AndroidFridaManager",
            "specs": []
        },
        {
            "name": "hexdump",
            "specs": []
        },
        {
            "name": "scapy",
            "specs": []
        },
        {
            "name": "watchdog",
            "specs": []
        },
        {
            "name": "click",
            "specs": []
        },
        {
            "name": "importlib-resources",
            "specs": []
        }
    ],
    "lcname": "fritap"
}
        
Elapsed time: 0.38246s