Giter Site home page Giter Site logo

adepierre / sniffcraft Goto Github PK

View Code? Open in Web Editor NEW
150.0 150.0 12.0 434 KB

C++ program to capture and display all traffic between a client and a server in minecraft

License: GNU General Public License v3.0

CMake 8.67% C++ 91.33%
minecraft packets protocol proxy

sniffcraft's People

Contributors

adepierre avatar clrxbl avatar kisaragieffective avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sniffcraft's Issues

SniffCraft disabling when logging in from 1.16.5 and above

Hello,

Please tell me why after the player login from version 1.16.5 above, the running sniffcraft is disabling with following error:

[0:0:0:32] [S --> C] Login Compression
[0:0:0:32] [S --> C] Game Profile
Segmentation fault (core dumped)

With respect,
Unhappy hurtlay.

Output packet capture files

Hi,

Can SniffCraft currently capture and output .PCAP or .PCAPNG files (and decompress packets)?

If not, I was thinking of adding that feature in my fork. It's currently a mess and it would take time for me so I wanted to ask first.

Thank you,

NULL MESSAGE exit

SniffCraft exits after connectting to the server for no reason

to replicate this connect to 8b8t.me using the version 1.12.2

...
[0:00:02:882] [S --> C] Set Player Team
[0:00:02:882] [S --> C] Set Player Team
[0:00:02:882] [S --> C] Tab List
Server --> Client: NULL MESSAGE WITH ID: 59
[0:00:02:908] [S --> C] Set Objective
[0:00:02:908] [S --> C] Set Objective

stuck on authentication completed

probably just doing something wrong but when i launch it outputs this and then stops

Loading updated conf file
Missing or malformed cached credentials for Mojang account with login <email>, sending credentials to get a new one...
Sending credentials to Mojang authentication server...
Authentication completed!

Win Binary

Have system error of not found zlib1__.dll in executable file

Make it actual sniffer and support encryption.

Move from proxying to sniffing is optional here.
When encryption is requested, we may still listen to packet talk,
but not interfere with communication happening after that.

We may breach encryption by making the client share it's shared secret.
I have made a Lua script that logs it to a file for further use.
I have already tested this solution by dumping TCP streams
and decrypting them with said logged key.

I suggested this somewhere else already:
uis246/MCPC_dissect#2

