Skip to content

Commit

Permalink
Remove CYLANG (Cycript language) support
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Oct 23, 2020
1 parent 3131e61 commit 38680b9
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 228 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "r2io/cycript"]
path = ext/cycript
url = https://github.com/nowsecure/frida-cycript.git
[submodule "ext/swift-frida"]
path = ext/swift-frida
url = https://github.com/trufae/swift-frida.git
69 changes: 5 additions & 64 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include config.mk

r2_version=$(VERSION)
frida_version=14.0.0
frida_version=14.0.1

ifeq ($(strip $(frida_os)),)
ifeq ($(shell uname -o 2> /dev/null),Android)
Expand Down Expand Up @@ -95,20 +95,6 @@ LDFLAGS+=-Wl,--gc-sections
endif
LDFLAGS+=-Wl,-dead_strip

# CYLANG
CFLAGS+=-DWITH_CYLANG=$(WITH_CYLANG)
ifeq ($(WITH_CYLANG),1)
CYLANG_CPPFLAGS+=-Iext/cycript/src
CYLANG_ARCHIVE=ext/cycript/src/.libs/libcycript.a
CYLANG_LIBS+=$(CYLANG_ARCHIVE)
CYLANG_OBJ=src/cylang.o
else
CYLANG_CPPFLAGS=
CYLANG_ARCHIVE=
CYLANG_LIBS=
CYLANG_OBJ=
endif

all: .git/modules/ext ext/frida
$(MAKE) io_frida.$(SO_EXT)

Expand Down Expand Up @@ -150,9 +136,9 @@ ext/frida: $(FRIDA_SDK)
config.mk:
./configure

io_frida.$(SO_EXT): src/io_frida.o $(CYLANG_OBJ)
io_frida.$(SO_EXT): src/io_frida.o
pkg-config --cflags r_core
$(CXX) $^ -o $@ $(LDFLAGS) $(FRIDA_LDFLAGS) $(FRIDA_LIBS) $(CYLANG_LIBS)
$(CXX) $^ -o $@ $(LDFLAGS) $(FRIDA_LDFLAGS) $(FRIDA_LIBS)

