Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

highly experimental macOS hijacking for v8killer launcher #28

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,24 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Build
- name: Build for Windows/Linux
if: matrix.os == 'ubuntu-latest' || matrix.os == 'windows-latest'
run: cargo build --verbose --release
- name: Build for macOS
if: matrix.os == 'macos-latest'
run: |
rustup target add aarch64-apple-darwin x86_64-apple-darwin
cargo build --verbose --release --target aarch64-apple-darwin
cargo build --verbose --release --target x86_64-apple-darwin
lipo -create -output target/libv8_killer_core.dylib \
target/aarch64-apple-darwin/release/libv8_killer_core.dylib \
target/x86_64-apple-darwin/release/libv8_killer_core.dylib
lipo -create -output target/v8_killer_launcher \
target/aarch64-apple-darwin/release/v8_killer_launcher \
target/x86_64-apple-darwin/release/v8_killer_launcher
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
Expand All @@ -24,3 +36,5 @@ jobs:
target/release/libv8_killer_core.so
target/release/libv8_killer_launcher.so
target/release/v8_killer_launcher
target/libv8_killer_core.dylib
target/v8_killer_launcher
30 changes: 24 additions & 6 deletions crates/launcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn default_lib_filename<'a>() -> Result<&'a str, Box<dyn Error>> {

#[cfg(target_os = "macos")]
{
// TODO: not sure
Ok("libv8_killer_core.dylib")
}

Expand All @@ -25,7 +24,7 @@ pub fn default_lib_filename<'a>() -> Result<&'a str, Box<dyn Error>> {
}

#[cfg(target_os = "linux")]
pub fn launch(lib_path: &str, executable: &str, args: &[String]) {
pub fn launch(lib_path: &str, executable: &str, args: &[&str]) {
use std::process::Command;
use std::process::ExitStatus;
use std::process::Stdio;
Expand All @@ -49,7 +48,7 @@ pub fn launch(lib_path: &str, executable: &str, args: &[String]) {
}

#[cfg(target_os = "windows")]
pub fn launch(lib_path: &str, executable: &str, args: &[String]) {
pub fn launch(lib_path: &str, executable: &str, args: &[&str]) {
use std::ffi::c_void;
use windows::core::PWSTR;
use windows::core::{s, w};
Expand Down Expand Up @@ -162,12 +161,31 @@ pub fn launch(lib_path: &str, executable: &str, args: &[String]) {
}

#[cfg(target_os = "macos")]
pub fn launch(lib_path: &str, exe_cmdline: &str) {
eprintln!("macOS is not supported yet.");
pub fn launch(lib_path: &str, executable: &str, args: &[&str]) {
use std::process::Command;
use std::process::ExitStatus;
use std::process::Stdio;

let mut child = Command::new(executable)
.args(args)
.env("DYLD_INSERT_LIBRARIES", lib_path)
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.spawn()
.expect("Failed to start command");

let status: ExitStatus = child.wait().expect("Failed to wait for child process");

if status.success() {
println!("Command executed successfully");
} else {
println!("Command failed with exit code: {:?}", status.code());
}
}

// 非以上系统
#[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
pub fn launch(lib_path: &str, exe_cmdline: &str) {
pub fn launch(lib_path: &str, executable: &str, args: &[&str]) {
eprintln!("Unsupported platform.");
}
3 changes: 2 additions & 1 deletion crates/launcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ fn main() {
let lib_path_str = lib_path.to_str().unwrap();

let exe = std::env::args().nth(1).expect("no executable provided");
let args = std::env::args().skip(2).collect::<Vec<String>>();
let args = std::env::args().skip(2).collect::<Vec<_>>();
let args = args.iter().map(|s| s.as_str()).collect::<Vec<_>>();

println!("[*] Executable: {}", exe);
println!("[*] Args: {:?}", args);
Expand Down
Loading