Skip to content

Instantly share code, notes, and snippets.

View segfo's full-sized avatar

segfo segfo

View GitHub Profile
@segfo
segfo / WMIPersistence.ps1
Last active August 7, 2024 06:43
WMIを用いた永続化手法(CimInstance版)
// 参考:https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1546.003/T1546.003.md
Param(
[ValidateSet("Persistence","Clean")]$Mode="Persistence",
[ValidateSet("OnStartup","OnLogon","OnInterval","OnTime")]$Trigger="OnStartup",
[string]$FilterName = 'WMIEventFilter Persistence',
[string]$ConsumerName = "WMIEventConsumer Persistence",
[int]$IntervalPeriod = 3600,
[string]$ExecutionTime = '10:00:00',
[string]$Command
)
@segfo
segfo / ワンライナー
Created November 1, 2023 14:18
one liner.txt
$otp = "cargo run --";iex $otp" --no-tui -g"|findstr /r /c:"/[0-9]"| %{$_ -replace ".*/","" }|%{for ($i=0;$i -le $_;$i++){ iex $otp" --no-tui -g -n $i" |findstr "otpauth"| %{qrcode -s -d $_};.\qrcode.svg}}
@segfo
segfo / IteratorSample.java
Last active September 5, 2021 12:21
イテレータのサンプル
import java.util.Iterator;
class IteratorSample {
public static void main(String[ ] args) {
FibonacciNumberGenerator fib = new FibonacciNumberGenerator();
for(int n: fib){
System.out.println(n+" ");
}
}
}
@segfo
segfo / recursive_trampoline.rs
Last active August 14, 2021 23:53
Rustで末尾再帰のトランポリン化
enum RetVal {
Num(u128),
Recursive(Box<dyn Fn() -> RetVal>),
}
fn trampoline(r: RetVal) -> u128 {
let mut r = r;
loop {
match &r {
RetVal::Recursive(func) => {
@segfo
segfo / memorymap_day2.csv
Last active April 5, 2021 12:39
みかん本メモリマップ
We can make this file beautiful and searchable if this error is corrected: Any value after quoted field isn't allowed in line 1.
"Physical Address":"0x00000000","Virtual Address":"0x00000000","Pages":160,"Memory Type":"CONVENTIONAL","Attributes":"UNCACHEABLE | WRITE_COMBINE | WRITE_THROUGH | WRITE_BACK"
"Physical Address":"0x00100000","Virtual Address":"0x00000000","Pages":1824,"Memory Type":"CONVENTIONAL","Attributes":"UNCACHEABLE | WRITE_COMBINE | WRITE_THROUGH | WRITE_BACK"
"Physical Address":"0x00820000","Virtual Address":"0x00000000","Pages":2016,"Memory Type":"BOOT_SERVICES_DATA","Attributes":"UNCACHEABLE | WRITE_COMBINE | WRITE_THROUGH | WRITE_BACK"
"Physical Address":"0x01000000","Virtual Address":"0x00000000","Pages":503808,"Memory Type":"CONVENTIONAL","Attributes":"UNCACHEABLE | WRITE_COMBINE | WRITE_THROUGH | WRITE_BACK"
"Physical Address":"0x7c000000","Virtual Address":"0x00000000","Pages":32,"Memory Type":"BOOT_SERVICES_DATA","Attributes":"UNCACHEABLE | WRITE_COMBINE | WRITE_THROUGH | WRITE_BACK"
"Physical Address":"0x7c020000","Virtual Address":"0x00000000","Pages":9923,"Memory Type":"CONVENTIONAL","Attributes":"UNCACHEAB
@segfo
segfo / input.rs
Created April 15, 2020 00:54
AtCoder入力マクロ
use std::io::BufRead;
macro_rules! readlines {
($cnt:expr) => {
{
let stdin = std::io::stdin();
let mut handle = stdin.lock();
let mut result = Vec::new();
for i in 0..$cnt{
let mut buf = String::new();
@segfo
segfo / Cargo.toml
Last active September 21, 2019 10:14
DLL検索順序の不備によるDLLの乗っ取りに脆弱なコードと検証用コード
[package]
name = "sideloading_dll"
version = "0.1.0"
authors = ["segfo <[email protected]>"]
edition = "2018"
[lib]
name = "sideloading"
path = "src/lib.rs"
crate-type = ["dylib"]
@segfo
segfo / buffering_test.py
Created June 27, 2019 17:38
子プロセス起動&子プロセスの標準出力を順次取得
import time
cnt=0
while True:
cnt+=1
if cnt > 5:
break
time.sleep(1)
print("python: "+str(cnt))
@segfo
segfo / config_deserializer.rs
Last active June 26, 2019 15:54
汎用デシリアライザ
use std::marker::PhantomData;
use serde_derive::{Serialize,Deserialize};
use serde::de::DeserializeOwned;
struct TomlConfigDeserializer<T>{
_t:PhantomData<T>
}
use std::fs::OpenOptions;
use std::io::{BufReader,prelude::*};
@segfo
segfo / resource_pool.rs
Last active June 23, 2019 03:35
汎用リソースプール
use std::collections::{VecDeque,HashMap};
// リソースプール
pub struct ResourceAllocator<K,V>{
pool:VecDeque<V>,
used_pool:HashMap<K,V>
}
impl<K,V> ResourceAllocator<K,V>
where K:std::cmp::Eq+std::hash::Hash+Clone{
pub fn new()->Self{
ResourceAllocator{