mirror of
https://github.com/BlWasp/PhantomTask
synced 2026-06-06 15:24:26 +00:00
Help in README and rustfmt
This commit is contained in:
@@ -31,6 +31,23 @@ The compiled binary will be available at `target/release/phantomtask.exe`
|
||||
|
||||
## Usage
|
||||
|
||||
### Help
|
||||
|
||||
```powershell
|
||||
Usage: phantomtask.exe [OPTIONS]
|
||||
|
||||
Options:
|
||||
-l, --list List active sessions on the local machine
|
||||
-n, --name <taskname> The name of the task to create
|
||||
-f, --program <program> The program to execute
|
||||
-a, --arguments <arguments> The arguments to pass to the program
|
||||
-u, --username <username> The username to run the task as
|
||||
-p, --password <password> The password for the specified username
|
||||
-s, --sessionid <sessionid> The session ID to run the task in
|
||||
-h, --help Print help
|
||||
-V, --version Print version
|
||||
```
|
||||
|
||||
### List Active Sessions
|
||||
|
||||
Display all active Windows Terminal Services sessions with their details:
|
||||
|
||||
+6
-11
@@ -1,13 +1,13 @@
|
||||
mod utils;
|
||||
mod tasks;
|
||||
mod sessions;
|
||||
mod tasks;
|
||||
mod utils;
|
||||
|
||||
use sessions::list_active_sessions;
|
||||
use tasks::create_task;
|
||||
|
||||
use windows::Win32::System::RemoteDesktop::WTSGetActiveConsoleSessionId;
|
||||
use windows::Win32::System::Com::CoUninitialize;
|
||||
use clap::{Arg, Command};
|
||||
use windows::Win32::System::Com::CoUninitialize;
|
||||
use windows::Win32::System::RemoteDesktop::WTSGetActiveConsoleSessionId;
|
||||
|
||||
fn main() -> windows_core::Result<()> {
|
||||
let args = Command::new("PhantomTask")
|
||||
@@ -90,12 +90,7 @@ fn main() -> windows_core::Result<()> {
|
||||
println!();
|
||||
|
||||
match create_task(
|
||||
task_name,
|
||||
task_path,
|
||||
arguments,
|
||||
user_name,
|
||||
password,
|
||||
session_id,
|
||||
task_name, task_path, arguments, user_name, password, session_id,
|
||||
) {
|
||||
Ok(_) => {
|
||||
println!("\n[+] Task successfully created and executed!");
|
||||
@@ -105,7 +100,7 @@ fn main() -> windows_core::Result<()> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsafe {
|
||||
CoUninitialize();
|
||||
println!("[i] COM library uninitialized");
|
||||
|
||||
+3
-4
@@ -4,9 +4,8 @@ use std::ptr::null_mut;
|
||||
|
||||
use windows::Win32::System::RemoteDesktop::{
|
||||
WTSActive, WTSConnectQuery, WTSConnected, WTSDisconnected, WTSDomainName, WTSDown,
|
||||
WTSEnumerateSessionsW, WTSFreeMemory, WTSIdle, WTSInit,
|
||||
WTSListen, WTSQuerySessionInformationW, WTSReset, WTSShadow, WTSUserName,
|
||||
WTS_CURRENT_SERVER_HANDLE, WTS_SESSION_INFOW,
|
||||
WTSEnumerateSessionsW, WTSFreeMemory, WTSIdle, WTSInit, WTSListen, WTSQuerySessionInformationW,
|
||||
WTSReset, WTSShadow, WTSUserName, WTS_CURRENT_SERVER_HANDLE, WTS_SESSION_INFOW,
|
||||
};
|
||||
|
||||
use windows_core::BSTR;
|
||||
@@ -144,4 +143,4 @@ pub fn get_user_from_session(session_id: u32) -> Result<Option<BSTR>, windows::c
|
||||
Err(_) => return Ok(Some(BSTR::from("[!] WTSQuerySessionInformationW Error"))),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-8
@@ -7,11 +7,10 @@ use windows::Win32::System::Com::{
|
||||
COINIT_MULTITHREADED, EOAC_NONE, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, RPC_C_IMP_LEVEL_IMPERSONATE,
|
||||
};
|
||||
use windows::Win32::System::TaskScheduler::{
|
||||
IExecAction, IPrincipal, IRegisteredTask, IRegistrationInfo,
|
||||
ITaskDefinition, ITaskFolder, ITaskService, ITimeTrigger, TaskScheduler,
|
||||
TASK_ACTION_EXEC, TASK_CREATE_OR_UPDATE, TASK_INSTANCES_IGNORE_NEW,
|
||||
TASK_LOGON_INTERACTIVE_TOKEN, TASK_LOGON_PASSWORD, TASK_RUNLEVEL_HIGHEST, TASK_RUN_NO_FLAGS,
|
||||
TASK_RUN_USE_SESSION_ID, TASK_TRIGGER_TIME,
|
||||
IExecAction, IPrincipal, IRegisteredTask, IRegistrationInfo, ITaskDefinition, ITaskFolder,
|
||||
ITaskService, ITimeTrigger, TaskScheduler, TASK_ACTION_EXEC, TASK_CREATE_OR_UPDATE,
|
||||
TASK_INSTANCES_IGNORE_NEW, TASK_LOGON_INTERACTIVE_TOKEN, TASK_LOGON_PASSWORD,
|
||||
TASK_RUNLEVEL_HIGHEST, TASK_RUN_NO_FLAGS, TASK_RUN_USE_SESSION_ID, TASK_TRIGGER_TIME,
|
||||
};
|
||||
use windows::Win32::System::Variant::VARIANT;
|
||||
use windows_core::BSTR;
|
||||
@@ -195,8 +194,6 @@ pub fn create_task(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn register_with_session_id(
|
||||
task_folder: &ITaskFolder,
|
||||
task_name: &str,
|
||||
@@ -228,4 +225,3 @@ fn register_with_session_id(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -8,4 +8,4 @@ pub fn from_wide_string(wide: *const u16) -> String {
|
||||
let slice = std::slice::from_raw_parts(wide, len);
|
||||
String::from_utf16_lossy(slice)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user