Skip to content

Commit

Permalink
Update devkit examples to the new APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed May 10, 2019
1 parent df91077 commit ddd4111
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
21 changes: 14 additions & 7 deletions releng/devkit-assets/frida-core-example-unix.c
Expand Up @@ -61,23 +61,30 @@ main (int argc,
if (error == NULL)
{
FridaScript * script;
FridaScriptOptions * options;

g_print ("[*] Attached\n");

script = frida_session_create_script_sync (session, "example",
"Interceptor.attach(Module.findExportByName(null, 'open'), {\n"
" onEnter: function (args) {\n"
" console.log('[*] open(\"' + Memory.readUtf8String(args[0]) + '\")');\n"
options = frida_script_options_new ();
frida_script_options_set_name (options, "example");
frida_script_options_set_runtime (options, FRIDA_SCRIPT_RUNTIME_V8);

script = frida_session_create_script_sync (session,
"Interceptor.attach(Module.getExportByName(null, 'open'), {\n"
" onEnter(args) {\n"
" console.log('[*] open(\"' + args[0].readUtf8String() + '\")');\n"
" }\n"
"});\n"
"Interceptor.attach(Module.findExportByName(null, 'close'), {\n"
" onEnter: function (args) {\n"
"Interceptor.attach(Module.getExportByName(null, 'close'), {\n"
" onEnter(args) {\n"
" console.log('[*] close(' + args[0].toInt32() + ')');\n"
" }\n"
"});",
&error);
options, &error);
g_assert (error == NULL);

g_clear_object (&options);

g_signal_connect (script, "message", G_CALLBACK (on_message), NULL);

frida_script_load_sync (script, &error);
Expand Down
21 changes: 14 additions & 7 deletions releng/devkit-assets/frida-core-example-windows.c
Expand Up @@ -70,23 +70,30 @@ main (int argc,
if (error == NULL)
{
FridaScript * script;
FridaScriptOptions * options;

g_print ("[*] Attached\n");

script = frida_session_create_script_sync (session, "example",
"Interceptor.attach(Module.findExportByName('kernel32.dll', 'CreateFileW'), {\n"
" onEnter: function (args) {\n"
" console.log('[*] CreateFileW(\"' + Memory.readUtf16String(args[0]) + '\")');\n"
options = frida_script_options_new ();
frida_script_options_set_name (options, "example");
frida_script_options_set_runtime (options, FRIDA_SCRIPT_RUNTIME_V8);

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.findExportByName('kernel32.dll', 'CloseHandle'), {\n"
" onEnter: function (args) {\n"
"Interceptor.attach(Module.getExportByName('kernel32.dll', 'CloseHandle'), {\n"
" onEnter(args) {\n"
" console.log('[*] CloseHandle(' + args[0] + ')');\n"
" }\n"
"});",
&error);
options, &error);
g_assert (error == NULL);

g_clear_object (&options);

g_signal_connect (script, "message", G_CALLBACK (on_message), NULL);

frida_script_load_sync (script, &error);
Expand Down
12 changes: 6 additions & 6 deletions releng/devkit-assets/frida-gumjs-example-unix.c
Expand Up @@ -18,16 +18,16 @@ main (int argc,

gum_init_embedded ();

backend = gum_script_backend_obtain_duk ();
backend = gum_script_backend_obtain_v8 ();

script = gum_script_backend_create_sync (backend, "example",
"Interceptor.attach(Module.findExportByName(null, 'open'), {\n"
" onEnter: function (args) {\n"
" console.log('[*] open(\"' + Memory.readUtf8String(args[0]) + '\")');\n"
"Interceptor.attach(Module.getExportByName(null, 'open'), {\n"
" onEnter(args) {\n"
" console.log('[*] open(\"' + args[0].readUtf8String() + '\")');\n"
" }\n"
"});\n"
"Interceptor.attach(Module.findExportByName(null, \"close\"), {\n"
" onEnter: function (args) {\n"
"Interceptor.attach(Module.getExportByName(null, \"close\"), {\n"
" onEnter(args) {\n"
" console.log('[*] close(' + args[0].toInt32() + ')');\n"
" }\n"
"});",
Expand Down
4 changes: 2 additions & 2 deletions releng/devkit-assets/frida-gumjs-example-windows.c
Expand Up @@ -28,12 +28,12 @@ main (int argc,
backend = gum_script_backend_obtain_duk ();

script = gum_script_backend_create_sync (backend, "example",
"Interceptor.attach(Module.findExportByName('user32.dll', 'MessageBeep'), {\n"
"Interceptor.attach(Module.getExportByName('user32.dll', 'MessageBeep'), {\n"
" onEnter: function (args) {\n"
" console.log('[*] MessageBeep(' + args[0].toInt32() + ')');\n"
" }\n"
"});\n"
"Interceptor.attach(Module.findExportByName('kernel32.dll', 'Sleep'), {\n"
"Interceptor.attach(Module.getExportByName('kernel32.dll', 'Sleep'), {\n"
" onEnter: function (args) {\n"
" console.log('[*] Sleep(' + args[0].toInt32() + ')');\n"
" }\n"
Expand Down

0 comments on commit ddd4111

Please sign in to comment.