Interpreting C++, executing the source and executable like a script.
- Writing powerful script using C++ just as easy as Python;
- Writing hot-loading C++ script code in running process;
- Based on Unicorn Engine qemu virtual cpu and Clang/LLVM C++ compiler;
- Integrated Boost internally with Standard C++23 supported;
- To reuse the existing C/C++ library as icpp module extension is extremely simple.
Copyright (c) vpand.com 2024.
* | Source | Executable | Package | Memory Resident |
---|---|---|---|---|
ICPP | C++ | ARM64/X86_64 Object | imod for *.icpp | iopad/icpp-gadget |
LLI | C++ | LLVM-IR Bitcode | N/A | N/A |
Python | Python | Bytecode | pip for *.wheel | N/A |
Frida | JavaScript | Bytecode | N/A | frida/frida-gadget |
Using ICPP to write C++ code just as a script. Write and then run directly, no creating project, no configuring build, no compiling, no linking...
No matter if you're a beginner or an expert with C++, ICPP is suitable for you. With ICPP, you can focus on:
- Writing snippet code to study any of the newest C++ features;
- Writing glue script to do some tasks;
- Writing test code before applying to the formal project;
- Writing sample code to study some new third C/C++ libraries;
- Making native plugin development scriptable, i.e., writing plugin using C++ dynamically.
- Tracing, profiling, performance optimizing;
- And so on...
ICPP, make programming all in one.
graph LR
A(C++ Source) -- Clang --> B(Object)
B -- Loader --> C(ICPP Interpreter)
A(C++ Source) -- Source.io --> H(IObject)
H(IObject) -- Parser --> C
E(Executable) -- Loader --> C
C -- Unicorn --> D(Output)
C -- Tracer --> F(Traces)
C -- Profiler --> G(Profiles)
graph LR
A(C++ Source) -- ICPP --> B(IObject)
B -- IOPAD --> C(ICPP Gadget)
C -- Interpreter --> D(Run in Process)
C -- Extension --> E(Hooking/Tracing)
C -- Extension --> F(Testing)
- icpp: a local C++ source compiler, interpreter and REPL used to interpret C++ directly;
- imod: an icpp module package manager tool used to install, uninstall and show the third-party modules;
- iopad: a local C++ source compiler driver, object launch pad and REPL for the remote icpp-gadget;
- icpp-gadget: a remote memory resident daemon which may run inside an Android/iOS process, waiting for iopad to send the interpretable object to execute.
vpand@MacBook-Pro icpp % icpp -h
OVERVIEW: ICPP v0.0.1.255 based on Unicorn and Clang/LLVM.
Interpreting C++, running C++ in anywhere like a script.
USAGE: icpp [options] file0 [file1 ...] [-- args]
OPTIONS:
-v, -version: print icpp version.
--version: print icpp and clang version.
-h, -help: print icpp help list.
--help: print icpp and clang help list.
-O0, -O1, -O2, -O3, -Os: optimization level passed to clang, default to -O2.
-I/path/to/include: header include directory passed to clang.
-L/path/to/library: library search directory passed to icpp interpreter.
-lname: full name of the dependent library file passed to icpp interpreter,
e.g.: liba.dylib, liba.so, a.dll.
-F/path/to/framework: framework search directory passed to icpp interpreter.
-fname: framework name of the dependent library file passed to icpp interpreter.
-p/path/to/json: a json configuration file for trace/profile/plugin/etc..
FILES: input file can be C++ source code(.c/.cc/.cpp/.cxx), MachO/ELF/PE executable.
ARGS: arguments passed to the main entry function of the input files.
e.g.:
icpp helloworld.cc
icpp helloworld.cc -- Hello World
i.e.: argc=3, argv[]={"helloworld.cc", "Hello", "World"}
icpp -O3 helloworld.cc
icpp -O0 -p/path/to/profile.json helloworld.cc
icpp -p/path/to/trace.json helloworld.exe
icpp -I/qt/include -L/qt/lib -llibQtCore.so hellowrold.cc
icpp -I/qt/include -L/qt/lib -lQtCore.dll hellowrold.cc
icpp -I/qt/include -F/qt/framework -fQtCore hellowrold.cc
vpand@MacBook-Pro icpp % icpp
ICPP v0.0.1.255. Copyright (c) vpand.com.
Running C++ in anywhere like a script.
>>> #include <stdio.h>
>>> puts("Hello, world.")
Hello, world.
>>> #include <iostream>
>>> std::cout << "Hello, world." << std::endl
Hello, world.
>>> std::cout << std::hex << 88888888 << std::endl
54c5638
vpand@MacBook-Pro icpp % imod -h
OVERVIEW: ICPP, Interpreting C++, running C++ in anywhere like a script.
IObject Module Manager Tool built with ICPP v0.0.1.255
USAGE: imod [options]
OPTIONS:
Generic Options:
--help - Display available options (--help-hidden for more)
--help-list - Display list of available options (--help-list-hidden for more)
--version - Display the version of this program
ICPP Module Manager Options:
--create=<string> - Create an icpp package from a json configuration file.
--install=<string> - Install an icpp package file.
--list - List all the installed modules.
--uninstall=<string> - Uninstall an installed module.
vpand@MacBook-Pro icpp % iopad -h
OVERVIEW: ICPP, Interpreting C++, running C++ in anywhere like a script.
IObject Launch Pad Tool built with ICPP v0.0.1.255
USAGE: iopad [options]
OPTIONS:
Generic Options:
--help - Display available options (--help-hidden for more)
--help-list - Display list of available options (--help-list-hidden for more)
--version - Display the version of this program
ICPP Interpretable Object Launch Pad Options:
--fire=<string> - Fire the input source file to the connected remote icpp-gadget to execute it.
--incdir=<string> - Specify the include directory for compilation, can be multiple.
--ip=<string> - Set the remote ip address of icpp-gadget.
--ndk=<string> - Set the Android NDK root path, default to the parent directory of the ndk-build in PATH.
--port=<int> - Set the connection port.
--repl - Enter into a REPL interactive shell to fire the input snippet code to the connected remote icpp-gadget to execute it.
ICPP_SRC/script:
- macOS ARM64 ✔
- Under developing...
OS | C++ Source | X86_64 Binary | AArch64 Binary | X86_64 on AArch64 | AArch64 on X86_64 |
---|---|---|---|---|---|
Windows | ✘ | ✘ | ✘ | ✘ | ✘ |
macOS | ✘ | ✘ | ✘ | ✘ | ✘ |
Linux | ✘ | ✘ | ✘ | ✘ | ✘ |
Make sure all of the prerequisites are in your system PATH environment:
- cmake (version >= 3.20)
- python (Windows), python3 (macOS/Linux)
- ninja (Windows), make (macOS/Linux)
# clone icpp
git clone --depth=1 https://github.com/vpand/icpp.git
cd icpp
# clone llvm, unicorn engine, boost, etc.
git submodule update --init --recursive --depth=1
mkdir build
cd build
# NOTE:
# all the following steps must be done in "x64 Native Tools Command Prompt for VS"
# or
# run VS_ROOT/.../VC/Auxiliary/Build/vcvarsall.bat to initialize for 'x64'
vcvarsall x64
# we use clang-cl as our compiler, to make it working, you should:
# have installed the Visual Studio with LLVM Toolchain support.
cmake -G Ninja -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_BUILD_TYPE=Release ..
cmake -DCMAKE_BUILD_TYPE=Release ..
# create the clang to be customized building scripts
cmake -B clangconf -DCMAKE_BUILD_TYPE=Release ../cmake/clangconf
# build our clang compiler with itself's libc++ support
cmake --build clangconf -- clang runtimes -j8
# use the clang that we built before as our compiler
cmake -DCMAKE_C_COMPILER=$PWD/llvm/bin/clang -DCMAKE_CXX_COMPILER=$PWD/llvm/bin/clang -DCMAKE_BUILD_TYPE=Release ..
# build the protoc compiler
cmake --build . -- protoc -j8
# build all the icpp components
cmake --build . -- icpp icppcli imod iopad icpp-gadget -j8
You can visit vpand.com for more information on VM, VMProtect, Clang/LLVM and Reverse Engineering products.
Or if you have any questions, just feel free to email to me: