Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TuxHook2: cross-platform NetHook2 port #1082

Closed
wants to merge 9 commits into from
Closed

TuxHook2: cross-platform NetHook2 port #1082

wants to merge 9 commits into from

Conversation

m4dEngi
Copy link
Contributor

@m4dEngi m4dEngi commented Apr 1, 2022

Here be dragons

Copy link
Contributor

@JustArchi JustArchi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the best thing that happened this year so far 😎

@@ -0,0 +1,10 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#!/usr/bin/env sh, from what I see you don't use any bash extensions. POSIX compatibility ftw!

I'd also append set -eu.

@@ -0,0 +1,10 @@
#!/bin/bash
STEAM_PID=$(ps -C steam -o pid= | head -1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not pidof steam?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno, i'm no bash expert.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also forgot to add passing PID by argument...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And other processes (srcds et al)?

@xPaw
Copy link
Member

xPaw commented Apr 2, 2022

### Windows
~~Net~~TuxHook is capable of self injecting and ejecting from running instances of Steam, so there's no requirement to use a separate loader such as winject.
### Linux
Use supplied inject.sh to inject ~~Net~~TuxHook into running steam process.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably mention that gdb is required.

@yaakov-h
Copy link
Member

yaakov-h commented Apr 3, 2022

Initial thoughts:

  • This should probably be an extension of NetHook2 rather than a clone. I don't want two to maintain. It also makes it hard to see what changes you've made between NetHook2 and TuxHook.
  • This should be included in CI.
  • Can we use LD_PRELOAD instead of / as well as GDB?
  • Can we detect GDB or LLDB and use the appropriate one?
  • Does this work on macOS? From what I can tell the hooks library you're using should support x86_64, but Apple have done some extra security work on aarch64/arm64 to prevent this.
  • Can this work on 64-bit Windows too?

@m4dEngi
Copy link
Contributor Author

m4dEngi commented Apr 3, 2022

Initial thoughts:

  • This should probably be an extension of NetHook2 rather than a clone. I don't want two to maintain. It also makes it hard to see what changes you've made between NetHook2 and TuxHook.
  • This should be included in CI.
  • Can we use LD_PRELOAD instead of / as well as GDB?
  • Can we detect GDB or LLDB and use the appropriate one?
  • Does this work on macOS? From what I can tell the hooks library you're using should support x86_64, but Apple have done some extra security work on aarch64/arm64 to prevent this.
  • Can this work on 64-bit Windows too?
  • And miss opportunity to make a linux related pun on 1st of april?!
  • I have no idea how to work with github actions
  • We can, it'll just be a little bit more messy and require bit more work than injection via gdb
  • If lldb is capable to call __libc_dlopen in target process i don't see why not
  • Will not work on arm/aarch64 due to platform limitations as stated in funchook library description.
  • It can, but will require separate implementation like linux version for obvious reasons.

@xPaw
Copy link
Member

xPaw commented Apr 3, 2022

Here's CI config, took me a while to get it working:

  nethook2:
    name: NetHook2 on ${{ matrix.os }}

    strategy:
      matrix:
        os: [ windows-latest, ubuntu-latest ]
      fail-fast: false

    runs-on: ${{ matrix.os }}

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Setup developer command prompt (Windows)
      if: matrix.os == 'windows-latest'
      uses: ilammy/msvc-dev-cmd@v1
      with:
        arch: win32

    - name: Install dependencies (Linux)
      if: matrix.os == 'ubuntu-latest'
      run: |
        sudo apt update
        sudo apt install -y g++-multilib libc++-11-dev libc++abi-11-dev

    - name: Create build directory
      run: mkdir Resources/TuxHook2/build

    - name: Generate make file (Windows)
      if: matrix.os == 'windows-latest'
      working-directory: Resources/TuxHook2/build/
      run: cmake -A Win32 ../

    - name: Generate make file (Linux)
      if: matrix.os == 'ubuntu-latest'
      working-directory: Resources/TuxHook2/build/
      run: cmake ../

    - name: Build NetHook2
      working-directory: Resources/TuxHook2/build/
      run: |
        cmake --build . --target deps --config Release
        cmake --build . --config Release

    - name: Tar files (Linux)
      if: matrix.os == 'ubuntu-latest'
      working-directory: Resources/TuxHook2/build/
      run: tar -cvf NetHook2-Linux.tar inject.sh *.so

    - name: Upload NetHook2 (Linux)
      uses: actions/upload-artifact@v3
      if: matrix.os == 'ubuntu-latest'
      with:
        name: NetHook2-Linux
        path: Resources/TuxHook2/build/NetHook2-Linux.tar

    - name: Upload NetHook2 (Windows)
      uses: actions/upload-artifact@v3
      if: matrix.os == 'windows-latest'
      with:
        name: NetHook2
        path: 'Resources/TuxHook2/build/Release/*.dll'

things to do:

  • git update-index --chmod=+x inject.sh
  • do not build protobuf compiler
  • warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc

@m4dEngi
Copy link
Contributor Author

m4dEngi commented Jun 21, 2022

If you ask me, it was ok for an april fools joke, but i'm weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants