๐
sean0x42 / mineshark Goto Github PK
View Code? Open in Web Editor NEWA (work in progress) packet sniffing proxy that sits between a Minecraft client and server. Essentially a MITM attack with custom middleware
A (work in progress) packet sniffing proxy that sits between a Minecraft client and server. Essentially a MITM attack with custom middleware
๐
There appears to be a race condition that occurs at the start of every new connection. About 60% of the time, the client will send its first packet before we have opened a connection with the server (I think), causing the connection to go silent.
I did attempt to resolve this issue by collecting all packets into a queue until the server explicitly fires the connect
event, and then releasing the queue. But this has not resolved the issue.
More investigation is needed.
See: https://wiki.vg/NBT
Packets should be immutable.
Signed and unsigned.
I don't really have much confidence in the packet readers and writers at the moment. Would be good to create a comprehensive set of unit (and possibly integration) tests for these.
Currently writing a packet's registry entry is a pretty exhausting task. Writing a reader and writer involves a LOT of duplication. See example:
Registry.register({
id: 0x26,
kind: PacketKind.JoinGame,
source: PacketSource.Server,
state: State.Play,
read: (reader) => ({
kind: PacketKind.JoinGame,
payload: {
entityId: reader.readInt(),
isHardcore: reader.readBoolean(),
gamemode: reader.readUnsignedByte(),
previousGamemode: reader.readByte(),
worlds: reader.readIdentifierArray(),
dimensionCodec: reader.readNbt(),
dimension: reader.readNbt(),
worldName: reader.readString(),
hashedSeed: reader.readLong(),
maxPlayers: reader.readVarInt(),
viewDistance: reader.readVarInt(),
reducedDebugInfo: reader.readBoolean(),
enableRespawnScreen: reader.readBoolean(),
isDebug: reader.readBoolean(),
isFlat: reader.readBoolean(),
},
}),
write: (writer, packet) => {
const payload = (packet as JoinGamePacket).payload;
writer
.writeInt(payload.entityId)
.writeBoolean(payload.isHardcore)
.writeUnsignedByte(payload.gamemode)
.writeByte(payload.previousGamemode)
.writeIdentifierArray(payload.worlds)
.writeNbt(payload.dimensionCodec)
.writeNbt(payload.dimension)
.writeString(payload.worldName)
.writeLong(payload.hashedSeed)
.writeVarInt(payload.maxPlayers)
.writeVarInt(payload.viewDistance)
.writeBoolean(payload.reducedDebugInfo)
.writeBoolean(payload.enableRespawnScreen)
.writeBoolean(payload.isDebug)
.writeBoolean(payload.isFlat);
},
});
It would be fantastic if we moved towards a different model, where you define a specification for the packet's payload instead. Something like:
Registry.register({
id: 0x26,
kind: PacketKind.JoinGame,
source: PacketSource.Server,
state: State.Play,
payload: {
entityId: DataType.Int,
isHardcore: DataType.Boolean,
gamemode: DataType.UnsignedByte,
// ...
// Custom data types could provide a callback reader and writer like the old way
worlds: {
read(reader) { /* ... */ },
write(writer, packet) { /* ... */ }
},
// ...
// Optional trailing data could be denoted with an extra flag
isFlat: {
type: DataType.Boolean,
optional: true
}
}
});
Previous implementation in typescript can be found here:
mineshark/src/reader/packetReader.ts
Line 33 in 0d2b40d
If a middleware throws an error, it would be good to catch that error and pass the packet to the next middleware in the chain. This would prevent middleware from bringing down the entire proxy when they encounter unexpected territory.
Both signed and unsigned.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.