Merge pull request #331 from AttorneyOnline/no-fantacrypt
Drop AO1 compatibility
This commit is contained in:
commit
dd085c8958
@ -15,6 +15,9 @@ HEADERS += $$files($$PWD/include/*.h)
|
|||||||
|
|
||||||
LIBS += -L$$PWD/lib
|
LIBS += -L$$PWD/lib
|
||||||
|
|
||||||
|
# Uncomment for verbose network logging
|
||||||
|
# DEFINES += DEBUG_NETWORK
|
||||||
|
|
||||||
# Uncomment to enable Discord Rich Presence
|
# Uncomment to enable Discord Rich Presence
|
||||||
# DEFINES += DISCORD
|
# DEFINES += DISCORD
|
||||||
|
|
||||||
|
@ -63,14 +63,10 @@ public:
|
|||||||
|
|
||||||
/////////////////server metadata//////////////////
|
/////////////////server metadata//////////////////
|
||||||
|
|
||||||
unsigned int s_decryptor = 5;
|
|
||||||
bool encryption_needed = true;
|
|
||||||
|
|
||||||
bool yellow_text_enabled = false;
|
bool yellow_text_enabled = false;
|
||||||
bool prezoom_enabled = false;
|
bool prezoom_enabled = false;
|
||||||
bool flipping_enabled = false;
|
bool flipping_enabled = false;
|
||||||
bool custom_objection_enabled = false;
|
bool custom_objection_enabled = false;
|
||||||
bool improved_loading_enabled = false;
|
|
||||||
bool desk_mod_enabled = false;
|
bool desk_mod_enabled = false;
|
||||||
bool evidence_enabled = false;
|
bool evidence_enabled = false;
|
||||||
bool cccc_ic_support_enabled = false;
|
bool cccc_ic_support_enabled = false;
|
||||||
|
@ -15,14 +15,10 @@ public:
|
|||||||
QStringList &get_contents() { return m_contents; }
|
QStringList &get_contents() { return m_contents; }
|
||||||
QString to_string();
|
QString to_string();
|
||||||
|
|
||||||
void encrypt_header(unsigned int p_key);
|
|
||||||
void decrypt_header(unsigned int p_key);
|
|
||||||
|
|
||||||
void net_encode();
|
void net_encode();
|
||||||
void net_decode();
|
void net_decode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool encrypted = false;
|
|
||||||
|
|
||||||
QString m_header;
|
QString m_header;
|
||||||
QStringList m_contents;
|
QStringList m_contents;
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
#ifndef ENCRYPTION_FUNCTIONS_H
|
|
||||||
#define ENCRYPTION_FUNCTIONS_H
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#include <QVector>
|
|
||||||
#include <cstddef>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <sstream>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
QString fanta_encrypt(QString p_input, unsigned int key);
|
|
||||||
QString fanta_decrypt(QString p_input, unsigned int key);
|
|
||||||
|
|
||||||
#endif // ENCRYPTION_FUNCTIONS_H
|
|
@ -1,16 +0,0 @@
|
|||||||
#ifndef HEX_OPERATIONS_H
|
|
||||||
#define HEX_OPERATIONS_H
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <bitset>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace omni {
|
|
||||||
std::string int_to_hex(unsigned int input);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // HEX_OPERATIONS_H
|
|
@ -1,7 +1,5 @@
|
|||||||
#include "aopacket.h"
|
#include "aopacket.h"
|
||||||
|
|
||||||
#include "encryption_functions.h"
|
|
||||||
|
|
||||||
AOPacket::AOPacket(QString p_packet_string)
|
AOPacket::AOPacket(QString p_packet_string)
|
||||||
{
|
{
|
||||||
QStringList packet_contents = p_packet_string.split("#");
|
QStringList packet_contents = p_packet_string.split("#");
|
||||||
@ -31,26 +29,10 @@ QString AOPacket::to_string()
|
|||||||
|
|
||||||
f_string += "#%";
|
f_string += "#%";
|
||||||
|
|
||||||
if (encrypted)
|
|
||||||
return "#" + f_string;
|
|
||||||
else
|
|
||||||
return f_string;
|
return f_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOPacket::encrypt_header(unsigned int p_key)
|
|
||||||
{
|
|
||||||
m_header = fanta_encrypt(m_header, p_key);
|
|
||||||
|
|
||||||
encrypted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AOPacket::decrypt_header(unsigned int p_key)
|
|
||||||
{
|
|
||||||
m_header = fanta_decrypt(m_header, p_key);
|
|
||||||
|
|
||||||
encrypted = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AOPacket::net_encode()
|
void AOPacket::net_encode()
|
||||||
{
|
{
|
||||||
for (int n_element = 0; n_element < m_contents.size(); ++n_element) {
|
for (int n_element = 0; n_element < m_contents.size(); ++n_element) {
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
#include "encryption_functions.h"
|
|
||||||
|
|
||||||
#include "hex_functions.h"
|
|
||||||
|
|
||||||
QString fanta_encrypt(QString temp_input, unsigned int p_key)
|
|
||||||
{
|
|
||||||
// using standard stdlib types is actually easier here because of implicit
|
|
||||||
// char<->int conversion which in turn makes encryption arithmetic easier
|
|
||||||
|
|
||||||
unsigned int key = p_key;
|
|
||||||
unsigned int C1 = 53761;
|
|
||||||
unsigned int C2 = 32618;
|
|
||||||
|
|
||||||
QVector<uint_fast8_t> temp_result;
|
|
||||||
std::string input = temp_input.toUtf8().constData();
|
|
||||||
|
|
||||||
for (unsigned int pos = 0; pos < input.size(); ++pos) {
|
|
||||||
uint_fast8_t output = input.at(pos) ^ (key >> 8) % 256;
|
|
||||||
temp_result.append(output);
|
|
||||||
key = (temp_result.at(pos) + key) * C1 + C2;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string result = "";
|
|
||||||
|
|
||||||
for (uint_fast8_t i_int : temp_result) {
|
|
||||||
result += omni::int_to_hex(i_int);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString final_result = QString::fromStdString(result);
|
|
||||||
|
|
||||||
return final_result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString fanta_decrypt(QString temp_input, unsigned int key)
|
|
||||||
{
|
|
||||||
std::string input = temp_input.toUtf8().constData();
|
|
||||||
|
|
||||||
QVector<unsigned int> unhexed_vector;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < input.length(); i += 2) {
|
|
||||||
std::string byte = input.substr(i, 2);
|
|
||||||
unsigned int hex_int = strtoul(byte.c_str(), nullptr, 16);
|
|
||||||
unhexed_vector.append(hex_int);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int C1 = 53761;
|
|
||||||
unsigned int C2 = 32618;
|
|
||||||
|
|
||||||
std::string result = "";
|
|
||||||
|
|
||||||
for (int pos = 0; pos < unhexed_vector.size(); ++pos) {
|
|
||||||
unsigned char output = unhexed_vector.at(pos) ^ (key >> 8) % 256;
|
|
||||||
result += output;
|
|
||||||
key = (unhexed_vector.at(pos) + key) * C1 + C2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString::fromStdString(result);
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
#include "hex_functions.h"
|
|
||||||
|
|
||||||
namespace omni {
|
|
||||||
std::string int_to_hex(unsigned int input)
|
|
||||||
{
|
|
||||||
if (input > 255)
|
|
||||||
return "FF";
|
|
||||||
|
|
||||||
std::stringstream stream;
|
|
||||||
stream << std::setfill('0') << std::setw(sizeof(char) * 2) << std::hex
|
|
||||||
<< input;
|
|
||||||
std::string result(stream.str());
|
|
||||||
std::transform(result.begin(), result.end(), result.begin(), ::toupper);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
} // namespace omni
|
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "courtroom.h"
|
#include "courtroom.h"
|
||||||
#include "debug_functions.h"
|
#include "debug_functions.h"
|
||||||
#include "encryption_functions.h"
|
|
||||||
#include "hardware_functions.h"
|
#include "hardware_functions.h"
|
||||||
#include "lobby.h"
|
#include "lobby.h"
|
||||||
#include "networkmanager.h"
|
#include "networkmanager.h"
|
||||||
@ -120,16 +119,11 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
|||||||
if (f_contents.size() == 0)
|
if (f_contents.size() == 0)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
// you may ask where 322 comes from. that would be a good question.
|
|
||||||
s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt();
|
|
||||||
|
|
||||||
// default(legacy) values
|
// default(legacy) values
|
||||||
encryption_needed = true;
|
|
||||||
yellow_text_enabled = false;
|
yellow_text_enabled = false;
|
||||||
prezoom_enabled = false;
|
prezoom_enabled = false;
|
||||||
flipping_enabled = false;
|
flipping_enabled = false;
|
||||||
custom_objection_enabled = false;
|
custom_objection_enabled = false;
|
||||||
improved_loading_enabled = false;
|
|
||||||
desk_mod_enabled = false;
|
desk_mod_enabled = false;
|
||||||
evidence_enabled = false;
|
evidence_enabled = false;
|
||||||
cccc_ic_support_enabled = false;
|
cccc_ic_support_enabled = false;
|
||||||
@ -140,10 +134,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
|||||||
additive_enabled = false;
|
additive_enabled = false;
|
||||||
effects_enabled = false;
|
effects_enabled = false;
|
||||||
|
|
||||||
// workaround for tsuserver4
|
|
||||||
if (f_contents.at(0) == "NOENCRYPT")
|
|
||||||
encryption_needed = false;
|
|
||||||
|
|
||||||
QString f_hdid;
|
QString f_hdid;
|
||||||
f_hdid = get_hdid();
|
f_hdid = get_hdid();
|
||||||
|
|
||||||
@ -176,12 +166,10 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (header == "FL") {
|
else if (header == "FL") {
|
||||||
// encryption_needed = true;
|
|
||||||
yellow_text_enabled = false;
|
yellow_text_enabled = false;
|
||||||
prezoom_enabled = false;
|
prezoom_enabled = false;
|
||||||
flipping_enabled = false;
|
flipping_enabled = false;
|
||||||
custom_objection_enabled = false;
|
custom_objection_enabled = false;
|
||||||
improved_loading_enabled = false;
|
|
||||||
desk_mod_enabled = false;
|
desk_mod_enabled = false;
|
||||||
evidence_enabled = false;
|
evidence_enabled = false;
|
||||||
cccc_ic_support_enabled = false;
|
cccc_ic_support_enabled = false;
|
||||||
@ -199,10 +187,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
|||||||
flipping_enabled = true;
|
flipping_enabled = true;
|
||||||
if (f_packet.contains("customobjections", Qt::CaseInsensitive))
|
if (f_packet.contains("customobjections", Qt::CaseInsensitive))
|
||||||
custom_objection_enabled = true;
|
custom_objection_enabled = true;
|
||||||
if (f_packet.contains("fastloading", Qt::CaseInsensitive))
|
|
||||||
improved_loading_enabled = true;
|
|
||||||
if (f_packet.contains("noencryption", Qt::CaseInsensitive))
|
|
||||||
encryption_needed = false;
|
|
||||||
if (f_packet.contains("deskmod", Qt::CaseInsensitive))
|
if (f_packet.contains("deskmod", Qt::CaseInsensitive))
|
||||||
desk_mod_enabled = true;
|
desk_mod_enabled = true;
|
||||||
if (f_packet.contains("evidence", Qt::CaseInsensitive))
|
if (f_packet.contains("evidence", Qt::CaseInsensitive))
|
||||||
@ -283,11 +267,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
|||||||
|
|
||||||
AOPacket *f_packet;
|
AOPacket *f_packet;
|
||||||
|
|
||||||
if (improved_loading_enabled)
|
|
||||||
f_packet = new AOPacket("RC#%");
|
f_packet = new AOPacket("RC#%");
|
||||||
else
|
|
||||||
f_packet = new AOPacket("askchar2#%");
|
|
||||||
|
|
||||||
send_server_packet(f_packet);
|
send_server_packet(f_packet);
|
||||||
|
|
||||||
// Remove any characters not accepted in folder names for the server_name
|
// Remove any characters not accepted in folder names for the server_name
|
||||||
@ -308,152 +288,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
|||||||
discord->state_server(server_name.toStdString(),
|
discord->state_server(server_name.toStdString(),
|
||||||
hash.result().toBase64().toStdString());
|
hash.result().toBase64().toStdString());
|
||||||
}
|
}
|
||||||
else if (header == "CI") {
|
|
||||||
if (!courtroom_constructed)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
for (int n_element = 0; n_element < f_contents.size(); n_element += 2) {
|
|
||||||
if (f_contents.at(n_element).toInt() != loaded_chars)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// this means we are on the last element and checking n + 1 element will
|
|
||||||
// be game over so
|
|
||||||
if (n_element == f_contents.size() - 1)
|
|
||||||
break;
|
|
||||||
|
|
||||||
QStringList sub_elements = f_contents.at(n_element + 1).split("&");
|
|
||||||
if (sub_elements.size() < 2)
|
|
||||||
break;
|
|
||||||
|
|
||||||
char_type f_char;
|
|
||||||
f_char.name = sub_elements.at(0);
|
|
||||||
f_char.description = sub_elements.at(1);
|
|
||||||
f_char.evidence_string = sub_elements.at(3);
|
|
||||||
// temporary. the CharsCheck packet sets this properly
|
|
||||||
f_char.taken = false;
|
|
||||||
|
|
||||||
++loaded_chars;
|
|
||||||
|
|
||||||
w_lobby->set_loading_text(tr("Loading chars:\n%1/%2")
|
|
||||||
.arg(QString::number(loaded_chars))
|
|
||||||
.arg(QString::number(char_list_size)));
|
|
||||||
|
|
||||||
w_courtroom->append_char(f_char);
|
|
||||||
|
|
||||||
int total_loading_size =
|
|
||||||
char_list_size * 2 + evidence_list_size + music_list_size;
|
|
||||||
int loading_value = int(
|
|
||||||
((loaded_chars + generated_chars + loaded_music + loaded_evidence) /
|
|
||||||
static_cast<double>(total_loading_size)) *
|
|
||||||
100);
|
|
||||||
w_lobby->set_loading_value(loading_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (improved_loading_enabled)
|
|
||||||
send_server_packet(new AOPacket("RE#%"));
|
|
||||||
else {
|
|
||||||
QString next_packet_number =
|
|
||||||
QString::number(((loaded_chars - 1) / 10) + 1);
|
|
||||||
send_server_packet(new AOPacket("AN#" + next_packet_number + "#%"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (header == "EI") {
|
|
||||||
if (!courtroom_constructed)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
// +1 because evidence starts at 1 rather than 0 for whatever reason
|
|
||||||
// enjoy fanta
|
|
||||||
if (f_contents.at(0).toInt() != loaded_evidence + 1)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
if (f_contents.size() < 2)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
QStringList sub_elements = f_contents.at(1).split("&");
|
|
||||||
if (sub_elements.size() < 4)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
evi_type f_evi;
|
|
||||||
f_evi.name = sub_elements.at(0);
|
|
||||||
f_evi.description = sub_elements.at(1);
|
|
||||||
// no idea what the number at position 2 is. probably an identifier?
|
|
||||||
f_evi.image = sub_elements.at(3);
|
|
||||||
|
|
||||||
++loaded_evidence;
|
|
||||||
|
|
||||||
w_lobby->set_loading_text(tr("Loading evidence:\n%1/%2")
|
|
||||||
.arg(QString::number(loaded_evidence))
|
|
||||||
.arg(QString::number(evidence_list_size)));
|
|
||||||
|
|
||||||
w_courtroom->append_evidence(f_evi);
|
|
||||||
|
|
||||||
int total_loading_size =
|
|
||||||
char_list_size * 2 + evidence_list_size + music_list_size;
|
|
||||||
int loading_value =
|
|
||||||
int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) /
|
|
||||||
static_cast<double>(total_loading_size)) *
|
|
||||||
100);
|
|
||||||
w_lobby->set_loading_value(loading_value);
|
|
||||||
|
|
||||||
QString next_packet_number = QString::number(loaded_evidence);
|
|
||||||
send_server_packet(new AOPacket("AE#" + next_packet_number + "#%"));
|
|
||||||
}
|
|
||||||
else if (header == "EM") {
|
|
||||||
if (!courtroom_constructed)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
bool musics_time = false;
|
|
||||||
int areas = 0;
|
|
||||||
|
|
||||||
for (int n_element = 0; n_element < f_contents.size(); n_element += 2) {
|
|
||||||
if (f_contents.at(n_element).toInt() != loaded_music)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (n_element == f_contents.size() - 1)
|
|
||||||
break;
|
|
||||||
|
|
||||||
QString f_music = f_contents.at(n_element + 1);
|
|
||||||
|
|
||||||
++loaded_music;
|
|
||||||
|
|
||||||
w_lobby->set_loading_text(tr("Loading music:\n%1/%2")
|
|
||||||
.arg(QString::number(loaded_music))
|
|
||||||
.arg(QString::number(music_list_size)));
|
|
||||||
|
|
||||||
if (musics_time) {
|
|
||||||
w_courtroom->append_music(f_music);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (f_music.endsWith(".wav") || f_music.endsWith(".mp3") ||
|
|
||||||
f_music.endsWith(".mp4") || f_music.endsWith(".ogg") ||
|
|
||||||
f_music.endsWith(".opus")) {
|
|
||||||
musics_time = true;
|
|
||||||
areas--;
|
|
||||||
w_courtroom->fix_last_area();
|
|
||||||
w_courtroom->append_music(f_music);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
w_courtroom->append_area(f_music);
|
|
||||||
areas++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int area_n = 0; area_n < areas; area_n++) {
|
|
||||||
w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown");
|
|
||||||
}
|
|
||||||
|
|
||||||
int total_loading_size =
|
|
||||||
char_list_size * 2 + evidence_list_size + music_list_size;
|
|
||||||
int loading_value = int(
|
|
||||||
((loaded_chars + generated_chars + loaded_music + loaded_evidence) /
|
|
||||||
static_cast<double>(total_loading_size)) *
|
|
||||||
100);
|
|
||||||
w_lobby->set_loading_value(loading_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString next_packet_number = QString::number(((loaded_music - 1) / 10) + 1);
|
|
||||||
send_server_packet(new AOPacket("AM#" + next_packet_number + "#%"));
|
|
||||||
}
|
|
||||||
else if (header == "CharsCheck") {
|
else if (header == "CharsCheck") {
|
||||||
if (!courtroom_constructed)
|
if (!courtroom_constructed)
|
||||||
goto end;
|
goto end;
|
||||||
@ -750,19 +584,9 @@ void AOApplication::send_server_packet(AOPacket *p_packet, bool encoded)
|
|||||||
|
|
||||||
QString f_packet = p_packet->to_string();
|
QString f_packet = p_packet->to_string();
|
||||||
|
|
||||||
if (encryption_needed) {
|
|
||||||
#ifdef DEBUG_NETWORK
|
|
||||||
qDebug() << "S(e):" << f_packet;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
p_packet->encrypt_header(s_decryptor);
|
|
||||||
f_packet = p_packet->to_string();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
#ifdef DEBUG_NETWORK
|
#ifdef DEBUG_NETWORK
|
||||||
qDebug() << "S:" << f_packet;
|
qDebug() << "S:" << f_packet;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
net_manager->ship_server_packet(f_packet);
|
net_manager->ship_server_packet(f_packet);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user