Skip to content

Commit

Permalink
Feature/improve command line (#96)
Browse files Browse the repository at this point in the history
Overall fixes
  • Loading branch information
cosmic-zip authored Jan 13, 2025
1 parent 7306081 commit ea3dd48
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 47 deletions.
10 changes: 5 additions & 5 deletions spellbook/archive/dataset/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,27 +383,27 @@
{
"name": "search.ans",
"description": "Search ans for ipv4 and ipv6",
"command": "search.ans --ip ip_address"
"command": "search.ans @@ip ip_address"
},
{
"name": "search.geoloc",
"description": "Geolocation search for coordinates",
"command": "search.geoloc --ip ip_address"
"command": "search.geoloc @@ip ip_address"
},
{
"name": "search.proxy",
"description": "Search proxy for IP routing",
"command": "search.proxy --ip ip_address"
"command": "search.proxy @@ip ip_address"
},
{
"name": "search.ipscore",
"description": "IP scoring for security (CIN score)",
"command": "search.ipscore --ip ip_address"
"command": "search.ipscore @@ip ip_address"
},
{
"name": "search.meta",
"description": "Social media profile search in over 1000 platforms",
"command": "search.social --keyword nickname"
"command": "search.social @@keyword nickname"
},
{
"name": "view.applogs",
Expand Down
4 changes: 3 additions & 1 deletion spellbook/archive/osint/osintdb.json
Original file line number Diff line number Diff line change
Expand Up @@ -11001,7 +11001,9 @@
"country": "United States",
"nsfw": "false",
"match_positive": [],
"match_negative": []
"match_negative": [
"Sign in to"
]
},
{
"url": "https://@@keyword.svbtle.com/",
Expand Down
1 change: 1 addition & 0 deletions witchcraft/src/core/consts.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub const SW_DEBUG: bool = false;
pub const TONK: &str = "@@";
pub const SPLIT_II: &str = "--";
pub const SPLIT_I: &str = "-";
Expand Down
92 changes: 51 additions & 41 deletions witchcraft/src/modules/osint/meta_search.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::core::consts::SW_DEBUG;
use crate::core::core::*;
use headless_chrome::{Browser, LaunchOptionsBuilder};
use reqwest::blocking::Client;
Expand Down Expand Up @@ -28,41 +29,7 @@ pub fn read_json_file(file_path: &str) -> OsintDatabase {
data
}

pub fn exec_meta_search(data: OsintEntry, keyword: &str) {
fn filter(data: OsintEntry, content: String, keyword: &str) {
let mut positive_found: Vec<String> = Vec::new();
let mut negative_found: Vec<String> = Vec::new();

if data.match_negative.is_empty() {
raise("Negative patterns can't be empty!", "fail");
}

for ps in &data.match_positive {
if content.to_lowercase().contains(&ps.to_lowercase()) {
positive_found.push(ps.to_string());
}
}

for ng in &data.match_negative {
if content.to_lowercase().contains(&ng.to_lowercase()) {
negative_found.push(ng.to_string());
}
}

if negative_found.is_empty() {
let key = data.url.replace("@@keyword", keyword);
raise(&format!("Found! :: {}", key), "good");
raise("Adicional information", "none");
raise(&format!("\t Category: {}", data.category), "none");
raise(&format!("\t Global rank: {}", data.global_rank), "none");
raise(&format!("\t Country: {}", data.country), "none");
raise(&format!("\t Is nsfw: {}\n", data.nsfw), "none");
}
}

let url = &data.url.replace("@@keyword", &keyword);

let client = Client::new();
fn grep_page_content(url: String) -> String {
let browser = Browser::new(
LaunchOptionsBuilder::default()
.headless(true)
Expand All @@ -81,19 +48,19 @@ pub fn exec_meta_search(data: OsintEntry, keyword: &str) {
&format!("Failed to navigate to URL: {}", err.to_string()),
"fail",
);
return;
return String::new();
}
}

match tab.wait_until_navigated() {
Ok(_) => {}
Err(err) => {
raise(&format!("exec_meta_search :: {}", err.to_string()), "fail");
return;
return String::new();
}
}

match tab.wait_for_element_with_custom_timeout("body", Duration::from_secs(30)) {
match tab.wait_for_element_with_custom_timeout("body", Duration::from_secs(15)) {
Ok(_element) => {
// element.click().unwrap(); // Example action
}
Expand All @@ -102,20 +69,63 @@ pub fn exec_meta_search(data: OsintEntry, keyword: &str) {
&format!("Element was not found within timeout: {}", err.to_string()),
"fail",
);
return;
return String::new();
}
}

let content = tab.get_content().unwrap();
return content;
}

pub fn exec_meta_search(data: OsintEntry, keyword: &str) {
fn filter(data: OsintEntry, content: String, keyword: &str) {
let mut positive_found: Vec<String> = Vec::new();
let mut negative_found: Vec<String> = Vec::new();

if data.match_negative.is_empty() {
raise("Negative patterns can't be empty!", "fail");
}

for ps in &data.match_positive {
if content.to_lowercase().contains(&ps.to_lowercase()) {
positive_found.push(ps.to_string());
}
}

for ng in &data.match_negative {
if content.to_lowercase().contains(&ng.to_lowercase()) {
negative_found.push(ng.to_string());
}
}

if negative_found.is_empty() {
let key = data.url.replace("@@keyword", keyword);
raise(&format!("Found! :: {}", key), "good");
raise("Adicional information", "none");
raise(&format!("\t Category: {}", data.category), "none");
raise(&format!("\t Global rank: {}", data.global_rank), "none");
raise(&format!("\t Country: {}", data.country), "none");
raise(&format!("\t Is nsfw: {}\n", data.nsfw), "none");
}
}

let url = &data.url.replace("@@keyword", &keyword);
let client = Client::new();

match client.get(url).send() {
Ok(res) => {
if res.status().as_u16() == 200 || res.status().as_u16() == 404 {
if res.status().as_u16() == 200 {
let content = grep_page_content(url.to_string());
filter(data, content, keyword);
}
}
Err(err) => {
raise(&format!("exec_meta_search :: {}", err.to_string()), "fail");
if SW_DEBUG {
raise(
&format!("exec_meta_search :: URL :: {} \n {}", url, err.to_string()),
"fail",
);
}
return;
}
}
Expand Down

0 comments on commit ea3dd48

Please sign in to comment.