src/io_frida.o: src/io_frida.c $(FRIDA_SDK) src/_agent.h
$(CC) -c $(CFLAGS) $(FRIDA_CPPFLAGS) $< -o $@
Expand Down Expand Up @@ -229,12 +215,8 @@ clean:
$(RM) src/*.o src/_agent.js src/_agent.h
$(RM) -rf $(R2A_DIR)

cycript-clean clean2:
-$(MAKE) -C ext/cycript clean

mrproper: clean
$(RM) $(FRIDA_SDK)
$(RM) -r ext/cycript
$(RM) -r ext/frida-$(frida_version)
$(RM) ext/frida
$(RM) -r ext/node
Expand Down Expand Up @@ -279,48 +261,7 @@ endif
#mv ext/frida ext/frida-$(frida_os)-$(frida_version)
cd ext && ln -fs frida-$(frida_os)-$(frida_version) frida

update: ext/cycript/ext/node/lib
-cd ext/cycript && git submodule update && $(RM) ext/frida/libfrida-core.a

ifeq ($(WITH_CYLANG),1)
ext/cycript/ext/node/lib:
mkdir -p ext/cycript ext/node/lib
cd ext/cycript && git submodule init && git submodule update
-cd ext/cycript && yes n | patch -p1 < ../../cycript.patch

ext/cycript/configure: ext/cycript/ext/node/lib
cd ext/cycript && $(SHELL) ./autogen.sh

ifeq ($(shell uname),Darwin)
CLANG=-rpath /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib
else
CLANG=no
endif

ext/cycript/Makefile: ext/cycript/configure
CFLAGS="$(CFLAGS)" \
CXXFLAGS="$(CXXFLAGS)" \
LDFLAGS="$(LDFLAGS)" \
cd ext/cycript && \
$(SHELL) ./configure \
--disable-console \
--disable-engine \
--disable-shared \
--enable-static \
--with-libclang="$(CLANG)" \
--with-python=/usr/bin/python-config

ext/cycript/src/.libs/libcycript.a: ext/cycript/Makefile
$(MAKE) -C ext/cycript CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" V=1 -j4

src/cylang.o: src/cylang.cpp $(CYLANG_ARCHIVE)
$(CXX) -c -std=c++11 $(CFLAGS) $(CXXFLAGS) $(FRIDA_CPPFLAGS) $(CYLANG_CPPFLAGS) $< -o $@
else
ext/cycript/ext/node/lib:
@echo do nothing

src/cylang.o:
touch src/cylang.o
endif
update:
git submodule update && $(RM) ext/frida/libfrida-core.a

.PHONY: all clean install uninstall release symstall
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if not exist ".\frida-core-sdk-%frida_version%-%frida_os_arch%.exe" (
cd ..

echo Compiling...
cl %DEBUG% /MT /nologo /LD /Gy /D_USRDLL /D_WINDLL /DWITH_CYLANG=0 io_frida.c %R2_INC% /I"%cd%" /I"%cd%\frida" "%cd%\frida\frida-core.lib" "%R2_BASE%\lib\*.lib" || (echo Compilation Failed & exit /b 1)
cl %DEBUG% /MT /nologo /LD /Gy /D_USRDLL /D_WINDLL io_frida.c %R2_INC% /I"%cd%" /I"%cd%\frida" "%cd%\frida\frida-core.lib" "%R2_BASE%\lib\*.lib" || (echo Compilation Failed & exit /b 1)

if not "%INSTALL%"=="" (
echo Installing...
Expand Down
23 changes: 1 addition & 22 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ control_c() {
exit 1
}
trap control_c 2
WANT_CYLANG=0
split_host() {
S="$"
while : ; do
Expand Down Expand Up @@ -155,10 +154,6 @@ System types:
--target=TARGET configure for building compilers for TARGET [HOST]
EOF2

printf "
Optional Features:
--with-cylang build with cylang (mjolner) support
"
printf "
Some influential environment variables:
CC C compiler command
Expand Down Expand Up @@ -234,7 +229,6 @@ echo "PKGNAME: r2frida"
echo "VERSION: 4.5.0"
echo "LANGS: c c++"
echo "PKG-CONFIG: r_core"
echo "FLAGS: --with-cylang"
exit 0
;;
--cache-file)
Expand Down Expand Up @@ -280,7 +274,6 @@ echo "FLAGS: --with-cylang"
--mandir)
MANDIR="$value"; ;;

"--with-cylang") WANT_CYLANG="1"; ;;
*) if [ "$value" ]; then eval "`echo $flag2=$value`" ;
else echo ; echo "WARNING: Unknown flag '$flag'." >&2 ; echo ; fi ;;
esac
Expand All @@ -298,7 +291,7 @@ parse_options "$1"
shift
done

ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_NUMBER PKGNAME VPATH CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C CXX CXXFLAGS HAVE_LANG_CXX R2_CFLAGS R2_LDFLAGS HAVE_PKGCFG_R_CORE HAVE_CURL CURL HAVE_WGET WGET HAVE_GIT GIT HAVE_XZ XZ HAVE_NODE NODE HAVE_NPM NPM WANT_CYLANG WITH_CYLANG"
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_NUMBER PKGNAME VPATH CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C CXX CXXFLAGS HAVE_LANG_CXX R2_CFLAGS R2_LDFLAGS HAVE_PKGCFG_R_CORE HAVE_CURL CURL HAVE_WGET WGET HAVE_GIT GIT HAVE_XZ XZ HAVE_NODE NODE HAVE_NPM NPM"

create_environ

Expand Down Expand Up @@ -521,11 +514,6 @@ echo no
fi
echo "error: This program is required." >&2
exit 1 ; fi
if [ 11 = "$WANT_CYLANG$HAVE_LANG_CXX" ]; then

WITH_CYLANG="1"
else
WITH_CYLANG="0"; fi
SEDFLAGS=" -e '"
COUNT=0
for A in ${ENVWORDS} ; do
Expand Down Expand Up @@ -570,12 +558,3 @@ done
done

do_remove
if [ "$QUIET" = 0 ]; then
echo
echo "Final report:"
for A in WITH_CYLANG ; do
eval VAL="\$${A}"
[ -z "${VAL}" ] && VAL="(null)"
echo " - ${A} = ${VAL}"
done
fi
9 changes: 0 additions & 9 deletions configure.acr
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,4 @@ CHKPRG! XZ xz
CHKPRG! NODE node
CHKPRG! NPM npm

ARG_WITH WANT_CYLANG cylang build with cylang (mjolner) support ;
IFAND WANT_CYLANG HAVE_LANG_CXX {
WITH_CYLANG = 1 ;
}{
WITH_CYLANG = 0 ;
}

REPORT WITH_CYLANG ;

SUBDIRS ./config.mk ./config.h ;
24 changes: 3 additions & 21 deletions src/agent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ let Gcwd = '/';
const ObjCAvailable = (Process.platform === 'darwin') && ObjC && ObjC.available && ObjC.classes && typeof ObjC.classes.NSString !== 'undefined';
const JavaAvailable = Java && Java.available;

if (ObjCAvailable) {
var mjolner = require('mjolner');
}

/* globals */
const pointerSize = Process.pointerSize;

Expand Down Expand Up @@ -601,7 +597,7 @@ if (Process.platform === 'windows') {
const _setfilecon = symf('setfilecon', 'int', ['pointer', 'pointer']);

if (Process.platform === 'darwin') {
// required for mjolner.register() to work on early instrumentation
// required for early instrumentation
try {
dlopen(['/System/Library/Frameworks/Foundation.framework/Foundation']);
} catch (e) {
Expand Down Expand Up @@ -936,7 +932,6 @@ async function dumpInfoJson () {
runtime: Script.runtime,
java: JavaAvailable,
mainLoop: hasMainLoop(),
cylang: mjolner !== undefined,
pageSize: Process.pageSize,
pointerSize: Process.pointerSize,
codeSigningPolicy: Process.codeSigningPolicy,
Expand Down Expand Up @@ -3552,11 +3547,7 @@ main();
}
const rawResult = (1, eval)(code); // eslint-disable-line
global._ = rawResult;
if (rawResult !== undefined && mjolner !== undefined) {
result = mjolner.toCYON(rawResult);
} else {
result = rawResult; // 'undefined';
}
result = rawResult; // 'undefined';
} catch (e) {
result = 'throw new ' + e.name + '("' + e.message + '")';
}
Expand Down Expand Up @@ -3597,21 +3588,12 @@ function hasMainLoop () {
return hasLoop;
}

if (ObjCAvailable) {
mjolner.register();
}

Script.setGlobalAccessHandler({
enumerate () {
return [];
},
get (property) {
if (mjolner !== undefined) {
const result = mjolner.lookup(property);
if (result !== null) {
return result;
}
}
return undefined;
}
});

Expand Down
63 changes: 0 additions & 63 deletions src/cylang.cpp

This file was deleted.

20 changes: 0 additions & 20 deletions src/cylang.h

This file was deleted.

Loading

0 comments on commit 38680b9

Please sign in to comment.