Skip to content

Commit 256b6ed

Browse files
committed
v0.0.8
1 parent 36ff2eb commit 256b6ed

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ulexec"
3-
version = "0.0.7"
3+
version = "0.0.8"
44
edition = "2021"
55
license = "MIT"
66
readme = "README.md"

PKGBUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Maintainer: VHSgunzo <vhsgunzo.github.io>
22
pkgname='ulexec-bin'
33
binname="${pkgname%-bin}"
4-
pkgver='0.0.7'
4+
pkgver='0.0.8'
55
pkgrel='1'
66
pkgdesc='A tool for loading and executing PE on Windows and ELF on Linux from memory'
77
arch=("x86_64")

src/main.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ fn main() {
277277
#[cfg(target_os = "linux")]
278278
{
279279
use std::time;
280-
use std::process;
281280
use std::fs::File;
282281
use std::ffi::CString;
283282
use std::os::fd::AsRawFd;
@@ -305,6 +304,18 @@ fn main() {
305304
}
306305
}
307306

307+
fn random_string(length: usize) -> String {
308+
const CHARSET: &[u8] = b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
309+
let mut rng = time::SystemTime::now().duration_since(time::UNIX_EPOCH).unwrap().as_secs();
310+
let mut result = String::with_capacity(length);
311+
for _ in 0..length {
312+
rng = rng.wrapping_mul(48271).wrapping_rem(0x7FFFFFFF);
313+
let idx = (rng % CHARSET.len() as u64) as usize;
314+
result.push(CHARSET[idx] as char);
315+
}
316+
result
317+
}
318+
308319
fn ul_exec(file_path: PathBuf, exec_args: Vec<String>) {
309320
let mut args_cstrs: Vec<CString> = exec_args.iter()
310321
.map(|arg|
@@ -329,7 +340,7 @@ fn main() {
329340
}
330341

331342
if args.reexec && !is_child && !args.mfdexec {
332-
let fifo_path = &env::temp_dir().join(process::id().to_string());
343+
let fifo_path = &env::temp_dir().join(random_string(8));
333344
if let Err(err) = mkfifo(fifo_path, Mode::S_IRWXU) {
334345
eprintln!("Failed to create fifo: {err}: {:?}", fifo_path);
335346
exit(1)

0 commit comments

Comments
 (0)