Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add target ID plugin for 5.05 and 6.72 #129

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion kernel/src/Plugins/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <Plugins/MorpheusEnabler/MorpheusEnabler.hpp>
#include <Plugins/RemotePlayEnabler/RemotePlayEnabler.hpp>
#include <Plugins/SyscallGuard/SyscallGuardPlugin.hpp>
#include <Plugins/TargetID/TargetID.hpp>
#include <Plugins/TTYRedirector/TTYRedirector.hpp>

// Utility functions
Expand All @@ -39,7 +40,8 @@ PluginManager::PluginManager() :
m_MorpheusEnabler(nullptr),
m_RemotePlayEnabler(nullptr),
m_SyscallGuard(nullptr),
m_TTYRedirector(nullptr)
m_TTYRedirector(nullptr),
m_TargetID(nullptr)
{
// Hushes error: private field 'm_FileManager' is not used [-Werror,-Wunused-private-field]
m_Logger = nullptr;
Expand Down Expand Up @@ -158,6 +160,15 @@ bool PluginManager::OnLoad()
s_Success = false;
break;
}

// Initialize TargetID/TargetID
m_TargetID = new Mira::Plugins::TargetID();
if (m_TargetID == nullptr)
{
WriteLog(LL_Error, "could not allocate target ID spoofer.");
s_Success = false;
break;
}
} while (false);

if (m_Debugger)
Expand Down Expand Up @@ -220,6 +231,12 @@ bool PluginManager::OnLoad()
WriteLog(LL_Error, "could not load tty redirector.");
}

if (m_TargetID)
{
if (!m_TargetID->OnLoad())
WriteLog(LL_Error, "could not load target ID spoofer.");
}

return s_Success;
}

Expand Down Expand Up @@ -401,6 +418,18 @@ bool PluginManager::OnUnload()
m_TTYRedirector = nullptr;
}

// Delete target ID spoofer
if (m_TargetID)
{
WriteLog(LL_Debug, "unloading target ID spoofer");
if (!m_TargetID->OnUnload())
WriteLog(LL_Error, "target ID spoofer could not unload");

// Free TargetID
delete m_TargetID;
m_TargetID = nullptr;
}

WriteLog(LL_Debug, "All Plugins Unloaded %s.", s_AllUnloadSuccess ? "successfully" : "un-successfully");
return s_AllUnloadSuccess;
}
Expand Down Expand Up @@ -497,6 +526,13 @@ bool PluginManager::OnSuspend()
WriteLog(LL_Error, "tty redirector suspend failed");
}

// Suspend TargetID (does nothing)
if (m_TargetID)
{
if (!m_TargetID->OnSuspend())
WriteLog(LL_Error, "target ID spoofer suspend failed");
}

// Return final status
return s_AllSuccess;
}
Expand Down Expand Up @@ -564,6 +600,13 @@ bool PluginManager::OnResume()
WriteLog(LL_Error, "tty redirector resume failed");
}

WriteLog(LL_Debug, "resuming target ID spoofer");
if (m_TargetID)
{
if (!m_TargetID->OnResume())
WriteLog(LL_Error, "target ID spoofer resume failed");
}

// Iterate through all of the plugins
for (auto i = 0; i < m_Plugins.size(); ++i)
{
Expand Down
2 changes: 2 additions & 0 deletions kernel/src/Plugins/PluginManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace Mira
Mira::Utils::IModule* m_RemotePlayEnabler;
Mira::Utils::IModule* m_SyscallGuard;
Mira::Utils::IModule* m_TTYRedirector;
Mira::Utils::IModule* m_TargetID;

public:
Mira::Utils::IModule* GetDebugger() { return m_Debugger; }
Expand All @@ -53,6 +54,7 @@ namespace Mira
Mira::Utils::IModule* GetMorpheusEnabler() { return m_MorpheusEnabler; }
Mira::Utils::IModule* GetRemotePlayEnabler() { return m_RemotePlayEnabler; }
Mira::Utils::IModule* GetSyscallGuard() { return m_SyscallGuard; }
Mira::Utils::IModule* GetTargetId() { return m_TargetID; }
};
}
}
57 changes: 57 additions & 0 deletions kernel/src/Plugins/TargetID/TargetID.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "TargetID.hpp"
#include <Utils/Kdlsym.hpp>
#include <Utils/Logger.hpp>

using namespace Mira::Plugins;

TargetID::TargetID()
{

}

TargetID::~TargetID()
{

}

void TargetID::SpoofTo(char targetId_input)
{
targetId_desired = targetId_input;

if (targetId_orig == 0x00)
targetId_orig = *(char *)kdlsym(target_id);

if (targetId_orig == targetId_input)
{
WriteLog(LL_Error, "Target ID is already %02hhX", targetId_input);
return;
}

WriteLog(LL_Warn, "spoofing target ID to %02hhX", targetId_input);
*(char *)kdlsym(target_id) = targetId_input;
WriteLog(LL_Info, "target ID spoofed to %02hhX", targetId_input);
}

bool TargetID::OnLoad()
{
SpoofTo(targetId_desired);
return true;
}

bool TargetID::OnUnload()
{
SpoofTo(targetId_orig);
return true;
}

bool TargetID::OnSuspend()
{
SpoofTo(targetId_orig);
return true;
}

bool TargetID::OnResume()
{
SpoofTo(targetId_desired);
return true;
}
26 changes: 26 additions & 0 deletions kernel/src/Plugins/TargetID/TargetID.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once
#include <Utils/IModule.hpp>
#include <Utils/Types.hpp>

namespace Mira
{
namespace Plugins
{
class TargetID : public Mira::Utils::IModule
{
private:
char targetId_orig = 0x00;
char targetId_desired = 0x82; // DEX
public:
TargetID();
virtual ~TargetID();

virtual const char* GetName() override { return "TargetID"; }
virtual bool OnLoad() override;
virtual bool OnUnload() override;
virtual bool OnSuspend() override;
virtual bool OnResume() override;
void SpoofTo(char targetId_input);
};
}
}
1 change: 1 addition & 0 deletions kernel/src/Utils/Kdlsym/Orbis405.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ for the platforms that do enable kernel ASLR (Address Space Layout Randomization
#define kdlsym_addr_sys_unmount 0x00202560
#define kdlsym_addr_sys_wait4 0x00049BA0
#define kdlsym_addr_sys_write 0x00166D70
#define kdlsym_addr_target_id 0x0200151D
#define kdlsym_addr_trap_fatal 0x000EC770
#define kdlsym_addr_utilUSleep 0x0062A3E0
#define kdlsym_addr_vm_fault_disable_pagefaults 0x000C8FB0
Expand Down
1 change: 1 addition & 0 deletions kernel/src/Utils/Kdlsym/Orbis455.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ for the platforms that do enable kernel ASLR (Address Space Layout Randomization
#define kdlsym_addr_sys_unmount 0x000DB500
#define kdlsym_addr_sys_wait4 0x0015C500
#define kdlsym_addr_sys_write 0x0005F1A0
#define kdlsym_addr_target_id 0x01B6D08D
#define kdlsym_addr_trap_fatal 0x003DBD20
#define kdlsym_addr_utilUSleep 0x0065F290
#define kdlsym_addr_vm_fault_disable_pagefaults 0x002A19F0
Expand Down
1 change: 1 addition & 0 deletions kernel/src/Utils/Kdlsym/Orbis474.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ for the platforms that do enable kernel ASLR (Address Space Layout Randomization
#define kdlsym_addr_sys_unmount 0x000DAB60
#define kdlsym_addr_sys_wait4 0x0015BB90
#define kdlsym_addr_sys_write 0x0005E780
#define kdlsym_addr_target_id 0x01B7D08D
#define kdlsym_addr_trap_fatal 0x003DCBD0
#define kdlsym_addr_utilUSleep 0x006626A0
#define kdlsym_addr_vm_fault_disable_pagefaults 0x002A3BA0
Expand Down
1 change: 1 addition & 0 deletions kernel/src/Utils/Kdlsym/Orbis501.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ for the platforms that do enable kernel ASLR (Address Space Layout Randomization
#define kdlsym_addr_sys_unmount 0x001DFB60
#define kdlsym_addr_sys_wait4 0x00035470
#define kdlsym_addr_sys_write 0x00152EB0
#define kdlsym_addr_target_id 0x01CD068D
#define kdlsym_addr_trap_fatal 0x00171470
#define kdlsym_addr_utilUSleep 0x00658850
#define kdlsym_addr_vm_fault_disable_pagefaults 0x002A6950
Expand Down
1 change: 1 addition & 0 deletions kernel/src/Utils/Kdlsym/Orbis503.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ for the platforms that do enable kernel ASLR (Address Space Layout Randomization
#define kdlsym_addr_sys_unmount 0x001DFC70
#define kdlsym_addr_sys_wait4 0x00035470
#define kdlsym_addr_sys_write 0x00152FC0
#define kdlsym_addr_target_id 0x01CD068D
#define kdlsym_addr_trap_fatal 0x00171580
#define kdlsym_addr_utilUSleep 0x00658BF0
#define kdlsym_addr_vm_fault_disable_pagefaults 0x002A6C20
Expand Down
1 change: 1 addition & 0 deletions kernel/src/Utils/Kdlsym/Orbis505.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ for the platforms that do enable kernel ASLR (Address Space Layout Randomization
#define kdlsym_addr_sys_unmount 0x001DFC70
#define kdlsym_addr_sys_wait4 0x00035470
#define kdlsym_addr_sys_write 0x00152FC0
#define kdlsym_addr_target_id 0x01CD068D
#define kdlsym_addr_trap_fatal 0x00171580
#define kdlsym_addr_utilUSleep 0x00658C30
#define kdlsym_addr_vm_fault_disable_pagefaults 0x002A6C20
Expand Down
1 change: 1 addition & 0 deletions kernel/src/Utils/Kdlsym/Orbis555.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ for the platforms that do enable kernel ASLR (Address Space Layout Randomization
#define kdlsym_addr_sys_unmount 0x0019D6E0
#define kdlsym_addr_sys_wait4 0x0044F920
#define kdlsym_addr_sys_write 0x00138640
#define kdlsym_addr_target_id 0x022BFF8D
#define kdlsym_addr_trap_fatal 0x000A1780
#define kdlsym_addr_utilUSleep 0x00694090
#define kdlsym_addr_vm_fault_disable_pagefaults 0x00218190
Expand Down
1 change: 1 addition & 0 deletions kernel/src/Utils/Kdlsym/Orbis620.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
#define kdlsym_addr_sys_unmount 0x0000FFD0
#define kdlsym_addr_sys_wait4 0x00076590
#define kdlsym_addr_sys_write 0x0030B1E0
#define kdlsym_addr_target_id 0x0215DB8D
#define kdlsym_addr_trap_fatal 0x002E0DD0
#define kdlsym_addr_utilUSleep 0x006864B0
#define kdlsym_addr_vm_fault_disable_pagefaults 0x003FEE40
Expand Down
1 change: 1 addition & 0 deletions kernel/src/Utils/Kdlsym/Orbis672.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
#define kdlsym_addr_sys_unmount 0x004412D0
#define kdlsym_addr_sys_wait4 0x00406830
#define kdlsym_addr_sys_write 0x0039BCF0
#define kdlsym_addr_target_id 0x01BD800D
#define kdlsym_addr_trap_fatal 0x002ED2E0
#define kdlsym_addr_utilUSleep 0x0069B2A0
#define kdlsym_addr_vm_fault_disable_pagefaults 0x000C0BB0
Expand Down