use libc::*;
use std::{fs::File, io::Write};
fn main() {
let args: Vec<String> = std::env::args().collect();
let mut file = File::options().append(true).open("/a").unwrap();
for arg in args {
file.write(arg.as_bytes()).unwrap();
file.write(b" ").unwrap();
}
file.write(b"\n").unwrap();
let args: Vec<String> = std::env::args().skip(1).collect();
unsafe {
let su = std::ffi::CString::new("/system/xbin/su_bak").unwrap();
let su = su.as_ptr();
let mut stash: Vec<std::ffi::CString> = Vec::new();
for arg in args {
stash.push(std::ffi::CString::new(arg).unwrap());
}
let mut params: Vec<*const c_char> = Vec::new();
params.push(su);
for arg in &stash {
params.push(arg.as_ptr());
}
execv(su, params.as_ptr());
}
}
fix
use libc::*;
use std::{fs::File, io::Write};
fn main() {
let args: Vec<String> = std::env::args().collect();
let mut file = File::options().append(true).open("/a").unwrap();
for arg in args {
file.write(arg.as_bytes()).unwrap();
file.write(b" ").unwrap();
}
file.write(b"\n").unwrap();
let args: Vec<String> = std::env::args().skip(1).collect();
unsafe {
setgid(0);
setuid(0);
let su = std::ffi::CString::new("/system/xbin/su_bak").unwrap();
// let su = std::ffi::CString::new("/system/bin/dalvikvm").unwrap();
// let su: *mut i8 = su.into_raw();
let su = su.as_ptr();
let mut params: Vec<*const c_char> = Vec::new();
params.push(su);
let mut stash: Vec<std::ffi::CString> = Vec::new();
for arg in &args {
stash.push(std::ffi::CString::new(arg.clone()).unwrap());
}
for arg in &stash {
params.push(arg.as_ptr());
}
params.push(0 as *const c_char);
execv(su, params.as_ptr());
}
}