All SniffCraft has to do on encryption request is to start
listening to that file for key and match proxy connection
by identifying local(Client) and remote(Proxy) addresses
and their ports. (Not server's IP+port we proxy to.)

BTW For connecting beside the local machine,
the proxy should always patch Handshake packet to
proper values to not include local IP and port.

BTW2 I might implement that script for other MC versions if needed.
You can contact me on Discord under username MajsterTynek#8884
or find me on AdvancedMacros Discord server.

Install Problems

I never worked with cmake, Visual Studio or C++. Can someone please help me install the programm? I tried it severel times and after finishing all steps and trying to run the sniffcraft command in cmd, i get the message that the command does not exist.

Connection::read_buffer is being overwritten

I found a bug.

It is during the decryption, in Connection::handle_read.

    std::vector<unsigned char>& data = read_buffer;
    size_t length = bytes_transferred;

    std::vector<unsigned char> processed_data;
    if (data_processor != nullptr)
    {
        processed_data = data_processor->ProcessIncomingData({ data.begin(), data.begin() + length });
        data = processed_data;
        length = processed_data.size();
    }

During my debugging, read_buffer which is basically being used as an unsigned char array for a buffer was changing size.
data is a reference to read_buffer and when you assign to a reference it overwrites the original and it depends on it being BUFFER_SIZE. The offending line:

        data = processed_data;

The fix I came up with is: 2dc1724

    std::vector<unsigned char> processed_data;
    if (data_processor != nullptr)
    {   
        processed_data = data_processor->ProcessIncomingData({ read_buffer.begin(), read_buffer.begin() + length });
        length = processed_data.size();
    }
    else 
    {
        processed_data = read_buffer;
    }

    {
        std::lock_guard<std::mutex> received_lock(received_mutex);
        ready_received_data.insert(ready_received_data.end(), processed_data.begin(), processed_data.begin() + length);

        // We need to protect the callback call in the mutex scope
        // otherwise we could have data in the buffer without the
        // data length being transmitted correctly
        if (data_callback)
        {
            data_callback(length);
        }
    }

1.19.2 forge and 1.19.2 fabric will cause a login disconnect due to sniffcraft.exe not having the mod loaders

C:\Windows\System32>"C:\Users\Ethan\Desktop\sniffcraft.exe" 12345 localhost:62709 "C:\Users\Ethan\Desktop\custom.json"
Waiting connection on 127.0.0.1:12345
Loading updated conf file...
Conf file loaded!
Trying to authenticate using Microsoft account
[2023-05-01 07:25:05.524] [INFO] [(21356)] Authentifier.cpp(86): Cached Minecraft token for Microsoft account still valid.
[2023-05-01 07:25:05.525] [INFO] [(21356)] Authentifier.cpp(89): Getting player certificates...
[2023-05-01 07:25:05.528] [INFO] [(21356)] Authentifier.cpp(1159): Cached player certificates still valid!
[2023-05-01 07:25:05.528] [INFO] [(21356)] Authentifier.cpp(96): Player certificates obtained!
Starting new proxy to localhost:62709
Waiting connection on 127.0.0.1:12345
[0:00:00:000] [(SC) --> S] Client Intention
[0:00:00:000] [C --> (SC)] Client Intention
[0:00:00:004] [S --> C] Login Disconnect
{
    "reason": {
        "raw_text": "{\"text\":\"This server has mods that require Forge to be installed on the client. Contact your server admin for more details.\"}"
    }
}

forge needs to be installed in sniffcraft.exe
even though the alt has it

{
    "LogToConsole": true,
    "LogToReplay": false,
    "LogRawBytes": false,
    "Online": true,
    "MicrosoftAccountCacheKey": "",
    "Handshaking": {
        "ignored_clientbound" : [
            
        ],
        "ignored_serverbound" : [
            
        ],
        "detailed_clientbound": [
            
        ],
        "detailed_serverbound": [
            
        ]
    },
    "Status": {
        "ignored_clientbound" : [
            
        ],
        "ignored_serverbound" : [
            
        ],
        "detailed_clientbound": [
            
        ],
        "detailed_serverbound": [
            
        ]
    },
    "Login": {
        "ignored_clientbound" : [
            
        ],
        "ignored_serverbound" : [
            
        ],
        "detailed_clientbound": [
            "Hello",
		"Login Disconnect"
        ],
        "detailed_serverbound": [
            "Key"
        ]
    },
    "Play": {
        "ignored_clientbound" : [
            "Move Entity Pos",
            "Move Entity PosRot",
            "Move Entity Rot",
            "Entity Event",
            "Player Position",
            "Rotate Head",
            "Level Chunk",
            "Section Blocks Update",
            "Light Update",
            "Forget Level Chunk",
            "Set Entity Data",
            "Update Attributes",
            "Add Entity",
            "Set Entity Motion",
            "Teleport Entity",
            "Set Equipment",
            "Add Mob",
            "Remove Entity",
            "Block Update",
            "Animate",
            "Keep Alive",
            "Set Time",
            "Block Event",
            "Sound"
        ],
        "ignored_serverbound" : [
            "Move Player Pos",
            "Move Player PosRot",
            "Move Player Rot",
            "Move Player Status Only",
            "Keep Alive"
        ],
        "detailed_clientbound": [
            "Container Set Content",
            "Container Set Slot"
        ],
        "detailed_serverbound": [
            "Container Click",
            "Container Close"
        ]
    }
}

If need be I can give the modpack zip for my forge modpack for testing if requested in discord

Failed to build with game version 1.16.5

Packets

ServerboundClientIntentionPacket
ClientboundGameProfilePacket
ClientboundLoginCompressionPacket
ClientboundHelloPacket

are not present in ProtocolCraft for version 1.16.5.
On commit b38b519 everything works fine

Replay mod support

Maybe useless for package ispection software, but in some cases it useful. For example if you have bot and want to see actions of other players or something like this.

Implementation example:
https://github.com/uis246/AltCraft-tools/blob/master/TransperentProxy/replaymod.c
(Yep. Another proxy)
It works with crushedpixels' replaymod.
Replay contains only clientbound packets, so no client representation without injection move packets to replay.

https://github.com/ReplayMod/ReplayMod/blob/57c7362e3417ec563235a3e41a300e4a2ab9a709/src/main/java/com/replaymod/recording/handler/RecordingEventHandler.java

Special Request

Would you mind adding me on discord for some help and to answer a few complicated questions?

Add encryption by having the sniffer join as client

Let me explain; BotCraft is capable of joining a server using encryption, and is capable of decrypting all packets as well. What stops us from when the player connects to our proxy server ( in offline mode ), to encrypt and forward all packets to the server we are connecting to. All packets we receive could be decrypted and forwarded to the client.

Pakkit ( https://github.com/Heath123/pakkit ) is a nodejs program that relies on node-minecraft-protocol ( https://github.com/PrismarineJS/node-minecraft-protocol ) and is capable of doing this, and manipulating packets as well.

The same method used by pakkit should be possible using the excellent ProtocolCraft as well.

error when starting?

builds fine but when i try to start it says "The code execution cannot proceed because zlib.dll was not found."

Issue when connecting to server

I'm getting this error when SniffCraft is running and I try to connect to localhost:

Starting new proxy to server-ip:25565
Empty mojang credentials, trying to authenticate using Microsoft account
[2022-08-16 23:31:44.118] [INFO] [(52208)] Authentifier.cpp(144): Cached Minecraft token for Microsoft account still valid.
Client --> Server: PARSING EXCEPTION: Wrong input size in ReadData || Hello
[0:0:0:0] [C --> S] Client Intention
[0:0:0:77] [S --> C] Hello
[0:0:0:269] [(SC) --> S] Key
Session closed

Anything I can do to resolve this?
Thanks

Can't build

Ever since the update to add the online mode I haven't been able to build the project. I keep getting this error

In file included from /usr/include/c++/11.1.0/memory:76,
                 from /home/trac/coding/SniffCraft/3rdparty/asio/asio/include/asio/associated_allocator.hpp:19,
                 from /home/trac/coding/SniffCraft/3rdparty/asio/asio/include/asio.hpp:18,
                 from /home/trac/coding/SniffCraft/sniffcraft/include/sniffcraft/server.hpp:3,
                 from /home/trac/coding/SniffCraft/sniffcraft/src/server.cpp:1:
/usr/include/c++/11.1.0/bits/unique_ptr.h: In instantiation of ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = Botcraft::Authentifier]’:
/usr/include/c++/11.1.0/bits/unique_ptr.h:361:17:   required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = Botcraft::Authentifier; _Dp = std::default_delete<Botcraft::Authentifier>]’
/home/trac/coding/SniffCraft/sniffcraft/include/sniffcraft/MinecraftProxy.hpp:26:7:   required from here
/usr/include/c++/11.1.0/bits/unique_ptr.h:83:23: error: invalid application of ‘sizeof’ to incomplete type ‘Botcraft::Authentifier’
   83 |         static_assert(sizeof(_Tp)>0,
      |                       ^~~~~~~~~~~
/usr/include/c++/11.1.0/bits/unique_ptr.h: In instantiation of ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = Botcraft::AESEncrypter]’:
/usr/include/c++/11.1.0/bits/unique_ptr.h:361:17:   required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = Botcraft::AESEncrypter; _Dp = std::default_delete<Botcraft::AESEncrypter>]’
/home/trac/coding/SniffCraft/sniffcraft/include/sniffcraft/MinecraftProxy.hpp:26:7:   required from here
/usr/include/c++/11.1.0/bits/unique_ptr.h:83:23: error: invalid application of ‘sizeof’ to incomplete type ‘Botcraft::AESEncrypter’
make[2]: *** [sniffcraft/CMakeFiles/sniffcraft.dir/build.make:146: sniffcraft/CMakeFiles/sniffcraft.dir/src/server.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:142: sniffcraft/CMakeFiles/sniffcraft.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

And the build steps in the README don't work because the folder is called SniffCraft not sniffcraft and -DWITH_ENCRYPTION gives you

CMake Error: Parse error in command line argument: WITH_ENCRYPTION
 Should be: VAR:type=value

CMake Error: Run 'cmake --help' for all supported options.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.