Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: frida/frida-objc-bridge
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 73f46193bc64d9b0e0083836ffb40a4d70a4d243
Choose a base ref
...
head repository: frida/frida-objc-bridge
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 37d7bb741969c1f434d988091ec04f49b72b939c
Choose a head ref

Commits on Jan 24, 2019

  1. Copy the full SHA
    6418a86 View commit details
  2. 3.0.5

    oleavr committed Jan 24, 2019
    Copy the full SHA
    a376e42 View commit details

Commits on Feb 18, 2019

  1. Copy the full SHA
    c88ce81 View commit details
  2. 3.1.0

    oleavr committed Feb 18, 2019
    Copy the full SHA
    97ab541 View commit details

Commits on Feb 20, 2019

  1. Copy the full SHA
    9e7bd88 View commit details
  2. Copy the full SHA
    16efd61 View commit details

Commits on Feb 21, 2019

  1. Copy the full SHA
    24ee254 View commit details
  2. Display console messages emitted by tests

    Instead of making tests fail when temporary logging is added.
    oleavr committed Feb 21, 2019
    Copy the full SHA
    f23d713 View commit details
  3. Add support for grouping tests

    oleavr committed Feb 21, 2019
    Copy the full SHA
    2c28b22 View commit details
  4. Copy the full SHA
    01b5b2c View commit details
  5. Copy the full SHA
    fa7ef5f View commit details
  6. Propagate native exceptions

    To make it easier to debug crashes.
    oleavr committed Feb 21, 2019
    Copy the full SHA
    def6ed4 View commit details
  7. 3.1.1

    oleavr committed Feb 21, 2019
    Copy the full SHA
    d8abffb View commit details

Commits on Mar 18, 2019

  1. Copy the full SHA
    057113a View commit details
  2. 3.1.2

    oleavr committed Mar 18, 2019
    Copy the full SHA
    98f089c View commit details

