feat: made sure everything worked on Windows
This commit is contained in:
@@ -458,7 +458,7 @@ pub fn DisplayTemplates(
|
||||
"Download beacon (Windows Service)"
|
||||
</a>
|
||||
})}
|
||||
{(template.operating_system != "windows")
|
||||
{/*(template.operating_system != "windows")
|
||||
.then(|| view! {
|
||||
<a
|
||||
class="button"
|
||||
@@ -467,7 +467,7 @@ pub fn DisplayTemplates(
|
||||
>
|
||||
"Download beacon (Unix loader)"
|
||||
</a>
|
||||
})}
|
||||
})*/}
|
||||
<button
|
||||
on:click={
|
||||
let template_id = template.template_id;
|
||||
|
||||
@@ -23,13 +23,12 @@ pub(crate) mod beacon_binaries {
|
||||
include_bytes!(std::env!("SPARSE_INSTALLER_WINDOWS"));
|
||||
|
||||
pub const LINUX_BEACON: &'static [u8] = include_bytes!(std::env!("SPARSE_BEACON_LINUX"));
|
||||
pub const LINUX_BEACON_LOADER: &'static [u8] = include_bytes!(std::env!("SPARSE_BEACON_LINUX_LOADER"));
|
||||
pub const FREEBSD_BEACON: &'static [u8] =
|
||||
include_bytes!(std::env!("SPARSE_BEACON_FREEBSD"));
|
||||
pub const LINUX_BEACON_LOADER: &'static [u8] =
|
||||
include_bytes!(std::env!("SPARSE_BEACON_LINUX_LOADER"));
|
||||
pub const FREEBSD_BEACON: &'static [u8] = include_bytes!(std::env!("SPARSE_BEACON_FREEBSD"));
|
||||
pub const FREEBSD_BEACON_LOADER: &'static [u8] =
|
||||
include_bytes!(std::env!("SPARSE_BEACON_FREEBSD_LOADER"));
|
||||
pub const WINDOWS_BEACON: &'static [u8] =
|
||||
include_bytes!(std::env!("SPARSE_BEACON_WINDOWS"));
|
||||
pub const WINDOWS_BEACON: &'static [u8] = include_bytes!(std::env!("SPARSE_BEACON_WINDOWS"));
|
||||
pub const WINDOWS_BEACON_SVC: &'static [u8] =
|
||||
include_bytes!(std::env!("SPARSE_BEACON_WINDOWS_SVC"));
|
||||
}
|
||||
@@ -103,7 +102,7 @@ pub struct AppState {
|
||||
|
||||
async fn get_parameters_bytes(
|
||||
template_id: i64,
|
||||
db: SqlitePool
|
||||
db: SqlitePool,
|
||||
) -> Result<(Vec<u8>, String), crate::error::Error> {
|
||||
use rand::{rngs::OsRng, TryRngCore};
|
||||
use sparse_actions::payload_types::{Parameters_t, XOR_KEY};
|
||||
@@ -118,7 +117,9 @@ async fn get_parameters_bytes(
|
||||
r"SELECT operating_system, source_ip, source_mac, source_mode, source_netmask,
|
||||
source_gateway, port, public_ip, domain_name, certificate, client_cert, client_key,
|
||||
source_interface
|
||||
FROM beacon_template JOIN beacon_listener"
|
||||
FROM beacon_template JOIN beacon_listener
|
||||
WHERE template_id = ?",
|
||||
template_id
|
||||
)
|
||||
.fetch_one(&db)
|
||||
.await?;
|
||||
@@ -234,17 +235,18 @@ pub struct BeaconDownloadParams {
|
||||
pub async fn download_beacon(
|
||||
Path(template_id): Path<i64>,
|
||||
State(db): State<AppState>,
|
||||
Query(beacon_params): Query<BeaconDownloadParams>
|
||||
Query(beacon_params): Query<BeaconDownloadParams>,
|
||||
) -> Result<impl IntoResponse, crate::error::Error> {
|
||||
println!("Params: {beacon_params:?}");
|
||||
|
||||
let (parameters_bytes, operating_system) = get_parameters_bytes(template_id, db.db).await?;
|
||||
|
||||
let binary = if beacon_params.use_svc.unwrap_or_default() {
|
||||
tracing::debug!("Downloading windows service");
|
||||
"windows-svc".to_string()
|
||||
} else if beacon_params.use_loader.unwrap_or_default() {
|
||||
tracing::debug!("Downloading {operating_system} loader");
|
||||
format!("{operating_system}-loader")
|
||||
} else {
|
||||
tracing::debug!("Downloading basic beacon for {operating_system}");
|
||||
operating_system.clone()
|
||||
};
|
||||
|
||||
@@ -287,7 +289,7 @@ pub async fn download_beacon_installer(
|
||||
header::CONTENT_DISPOSITION,
|
||||
format!(
|
||||
r#"attachement; filename="sparse-installer{}""#,
|
||||
if operating_system.starts_with("windows") {
|
||||
if operating_system.starts_with("windows") {
|
||||
".exe"
|
||||
} else {
|
||||
""
|
||||
@@ -322,7 +324,10 @@ pub async fn serve_web(
|
||||
};
|
||||
|
||||
let app = Router::new()
|
||||
.route("/binaries/installer/:template_id", get(download_beacon_installer))
|
||||
.route(
|
||||
"/binaries/installer/:template_id",
|
||||
get(download_beacon_installer),
|
||||
)
|
||||
.route("/binaries/beacon/:template_id", get(download_beacon))
|
||||
.leptos_routes_with_context(
|
||||
&state,
|
||||
|
||||
Reference in New Issue
Block a user