Trying more things. I think clientek is being rejected.

This commit is contained in:
Manevolent
2018-07-25 12:20:24 -04:00
parent 2dd96d39f3
commit 567ee472d6
4 changed files with 56 additions and 9 deletions
@@ -7,12 +7,15 @@ import com.github.manevolent.ts3j.protocol.NetworkPacket;
import com.github.manevolent.ts3j.protocol.ProtocolRole; import com.github.manevolent.ts3j.protocol.ProtocolRole;
import com.github.manevolent.ts3j.protocol.SocketRole; import com.github.manevolent.ts3j.protocol.SocketRole;
import com.github.manevolent.ts3j.protocol.header.ClientPacketHeader; import com.github.manevolent.ts3j.protocol.header.ClientPacketHeader;
import com.github.manevolent.ts3j.protocol.header.HeaderFlag;
import com.github.manevolent.ts3j.protocol.packet.Packet6Ack; import com.github.manevolent.ts3j.protocol.packet.Packet6Ack;
import com.github.manevolent.ts3j.protocol.packet.PacketType; import com.github.manevolent.ts3j.protocol.packet.PacketType;
import com.github.manevolent.ts3j.protocol.packet.channel.PacketChannel; import com.github.manevolent.ts3j.protocol.packet.channel.PacketChannel;
import com.github.manevolent.ts3j.protocol.packet.handler.client.LocalClientHandler; import com.github.manevolent.ts3j.protocol.packet.handler.client.LocalClientHandler;
import com.github.manevolent.ts3j.protocol.packet.transformation.PacketTransformation;
import com.github.manevolent.ts3j.protocol.socket.LocalTeamspeakSocket; import com.github.manevolent.ts3j.protocol.socket.LocalTeamspeakSocket;
import com.github.manevolent.ts3j.protocol.packet.Packet; import com.github.manevolent.ts3j.protocol.packet.Packet;
import com.github.manevolent.ts3j.util.Ts3Crypt;
import com.github.manevolent.ts3j.util.Ts3Logging; import com.github.manevolent.ts3j.util.Ts3Logging;
import java.io.IOException; import java.io.IOException;
@@ -72,6 +75,10 @@ public class LocalTeamspeakClient extends LocalEndpoint implements TeamspeakClie
return clientOptions; return clientOptions;
} }
public void setSecureParameters(Ts3Crypt.SecureChannelParameters parameters) {
getSocket().setPacketTransformation(new PacketTransformation(parameters.getIvStruct()));
}
/** /**
* Sends a command to the remote server. * Sends a command to the remote server.
* @param command Command to send. * @param command Command to send.
@@ -108,6 +115,7 @@ public class LocalTeamspeakClient extends LocalEndpoint implements TeamspeakClie
* @param packet Packet to send * @param packet Packet to send
* @throws IOException * @throws IOException
*/ */
int z = 0;
public void send(Packet packet) throws IOException { public void send(Packet packet) throws IOException {
// Construct header // Construct header
ClientPacketHeader header = new ClientPacketHeader(); ClientPacketHeader header = new ClientPacketHeader();
@@ -117,10 +125,15 @@ public class LocalTeamspeakClient extends LocalEndpoint implements TeamspeakClie
packet.setHeaderValues(header); packet.setHeaderValues(header);
if (connectionState == ClientConnectionState.CONNECTING) {
header.setPacketId(z++);
header.setPacketFlag(HeaderFlag.NEW_PROTOCOL, true);
}
getSocket().send(header, packet); getSocket().send(header, packet);
} }
private void setConnectionState(ClientConnectionState state) { public void setConnectionState(ClientConnectionState state) {
synchronized (connectionStateLock) { synchronized (connectionStateLock) {
if (state != this.connectionState) { if (state != this.connectionState) {
Ts3Logging.debug("State changing: " + state.name()); Ts3Logging.debug("State changing: " + state.name());
@@ -10,6 +10,7 @@ public abstract class PacketHeader {
private final ProtocolRole role; private final ProtocolRole role;
//private final byte[] DEFAULT_MAC = new byte[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}; // 8x0's //private final byte[] DEFAULT_MAC = new byte[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}; // 8x0's
private int packetGeneration;
private byte[] mac = new byte[8]; // 8 bytes private byte[] mac = new byte[8]; // 8 bytes
private int packetId = 0; private int packetId = 0;
private PacketType type; private PacketType type;
@@ -100,4 +101,12 @@ public abstract class PacketHeader {
public ProtocolRole getRole() { public ProtocolRole getRole() {
return role; return role;
} }
public int getGeneration() {
return packetGeneration;
}
public void setGeneration(int packetGeneration) {
this.packetGeneration = packetGeneration;
}
} }
@@ -5,6 +5,7 @@ import com.github.manevolent.ts3j.command.part.CommandSingleParameter;
import com.github.manevolent.ts3j.license.License; import com.github.manevolent.ts3j.license.License;
import com.github.manevolent.ts3j.protocol.NetworkPacket; import com.github.manevolent.ts3j.protocol.NetworkPacket;
import com.github.manevolent.ts3j.protocol.ProtocolRole; import com.github.manevolent.ts3j.protocol.ProtocolRole;
import com.github.manevolent.ts3j.protocol.client.ClientConnectionState;
import com.github.manevolent.ts3j.protocol.client.LocalTeamspeakClient; import com.github.manevolent.ts3j.protocol.client.LocalTeamspeakClient;
import com.github.manevolent.ts3j.protocol.packet.Packet2Command; import com.github.manevolent.ts3j.protocol.packet.Packet2Command;
import com.github.manevolent.ts3j.protocol.packet.Packet8Init1; import com.github.manevolent.ts3j.protocol.packet.Packet8Init1;
@@ -200,12 +201,30 @@ public class LocalClientHandlerConnecting extends LocalClientHandler {
); );
getClient().send(clientek); getClient().send(clientek);
Ts3Crypt.SecureChannelParameters secureChannelParameters =
Ts3Crypt.cryptoInit2(license, alphaBytes, omega, proof, beta, keyPair.getValue()); Ts3Crypt.cryptoInit2(license, alphaBytes, omega, proof, beta, keyPair.getValue());
// send client init... Packet2Command clientinit = new Packet2Command(ProtocolRole.CLIENT);
clientinit.setText(
// DONE! new SimpleCommand(
"clientinit", ProtocolRole.CLIENT,
new CommandSingleParameter("client_nickname", "test"),
new CommandSingleParameter("client_version", "3.0.19.3"),
new CommandSingleParameter("client_platform", "Windows"),
new CommandSingleParameter("client_version_sign", "a1OYzvM18mrmfUQBUgxYBxYz2DUU6y5k3/mEL6FurzU0y97Bd1FL7+PRpcHyPkg4R+kKAFZ1nhyzbgkGphDWDg=="),
new CommandSingleParameter("client_input_hardware", "true"),
new CommandSingleParameter("client_output_hardware", "false"),
new CommandSingleParameter("client_default_channel", ""),
new CommandSingleParameter("client_default_channel_password", ""),
new CommandSingleParameter("client_server_password", ""),
new CommandSingleParameter("client_nickname_phonetic", "test"),
new CommandSingleParameter("client_meta_data", ""),
new CommandSingleParameter("client_default_token", ""),
new CommandSingleParameter("client_key_offset", Long.toString(getClient().getLocalIdentity().getKeyOffset())),
new CommandSingleParameter("hwid", "87056c6e1268aaf5055abf8256415e0e,408978b6d98810cc03f0aa16a4c75600")
).build()
);
getClient().send(clientinit);
} }
} }
} }
@@ -45,7 +45,7 @@ public class PacketTransformation {
temporaryByteBuffer.put((byte) (header.getRole() == ProtocolRole.SERVER ? 0x30 : 0x31)); temporaryByteBuffer.put((byte) (header.getRole() == ProtocolRole.SERVER ? 0x30 : 0x31));
temporaryByteBuffer.put((byte) (header.getType().getIndex() & 0xFF)); temporaryByteBuffer.put((byte) (header.getType().getIndex() & 0xFF));
temporaryByteBuffer.put((byte) 0); // TODO generation temporaryByteBuffer.put((byte) (header.getGeneration() & 0xFF));
if (key.length == 20) { if (key.length == 20) {
//temporary[6 - 26] = SIV[0 - 20] //temporary[6 - 26] = SIV[0 - 20]
@@ -76,7 +76,11 @@ public class PacketTransformation {
Pair<byte[], byte[]> parameters = computeParameters(packet.getHeader()); Pair<byte[], byte[]> parameters = computeParameters(packet.getHeader());
// Write header (this is temporary) // Write header (this is temporary)
ByteBuffer headerBuffer = packet.writeHeader(ByteBuffer.allocate(packet.getHeader().getSize())); ByteBuffer headerBuffer = packet.writeHeader(
ByteBuffer
.allocate(packet.getHeader().getSize())
.order(ByteOrder.BIG_ENDIAN)
);
// Get the header without a MAC for the associated text field // Get the header without a MAC for the associated text field
byte[] headerWithoutMac = new byte[packet.getHeader().getSize() - MAC_LEN]; byte[] headerWithoutMac = new byte[packet.getHeader().getSize() - MAC_LEN];
@@ -90,7 +94,7 @@ public class PacketTransformation {
); );
int dataLen = packet.getPacket().getSize(); int dataLen = packet.getPacket().getSize();
ByteBuffer packetBuffer = packet.writeBody(ByteBuffer.allocate(dataLen)); ByteBuffer packetBuffer = packet.writeBody(ByteBuffer.allocate(dataLen).order(ByteOrder.BIG_ENDIAN));
byte[] result; byte[] result;
int len; int len;
@@ -116,6 +120,8 @@ public class PacketTransformation {
// Rest of header // Rest of header
outputBuffer.put(headerWithoutMac); outputBuffer.put(headerWithoutMac);
Ts3Logging.debug("WRITE HEADER: " + Ts3Logging.getHex(outputBuffer.array(), headerBuffer.limit()));
// Encrypted body // Encrypted body
outputBuffer.put(result, 0, len - MAC_LEN); outputBuffer.put(result, 0, len - MAC_LEN);