Add !!Con 2021 content
This commit is contained in:
parent
6ff7b698d8
commit
c7b1af832e
21 changed files with 11551 additions and 0 deletions
35
content/pages/bangbangcon2021/demo/src/main.rs
Normal file
35
content/pages/bangbangcon2021/demo/src/main.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use crate::things::*;
|
||||
use libc::*;
|
||||
use std::{mem, slice, str};
|
||||
mod things;
|
||||
|
||||
use owoify::OwOifiable;
|
||||
static mut REAL_WRITE: Option<LibcWrite> = None;
|
||||
|
||||
unsafe extern "C" fn write_owo(fd: i32, ptr: *const c_void, len: usize) -> isize {
|
||||
let s = slice::from_raw_parts(ptr as *const _, len);
|
||||
let s = str::from_utf8(s).unwrap();
|
||||
let owoified = s.to_string().owoify();
|
||||
|
||||
REAL_WRITE.unwrap()(fd, owoified.as_ptr() as *const _, owoified.len());
|
||||
len as isize
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let addr = get_hex_from_cmdline();
|
||||
let addr = (addr + 0x555555554000) as *mut usize;
|
||||
|
||||
unsafe {
|
||||
REAL_WRITE = Some(mem::transmute(*addr));
|
||||
mprotect(
|
||||
(addr as usize & !(0x1000 - 1)) as *mut _,
|
||||
0x1000,
|
||||
PROT_READ | PROT_WRITE,
|
||||
);
|
||||
*addr = write_owo as usize;
|
||||
}
|
||||
let s = "hello !!con!!\n";
|
||||
unsafe { write(1, s.as_ptr() as *const _, s.len()) };
|
||||
|
||||
println!("hello !!con!! from println");
|
||||
}
|
||||
4
content/pages/bangbangcon2021/demo/src/things.rs
Normal file
4
content/pages/bangbangcon2021/demo/src/things.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
pub type LibcWrite = unsafe extern "C" fn(fd: i32, ptr: *const libc::c_void, len: usize) -> isize;
|
||||
pub fn get_hex_from_cmdline() -> usize {
|
||||
usize::from_str_radix(&std::env::args().skip(1).next().unwrap(), 16).unwrap()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue