From 58309c2cf84aec4b555de3df7d897f918d877642 Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Sun, 12 Feb 2023 14:45:41 -0500 Subject: [PATCH] add configurable fake IP to iauth --- amcus/config.c | 1 + amcus/config.h | 2 ++ amcus/iauth.c | 43 +++++++++++++++++++++++++++++++++++-------- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/amcus/config.c b/amcus/config.c index 6e04538..37d3e9a 100644 --- a/amcus/config.c +++ b/amcus/config.c @@ -15,4 +15,5 @@ void amcus_config_load(struct amcus_config *cfg, const wchar_t *filename) GetPrivateProfileStringW(L"amcus", L"am_serial", L"ABGN6789012", cfg->am_serial, _countof(cfg->am_serial), filename); es3sec_config_load(&cfg->dongle, filename); + netenv_config_load(&cfg->netenv, filename); } diff --git a/amcus/config.h b/amcus/config.h index c671ef0..a1bb015 100644 --- a/amcus/config.h +++ b/amcus/config.h @@ -3,6 +3,7 @@ #include #include #include "platform/es3sec.h" +#include "platform/netenv.h" struct amcus_config { bool enable; @@ -13,6 +14,7 @@ struct amcus_config { wchar_t server_host[257]; wchar_t am_serial[12]; struct es3sec_config dongle; + struct netenv_config netenv; }; void amcus_config_load(struct amcus_config *cfg, const wchar_t *filename); diff --git a/amcus/iauth.c b/amcus/iauth.c index 1903b33..5703843 100644 --- a/amcus/iauth.c +++ b/amcus/iauth.c @@ -8,10 +8,38 @@ #include "util/dprintf.h" static struct amcus_config config; -// 16 0 5 6 9 +static char local_ip[16]; +static char subnet[16]; +static char router_ip[16]; +static char auth_srv_ip[16]; + void iauth_set_config(struct amcus_config *cfg) { memcpy(&config, cfg, sizeof(*cfg)); + uint32_t netenv_ip_prefix = cfg->netenv.subnet; + uint32_t netenv_ip_iface = cfg->netenv.subnet | cfg->netenv.addr_suffix; + uint32_t netenv_ip_router = cfg->netenv.subnet | cfg->netenv.router_suffix; + + sprintf_s(local_ip, _countof(local_ip), + "%i.%i.%i.%i", + (uint8_t) (netenv_ip_iface >> 24), + (uint8_t) (netenv_ip_iface >> 16), + (uint8_t) (netenv_ip_iface >> 8), + (uint8_t) (netenv_ip_iface )); + + sprintf_s(subnet, _countof(subnet), + "%i.%i.%i.%i", + (uint8_t) (netenv_ip_prefix >> 24), + (uint8_t) (netenv_ip_prefix >> 16), + (uint8_t) (netenv_ip_prefix >> 8), + (uint8_t) (netenv_ip_prefix )); + + sprintf_s(router_ip, _countof(router_ip), + "%i.%i.%i.%i", + (uint8_t) (netenv_ip_router >> 24), + (uint8_t) (netenv_ip_router >> 16), + (uint8_t) (netenv_ip_router >> 8), + (uint8_t) (netenv_ip_router )); } static ULONG REF_COUNT = 0; @@ -165,13 +193,12 @@ static HRESULT STDMETHODCALLTYPE IAuth_GetCabinetConfig(IAuth FAR *This, struct strcpy_s(arr->pcbid, sizeof(arr->pcbid), am_serial); strcpy_s(arr->dongle_serial, sizeof(arr->dongle_serial), dongle_serial); - // TODO: Load fake IP addresses from config - strcpy_s(arr->shop_router_ip, sizeof(arr->shop_router_ip), "192.168.123.254"); // router ip - strcpy_s(arr->auth_server_ip, sizeof(arr->auth_server_ip), "192.168.1.114"); // "default" in dnshook - strcpy_s(arr->local_ip, sizeof(arr->local_ip), "192.168.123.11"); // fake ip - strcpy_s(arr->subnet_mask, sizeof(arr->subnet_mask), "255.255.225.0"); // fake subnet - strcpy_s(arr->gateway, sizeof(arr->gateway), "192.168.123.254"); // router ip - strcpy_s(arr->primary_dns, sizeof(arr->primary_dns), "192.168.1.3"); // ?? + strcpy_s(arr->shop_router_ip, sizeof(arr->shop_router_ip), router_ip); // router ip + strcpy_s(arr->auth_server_ip, sizeof(arr->auth_server_ip), router_ip); // "default" in dnshook + strcpy_s(arr->local_ip, sizeof(arr->local_ip), local_ip); // fake ip + strcpy_s(arr->subnet_mask, sizeof(arr->subnet_mask), subnet); // fake subnet + strcpy_s(arr->gateway, sizeof(arr->gateway), router_ip); // router ip + strcpy_s(arr->primary_dns, sizeof(arr->primary_dns), router_ip); // Pokken doesn't read this it seems arr->hop_count = 1; arr->line_type = TYPE_FFT;