forked from nowsecure/r2frida
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.bat
64 lines (52 loc) · 2.44 KB
/
build.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@echo off
setlocal EnableDelayedExpansion
set R2_BASE=""
set frida_version=15.1.1
if "%PLATFORM%" == "x64" (set frida_os_arch=x86_64) else (set frida_os_arch=x86)
for /f %%i in ('radare2 -H R2_USER_PLUGINS') do set R2_PLUGDIR=%%i
REM for /f %%i in ('where radare2') do set R2_BASE=%%i\..
set R2_BASE=%cd%\radare2
set DEBUG=/O2
set INSTALL=
for /f %%i in ('radare2 -qv') do set R2V=%%i
if not exist %R2_BASE% (
echo radare2 not found
set /p R2_BASE="Please enter full path of radare2 installation: "
set /p R2_PLUGDIR="Please enter full path of radare2 plugin dir (radare2 -H): "
)
echo Using R2_BASE: %R2_BASE%
set R2_INC=/I"%R2_BASE%\include" /I"%R2_BASE%\include\libr" /I"%R2_BASE%\include\libr\sdb"
for %%i in (%*) do (
if "%%i"=="debug" (set DEBUG=/Z7)
if "%%i"=="install" (set INSTALL=1)
)
copy config.h.w64 config.h
call npm install
cd src
cat .\_agent.js | xxd -i > .\_agent.h || (echo "xxd not in path?" & exit /b 1)
REM radare2 -nfqcpc _agent.js | grep 0x > _agent.h || (echo "radare2.exe must be in path & exit /b 1)
mkdir frida > nul 2>&1
cd frida
set FRIDA_SDK_URL="https://github.com/frida/frida/releases/download/!frida_version!/frida-core-devkit-!frida_version!-windows-!frida_os_arch!.exe"
if not exist ".\frida-core-sdk-!frida_version!-!frida_os_arch!.exe" (
echo Downloading Frida Core Sdk
powershell -command "(New-Object System.Net.WebClient).DownloadFile($env:FRIDA_SDK_URL, ""frida-core-sdk.exe-!frida_version!-!frida_os_arch!"")" ^
|| wget -q --show-progress %FRIDA_SDK_URL% .\frida-core-sdk.exe -O .\frida-core-sdk-!frida_version!-!frida_os_arch!.exe || python -m wget %FRIDA_SDK_URL% -o frida-core-sdk-!frida_version!-!frida_os_arch!.exe
echo Extracting...
.\frida-core-sdk-!frida_version!-!frida_os_arch!.exe || (echo Failed to extract & exit /b 1)
)
cd ..
echo Compiling...
echo 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"
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)
zip ..\r2frida-%R2V%-w64.zip io_frida.dll
if not "%INSTALL%"=="" (
echo Installing...
mkdir "%R2_PLUGDIR%" > nul 2>&1
echo Copying 'io_frida.dll' to %R2_PLUGDIR%
copy io_frida.dll "%R2_PLUGDIR%\io_frida.dll"
if not "%DEBUG%"=="/O2" (
echo Copying 'io_frida.pdb' to %R2_PLUGDIR%
cp io_frida.pdb "%R2_PLUGDIR%\io_frida.pdb"
)
)