Skip to content

Instantly share code, notes, and snippets.

@vallahor
vallahor / README.md
Last active January 13, 2024 15:20

usage

python makedirs.py -f input.txt -o output.txt -indent 4

From a given txt file of directories and/or files structured by indentation generate a sh script that can create that directory tree. Be carefull with indentation.

Example:

@vallahor
vallahor / hook.odin
Created January 12, 2024 18:56
Hook Windows API (MessageBox) using Odin Lang
package hook
import "core:fmt"
import "core:intrinsics"
import "core:mem"
import "core:os"
import "core:runtime"
import "core:strings"
import win32 "core:sys/windows"
@vallahor
vallahor / is_anagram.py
Created November 5, 2023 17:21
short anagram check
def is_anagram(s1, s2):
if len(s1) != len(s2):
return False
result = 0
for c1, c2 in zip(s1, s2):
result ^= ord(c1) ^ ord(c2)
return result == 0
@vallahor
vallahor / main.cpp
Created August 8, 2023 01:43
Simple Thread Windows
#include <stdio.h.>
#include <windows.h>
#include <processthreadsapi.h>
DWORD WINAPI ThreadFn(PVOID param);
struct Inner {
const char* innerName;
int result;
@vallahor
vallahor / main.rs
Created August 6, 2023 20:54
Simple dll injector using CreateRemoteThread in rust
use std::ffi::CStr;
use windows_sys::{
core::*, Win32::Foundation::*, Win32::System::Diagnostics::Debug::*,
Win32::System::Diagnostics::ToolHelp::*, Win32::System::LibraryLoader::*,
Win32::System::Memory::*, Win32::System::StationsAndDesktops::*, Win32::System::Threading::*,
Win32::UI::WindowsAndMessaging::*,
};
fn get_pid(process: &str) -> Result<u32, &'static str> {
unsafe {
@vallahor
vallahor / main.cpp
Last active January 12, 2024 19:04
Simple dll injector using CreateRemoteThread
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>
DWORD GetPid(const char* processName) {
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (snapshot == INVALID_HANDLE_VALUE) {
printf("Snapshot error: %lu\n", GetLastError());
return 0;
}
@vallahor
vallahor / main.cpp
Last active January 12, 2024 19:04
Enum Processes Windows
#include <stdio.h>
#include <windows.h>
#include <tlhelp32.h>
#include <wtsapi32.h>
#pragma comment(lib, "wtsapi32")
void EnumProcToolhelp() {
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (snapshot == INVALID_HANDLE_VALUE)
@vallahor
vallahor / flatten_dict.py
Last active September 23, 2022 00:19
flatten dict in python
def flatten_dict_aux(data, acc, get="kv"):
if isinstance(data, list):
for lst in data:
flatten_dict_aux(lst, acc, get)
elif isinstance(data, dict):
for k, v in data.items():
if isinstance(v, list) or isinstance(v, dict):
flatten_dict_aux(v, acc, get)
# delete this else to get all keys even keys with dict and arrays
else: