sys_ss/RPCN: Add PSID randomisation

This commit is contained in:
derole 2025-10-01 00:58:24 +01:00 committed by Elad
parent 054000fb37
commit 86b7ccef93
4 changed files with 19 additions and 14 deletions

View file

@ -206,12 +206,11 @@ error_code sys_ss_get_console_id(vm::ptr<u8> buf)
return sys_ss_appliance_info_manager(0x19003, buf);
}
error_code sys_ss_get_open_psid(vm::ptr<CellSsOpenPSID> psid)
error_code sys_ss_get_open_psid(vm::ptr<u128> psid)
{
sys_ss.notice("sys_ss_get_open_psid(psid=*0x%x)", psid);
psid->high = g_cfg.sys.console_psid_high;
psid->low = g_cfg.sys.console_psid_low;
*psid = g_cfg.sys.console_psid.get();
return CELL_OK;
}
@ -259,8 +258,8 @@ error_code sys_ss_appliance_info_manager(u32 code, vm::ptr<u8> buffer)
case 0x19005:
{
// AIM_get_open_ps_id
be_t<u64> psid[2] = { +g_cfg.sys.console_psid_high, +g_cfg.sys.console_psid_low };
std::memcpy(buffer.get_ptr(), psid, 16);
const be_t<u128> psid = g_cfg.sys.console_psid.get();
std::memcpy(buffer.get_ptr(), &psid, 16);
break;
}
case 0x19006:

View file

@ -13,16 +13,10 @@ enum sys_ss_rng_error : u32
SYS_SS_RTC_ERROR_UNK = 0x8001050f,
};
struct CellSsOpenPSID
{
be_t<u64> high;
be_t<u64> low;
};
error_code sys_ss_random_number_generator(u64 pkg_id, vm::ptr<void> buf, u64 size);
error_code sys_ss_access_control_engine(u64 pkg_id, u64 a2, u64 a3);
error_code sys_ss_get_console_id(vm::ptr<u8> buf);
error_code sys_ss_get_open_psid(vm::ptr<CellSsOpenPSID> psid);
error_code sys_ss_get_open_psid(vm::ptr<u128> psid);
error_code sys_ss_appliance_info_manager(u32 code, vm::ptr<u8> buffer);
error_code sys_ss_get_cache_of_product_mode(vm::ptr<u8> ptr);
error_code sys_ss_secure_rtc(u64 cmd, u64 a2, u64 a3, u64 a4);

View file

@ -3,6 +3,8 @@
#include "util/sysinfo.hpp"
#include <random>
cfg_root g_cfg{};
cfg_root g_backup_cfg{};
@ -16,3 +18,13 @@ std::string cfg_root::node_sys::get_random_system_name()
std::srand(static_cast<u32>(std::time(nullptr)));
return "RPCS3-" + std::to_string(100 + std::rand() % 899);
}
u128 cfg_root::node_sys::get_random_psid()
{
std::random_device rnd;
std::mt19937_64 prng(rnd());
std::uniform_int_distribution<u64> uniformDist;
u128 result = uniformDist(prng);
result += u128{uniformDist(prng)} << 64;
return result;
}

View file

@ -296,6 +296,7 @@ struct cfg_root : cfg::node
struct node_sys : cfg::node
{
static std::string get_random_system_name();
static u128 get_random_psid();
node_sys(cfg::node* _this) : cfg::node(_this, "System") {}
@ -307,8 +308,7 @@ struct cfg_root : cfg::node
cfg::_enum<time_format> time_fmt{ this, "Time Format", time_format::clock24 };
cfg::_int<-60*60*24*365*100LL, 60*60*24*365*100LL> console_time_offset{ this, "Console time offset (s)", 0 }; // console time offset, limited to +/-100years
cfg::string system_name{this, "System Name", get_random_system_name()};
cfg::uint<0, umax> console_psid_high{this, "PSID high"};
cfg::uint<0, umax> console_psid_low{this, "PSID low"};
cfg::uint128 console_psid{this, "Console PSID", get_random_psid()};
cfg::string hdd_model{this, "HDD Model Name", ""};
cfg::string hdd_serial{this, "HDD Serial Number", ""};
cfg::node_map_entry sup_argv{ this, "Process ARGV" };