-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
88 lines (71 loc) · 2.87 KB
/
run.sh
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
sudo clear
#Run this in the build folder!!!
#Credits to:
#0xAgartha - https://www.unknowncheats.me/forum/members/5290135.html
#ghostrazzor - https://www.unknowncheats.me/forum/members/2764232.html
# Function to handle errors
handle_error() {
echo "Error: $1"
exit 1
}
# Main directory path is where the script is executed
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Log file path in the main directory
log_file="$script_dir/script_log.txt"
# Function to log messages
log() {
echo "$(date +"%Y-%m-%d %H:%M:%S") - $1" >> "$log_file" || handle_error "Failed to write to log file: $log_file"
}
# Create log file directory if it doesn't exist
mkdir -p "$script_dir" || handle_error "Failed to create log directory: $script_dir"
# Log script start
log "Script started"
# Original binary name
original_binary_name="nanoclient"
# Generate a random name for the temporary binary
temp_binary_name=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)
# Temporary path for the temporary binary
temp_binary_path="/$script_dir/$temp_binary_name"
# Copy the original binary to the temporary path
if ! cp "$script_dir/$original_binary_name" "$temp_binary_path"; then
log "Failed to copy binary: $script_dir/$original_binary_name to $temp_binary_path"
exit 1
fi
log "Binary copied: $script_dir/$original_binary_name to $temp_binary_path"
# Log the binary being executed
log "Executing binary: $temp_binary_name"
# Execute the binary
sleep 0.3
echo "Executing $original_binary_name as $temp_binary_name"
sleep 0.3
# Execute the binary with XDG_RUNTIME_DIR set to avoid ugly error in console, the dir (usually doesn't exist)
# but it doesn't matter, it breaks nothing... if we run the binary as sudo it just doesn't have that env variable set
# meaning random stuff that's looking for that variable is warning us in console without actually needing the folder lol
(sudo env XDG_RUNTIME_DIR="/run/user/0" "./$temp_binary_name") & pid=$! # Get the PID of the executed binary
log "Binary executed with PID: $pid"
# Hide the PID of the executed binary and its child processes
if echo "$pid" | sudo tee /proc/sys/kernel/ns_last_pid > /dev/null; then
log "Process ID $pid hidden successfully"
# Hide child process PIDs
child_pids=$(pgrep -P $pid)
for child_pid in $child_pids; do
if echo "$child_pid" | sudo tee /proc/sys/kernel/ns_last_pid > /dev/null; then
log "Child process ID $child_pid hidden successfully"
else
log "Failed to hide child process ID $child_pid"
fi
done
else
log "Failed to hide process ID $pid"
fi
# Wait for the binary to finish execution
if ! wait $pid; then
#log "Failed to execute binary with PID: $pid"
log "Deleting binary with PID: $pid"
rm "$temp_binary_name"
exit 1
fi
log "Binary execution completed"
# Log script end
log "Script completed"