metasploit/msf/async/
sessions.rs1#![allow(non_camel_case_types)]
2use crate::client::Client;
3use crate::error::Error as E;
4use serde::de::DeserializeOwned as DOwned;
5#[path="../blocking/sessions.rs"] mod sessions;
6
7pub async fn list<T:DOwned>(client:Client) -> Result<T,E> {
8 sessions::list(client.clone())
9}
10pub async fn stop<T:DOwned>(client:Client,sessionidstr:&str) -> Result<T,E> {
11 sessions::stop(client.clone(),sessionidstr)
12}
13pub struct shell;
14impl shell {
15 pub async fn read<T:DOwned>(client:Client,sessionidstr:&str,readpointer:Option<i32>) -> Result<T,E> {
16 sessions::shell::read(client.clone(),sessionidstr,readpointer)
17 }
18 pub async fn write<T:DOwned>(client:Client,sessionidstr:&str,datastr:&str) -> Result<T,E> {
19 sessions::shell::write(client.clone(),sessionidstr,datastr)
20 }
21}
22pub struct meterpreter {
23 pub sessionid:String,
24 pub client:Client,
25}
26impl meterpreter {
27 pub fn new(client:Client,sessionidstr:&str) -> Self {
28 meterpreter {
29 sessionid:sessionidstr.to_string(),
30 client:client,
31 }
32 }
33 pub async fn write<T:DOwned>(&self,datastr:&str) -> Result<T,E> {
34 let mtpr=sessions::meterpreter::new(self.client.clone(),&self.sessionid);
35 mtpr.write(datastr)
36 }
37 pub async fn read<T:DOwned>(&self) -> Result<T,E> {
38 let mtpr=sessions::meterpreter::new(self.client.clone(),&self.sessionid);
39 mtpr.read()
40 }
41 pub async fn run_single<T:DOwned>(&self,commandstr:&str) -> Result<T,E> {
42 let mtpr=sessions::meterpreter::new(self.client.clone(),&self.sessionid);
43 mtpr.run_single(commandstr)
44 }
45 pub async fn script<T:DOwned>(&self,scriptnamestr:&str) -> Result<T,E> {
46 let mtpr=sessions::meterpreter::new(self.client.clone(),&self.sessionid);
47 mtpr.script(scriptnamestr)
48 }
49 pub async fn detach_session<T:DOwned>(&self) -> Result<T,E> {
50 let mtpr=sessions::meterpreter::new(self.client.clone(),&self.sessionid);
51 mtpr.detach_session()
52 }
53 pub async fn kill_session<T:DOwned>(&self) -> Result<T,E> {
54 let mtpr=sessions::meterpreter::new(self.client.clone(),&self.sessionid);
55 mtpr.kill_session()
56 }
57 pub async fn tabs<T:DOwned>(&self,inputlinestr:&str) -> Result<T,E> {
58 let mtpr=sessions::meterpreter::new(self.client.clone(),&self.sessionid);
59 mtpr.tabs(inputlinestr)
60 }
61 pub async fn compactible_modules<T:DOwned>(&self) -> Result<T,E> {
62 let mtpr=sessions::meterpreter::new(self.client.clone(),&self.sessionid);
63 mtpr.compactible_modules()
64 }
65}
66pub async fn shell_upgrade<T:DOwned>(client:Client,sessionidstr:&str,connecthoststr:&str,connectport:i32) -> Result<T,E> {
67 sessions::shell_upgrade(client.clone(),sessionidstr,connecthoststr,connectport)
68}
69pub struct ring {
70 client:Client,
71 sessionid:String,
72}
73impl ring {
74 pub fn new(client:Client,sessionid:&str) -> Self {
75 ring {
76 client:client,
77 sessionid:sessionid.to_string(),
78 }
79 }
80 pub async fn clear<T:DOwned>(&self) -> Result<T,E> {
81 let rng=sessions::ring::new(self.client.clone(),&self.sessionid);
82 rng.clear()
83 }
84 pub async fn last<T:DOwned>(&self) -> Result<T,E> {
85 let rng=sessions::ring::new(self.client.clone(),&self.sessionid);
86 rng.last()
87 }
88 pub async fn put<T:DOwned>(&self,datastr:&str) -> Result<T,E> {
89 let rng=sessions::ring::new(self.client.clone(),&self.sessionid);
90 rng.put(datastr)
91 }
92}