/*
* To build, set up your Release configuration like this:
*
* [Runtime Library]
* Multi-threaded (/MT)
*
* Visit https://frida.re to learn more about Frida.
*/
#include "frida-core.h"
#include <stdlib.h>
#include <string.h>
static void on_detached (FridaSession * session, FridaSessionDetachReason reason, FridaCrash * crash, gpointer user_data);
static void on_message (FridaScript * script, const gchar * message, GBytes * data, gpointer user_data);
static void on_signal (int signo);
static gboolean stop (gpointer user_data);
static GMainLoop * loop = NULL;
int
main (int argc,
char * argv[])
{
guint target_pid;
FridaDeviceManager * manager;
GError * error = NULL;
FridaDeviceList * devices;
gint num_devices, i;
FridaDevice * local_device;
FridaSession * session;
frida_init ();
if (argc != 2 || (target_pid = atoi (argv[1])) == 0)
{
g_printerr ("Usage: %s <pid>\n", argv[0]);
return 1;
}
loop = g_main_loop_new (NULL, TRUE);
signal (SIGINT, on_signal);
signal (SIGTERM, on_signal);
manager = frida_device_manager_new ();
devices = frida_device_manager_enumerate_devices_sync (manager, NULL, &error);
g_assert (error == NULL);
local_device = NULL;
num_devices = frida_device_list_size (devices);
for (i = 0; i != num_devices; i++)
{
FridaDevice * device = frida_device_list_get (devices, i);
g_print ("[*] Found device: \"%s\"\n", frida_device_get_name (device));
if (frida_device_get_dtype (device) == FRIDA_DEVICE_TYPE_LOCAL)
local_device = g_object_ref (device);
g_object_unref (device);
}
g_assert (local_device != NULL);
frida_unref (devices);
devices = NULL;
session = frida_device_attach_sync (local_device, target_pid, NULL, NULL, &error);
if (error == NULL)
{
FridaScript * script;
FridaScriptOptions * options;
g_signal_connect (session, "detached", G_CALLBACK (on_detached), NULL);
if (frida_session_is_detached (session))
goto session_detached_prematurely;
g_print ("[*] Attached\n");
options = frida_script_options_new ();
frida_script_options_set_name (options, "example");
frida_script_options_set_runtime (options, FRIDA_SCRIPT_RUNTIME_QJS);
script = frida_session_create_script_sync (session,
"Interceptor.attach(Module.getExportByName('kernel32.dll', 'CreateFileW'), {\n"
" onEnter(args) {\n"
" console.log(`[*] CreateFileW(\"${args[0].readUtf16String()}\")`);\n"
" }\n"
"});\n"
"Interceptor.attach(Module.getExportByName('kernel32.dll', 'CloseHandle'), {\n"
" onEnter(args) {\n"
" console.log(`[*] CloseHandle(${args[0]})`);\n"
" }\n"
"});",
options, NULL, &error);
g_assert (error == NULL);
g_clear_object (&options);
g_signal_connect (script, "message", G_CALLBACK (on_message), NULL);
frida_script_load_sync (script, NULL, &error);
g_assert (error == NULL);
g_print ("[*] Script loaded\n");
if (g_main_loop_is_running (loop))
g_main_loop_run (loop);
g_print ("[*] Stopped\n");
frida_script_unload_sync (script, NULL, NULL);
frida_unref (script);
g_print ("[*] Unloaded\n");
frida_session_detach_sync (session, NULL, NULL);
session_detached_prematurely:
frida_unref (session);
g_print ("[*] Detached\n");
}
else
{
g_printerr ("Failed to attach: %s\n", error->message);
g_error_free (error);
}
frida_unref (local_device);
frida_device_manager_close_sync (manager, NULL, NULL);
frida_unref (manager);
g_print ("[*] Closed\n");
g_main_loop_unref (loop);
return 0;
}
static void
on_detached (FridaSession * session,
FridaSessionDetachReason reason,
FridaCrash * crash,
gpointer user_data)
{
gchar * reason_str;
reason_str = g_enum_to_string (FRIDA_TYPE_SESSION_DETACH_REASON, reason);
g_print ("on_detached: reason=%s crash=%p\n", reason_str, crash);
g_free (reason_str);
g_idle_add (stop, NULL);
}
static void
on_message (FridaScript * script,
const gchar * message,
GBytes * data,
gpointer user_data)
{
JsonParser * parser;
JsonObject * root;
const gchar * type;
parser = json_parser_new ();
json_parser_load_from_data (parser, message, -1, NULL);
root = json_node_get_object (json_parser_get_root (parser));
type = json_object_get_string_member (root, "type");
if (strcmp (type, "log") == 0)
{
const gchar * log_message;
log_message = json_object_get_string_member (root, "payload");
g_print ("%s\n", log_message);
}
else
{
g_print ("on_message: %s\n", message);
}
g_object_unref (parser);
}
static void
on_signal (int signo)
{
g_idle_add (stop, NULL);
}
static gboolean
stop (gpointer user_data)
{
g_main_loop_quit (loop);
return FALSE;
}
没有合适的资源?快使用搜索试试~ 我知道了~
面向开发人员、逆向工程和安全人员的动态检测工具包
共81个文件
yml:13个
mk:9个
sh:9个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 85 浏览量
2023-07-09
08:47:29
上传
评论
收藏 138KB ZIP 举报
温馨提示
面向开发人员、逆向工程和安全人员的动态检测工具包。frida是一款便携的、自由的、支持全平台的hook框架,可以通过编写JavaScript、Python代码来和frida_server端进行交互
资源推荐
资源详情
资源评论
收起资源包目录
frida-main.zip (81个子文件)
frida-main
frida-python
Makefile.macos.mk 20KB
frida-go
frida-clr
frida-gum
.github
CODEOWNERS 28B
workflows
ci.yml 78KB
actions
setup-windows-env
action.yml 2KB
package-ios-assets
action.yml 554B
setup-freebsd-env
action.yml 2KB
package-artifact-file
action.yml 1KB
publish-python-bindings
action.yml 2KB
package-artifact-files-as-sfx
action.yml 623B
setup-macos-env
action.yml 4KB
publish-ios-debs
action.yml 2KB
teardown-macos-env
action.yml 349B
setup-linux-env
action.yml 2KB
package-artifact-files-as-tarball
action.yml 642B
Makefile 1KB
Makefile.toolchain.mk 5KB
Makefile.freebsd.mk 7KB
frida.sln 26KB
.cirrus.yml 4KB
Makefile.sdk.mk 3KB
Makefile.linux.mk 28KB
frida-core
CONTRIBUTING.md 23KB
config.mk 1KB
frida-tools
releng
system.mk 430B
bootstrap-toolchain.sh 1KB
detect-variant.sh 216B
frida-deps.vcxproj 10KB
frida-deps.vcxproj.filters 948B
build-deps-windows.py 28KB
winenv.py 3KB
generate-version-header.py 1002B
frida.props 5KB
package-cirrus-ci-artifacts.sh 3KB
frida_version.py 1KB
modules
frida-gadget-ios
download.js 3KB
index.d.ts 208B
package.json 563B
.npmignore 9B
index.js 289B
crosstool-ng
arm-linux-gnueabihf.config 22KB
arm-linux-gnueabi.config 13KB
mipsel-unknown-linux-uclibc.config 10KB
aarch64-linux-gnu.config 21KB
mips-unknown-linux-uclibc.config 10KB
frida.mk 3KB
deps.py 12KB
frida-Debug.props 1KB
deps.mk 16KB
rename-release-assets.sh 665B
sync-from-upstream.py 7KB
machine_file.py 3KB
driver-wrapper-android.sh.in 2KB
mkfatmacho.py 2KB
devkit-assets
frida-core-example.sln 1KB
frida-gumjs-example-windows.c 2KB
frida-gum-example.vcxproj 7KB
frida-gumjs-example.vcxproj.filters 1KB
frida-gumjs-example-unix.c 2KB
frida-gumjs-example.sln 1KB
frida-gum-example-unix.c 3KB
frida-core-example-unix.c 5KB
frida-gum-example.sln 1KB
frida-gumjs-example.vcxproj 7KB
frida-core-example-windows.c 5KB
frida-core-example.vcxproj.filters 1KB
frida-gum-example-windows.c 3KB
frida-core-example.vcxproj 7KB
frida-gum-example.vcxproj.filters 1KB
patches
ninja-linux-arm-ppoll-fallback.patch 1012B
frida-Release.props 1KB
setup-env.sh 29KB
frida-toolchain.props 320B
meson
pkgify.sh 1KB
detect-os.sh 145B
detect-arch.sh 458B
devkit.py 26KB
make-changelog.sh 4KB
.gitmodules 902B
frida-node
.gitignore 161B
BSDmakefile 74B
frida-qml
frida-swift
COPYING 2KB
共 81 条
- 1
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6732
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功