Skip to content

Commit

Permalink
Fix symbol_frida_agent_main (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiasap authored Dec 10, 2024
1 parent fbfa3e3 commit 153bbb7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
16 changes: 8 additions & 8 deletions patches/frida-core/0003-Florida-symbol_frida_agent_main.patch
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ index 73e0c017..a3db1112 100644

void * main_func_symbol;
- var main_func_found = container.module.symbol ("frida_agent_main", out main_func_symbol);
+ var main_func_found = container.module.symbol ("frida_agent_main", out main_func_symbol);
+ var main_func_found = container.module.symbol ("main", out main_func_symbol);
assert (main_func_found);
container.main_impl = (AgentMainFunc) main_func_symbol;

Expand Down Expand Up @@ -72,7 +72,7 @@ index ab9b2900..4369922d 100644
uint id;

- unowned string entrypoint = "frida_agent_main";
+ unowned string entrypoint = "frida_agent_main";
+ unowned string entrypoint = "main";
#if HAVE_EMBEDDED_ASSETS
id = yield fruitjector.inject_library_resource (pid, agent, entrypoint, agent_parameters, cancellable);
#else
Expand All @@ -85,7 +85,7 @@ index a2204a4e..eac16116 100644
var stream_request = Pipe.open (t.local_address, cancellable);

- var id = yield binjector.inject_library_resource (pid, agent_desc, "frida_agent_main",
+ var id = yield binjector.inject_library_resource (pid, agent_desc, "frida_agent_main",
+ var id = yield binjector.inject_library_resource (pid, agent_desc, "main",
make_agent_parameters (pid, t.remote_address, options), cancellable);
injectee_by_pid[pid] = id;

Expand All @@ -98,7 +98,7 @@ index 64245792..086d0b96 100644
Cancellable? cancellable, out Object? transport) throws Error, IOError {
uint id;
- string entrypoint = "frida_agent_main";
+ string entrypoint = "frida_agent_main";
+ string entrypoint = "main";
string parameters = make_agent_parameters (pid, "", options);
AgentFeatures features = CONTROL_CHANNEL;
var linjector = (Linjector) injector;
Expand All @@ -111,7 +111,7 @@ index 69f2995f..a4e59ab2 100644
var stream_request = Pipe.open (t.local_address, cancellable);

- var id = yield qinjector.inject_library_resource (pid, agent_desc, "frida_agent_main",
+ var id = yield qinjector.inject_library_resource (pid, agent_desc, "frida_agent_main",
+ var id = yield qinjector.inject_library_resource (pid, agent_desc, "main",
make_agent_parameters (pid, t.remote_address, options), cancellable);
injectee_by_pid[pid] = id;

Expand All @@ -124,7 +124,7 @@ index 67f1f3ef..518cd256 100644

var winjector = injector as Winjector;
- var id = yield winjector.inject_library_resource (pid, agent, "frida_agent_main",
+ var id = yield winjector.inject_library_resource (pid, agent, "frida_agent_main",
+ var id = yield winjector.inject_library_resource (pid, agent, "main",
make_agent_parameters (pid, t.remote_address, options), cancellable);
injectee_by_pid[pid] = id;

Expand All @@ -137,7 +137,7 @@ index d28e67fd..bbdc29b3 100644

void * main_func_symbol;
- var main_func_found = module.symbol ("frida_agent_main", out main_func_symbol);
+ var main_func_found = module.symbol ("frida_agent_main", out main_func_symbol);
+ var main_func_found = module.symbol ("main", out main_func_symbol);
assert_true (main_func_found);
main_impl = (AgentMainFunc) main_func_symbol;

Expand All @@ -150,7 +150,7 @@ index 03c219e6..a7720c3d 100644
assert_true (FileUtils.test (path, FileTest.EXISTS));

- yield injector.inject_library_file (process.id, path, "frida_agent_main", data);
+ yield injector.inject_library_file (process.id, path, "frida_agent_main", data);
+ yield injector.inject_library_file (process.id, path, "main", data);
} catch (GLib.Error e) {
printerr ("\nFAIL: %s\n\n", e.message);
assert_not_reached ();
Expand Down
31 changes: 31 additions & 0 deletions patches/frida-core/0010-exec-anti-anti-frida.py.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From 09c74884dda5e9a5d452a7d5b78eb1c3e8a717c9 Mon Sep 17 00:00:00 2001
From: Thiasap <[email protected]>
Date: Mon, 9 Dec 2024 16:28:59 +0800
Subject: [PATCH] exec anti-anti-frida.py

---
src/embed-agent.py | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/src/embed-agent.py b/src/embed-agent.py
index 1cdd46da..4459b9c1 100644
--- a/src/embed-agent.py
+++ b/src/embed-agent.py
@@ -78,6 +78,14 @@ def main(argv):
shutil.copy(agent, embedded_agent)
else:
embedded_agent.write_bytes(b"")
+ import os
+ custom_script=str(output_dir)+"/../../../../frida/subprojects/frida-core/src/anti-anti-frida.py"
+ return_code = os.system("python3 "+custom_script+" "+str(priv_dir / f"frida-agent-{flavor}.so"))
+ if return_code == 0:
+ print("anti-anti-frida finished")
+ else:
+ print("anti-anti-frida error. Code:", return_code)
+
embedded_assets += [embedded_agent]
elif host_os in {"freebsd", "qnx"}:
embedded_agent = priv_dir / "frida-agent.so"
--
2.34.1

0 comments on commit 153bbb7

Please sign in to comment.