Commits on Apr 4, 2019

  1. Fix handling of union type encodings (#15)

    AV-IO authored and oleavr committed Apr 4, 2019
    Copy the full SHA
    08c059e View commit details

Commits on Apr 12, 2019

  1. 3.1.3

    oleavr committed Apr 12, 2019
    Copy the full SHA
    7298cef View commit details

Commits on Jun 19, 2019

  1. Fix tests on macOS (#17)

    Need to make sure rpath references /usr/lib/swift.
    
    With Xcode on 10.14.5 I was otherwise getting the error:
    
    > This copy of libswiftCore.dylib requires an OS version prior to 10.14.4.`
    
    - https://forums.developer.apple.com/thread/115020 helped solve it.
    dweinstein authored and oleavr committed Jun 19, 2019
    Copy the full SHA
    5db48d9 View commit details

Commits on Jun 20, 2019

  1. Add ObjC.Object#$moduleName (#16)

    Useful to determine which module owns a given class.
    dweinstein authored and oleavr committed Jun 20, 2019
    Copy the full SHA
    c7967ae View commit details
  2. 3.2.0

    oleavr committed Jun 20, 2019
    Copy the full SHA
    9c59935 View commit details

Commits on Jul 31, 2019

  1. Update dependencies

    oleavr committed Jul 31, 2019
    Copy the full SHA
    4ad5354 View commit details
  2. 4.0.0

    oleavr committed Jul 31, 2019
    Copy the full SHA
    e86ec66 View commit details
  3. Copy the full SHA
    350465d View commit details
  4. 4.0.1

    oleavr committed Jul 31, 2019
    Copy the full SHA
    37d7bb7 View commit details
Showing with 6,645 additions and 1,108 deletions.
  1. +3 −1 .gitignore
  2. +211 −119 index.js
  3. +2 −954 package-lock.json
  4. +2 −34 package.json
  5. +18 −0 test/.babelrc
  6. +135 −0 test/Makefile
  7. +915 −0 test/basics.m
  8. +1 −0 test/bundle.js
  9. +54 −0 test/fixture.h
  10. +507 −0 test/fixture.m
  11. +4,640 −0 test/package-lock.json
  12. +17 −0 test/package.json
  13. +127 −0 test/runner.m
  14. BIN test/runner.xcent
  15. +13 −0 test/taylor.swift
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/node_modules
/node_modules/
/npm-debug.log
/test/_agent.js
/test/build/
/test/node_modules/
330 changes: 211 additions & 119 deletions index.js

Large diffs are not rendered by default.

956 changes: 2 additions & 954 deletions package-lock.json

Large diffs are not rendered by default.

36 changes: 2 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,11 @@
{
"name": "frida-objc",
"version": "3.0.4",
"version": "4.0.1",
"description": "Objective-C runtime interop from Frida",
"main": "index.js",
"files": [
"/index.js"
],
"browserify": {
"transform": [
[
"babelify",
{
"presets": [
[
"@babel/preset-env",
{
"loose": true
}
]
],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
"corejs": 2
}
]
]
}
]
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/frida/frida-objc.git"
@@ -39,12 +14,5 @@
"bugs": {
"url": "https://github.com/frida/frida-objc/issues"
},
"homepage": "https://github.com/frida/frida-objc#readme",
"dependencies": {
"@babel/core": "^7.1.2",
"@babel/plugin-transform-runtime": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@babel/runtime-corejs2": "^7.1.2",
"babelify": "^10.0.0"
}
"homepage": "https://github.com/frida/frida-objc#readme"
}
18 changes: 18 additions & 0 deletions test/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"presets": [
[
"@babel/preset-env",
{
"loose": true
}
]
],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
"corejs": 2
}
]
]
}
135 changes: 135 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
RUNNER_ARGS ?=

IOS_HOST = iphone
IOS_ARCH = arm64
IOS_PREFIX = /usr/local/opt/frida-objc-tests-$(IOS_ARCH)

frida_version := 12.6.7

cflags := -Wall -pipe -Os -g
ldflags := -Wl,-framework,Foundation -lfrida-gumjs -lresolv -Wl,-dead_strip
toolchain := $(shell dirname $(shell dirname $(shell dirname $(shell xcrun --toolchain XcodeDefault -f swift))))

macos_cc := $(shell xcrun --sdk macosx -f clang)
macos_swift := $(shell xcrun --sdk macosx -f swift)
macos_sdk := $(shell xcrun --sdk macosx --show-sdk-path)
macos_cflags := -isysroot "$(macos_sdk)" -arch x86_64 $(cflags) -DHAVE_MACOS
macos_runtimedir := $(toolchain)/usr/lib/swift/macosx
macos_swift_runtimedir := /usr/lib/swift
macos_ldflags := "-L$(macos_runtimedir)" -lswiftObjectiveC "-Wl,-rpath,$(macos_swift_runtimedir),-rpath,$(macos_runtimedir)" $(ldflags)

ios_cc := $(shell xcrun --sdk iphoneos -f clang)
ios_swift := $(shell xcrun --sdk iphoneos -f swift)
ios_sdk := $(shell xcrun --sdk iphoneos --show-sdk-path)
ios_cflags := -isysroot "$(ios_sdk)" -arch $(IOS_ARCH) -miphoneos-version-min=7.0 $(cflags) -DHAVE_IOS
ios_runtimedir := $(toolchain)/usr/lib/swift/iphoneos
ios_ldflags := "-L$(ios_runtimedir)" -lswiftObjectiveC "-Wl,-rpath,$(IOS_PREFIX)" $(ldflags)
ios_codesign := $(shell xcrun --sdk iphoneos -f codesign)
ios_swift_libraries := \
$(ios_runtimedir)/libswiftCore.dylib \
$(ios_runtimedir)/libswiftCoreFoundation.dylib \
$(ios_runtimedir)/libswiftCoreGraphics.dylib \
$(ios_runtimedir)/libswiftDarwin.dylib \
$(ios_runtimedir)/libswiftDispatch.dylib \
$(ios_runtimedir)/libswiftFoundation.dylib \
$(ios_runtimedir)/libswiftObjectiveC.dylib \
$(ios_runtimedir)/libswiftSwiftOnoneSupport.dylib \
$(NULL)

objc_sources := runner.m basics.m
objc_headers := fixture.m
swift_sources := taylor.swift

js_sources := ../index.js

all: run-macos

clean:
rm -rf build

build-macos: build/macos-x86_64/runner
build-ios: build/ios-$(IOS_ARCH)/runner

run-macos: build/macos-x86_64/runner build/frida-objc.js
$< $(RUNNER_ARGS)
run-ios: build/ios-$(IOS_ARCH)/runner build/frida-objc.js build/ios-$(IOS_ARCH)/.swift-runtime-stamp
cd build/ios-$(IOS_ARCH)/ && rsync -rLz runner ../frida-objc.js *.dylib "$(IOS_HOST):$(IOS_PREFIX)/"
ssh $(IOS_HOST) "$(IOS_PREFIX)/runner $(RUNNER_ARGS)"

watch-macos: build/macos-x86_64/runner build/frida-objc.js
npm run watch &
./node_modules/.bin/chokidar \
build/frida-objc.js \
-c 'build/macos-x86_64/runner $(RUNNER_ARGS)'
watch-ios: build/ios-$(IOS_ARCH)/runner build/frida-objc.js
npm run watch &
./node_modules/.bin/chokidar \
build/frida-objc.js \
-c 'scp build/frida-objc.js "$(IOS_HOST):$(IOS_PREFIX)/" \
&& ssh $(IOS_HOST) "$(IOS_PREFIX)/runner $(RUNNER_ARGS)"'

build/macos-x86_64/runner: $(objc_sources) $(objc_headers) build/macos-x86_64/taylor.o build/macos-x86_64/libfrida-gumjs.a
"$(macos_cc)" \
$(macos_cflags) \
$(objc_sources) \
build/macos-x86_64/taylor.o \
-o $@ \
-Ibuild/macos-x86_64 -Lbuild/macos-x86_64 \
$(macos_ldflags)
build/ios-$(IOS_ARCH)/runner: $(objc_sources) $(objc_headers) build/ios-$(IOS_ARCH)/taylor.o runner.xcent build/ios-$(IOS_ARCH)/libfrida-gumjs.a
"$(ios_cc)" \
$(ios_cflags) \
$(objc_sources) \
build/ios-$(IOS_ARCH)/taylor.o \
-o $@ \
-Ibuild/ios-$(IOS_ARCH) -Lbuild/ios-$(IOS_ARCH) \
$(ios_ldflags)
"$(ios_codesign)" -f -s "$$IOS_CERTID" --entitlements runner.xcent $@

build/macos-x86_64/taylor.o: taylor.swift
@mkdir -p $(@D)
"$(macos_swift)" \
-frontend \
-c \
-primary-file taylor.swift \
-sdk "$(macos_sdk)" \
-module-name FridaObjCTests \
-emit-module-path build/macos-x86_64/FridaObjCTests.swiftmodule \
-emit-objc-header-path build/macos-x86_64/taylor.h \
-enable-testing \
-enable-objc-interop \
-parse-as-library \
-o $@
build/ios-$(IOS_ARCH)/taylor.o: taylor.swift
@mkdir -p $(@D)
"$(ios_swift)" \
-frontend \
-c \
-primary-file taylor.swift \
-target $(IOS_ARCH)-apple-ios7.0-iphoneos \
-sdk "$(ios_sdk)" \
-module-name FridaObjCTests \
-emit-module-path build/ios-$(IOS_ARCH)/FridaObjCTests.swiftmodule \
-emit-objc-header-path build/ios-$(IOS_ARCH)/taylor.h \
-enable-testing \
-enable-objc-interop \
-parse-as-library \
-o $@

build/ios-$(IOS_ARCH)/.swift-runtime-stamp: $(ios_swift_libraries)
@mkdir -p $(@D)
cp $^ $(@D)
"$(ios_codesign)" -f -s "$$IOS_CERTID" $(@D)/*.dylib
@touch $@

build/%/libfrida-gumjs.a:
@mkdir -p $(@D)
curl -Ls https://github.com/frida/frida/releases/download/$(frida_version)/frida-gumjs-devkit-$(frida_version)-$*.tar.xz | tar -xJf - -C $(@D)

build/frida-objc.js: $(js_sources) node_modules
npm run build

node_modules: package.json
npm install

.PHONY: all clean build-macos build-ios run-macos run-ios watch-macos watch-ios
915 changes: 915 additions & 0 deletions test/basics.m

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global.LocalObjC = require('../');
54 changes: 54 additions & 0 deletions test/fixture.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2008-2019 Ole André Vadla Ravnås <oleavr@nowsecure.com>
* Copyright (C) 2009 Haakon Sporsheim <haakon.sporsheim@gmail.com>
*
* Licence: wxWindows Library Licence, Version 3.1
*/

#ifndef __TEST_FIXTURE_H__
#define __TEST_FIXTURE_H__

#include <frida-gumjs.h>

#define TESTLIST_BEGIN(NAME) \
void test_ ##NAME## _add_tests (gpointer fixture_data) \
{ \
const gchar * group = "";
#define TESTLIST_END() \
}

#define TESTENTRY_SIMPLE(NAME, PREFIX, FUNC) \
G_STMT_START \
{ \
extern void PREFIX## _ ##FUNC (void); \
g_test_add_func ("/" NAME "/" #FUNC, PREFIX## _ ##FUNC); \
} \
G_STMT_END;
#define TESTENTRY_WITH_FIXTURE(NAME, PREFIX, FUNC, STRUCT) \
G_STMT_START \
{ \
extern void PREFIX## _ ##FUNC (STRUCT * fixture, gconstpointer data); \
g_test_add ("/" NAME "/" #FUNC, \
STRUCT, \
fixture_data, \
PREFIX## _fixture_setup, \
PREFIX## _ ##FUNC, \
PREFIX## _fixture_teardown); \
} \
G_STMT_END;

#define TESTGROUP_BEGIN(NAME) \
group = NAME;
#define TESTGROUP_END() \
group = "";

#define TEST_RUN_LIST(NAME) TEST_RUN_LIST_WITH_DATA (NAME, NULL)
#define TEST_RUN_LIST_WITH_DATA(NAME, FIXTURE_DATA) \
G_STMT_START \
{ \
extern void test_ ##NAME## _add_tests (gpointer fixture_data); \
test_ ##NAME## _add_tests (FIXTURE_DATA); \
} \
G_STMT_END

#endif
507 changes: 507 additions & 0 deletions test/fixture.m

Large diffs are not rendered by default.

4,640 changes: 4,640 additions & 0 deletions test/package-lock.json

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "frida-objc-bundle",
"version": "1.0.0",
"description": "Bundled up version of frida-objc for testing",
"private": true,
"main": "bundle.js",
"scripts": {
"prepublish": "npm run build",
"build": "frida-compile bundle -o build/frida-objc.js",
"watch": "frida-compile bundle -o build/frida-objc.js -w"
},
"license": "LGPL-2.0 WITH WxWindows-exception-3.1",
"dependencies": {
"chokidar-cli": "^1.2.2",
"frida-compile": "^9.0.3"
}
}
127 changes: 127 additions & 0 deletions test/runner.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#include "fixture.h"

#include <frida-gumjs.h>

#define RUN_SUITE(name) \
TEST_RUN_LIST_WITH_DATA (name, gum_script_backend_obtain_duk ()); \
if (v8_backend != NULL) \
TEST_RUN_LIST_WITH_DATA (name, v8_backend)

static gchar * load_bundle (void);

static gchar * detect_runner_location (void);
static gboolean store_path_of_test_runner (const GumModuleDetails * details,
gpointer user_data);

gchar * frida_objc_bundle = NULL;
guint num_tests_run = 0;

int
main (int argc, char * argv[])
{
gint result;
GumExceptor * exceptor;
GumScriptBackend * v8_backend = NULL;
gdouble t;

gum_init_embedded ();
g_test_init (&argc, &argv, NULL);

#ifdef HAVE_IOS
if (g_file_test ("/usr/lib/libjailbreak.dylib", G_FILE_TEST_EXISTS))
{
GModule * module;
void (* entitle_now) (pid_t pid);

module = g_module_open ("/usr/lib/libjailbreak.dylib", G_MODULE_BIND_LAZY);

entitle_now = NULL;
g_module_symbol (module, "jb_oneshot_entitle_now",
(gpointer *) &entitle_now);

entitle_now (getpid ());

g_module_close (module);
}
#endif

frida_objc_bundle = load_bundle ();

exceptor = gum_exceptor_obtain ();

#ifdef HAVE_V8
v8_backend = gum_script_backend_obtain_v8 ();
#endif

RUN_SUITE (basics);

@autoreleasepool
{
GTimer * timer = g_timer_new ();

result = g_test_run ();

t = g_timer_elapsed (timer, NULL);
g_timer_destroy (timer);
}

g_print ("\nRan %d test%s in %.2f seconds\n",
num_tests_run,
(num_tests_run != 1) ? "s" : "",
t);

g_clear_object (&exceptor);

return result;
}

static gchar *
load_bundle (void)
{
gchar * bundle_source;
gchar * runner_location, * runner_dir;
gchar * bundle_dir, * bundle_location;
GError * error;

runner_location = detect_runner_location ();
runner_dir = g_path_get_dirname (runner_location);
#ifdef HAVE_MACOS
bundle_dir = g_path_get_dirname (runner_dir);
#else
bundle_dir = g_strdup (runner_dir);
#endif
bundle_location = g_build_filename (bundle_dir, "frida-objc.js", NULL);
g_free (bundle_dir);
g_free (runner_dir);
g_free (runner_location);

if (!g_file_get_contents (bundle_location, &bundle_source, NULL, &error))
{
g_printerr ("Unable to load bundle: %s\n", error->message);
exit (1);
}

return bundle_source;
}

static gchar *
detect_runner_location (void)
{
gchar * location = NULL;

gum_process_enumerate_modules (store_path_of_test_runner, &location);
g_assert (location != NULL);

return location;
}

static gboolean
store_path_of_test_runner (const GumModuleDetails * details,
gpointer user_data)
{
gchar ** path = user_data;

*path = g_strdup (details->path);

return FALSE;
}
Binary file added test/runner.xcent
Binary file not shown.
13 changes: 13 additions & 0 deletions test/taylor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Foundation

public class Taylor: NSObject {
@objc public var mood: String

public override init() {
self.mood = "creative"
}

public func saySomething() -> String {
return "I am feeling \(mood)"
}
}