Teaspeak-Server/client/main.cpp

1176 lines
57 KiB
C++
Raw Normal View History

#include <iostream>
#include <tomcrypt.h>
#include <iomanip>
#include <ThreadPool/Timer.h>
#include <License.h>
#include "src/Identity.h"
#include "src/protocol/Connection.h"
#include <ed25519/ed25519.h>
#include <ed25519/ge.h>
#include <misc/base64.h>
#include <log/LogUtils.h>
#include <LicenseKey.pb.h>
#include <ed25519/sc.h>
#include <misc/digest.h>
#define QLZ_COMPRESSION_LEVEL 3
#include "qlz/QuickLZ.h"
using namespace std;
using namespace ts;
using namespace license::teamspeak;
void hexout(std::ostream& os, unsigned char c)
{
unsigned char uc = static_cast<unsigned char>(c);
os << std::setw(2) << std::setfill('0') << (unsigned int)uc << ' ';
}
void hexdump(std::ostream& outs, const std::string& s, size_t line_len = 16)
{
std::ostringstream os;
const std::string::size_type slen(s.size());
int i(0);
std::string::size_type pos(0);
const std::streamsize lines(slen / line_len);
const std::streamsize chars(slen % line_len);
std::ios::fmtflags f(os.flags());
os << "Length: " << s.length() << "/" << std::hex << "0x" << s.length() << endl;
for(std::streamsize line = 0; line <= lines - (chars == 0 ? 1 : 0); ++line)
{
os << std::hex << setfill('0') << setw(3) << line * line_len << " | ";
for(i = 0; i < line_len; ++i)
{
if(pos < s.length())
hexout(os, s[pos]);
else os << " ";
pos++;
}
os << " | ";
if(pos - line_len < s.length()){
auto av = s.substr(pos - line_len);
for(char c : av.substr(0, min(av.length(), line_len))){
if(isprint(c))
os << c << " ";
else
os << "." << " ";
}
}
os << '\n';
}
os.flags(f);
outs << os.str() << endl;
}
//This RSA puzzel crashes the manager
//545333494e49543100658803ffED1eBAACDe66bd212F3B91A0C1dbd65b374F1FCEe353A74C78eB99B5b8B2e0eC7DC9Ce7bCdfcFE97622AbD015B4EBCB3fecc7D23bBfaA2B15DBBBBC1d009DBcd924B06Eb2e0CBCD0AfBbadc2ecbb812C47d5dcAA4BcFdaF73ACe89A106c98f6c0DBeac8e8FeF9d6d836Bd1Cd791f376452Cff581400ed760acB2deAE1Be53E98152AbaBfaC823e3e4FACdaAf69E977C8dE328ECDA5FEE3c327FfCf9228caf8D761aeF7bAdbebe5eAcda87Eba61F09D7AEC9D4EeBa763cFE3c9cE718d37dd4F73CA10ffB4127d15Bee7cF9Edc644b4be06f0F9C4aEb2FBDd9549e215959FaFea57b5B7900000000
/*
auto parent = import((char*) root);
fe_neg(parent.X, parent.X);
fe_neg(parent.T, parent.T);
char buf[32];
ge_p3_tobytes((u_char*) buf, &parent);
return string(buf, 32);
*/
using namespace std::chrono;
inline std::string keyMul(const char* publicKey /* compressed */, char* privateKey /* uncompressed */, bool negate){
ge_p3 keyA{};
ge_p2 result{};
ge_frombytes_negate_vartime(&keyA, (u_char*) publicKey);
if(negate) {
fe_neg(keyA.X, keyA.X); /* undo negate */
fe_neg(keyA.T, keyA.T); /* undo negate */
}
ge_scalarmult_vartime(&result, (u_char*) privateKey, &keyA);
char buffer[32];
ge_tobytes((u_char*) buffer, &result);
return string(buffer, 32);
}
#include "ed25519/sha512.h"
static int consttime_equal(const unsigned char *x, const unsigned char *y) {
unsigned char r = 0;
r = x[0] ^ y[0];
#define F(i) r |= x[i] ^ y[i]
F(1);
F(2);
F(3);
F(4);
F(5);
F(6);
F(7);
F(8);
F(9);
F(10);
F(11);
F(12);
F(13);
F(14);
F(15);
F(16);
F(17);
F(18);
F(19);
F(20);
F(21);
F(22);
F(23);
F(24);
F(25);
F(26);
F(27);
F(28);
F(29);
F(30);
F(31);
#undef F
return !r;
}
int ed25519_verify(bool do_hash, const unsigned char *signature, const unsigned char *message, size_t message_len, const unsigned char *public_key) {
unsigned char h[64];
unsigned char checker[32];
sha512_context hash;
ge_p3 A;
ge_p2 R;
if (signature[63] & 224) {
return 0;
}
if (ge_frombytes_negate_vartime(&A, public_key) != 0) {
return 0;
}
if(do_hash) {
//sha512_init(&hash);
//sha512_update(&hash, signature, 32);
//sha512_update(&hash, public_key, 32);
//sha512_update(&hash, message, message_len);
//sha512_final(&hash, h);
assert(false);
} else {
memcpy(h, message, 64);
}
sc_reduce(h);
ge_double_scalarmult_vartime(&R, h, &A, signature + 32);
ge_tobytes(checker, &R);
if (!consttime_equal(checker, signature)) {
return 0;
}
return 1;
}
/*
char seed[64];
LicenseChain chain;
//E813384CE058BA63F5792D16A093B0C503D2C51FD19A1DC36FD613EFB88E7334
u_char publicKey[32];
u_char privateKey[32] = {0xE8, 0x13, 0x38, 0x4C, 0xE0, 0x58, 0xBA, 0x63, 0xF5, 0x79, 0x2D, 0x16, 0xA0, 0x93, 0xB0, 0xC5, 0x03, 0xD2, 0xC5, 0x1F, 0xD1, 0x9A, 0x1D, 0xC3, 0x6F, 0xD6, 0x13, 0xEF, 0xB8, 0x8E, 0x73, 0x34};
//privateKey[0] &= 248;
//privateKey[31] &= 63;
//privateKey[31] |= 64;
ge_p3 A;
ge_scalarmult_base(&A, privateKey);
ge_p3_tobytes(publicKey, &A);
hexDump((char*) publicKey, 32, 32, 32);
cout << "A: " << base64::encode(keyMul((char*) chain.generatePublicKey(public_tea_root).data(), (char*) chain.generatePrivateKey((u_char*) privateKey).data(), true)) << endl;
cout << "A: " << base64::encode(keyMul((char*) chain.generatePublicKey((u_char*) publicKey).data(), (char*) chain.generatePrivateKey((u_char*) private_tea_root).data(), true)) << endl;
/*
for(char& c : seed)
c = rand();
ed25519_create_keypair((u_char*) publicKey, (u_char*) privateKey, (u_char*) seed);
cout << "A: " << base64::encode(keyMul((char*) public_tea_root, privateKey, true)) << endl;
cout << "B: " << base64::encode(keyMul(publicKey, (char*) private_tea_root, true)) << endl;
chain.addServerEntry(7, "TeaSpeak");
chain.addEphemeralEntry();
/
istringstream is(chain.exportChain());
auto c2 = LicenseChain::parse(is, error);
chain.print();
c2->print();
cout << "A: " << base64::encode(keyMul((char*) c2->generatePublicKey(public_tea_root).data(), (char*) chain.generatePrivateKey((u_char*) privateKey).data(), true)) << endl;
cout << "A: " << base64::encode(keyMul((char*) c2->generatePublicKey((u_char*) publicKey).data(), (char*) chain.generatePrivateKey((u_char*) private_tea_root).data(), true)) << endl;
cout << "Chain: " << base64::encode(chain.exportChain()) << endl;
*/
inline std::string parseHex(const std::string& in) {
char buffer[(in.length() + 1) / 2];
memset(buffer, 0, sizeof(buffer));
size_t nibble_index = 0;
for(auto c : in) {
if(c == '\n' || c == ' ') continue;
uint8_t nibble = 0;
if(c >= 'A' && c <= 'F')
nibble = c - 'A' + 10;
else if(c >= 'a' && c <= 'f')
nibble = c - 'a' + 10;
else if(c >= '0' && c <= '9')
nibble = c - '0';
if(nibble_index % 2 == 0)
nibble <<= 4;
else
nibble &= 0xF;
buffer[nibble_index / 2] |= nibble;
nibble_index++;
}
return string(buffer, (nibble_index + 1) / 2);
}
bool read_crypted_string(std::string& result, const char* buffer, int length) {
char tmp[264];
char current;
int index = 0;
do {
//cout << "Read: " << ((index & 0x1F) - length) << " | " << index << endl;
tmp[index] = length ^ buffer[index] ^ buffer[(index & 0x1F) - length];
} while(tmp[index++]);
result = string(tmp, index - 1);
return true;
}
void print_dec_teamspeak() {
auto bin = parseHex("3EF0E405913439B81A2D60D467C04D11\n"
"8E7D6C6CC8DC2B8B8F62FD30F7027393\n"
"29B7A64DC47E7BAD0E6A788E7E881805\n"
"9D373E29D0FC5FAFBC57C8757C8E4CA7\n"
"B44ED70A35E78019D531CBC8299A2E34\n"
"F107D5C124B35F47C62A1F52EA43FF68\n"
"29B14B0F13EDE81BB7AD43C900CD7D41\n"
"AD02A125F7E306917D65E40B3F70CC61\n"
"C35F019E616A71CFC6369FCE3FFA26E5\n"
"1C739028E2FC58812827CBF0051EFC66\n"
"CA8257EE96943F9935D6F23B22C352F0\n"
"F432D2E6A915ED1E889B48BEABAF1613\n"
"E50143BD39F929C1B657F53627DB429E\n"
"874E42B42D8D8D48B999DB24C369EDA4\n"
"7ECBD3C97668FBAA7368C21ABABD3A93\n"
"B9E213EE48DED608F6E7E4585EA86C8D\n"
"66789F00B8AF2982F2D645FE50C08310\n"
"F6FAFC5923638A8264E1532C71A8B319\n"
"4D948F08FE727FF4536325F45E9D8609\n"
"F17176F1587229F848A7B210F97E6EE6\n"
"4B6178A0369B1047C520543DD4DC3AFA\n"
"2F009C270F4FFA5EAB4A33A6534954E6\n"
"971EF2F10D86342CB0142221F96FC249\n"
"1E9C790D04EBB03D8C2328A21D3C1408\n"
"E1ED1B822222E7293B7CCE76CC576EF0\n"
"1105FF7FD79676F6D6862D893BABF16F\n"
"D2AF8A2436CA7765EDD62C39C457EFF9\n"
"6BD6E0E929AB0889EB57B1A4AE413DED\n"
"5152A23AFE7EFBA855E13029C94A9D9E\n"
"5D58A5329E8212F58EC678CD61F1BB61\n"
"C6DAD36233822B35C356FFBC75798F16\n"
"B6B6739DAFE85AE258C3DA11EFF7E203\n"
"51AF150AED16549F8166F9415ADA3C5F\n"
"09F241E66B37A85B506A50938E7AAB0E\n"
"038220175AEE5DFA772BB4474C7663AA\n"
"AB59CB7379F114672F8E2CCE431F8073\n"
"784219DCC22EBD115B9E391B47B605A2\n"
"2F73EC1F142E05C7CA73B10B1D9A391A\n"
"5AF154E46D22AA58003A39FBF64F8832\n"
"3CA603672A9E2D8A075BC4373C0603E1\n"
"EF178B6A29A910737DC577D0560C8423\n"
"667D96C336969E69ED3AE0126ACD33EB\n"
"E80D8A3867A702277BD839D34603846A\n"
"627ED38234818579EE3EFD0F21CD33E6\n"
"EF0F9B2329A1443771DD779E400A8275\n"
"7760B6B44C42A4628B8308AC90C06294\n"
"64FFB17DDBCFDB7A7B9D3C7CD357C350\n"
"B9C560814A54B32C948305AEDEC062C6\n"
"65FBB05D769D8364FB43589C576D6454\n"
"879B63EC5E52B77C899270EA460EDB62\n"
"1A14AC1EB93F65ED4A0F14FFAA5FFFF7\n"
"008453897B03A45A828164E3512E66A1\n"
"AF55CB2A68EA403332833A9B1D5CD56F\n"
"723699957BD9DE3DA767A75B6DC365B9\n"
"FA57C66962E857765E6AA4E609816F6D\n"
"EC732AE3FF1B86226BA6073E76CF7BD5\n"
"1F0F956C7B70C9CB78F9D8130DEA75CD\n"
"D612F9D4CA3FCD26A2FC65949FC62E3F\n"
"C2646B9B12BAF43F21C659E1FA3ED5F8\n"
"E61BAF108ADB41BFEBCAC22B37D34EEA\n"
"A36ECFF6BE07B31DD7CF51A1B7A31E12\n"
"B15D5CBB22E43EDDE94FED263B9E2BA7\n"
"4E52B62B8FC600A09CDA79D96BFBA036\n"
"82C7DB656C837431CA439608B1C52F84\n"
"4148BF6FEB4D9C9374E150509D6C4D17\n"
"A707B7687DEF784094D360F34D40C663\n"
"5D57A61CA43F71F10F091EF3EB4FF4ED\n"
"019E4E8E7244E046909D33866BBFF85D\n"
"D87869ED4570288D3FDC18439232313D\n"
"91C07ED9C02AA062A85B638F71A4AD4D\n"
"D9616BE30675339F35DD7121F4E04E97\n"
"3E3CAA513062CD78DE471696737571C6\n"
"C533C0967CF835F5077FD475E8E71B8E\n"
"2B3BBD16666FD07BC5077AD10410BE67\n"
"CECC5AA1C597208828F6E27A95839237\n"
"6B90637C8C12DF05F78F28C10408F02B\n"
"AF8A5F4EAA3F829659BE9ED37AD42DAC\n"
"A327C9D9D960738D6A2ACC4B9F17C38D\n"
"4658BF20988347AB9DCB2BCE7EFEA735\n"
"82CAD6632FD42738C8569B41B3CB6C85\n"
"404CB46FEB579C8265FA42599D7A5015\n"
"B810A02C38AB0B011CB9AD47E0ED479C\n"
"5A856957967AB9B345D57565BD4C7C24\n"
"8336800C188B2B213C998D67C0CD67BC\n"
"7AA54977B615DAD560A7051D8F2B0D41\n"
"BD02F66021BF4C4047EAB90AA1BD4999\n"
"752CF4F712952778B0086C63D967C247\n"
"1C866F7968CD916A998676E825FF0D75\n"
"D23BFEF20AD155D01915E37ADADA1FF1\n"
"C384368E34AFB6629F92C76F28C4797C\n"
"9113D917A5907BCE194282F9342CCF56\n"
"BFF370D2E9BE11B80288DD05A4A2B70C\n"
"05F45304A838BB3DC5AA5DF43F368E48\n"
"EAFC7DD8E8AC5FA50595CE44B8A4A24F\n"
"57E94E57BD37F53FCCF84FFC37238E49\n"
"F7E767D5E9BC11CCB1696FDD1AB8A032\n"
"96B0FC0CEB57DAC91BE4FAED1050BA1E\n"
"12E925A161DAEA4BA56D6E8908A5AF60\n"
"96BCF549BF48D09B1FEAF0B8104DBD00\n"
"03FB6BAB6ADAFC02AA643C8E01B9B524\n"
"8DA2F62C1CD5C92DB0145D88314956F5\n"
"44ED7A21AF4B0844E3FB0EA3EB47DA17\n"
"DC3359A313DAC761A6150F8A370A4190\n"
"22EFF7148D6428AB093265CA63D95306\n"
"DE7E796ECEC5389EDF7FE433EA137780\n"
"2680CA031FFB66C28B5EE79F87369133\n"
"ABE63C83919D3B2299787E9300D70BE4\n"
"886FCB4205F271D0C249EDBFC6293ED8\n"
"58E4F124EAF8BF0DB50F94AD9E534BA8\n"
"31D8811DBB848C71D82CEEBB24C2C5D4\n"
"24729E6766DB59DC1EBBD271F2BF726A\n"
"8910F9A03C9AA5AD56EC4BD39917B0E8\n"
"F20545A90942E371AF7D8AB25EA0757C\n"
"9C08B0BA32D7A4E24EE40CA04E859B7C\n"
"E34B408463490CA109B93521B2121805\n"
"A0B45EF9F45E85439C704E8F6EA5BB5C\n"
"C36B60A443692C812999020DDB2F5019\n"
"D0DE38AD5A762DD4C03CB54218862517\n"
"53A246E47233B1455D1AF0EF0AFDB55D\n"
"C803CF2740E50ECFDE36EB421C86390F\n"
"42EB5FF13B23B75C541B9EF0091DE168\n"
"9FC55BF8CA8E7F9E2EA7FE6C9880E741\n"
"7373657274696F6E20226D5F74696D65\n"
"725265736F6C7574696F6E20213D2030\n"
"22206661696C6564206174202E2E2F2E\n"
"2E2F2E2E2F2E2E2F732F646570732F74\n"
"65616D737065616B5F7365727665725F\n"
"6C69622F7372632F74735F7365727665\n"
"722F616E7469666C6F6F642E6370703A\n"
"00416E7469466C6F6F64004173736572\n"
"74696F6E20226D5F706F696E74735469\n"
"636B5261746520213D20302220666169\n"
"6C6564206174202E2E2F2E2E2F2E2E2F\n"
"2E2E2F732F646570732F7465616D7370\n"
"65616B5F7365727665725F6C69622F73\n"
"72632F74735F7365727665722F616E74\n"
"69666C6F6F642E6370703A0052656765\n"
"7870206572726F7220666F7220495020\n"
"65787072657373696F6E202200222C20\n"
"6572726F723A200042616E4D616E6167\n"
"657200526567657870206572726F7220\n"
"666F72204E616D652065787072657373\n"
"696F6E20220054686973206E616D6520\n"
"69732000596F7520617265200062616E\n"
"6E6564207065726D616E656E746C792E\n"
"0062616E6E65642074656D706F726172\n"
"696C792E0020526561736F6E3A202200\n"
"0A54727920616761696E20696E20006E\n"
"6F7469667962616E6C697374006C6173\n"
"746E69636B6E616D6500696E766F6B65\n"
"72636C6462696400656E666F7263656D\n"
"656E74730062616E5F696E736572742E\n"
"73716C0062616E5F69700062616E5F6E\n"
"616D650062616E5F7569640062616E5F\n"
"74696D657374616D700062616E5F6C65\n"
"6E6774680062616E5F696E766F6B6572\n"
"5F636C69656E745F69640062616E5F69\n"
"6E766F6B65725F7569640062616E5F69\n"
"6E766F6B65725F6E616D650062616E5F\n"
"726561736F6E0062616E5F6861736800\n"
"62616E5F64656C6574652E73716C0062\n"
"616E5F696400417373657274696F6E20\n"
"226572726F72203D3D204552524F525F\n"
"6F6B22206661696C6564206174202E2E\n"
"2F2E2E2F2E2E2F2E2E2F732F64657073\n"
"2F7465616D737065616B5F7365727665\n"
"725F6C69622F7372632F74735F736572\n"
"7665722F62616E6D616E616765722E63\n"
"70703A0062616E2064656C6574656420\n"
"28657870697265642920726561736F6E\n"
"3D0062616E5F6C6973742E73716C0069\n"
"6E76616C69642062616E206974656D20\n"
"776974682069643A2000000000000000\n"
"4E5374335F5F3132315F5F656D707479\n"
"5F6E6F6E5F6F776E5F73746174654963\n"
"45450000000000000000000000000000\n"
"4E5374335F5F3131355F5F6861735F6F\n"
"6E655F73746174654963454500000000\n"
"4E5374335F5F31365F5F6E6F64654963\n"
"45450000000000000000000000000000\n"
"4E5374335F5F3131315F5F616C746572\n"
"6E617465496345450000000000000000\n"
"4E5374335F5F3131375F5F6F776E735F\n"
"74776F5F737461746573496345450000\n"
"4E5374335F5F3131365F5F6F776E735F\n"
"6F6E655F737461746549634545000000\n"
"4E5374335F5F3131375F5F7265706561\n"
"745F6F6E655F6C6F6F70496345450000\n"
"4E5374335F5F31365F5F6C6F6F704963\n"
"45450000000000000000000000000000\n"
"4E5374335F5F3132365F5F656E645F6D\n"
"61726B65645F73756265787072657373\n"
"696F6E49634545000000000000000000\n"
"4E5374335F5F3132385F5F626567696E\n"
"5F6D61726B65645F7375626578707265\n"
"7373696F6E4963454500000000000000\n"
"4E5374335F5F3131305F5F725F616E63\n"
"686F7249634545000000000000000000\n"
"4E5374335F5F3131305F5F6C5F616E63\n"
"686F7249634545000000000000000000\n"
"4E5374335F5F3131325F5F6D61746368\n"
"5F636861724963454500000000000000\n"
"4E5374335F5F3132305F5F6D61746368\n"
"5F636861725F636F6C6C61746549634E\n"
"535F313272656765785F747261697473\n"
"49634545454500000000000000000000\n"
"4E5374335F5F3131385F5F6D61746368\n"
"5F636861725F696361736549634E535F\n"
"313272656765785F7472616974734963\n"
"45454545000000000000000000000000\n"
"4E5374335F5F3132305F5F627261636B\n"
"65745F65787072657373696F6E49634E\n"
"535F313272656765785F747261697473\n"
"49634545454500000000000000000000\n"
"4E5374335F5F3131315F5F6D61746368\n"
"5F616E79496345450000000000000000\n"
"4E5374335F5F3131305F5F6261636B5F\n"
"72656649634545000000000000000000\n"
"4E5374335F5F3131385F5F6261636B5F\n"
"7265665F636F6C6C61746549634E535F\n"
"313272656765785F7472616974734963\n"
"45454545000000000000000000000000\n"
"4E5374335F5F3131365F5F6261636B5F\n"
"7265665F696361736549634E535F3132\n"
"72656765785F74726169747349634545\n"
"45450000000000000000000000000000\n"
"4E5374335F5F3132335F5F6D61746368\n"
"5F616E795F6275745F6E65776C696E65\n"
"49634545000000000000000000000000\n"
"4E5374335F5F3131315F5F6C6F6F6B61\n"
"6865616449634E535F31327265676578\n"
"5F747261697473496345454545000000\n"
"4E5374335F5F3131355F5F776F72645F\n"
"626F756E6461727949634E535F313272\n"
"656765785F7472616974734963454545\n"
"45000000000000000000000000000000\n"
"4E5374335F5F3131335F5F656D707479\n"
"5F737461746549634545000000000000\n"
"4E5374335F5F3132305F5F7368617265\n"
"645F7074725F706F696E74657249504E\n"
"535F31335F5F656D7074795F73746174\n"
"65496345454E535F313464656661756C\n"
"745F64656C6574654953325F45454E53\n"
"5F39616C6C6F6361746F724953325F45\n"
"45454500000000000000000000000000\n"
"4E5374335F5F31313464656661756C74\n"
"5F64656C657465494E535F31335F5F65\n"
"6D7074795F7374617465496345454545\n"
"00000000000000000000000000000000\n"
"4E5374335F5F3131315F5F656E645F73\n"
"74617465496345450041737365727469\n"
"6F6E20226D5F705669727475616C5365\n"
"7276657220213D205F5F6E756C6C2220\n"
"6661696C6564206174202E2E2F2E2E2F\n"
"2E2E2F2E2E2F732F646570732F746561\n"
"6D737065616B5F7365727665725F6C69\n"
"622F7372632F74735F7365727665722F\n"
"6368616E636C69656E74736361636865\n"
"2E6370703A004368616E436C69656E43\n"
"6163686500417373657274696F6E2022\n"
"6D5F5468726561644944203D3D207374\n"
"643A3A746869735F7468726561643A3A\n"
"6765745F6964282922206661696C6564\n"
"206174202E2E2F2E2E2F2E2E2F2E2E2F\n"
"732F646570732F7465616D737065616B\n"
"5F7365727665725F6C69622F7372632F\n"
"74735F7365727665722F6368616E636C\n"
"69656E747363616368652E6370703A00\n"
"636F6D706C61696E5F696E736572742E\n"
"73716C00636F6D706C61696E5F66726F\n"
"6D5F636C69656E745F696400636F6D70\n"
"6C61696E5F746F5F636C69656E745F69\n"
"6400636F6D706C61696E5F6D65737361\n"
"676500636F6D706C61696E5F74696D65\n"
"7374616D7000636F6D706C61696E5F68\n"
"61736800636F6D706C61696E5F64656C\n"
"6574652E73716C00636F6D706C61696E\n"
"5F64656C6574655F616C6C2E73716C00\n"
"636F6D706C61696E5F64656C6574655F\n"
"7072756E652E73716C00636F6D706C61\n"
"696E5F6765745F62795F736572766572\n"
"69642E73716C00536F6D6520636F6D70\n"
"6C61696E7420656E7472696573206672\n"
"6F6D2074686520646174616261736520\n"
"77657265206E6F74206C6F6164656420\n"
"62656361757365207468657920776572\n"
"65206475706C696361746573206F6620\n"
"616C7265616479206C6F61646564206F\n"
"6E657300436F6D706C61696E4D677200\n"
"6368616E6E656C5F696E736572745F62\n"
"756C6B2E73716C006F72675F6368616E\n"
"6E656C5F6964006368616E6E656C5F69\n"
"6E736572745F62756C6B5F6669787570\n"
"2E73716C006368616E6E656C5F696E73\n"
"6572745F62756C6B5F6D617070696E67\n"
"2E73716C006368616E6E656C5F70726F\n"
"706572746965735F62756C6B5F696E73\n"
"6572742E73716C006368616E6E656C5F\n"
"64656C6574652E73716C006368616E6E\n"
"656C5F696E736572742E73716C006368\n"
"616E6E656C5F7570646174655F706172\n"
"656E7469642E73716C00536572766572\n"
"517565727920477565737400636C6965\n"
"6E745F696E736572742E73716C00636C\n"
"69656E745F696E736572745F62756C6B\n"
"2E73716C006F72675F636C69656E745F\n"
"696400636C69656E745F696E73657274\n"
"5F62756C6B5F6D617070696E672E7371\n"
"6C00636C69656E745F70726F70657274\n"
"6965735F62756C6B5F696E736572742E\n"
"73716C00636C69656E745F6765745F62\n"
"795F7569642E73716C00636C69656E74\n"
"5F6D6F6E74685F75706C6F616400636C\n"
"69656E745F746F74616C5F75706C6F61\n"
"6400636C69656E745F6D6F6E74685F64\n"
"6F776E6C6F616400636C69656E745F74\n"
"6F74616C5F646F776E6C6F616400636C\n"
"69656E745F64656C6574652E73716C00\n"
"636C69656E745F7570646174655F6C6F\n"
"67696E5F696E666F2E73716C00636C69\n"
"656E745F7570646174655F6E616D652E\n"
"73716C00636C69656E745F7570646174\n"
"655F73746174732E73716C00636C6965\n"
"6E745F7570646174655F747261666669\n"
"635F73746174732E73716C006D657373\n"
"6167655F6765745F756E726561645F62\n"
"795F636C69656E7469642E73716C0075\n"
"6E72656164002E736F006C6962007761\n"
"6974696E6720666F7220636F6E6E6563\n"
"74696F6E20617661696C61626C650064\n"
"6174616261736520636F6E6E65637469\n"
"6F6E206E6F7420666F756E6400417373\n"
"657274696F6E20226572726F72203D3D\n"
"204552524F525F6F6B22206661696C65\n"
"64206174202E2E2F2E2E2F2E2E2F2E2E\n"
"2F732F646570732F7465616D73706561\n"
"6B5F7365727665725F6C69622F737263\n"
"2F74735F7365727665722F6461746162\n"
"6173652F64625F64617461626173652E\n"
"6370703A00506C65617365206D616B65\n"
"207375726520796F7520757365207468\n"
"6520737570706C696564207473337365\n"
"727665725F6D696E696D616C5F72756E\n"
"7363726970742E736820746F2072756E\n"
"20746865207365727665722C206F7220\n"
"736574204C445F4C4942524152595F50\n"
"41544820796F757273656C6600756E61\n"
"626C6520746F206C6F61642064617461\n"
"6261736520706C7567696E206C696272\n"
"617279202200222C2068616C74696E67\n"
"21007473336462706C7567696E5F696E\n"
"6974007473336462706C7567696E5F73\n"
"687574646F776E007473336462706C75\n"
"67696E5F636F6E6E6563740074733364\n"
"62706C7567696E5F646973636F6E6E65\n"
"6374007473336462706C7567696E5F65\n"
"786563007473336462706C7567696E5F\n"
"6F70656E007473336462706C7567696E\n"
"5F62756C6B5F696E7365727400747333\n"
"6462706C7567696E5F6765746C617374\n"
"696E736572746964007473336462706C\n"
"7567696E5F6765746D6F646966696564\n"
"726F77636F756E74007473336462706C\n"
"7567696E5F7461626C65657869737473\n"
"007473336462706C7567696E5F766572\n"
"73696F6E007473336462706C7567696E\n"
"5F6E616D65007473336462706C756769\n"
"6E5F73686F72746E616D650074733364\n"
"62706C7567696E5F6170697665727369\n"
"6F6E007473336462706C7567696E5F67\n"
"65746C6173746572726F72004661696C\n"
"656420746F20696D706F727420220022\n"
"2066726F6D202200436F756C64206E6F\n"
"74206C6F616420646174616261736520\n"
"706C7567696E006462506C7567696E20\n"
"6E616D653A20202020006462506C7567\n"
"696E2076657273696F6E3A2000506C75\n"
"67696E206170692076657273696F6E20\n"
"69732000207768696C65200020697320\n"
"72657175697265640064625F65786563\n"
"2829200064625F62756C6B5F696E7365\n"
"72742829200064625F6F70656E282920\n"
"00646174616261736520627573792C20\n"
"77616974696E6720666F722066696E69\n"
"7368696E6720696E646578207461736B\n"
"732C206D61792074616B6520736F6D65\n"
"2074696D65210073657453514C66726F\n"
"6D46696C65282066696C653A00726570\n"
"206669656C6473202F20696E73657274\n"
"20706F696E742073697A65206E6F7420\n"
"73616D6520666F722073716C20616E64\n"
"20726570656174207061727400417373\n"
"657274696F6E2022737472696E675F66\n"
"69656C645F636F756E74203D3D207374\n"
"72696E675F6669656C645F6E616D6573\n"
"2E73697A65282922206661696C656420\n"
"6174202E2E2F2E2E2F2E2E2F2E2E2F73\n"
"2F646570732F7465616D737065616B5F\n"
"7365727665725F6C69622F7372632F74\n"
"735F7365727665722F64617461626173\n"
"652F64625F64617461626173652E6370\n"
"703A00696E76616C696420706172616D\n"
"6574657220666F756E6420005C5B5C5B\n"
"5C5B282E2A3F295C5D5C5D5C5D005C3A\n"
"285B5E5C3A5D2A3F5C2A295C3A003A24\n"
"3031303A003A24303100417373657274\n"
"696F6E2022216D5F73746F726167652E\n"
"656F66282922206661696C6564206174\n"
"202E2E2F2E2E2F2E2E2F2E2E2F732F64\n"
"6570732F7465616D737065616B5F7365\n"
"727665725F6C69622F7372632F74735F\n"
"7365727665722F64617461626173652F\n"
"64625F64617461626173652E6370703A\n"
"00756E6B6E6F776E207461626C652066\n"
"69656C64207265717565737465643A20\n"
"00417373657274696F6E2022636F756E\n"
"74203C3D20363422206661696C656420\n"
"6174202E2E2F2E2E2F2E2E2F2E2E2F73\n"
"2F646570732F7465616D737065616B5F\n"
"7365727665725F6C69622F7372632F74\n"
"735F7365727665722F64617461626173\n"
"652F64625F64617461626173652E6370\n"
"703A00417373657274696F6E20227369\n"
"7A65735B695D203C3D207374643A3A6E\n"
"756D657269635F6C696D6974733C756E\n"
"7369676E656420696E743E3A3A6D6178\n"
"282922206661696C6564206174202E2E\n"
"2F2E2E2F2E2E2F2E2E2F732F64657073\n"
"2F7465616D737065616B5F7365727665\n"
"725F6C69622F7372632F74735F736572\n"
"7665722F64617461626173652F64625F\n"
"64617461626173652E6370703A005C3A\n"
"285B612D7A412D5A302D395F2D5D2A3F\n"
"295C3A005C3A285B612D7A412D5A302D\n"
"395F2D5D2A3F295C2A303F5C3A000000\n"
"3134437573746F6D4461746162617365\n"
"00000000000000000000000000000000\n"
"3134506C7567696E4461746162617365\n"
"0064625F4372656174655461626C6573\n"
"282920756E61626C6520746F206C6F61\n"
"6420696E7374616E6365206465666175\n"
"6C742076616C7565730053514C006372\n"
"656174655F7461626C65732E73716C00\n"
"64625F4372656174655461626C657328\n"
"2920756E61626C6520746F2063726561\n"
"7465207461626C65730064625F437265\n"
"6174655461626C65732829207461626C\n"
"65732063726561746564006465666175\n"
"6C74732E73716C0064625F4372656174\n"
"655461626C6573282920756E61626C65\n"
"20746F20696E73657274206465666175\n"
"6C742076616C7565730064625F437265\n"
"6174655461626C6573282920666F756E\n"
"6420696E76616C696420646174616261\n"
"73652076657273696F6E0064625F4372\n"
"656174655461626C6573282920756E61\n"
"626C6520746F207361766520696E7374\n"
"616E63652064656661756C742076616C\n"
"7565730064625F437265617465546162\n"
"6C6573282920756E61626C6520746F20\n"
"696E7365727420646174616261736520\n"
"76657273696F6E0064726F705F746162\n"
"6C65732E73716C0064625F4372656174\n"
"655461626C65732829207461626C6573\n"
"2064726F7065640064625F4372656174\n"
"655461626C6573282920756E61626C65\n"
"20746F2064726F70207461626C657300\n"
"7570646174655F64617461626173655F\n"
"76657273696F6E2E73716C0043524954\n"
"4943414C206572726F72207768696C65\n"
"207570646174696E6720646174616261\n"
"73652076657273696F6E007570646174\n"
"655F0064617461626173652075706461\n"
"746564207375636365737366756C6C79\n"
"20746F207265766973696F6E3A200075\n"
"70646174655461626C6573282920756E\n"
"61626C6520746F207570646174652064\n"
"617461626173652076657273696F6E00\n"
"64617461626173652075706461746520\n"
"746F207265766973696F6E3A20006375\n"
"73746F6D5F696E736572742E73716C00\n"
"637573746F6D5F64656C6574655F6279\n"
"5F636C69656E7469642E73716C00636C\n"
"69656E745F64656C6574655F7072756E\n"
"652E73716C0067726F7570735F736572\n"
"7665720067726F7570735F6368616E6E\n"
"656C007065726D5F696E736572742E73\n"
"716C007065726D5F6964007065726D5F\n"
"76616C7565007065726D5F6E65676174\n"
"6564007065726D5F736B697000706572\n"
"6D5F64656C6574655F62795F67726F75\n"
"7069642E73716C007065726D5F64656C\n"
"6574655F62795F7065726D69642E7371\n"
"6C007065726D5F696E736572745F6275\n"
"6C6B2E73716C0067726F75705F6D656D\n"
"6265725F696E736572745F62756C6B2E\n"
"73716C0067726F75705F696E73657274\n"
"2E73716C0067726F75705F696E736572\n"
"745F62756C6B5F736E617073686F742E\n"
"73716C006F72675F67726F75705F6964\n"
"0067726F75705F696E736572745F6275\n"
"6C6B5F736E617073686F745F6765745F\n"
"6D617070696E672E73716C0067726F75\n"
"705F64656C6574652E73716C00746162\n"
"6C6567726F7570007461626C65706572\n"
"6D73007461626C656D656D6265727300\n"
"67726F75705F72656E616D652E73716C\n"
"0067726F7570735F6765745F62795F73\n"
"657276657269645F747970652E73716C\n"
"0067726F75705F69645F6765745F6279\n"
"5F6E616D652E73716C007065726D5F75\n"
"70646174655F6765745F67726F757073\n"
"2E73716C006661696C656420746F2075\n"
"7064617465207065726D697373696F6E\n"
"732C2068616C74656421007065726D5F\n"
"72656E616D652E73716C006F6C645F70\n"
"65726D5F6E616D65006E65775F706572\n"
"6D5F6E616D6500756E61626C6520746F\n"
"2072656E616D65207065726D69737369\n"
"6F6E2C2068616C74656421007065726D\n"
"5F636F70795F64656661756C745F7065\n"
"726D697373696F6E732E73716C00756E\n"
"61626C6520746F20636F707920646566\n"
"61756C74207065726D697373696F6E73\n"
"2C2068616C74656421006661696C6564\n"
"20746F20726574726965766520766972\n"
"7475616C736572766572732C2068616C\n"
"74656421007065726D5F736572766572\n"
"5F67726F757000695F636C69656E745F\n"
"6D6F646966795F706F77657200695F6E\n"
"65656465645F6D6F646966795F706F77\n"
"65725F636C69656E745F6D6F64696679\n"
"5F706F77657200695F636C69656E745F\n"
"6E65656465645F6D6F646966795F706F\n"
"77657200695F6E65656465645F6D6F64\n"
"6966795F706F7765725F636C69656E74\n"
"5F6E65656465645F6D6F646966795F70\n"
"6F776572007570646174656420706572\n"
"6D697373696F6E7320746F2076657273\n"
"696F6E2031007065726D5F6368616E6E\n"
"656C5F67726F75707300757064617465\n"
"64207065726D697373696F6E7320746F\n"
"2076657273696F6E2032007570646174\n"
"6564207065726D697373696F6E732074\n"
"6F2076657273696F6E20330075706461\n"
"746564207065726D697373696F6E7320\n"
"746F2076657273696F6E203400757064\n"
"61746564207065726D697373696F6E73\n"
"20746F2076657273696F6E2035007570\n"
"6461746564207065726D697373696F6E\n"
"7320746F2076657273696F6E20360075\n"
"706461746564207065726D697373696F\n"
"6E7320746F2076657273696F6E203700\n"
"695F6368616E6E656C5F6D6F64696679\n"
"5F6D616B655F636F6465635F656E6372\n"
"79707465640075706461746564207065\n"
"726D697373696F6E7320746F20766572\n"
"73696F6E203800757064617465642070\n"
"65726D697373696F6E7320746F207665\n"
"7273696F6E2039007570646174656420\n"
"7065726D697373696F6E7320746F2076\n"
"657273696F6E20313000695F636C6965\n"
"6E745F6D61785F636C6F6E657300695F\n"
"6E65656465645F6D6F646966795F706F\n"
"7765725F636C69656E745F6D61785F63\n"
"6C6F6E65730075706461746564207065\n"
"726D697373696F6E7320746F20766572\n"
"73696F6E203131007570646174655F70\n"
"65726D697373696F6E735F31322E7371\n"
"6C006661696C656420746F2075706772\n"
"616465207065726D697373696F6E732C\n"
"2068616C746564210075706461746564\n"
"207065726D697373696F6E7320746F20\n"
"76657273696F6E203132007570646174\n"
"6564207065726D697373696F6E732074\n"
"6F2076657273696F6E20313300757064\n"
"61746564207065726D697373696F6E73\n"
"20746F2076657273696F6E2031340075\n"
"706461746564207065726D697373696F\n"
"6E7320746F2076657273696F6E203135\n"
"0075706461746564207065726D697373\n"
"696F6E7320746F2076657273696F6E20\n"
"31360075706461746564207065726D69\n"
"7373696F6E7320746F2076657273696F\n"
"6E20313700625F7669727475616C7365\n"
"727665725F6D6F646966795F64656661\n"
"756C745F74656D705F6368616E6E656C\n"
"5F64656C6574655F64656C617900695F\n"
"6E65656465645F6D6F646966795F706F\n"
"7765725F7669727475616C7365727665\n"
"725F6D6F646966795F64656661756C74\n"
"5F74656D705F6368616E6E656C5F6465\n"
"6C6574655F64656C617900695F636861\n"
"6E6E656C5F6372656174655F6D6F6469\n"
"66795F74656D705F64656C6574655F64\n"
"656C617900695F6E65656465645F6D6F\n"
"646966795F706F7765725F6368616E6E\n"
"656C5F6372656174655F6D6F64696679\n"
"5F74656D705F64656C6574655F64656C\n"
"61790075706461746564207065726D69\n"
"7373696F6E7320746F2076657273696F\n"
"6E203138007570646174656420706572\n"
"6D697373696F6E7320746F2076657273\n"
"696F6E20313900757064617465506572\n"
"6D697373696F6E73282920756E61626C\n"
"6520746F20696E736572742064617461\n"
"626173652076657273696F6E00736572\n"
"7665725F696E736572742E73716C0073\n"
"65727665725F64656C6574652E73716C\n"
"0062696E64696E67735F6C6973742E73\n"
"716C007365727665725F757064617465\n"
"5F747261666669635F73746174732E73\n"
"716C007365727665725F757064617465\n"
"5F706F72742E73716C00736572766572\n"
"5F7570646174655F6175746F73746172\n"
"742E73716C007365727665725F676574\n"
"5F6279706F72742E73716C0073657276\n"
"65725F7570646174655F6D616368696E\n"
"655F69642E73716C007265766F636174\n"
"696F6E735F696E736572745F62756C6B\n"
"2E73716C007265766F636174696F6E5F\n"
"74797065007265766F636174696F6E5F\n"
"65787069726174696F6E007265766F63\n"
"6174696F6E5F6B6579007265766F6361\n"
"74696F6E735F6765746C6973742E7371\n"
"6C00496E76616C6964207265766F6361\n"
"74696F6E206B657920007265766F6361\n"
"74696F6E735F64656C6574652E73716C\n"
"003B20726561736F6E3A200046696C65\n"
"4D616E6167657200436F756C64206E6F\n"
"742062696E642066696C657472616E73\n"
"666572206C697374656E20706F727420\n"
"6F6E2064656661756C74206164647265\n"
"737365730066696C657472616E736665\n"
"722062696E64206661696C6564206F6E\n"
"20004572726F72207768696C65206765\n"
"7474696E67206C697374656E696E6720\n"
"6164647265737365732E200041737365\n"
"7274696F6E20226D5F62616E64776964\n"
"74685F6C696D69745F73657276657273\n"
"2E66696E64287365727665725F696429\n"
"203D3D206D5F62616E6477696474685F\n"
"6C696D69745F736572766572732E656E\n"
"64282922206661696C6564206174202E\n"
"2E2F2E2E2F2E2E2F2E2E2F732F646570\n"
"732F7465616D737065616B5F73657276\n"
"65725F6C69622F7372632F74735F7365\n"
"727665722F66696C657472616E736665\n"
"722F73657276657266696C656D616E61\n"
"6765722E6370703A0041737365727469\n"
"6F6E2022697420213D206D5F62616E64\n"
"77696474685F6C696D69745F73657276\n"
"6572732E656E64282922206661696C65\n"
"64206174202E2E2F2E2E2F2E2E2F2E2E\n"
"2F732F646570732F7465616D73706561\n"
"6B5F7365727665725F6C69622F737263\n"
"2F74735F7365727665722F66696C6574\n"
"72616E736665722F7365727665726669\n"
"6C656D616E616765722E6370703A0045\n"
"72726F7220616363657074696E672066\n"
"696C657472616E736665722000417373\n"
"657274696F6E202262775F7365727665\n"
"7220213D206D5F62616E647769647468\n"
"5F6C696D69745F736572766572732E65\n"
"6E64282922206661696C656420617420\n"
"2E2E2F2E2E2F2E2E2F2E2E2F732F6465\n"
"70732F7465616D737065616B5F736572\n"
"7665725F6C69622F7372632F74735F73\n"
"65727665722F66696C657472616E7366\n"
"65722F73657276657266696C656D616E\n"
"616765722E6370703A00417373657274\n"
"696F6E202262775F636C69656E742021\n"
"3D2062775F7365727665722D3E736563\n"
"6F6E642E6D5F636C69656E745F62616E\n"
"647769647468732E656E642829222066\n"
"61696C6564206174202E2E2F2E2E2F2E\n"
"2E2F2E2E2F732F646570732F7465616D\n"
"737065616B5F7365727665725F6C6962\n"
"2F7372632F74735F7365727665722F66\n"
"696C657472616E736665722F73657276\n"
"657266696C656D616E616765722E6370\n"
"703A0046696C654D616E616765722054\n"
"696D657220657870697265735F66726F\n"
"6D5F6E6F772072657475726E65642065\n"
"72726F723A2000747269656420746F20\n"
"72656D6F766520697020746861742077\n"
"6173206E6F7420696E206C6973742120\n"
"00636C6F7365006C6F63616C5F656E64\n"
"706F696E740000000000000000000000\n"
"1E000000000000001E00000000000000\n"
"0A00000000000000C800000000000000\n"
"F4010000000000000000000000000000\n"
"25000000000000000000000000000000\n"
"00000000000000000000000000000000\n"
"0000000000000080FFFFFFFFFFFFFF7F\n"
"0100000000000080FDFFFFFFFFFFFF7F");
cout << "Bin length: " << bin.length() << endl;
//0x33E 0x43C
//cout << "Str: " << read_crypted_string(bin.data() + 0x3BA, 0x3BA) << endl;
//cout << "Str: " << read_crypted_string(bin.data() + 0x3DF, 0x3DF) << endl;
//cout << "Str: " << read_crypted_string(bin.data() + 0x405, 0x405) << endl; => virtual server id
//cout << "Str: " << read_crypted_string(bin.data() + 0x43C, 0x43C) << endl; => is duplicated in same instance, shutting down!
for(int index = 0x3E; index < bin.length() + 1; ) {
string str;
read_crypted_string(str, bin.data() + index, index);
cout << "Hex: 0x" << hex << setfill('0') << setw(3) << index << " => " << str << endl;
index += str.length() + 1;
}
}
int main(int argc, char** argv){
threads::timer t("");
srand(system_clock::now().time_since_epoch().count());
init_LTM();
if(register_prng(&sprng_desc) == -1) {
cerr << "could not setup prng" << endl;
return EXIT_FAILURE;
}
if (register_cipher(&rijndael_desc) == -1) {
cerr << "could not setup rijndael" << endl;
return EXIT_FAILURE;
}
string error;
if(false) {
auto base64_tvd = base64::decode("AQCvbHFTQDY/terPeilrp/ECU9xCH5U3xC92lYTNaY/0KQAJFueAazbsgAAAACVUZWFtU3BlYWsgU3lzdGVtcyBHbWJIAADmqdzhKVTai5ZX3LMCOmhH4wOWa7Jrb27PTN6XJSvOaAAKcspvMINAZwAAACRUZWFtU3BlYWsgc3lzdGVtcyBHbWJIAADRNBxg9GPfGFpwf0akzRQs4B/VhIvD+cKAC7vzRAys/AIKfC4AC27CAAYAAAAAW09EQU5JIEHDhyBUQUtJTF0gVHMzLkFtYWNpT2xtYXlhblRheWZhLkNPTSB8IFdFQkRpeW8uQ09NAA==");
istringstream s(base64_tvd);
auto result = LicenseChain::parse(s, error);
if(!result) {
cerr << error << endl;
return 0;
}
result->print();
return 0;
}
cout << base64::encode(license::teamspeak::Anonymous::chain->exportChain()) << endl;
cout << base64::encode(reinterpret_cast<const char *>(license::teamspeak::Anonymous::root_key), 32) << endl;
if(false) {
auto key_plk = license::teamspeak::Anonymous::chain->generatePublicKey();
auto key_prv = license::teamspeak::Anonymous::chain->generatePrivateKey((u_char*) license::teamspeak::Anonymous::root_key, license::teamspeak::Anonymous::root_index);
u_char sign[64];
string message = "Hello World";
ed25519_sign(sign, (u_char*) message.data(), message.length(), (u_char*) key_plk.data(), (u_char*) key_prv.data());
assert(ed25519_verify(sign, (const u_char*) message.data(), message.length(), (u_char*) key_plk.data()));
}
#if false
auto base64_license = "Co4CCsQBAQCvbHFTQDY/terPeilrp/ECU9xCH5U3xC92lYTNaY/0KQAJFueAazbsgAAAACVUZWFtU3BlYWsgU3lzdGVtcyBHbWJIAABVa/g1Aa+EhqDv4a+FKZ+nhnzgNNoG5LZZDMbWP1rUJwAJjrHNL59A2wAAACRUZWFtU3BlYWsgc3lzdGVtcyBHbWJIAAAY8GKBKoLJ2NJT15WG1E3GQ0vl0Ju29Oq3KqYAeEH9GQIJmBqACpU6gAQAAAIAVG9tIFdlYmVyABIgwLAWtDC3hSt8KzSBEksYyaYXxrIybtV207ImV+ugSWkYgAQgCioeVGVhbVNwZWFrIDMgTm9uLVByb2ZpdCBMaWNlbnNlErUBAQCvbHFTQDY/terPeilrp/ECU9xCH5U3xC92lYTNaY/0KQAJFueAazbsgAAAACVUZWFtU3BlYWsgU3lzdGVtcyBHbWJIAABVa/g1Aa+EhqDv4a+FKZ+nhnzgNNoG5LZZDMbWP1rUJwAJjrHNL59A2wAAACRUZWFtU3BlYWsgc3lzdGVtcyBHbWJIAACWjeLEq44YFFAhN9aie2W8g7q3LO2UN/FiHtoGxOoiKAUJjrHNL59A2xpARpdAlulkIKm793JIeJcyxYvvc/tdj4Bx45qcLMISR8qdAOjtgTAV2fWbkdjx0roelL6EAubc3HPij+5Xny1UDw==";
ts::proto::license::teamspeak::License license;
license.ParseFromString(base64::decode(base64_license));
auto chain_sign = LicenseChain::parse(license.sign_chain(), error);
auto chain_license = LicenseChain::parse(license.license().chain(), error);
{
auto key = chain_sign->generatePublicKey();
auto signature = license.license_sign();
auto message = license.license().SerializeAsString();
assert(ed25519_verify((const u_char*) signature.data(), (const u_char*) message.data(), message.length(), (u_char*) key.data()));
}
{
auto key_plk = chain_license->generatePublicKey();
auto key_prv = chain_license->generatePrivateKey((u_char*) license.license().root().data(), 3);
u_char sign[64];
string message = "Hello World";
ed25519_sign(sign, (u_char*) message.data(), message.length(), (u_char*) key_plk.data(), (u_char*) key_prv.data());
assert(ed25519_verify(sign, (const u_char*) message.data(), message.length(), (u_char*) key_plk.data()));
}
chain_sign->print();
chain_license->print();
cout << "version:0" << endl;
cout << "chain:" << base64::encode(chain_license->exportChain()) << endl;
cout << "root_key_prv:" << base64::encode(license.license().root()) << endl;
cout << "root_key_pbl:" << base64::encode((const char*) public_root, 32) << endl;
cout << "root_prv_index:" << to_string(3) << endl;
#endif
//return 0;
/**
* DONT DELET!
*/
//Last checked offset was 1591824411998
//Level 39
//ts::Identity* id = new ts::Identity("4161411998Vginro7hE2a4haFhxRR5+Q1aknrR8Nn1iYAAUZldWVn8XZFVVUnUOVBFeMQJ9HHZaOVh3fEhLShwdXHkie2lza1gDWQltMwhROBNeVTQ2GS5EeFNbA2dBE3QvXU9jJ0VKMXd4YkpxU0tFQUlnYVZaeVVTTTYzSldSLzBRT3Nqd3hSelJBYmRpZ2xsaFhsVTF5L3hVYWgxWT0=");
//Last checked offset was 1330241596003
//Level 48 535525596003
//ts::Identity* id = new ts::Identity("535525596003VMXsJbBqTW70w6dnQUt/X/CiIeth9DEVcVEVUUxBjXUY9RGxSeVN+OhYDHjJSFRoCJHIDd3FjXCgSdH0Gf3RhBlJ0SGYbIEBCVzNcAAITKD9yY30aAgBqOnQIQmVdVQB5L3NVWnZkQUNJUUR2dG5ScnNYdHVWZkFhem9OYVNxTGhjZ2ZwVXhVelFpcGMrSDFSbkIrL3dRPT0=");
/*
for(int i = 0; ltc_ecc_sets[i].size != 0; i++){
cout << " -> " << ltc_ecc_sets[i].name << endl;
}
int targetLevel = 20;
if(argc > 1){
targetLevel = atoi(argv[1]);
}
cout << "Try to find security level " << targetLevel << endl;
ts::Identity* id = new ts::Identity("30895417VvPSPlSzA2mTBpjn7RrJYEq/PmZcNAmhDCXkVdStbXUU2bVxBQ0IHNVAGNTR/CXplN2Z/AwRASSFTQn0GV3NTGX18dXENB2laLQJHKVFUKgl/VHRgD21LUlAHVk18FQcEMGpAXTBxUUNJSEtnTCtOcXJhZDRUSTlKNk04clZXMHkxQjcwWnNsanNsbldOOWo5cjBObA==");
id->improveSecurityLevelMultithreaded(targetLevel, 16, 1000000, 10 * 1000 * 1000U, true);
cout << "New string: " << id->exportIdentity() << endl;
if(true) return false;
*/
/*
string error;
//auto stream = stringstream(base64::decode("AQCvbHFTQDY/terPeilrp/ECU9xCH5U3xC92lYTNaY/0KQAJFueAazbsgAAAACVUZWFtU3BlYWsgU3lzdGVtcyBHbWJIAABhl9gwla/UJp2Eszst9TRVXO/PeE6a6d+CTI6Pg7OEVgAJc5CrL4Nh8gAAACRUZWFtU3BlYWsgc3lzdGVtcyBHbWJIAACvTQIgpv6zmLZq3znh7ygmOSokGFkFjz4bTigrOnetrgIJdIIACdS/gAYAAAAAU29zc2VuU3lzdGVtcy5iaWQAADY7+uV1CQ1niOvYSdGzsu83kPTNWijovr3B78eHGeePIAm98vQJvpu0"));
auto stream = stringstream(base64::decode("AQA1hUFJiiSs0wFXkYuPUJVcDa6XCrZTcsvkB0Ffzz4CmwIITRXgCqeTYAcAAAAgQW5vbnltb3VzAAC4R+5mos+UQ/KCbkpQLMI5WRp4wkQu8e5PZY4zU+/FlyAJwaE8CcJJ/A=="));
auto chain = LicenseChain::parse(stream, error);
if(!chain) {
cerr << "Could not parse: " << error << endl;
return 0;
}
chain->print();
cout << chain->exportChain() << endl;
auto key = chain->generateKey();
cout << " -> " << base64::encode(key) << endl;
cout << hex;
for(const auto& c : key)
cout << " " << (uint32_t) (uint8_t) c << endl;
if(true) return 0;
*/
ts::Identity* identity;
//identity = new ts::Identity("30895417VvPSPlSzA2mTBpjn7RrJYEq/PmZcNAmhDCXkVdStbXUU2bVxBQ0IHNVAGNTR/CXplN2Z/AwRASSFTQn0GV3NTGX18dXENB2laLQJHKVFUKgl/VHRgD21LUlAHVk18FQcEMGpAXTBxUUNJSEtnTCtOcXJhZDRUSTlKNk04clZXMHkxQjcwWnNsanNsbldOOWo5cjBObA==");
identity = new ts::Identity("4161411998Vginro7hE2a4haFhxRR5+Q1aknrR8Nn1iYAAUZldWVn8XZFVVUnUOVBFeMQJ9HHZaOVh3fEhLShwdXHkie2lza1gDWQltMwhROBNeVTQ2GS5EeFNbA2dBE3QvXU9jJ0VKMXd4YkpxU0tFQUlnYVZaeVVTTTYzSldSLzBRT3Nqd3hSelJBYmRpZ2xsaFhsVTF5L3hVYWgxWT0=");
cout << "Private key: " << identity->privateKey() << endl;
cout << "Public key: " << identity->publicKey() << endl;
{
auto hash = digest::sha256("Hello World");
auto sign_rfc = base64::decode("kjEYFcZ4iDxosbhi7bV04nRu0c0JzEIKAACSpLo9G1cJX60Ta46QpoPXTpMg9E8z5pHeZXPVUx75zmWE/LQTuQ==");
int state;
auto result = ecc_verify_hash_rfc7518((u_char*) sign_rfc.data(), sign_rfc.length(), (u_char*) hash.data(), hash.length(), &state, identity->getKeyPair());
__asm__("nop");
}
//identity = ts::Identity::createNew();
//identity->improveSecurityLevel(9);
/*
identity = ts::Identity::createNew();
cout << "Improve" << endl;
identity->improveSecurityLevelMultithreaded(24, 12);
cout << "Got level: " << identity->getSecurityLevel() << " at " << identity->lastValidKeyOffset() << " - " << identity->privateKey() << " - " << identity->publicKey() << endl;
return 0;
*/
auto lastConnect = time_point<system_clock>();
for(int i = 0; i < 1; i++){
//identity = ts::Identity::createNew();
//identity->improveSecurityLevel(9);
//identity = new ts::Identity("4161411998Vginro7hE2a4haFhxRR5+Q1aknrR8Nn1iYAAUZldWVn8XZFVVUnUOVBFeMQJ9HHZaOVh3fEhLShwdXHkie2lza1gDWQltMwhROBNeVTQ2GS5EeFNbA2dBE3QvXU9jJ0VKMXd4YkpxU0tFQUlnYVZaeVVTTTYzSldSLzBRT3Nqd3hSelJBYmRpZ2xsaFhsVTF5L3hVYWgxWT0=");
//identity = new ts::Identity("8008VgvLYFzLLe4lE6oTKyMBPViPHzJVdCGVqAGc7VQQJXkcIRUZcCkFzMDJmHCYBMF1kWmdzRwlQBy4PT3Eie2lzVmUCd39bD3RnNC9gAyRQFh14Z0YGEHJHDg4nGkceNgdWBH9RAE1ZTjlqUUlnV1hUck5vZVdUQ21sNkVYeDNMUm80M0pMU0ZDdkRzWUorR0VkeDE3ZDJLST0=");
//identity = identity->createNew();
//cout << "Improve" << endl;
//identity->improveSecurityLevelMultithreaded(10, 12);
//cout << "Using identity: " << identity->exportIdentity() << endl;
auto connection = new ts::connection::ServerConnection();
while(system_clock::now() - lastConnect < milliseconds(250)) usleep(1000);
lastConnect = system_clock::now();
string host =
"127.0.0.1"
//"51.255.133.2"
//"79.133.54.198"
//"51.255.133.6"
//"79.133.54.207" //GommeHD.net
//"79.133.54.202" //Rewi
//"79.133.54.210" //minesucht.net:9988
//"91.134.112.225" //The Beast (NOT 3.1!)
//"79.133.54.198" //Grifer games:9180
//"52.63.60.28"
//"87.106.252.164"
//"5.1.80.215" //Twerion
//"212.114.60.36" //Domies ts
//"54.36.90.72"
//"87.106.252.164"
//"84.200.62.248"
//"79.133.54.198" //Durchrasten.de:9122
""
;
string port = "9987";
if(argc > 2) {
host = argv[1];
port = argv[2];
}
threads::Thread([connection, host, port, identity]() {
string error;
cout << host << ":" << port << endl;
if(!connection->connect(host, port, identity)){
cerr << "Cant connect!" << endl;
goto sleep;
}
if(!connection->handshake(error)){
cerr << "Cant handschake: " << error << endl;
goto sleep;
}
threads::self::sleep_for(seconds(10 + rand() % 10));
sleep:;
//connection->disconnect();
//delete connection;
}).detach();
//connection->disconnect();
usleep(1000 * 1000);
}
cout << "Done!" << endl;
while(true) usleep(1000 * 2000);
}