mirror of
https://github.com/pumpbin/pumpbin
synced 2026-03-14 23:04:30 -07:00
fix(replace): no error returned when holder not found
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -3177,7 +3177,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pumpbin"
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "pumpbin"
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
authors = ["b1n <b1n@b1n.io>"]
|
||||
edition = "2021"
|
||||
description = "PumpBin is an Implant Generation Platform."
|
||||
|
||||
8
build.rs
8
build.rs
@@ -1,4 +1,6 @@
|
||||
fn build_capnp() {
|
||||
fn main() {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
capnpc::CompilerCommand::new()
|
||||
.src_prefix("capnp")
|
||||
.file("capnp/plugin.capnp")
|
||||
@@ -7,10 +9,6 @@ fn build_capnp() {
|
||||
.expect("schema compiler command");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
#[cfg(debug_assertions)]
|
||||
build_capnp();
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let mut res = winresource::WindowsResource::new();
|
||||
|
||||
@@ -479,14 +479,14 @@ impl Plugin {
|
||||
self.replace().src_prefix(),
|
||||
shellcode_src.as_slice(),
|
||||
self.replace().max_len(),
|
||||
);
|
||||
)?;
|
||||
|
||||
// replace pass
|
||||
for pass in pass {
|
||||
let holder = pass.holder();
|
||||
let replace_by = pass.replace_by();
|
||||
|
||||
utils::replace(bin, holder, replace_by, holder.len());
|
||||
utils::replace(bin, holder, replace_by, holder.len())?;
|
||||
}
|
||||
|
||||
// replace size_holder
|
||||
@@ -503,7 +503,7 @@ impl Plugin {
|
||||
.collect();
|
||||
size_bytes.extend_from_slice(shellcode_len_bytes.as_slice());
|
||||
|
||||
utils::replace(bin, size_holder, size_bytes.as_slice(), size_holder.len());
|
||||
utils::replace(bin, size_holder, size_bytes.as_slice(), size_holder.len())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
16
src/utils.rs
16
src/utils.rs
@@ -1,5 +1,6 @@
|
||||
use std::iter;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use iced::{
|
||||
advanced::graphics::image::image_rs::ImageFormat,
|
||||
window::{self, Level, Position},
|
||||
@@ -62,11 +63,17 @@ pub fn window_settings() -> window::Settings {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace(bin: &mut [u8], holder: &[u8], replace_by: &[u8], max_len: usize) {
|
||||
pub fn replace(
|
||||
bin: &mut [u8],
|
||||
holder: &[u8],
|
||||
replace_by: &[u8],
|
||||
max_len: usize,
|
||||
) -> anyhow::Result<()> {
|
||||
let mut replace_by = replace_by.to_owned();
|
||||
|
||||
let find = memmem::find_iter(bin, holder).next();
|
||||
if let Some(position) = find {
|
||||
let position = memmem::find_iter(bin, holder)
|
||||
.next()
|
||||
.ok_or(anyhow!("Not found {}", String::from_utf8_lossy(holder)))?;
|
||||
let mut random: Vec<u8> = iter::repeat(b'0')
|
||||
.take(max_len - replace_by.len())
|
||||
.collect();
|
||||
@@ -74,5 +81,6 @@ pub fn replace(bin: &mut [u8], holder: &[u8], replace_by: &[u8], max_len: usize)
|
||||
replace_by.extend_from_slice(random.as_slice());
|
||||
|
||||
bin[position..(position + max_len)].copy_from_slice(replace_by.as_slice());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user