Skip to content

Instantly share code, notes, and snippets.

View ldmsys's full-sized avatar

Dongmin Lee ldmsys

View GitHub Profile
@ldmsys
ldmsys / arch-dropbear.patch
Last active July 8, 2024 00:06
Arch Linux mkinitcpio-dropbear patch for support copying ED25519 key from host
--- dropbear.old 2024-07-08 08:56:16.334606650 +0900
+++ dropbear 2024-07-08 09:05:31.146341355 +0900
@@ -8,7 +8,7 @@
display_fingerprints() {
local keyfile
- for keyfile in "/etc/dropbear/dropbear_rsa_host_key" "/etc/dropbear/dropbear_dss_host_key" "/etc/dropbear/dropbear_ecdsa_host_key" ; do
+ for keyfile in "/etc/dropbear/dropbear_rsa_host_key" "/etc/dropbear/dropbear_dss_host_key" "/etc/dropbear/dropbear_ecdsa_host_key" "/etc/dropbear/dropbear_ed25519_host_key" ; do
if [ -s "${keyfile}" ] ; then
echo "$(basename "${keyfile}") : $(get_fingerprint "${keyfile}")"
@ldmsys
ldmsys / fakemcserver-minimal.c
Last active March 7, 2024 00:40
FakeMCServer Minimal Edition (requires 3 syscall: read(), write(), close())
#define MC_MTU 1500
#define MC_COLOR_PREFIX "\xc2\247"
#define MC_MOTD MC_COLOR_PREFIX "b" MC_COLOR_PREFIX "l" "FakeMCServer Test"
#define MC_KICK_MESSAGE "You are not white-listed on this server!"
typedef int type_debug_func (const char*, ...);
size_t mc_varintSize(unsigned char* varint) {
int i;
for(i=0;i<4;i++) if((varint[i] & 0x80) == 0) break;
@ldmsys
ldmsys / syscall_bomb.c
Last active November 24, 2023 15:23
syscall bomb test
#define TEST_CNT 10000000UL
void _start() {
for(long long i=0;i<TEST_CNT;i++) {
__asm( "mov $0xa9, %rax\n\t"
"mov $0xfee1dead, %rdi\n\t"
"mov $0x28121969, %rsi\n\t"
"mov $0x89abcdef, %rdx\n\t"
"syscall\n\t");
From dd0dc8f645a038a50de65664ac072db5ca069931 Mon Sep 17 00:00:00 2001
From: Dongmin Lee <[email protected]>
Date: Fri, 3 Nov 2023 12:59:28 +0900
Subject: [PATCH] kernel/reboot: Explictly notify if halt occurred instead of
power off
When kernel_can_power_off() returns false, and reboot has called with
LINUX_REBOOT_CMD_POWER_OFF, kernel_halt() will be initiated instead of
actual power off function.
@ldmsys
ldmsys / qemu-ga-install-vendor.yaml
Last active October 13, 2023 08:11
vendor-data that installs qemu-ga
#cloud-config
ssh_pwauth: True
chpasswd: { expire: False }
runcmd:
- mkdir -p /etc/qemu/fsfreeze-hook.d
- echo IyEvYmluL3NoCgojIFRoaXMgc2NyaXB0IGlzIGV4ZWN1dGVkIHdoZW4gYSBndWVzdCBhZ2VudCByZWNlaXZlcyBmc2ZyZWV6ZS1mcmVlemUgYW5kCiMgZnNmcmVlemUtdGhhdyBjb21tYW5kLCBpZiBpdCBpcyBzcGVjaWZpZWQgaW4gLS1mc2ZyZWV6ZS1ob29rICgtRikKIyBvcHRpb24gb2YgcWVtdS1nYSBvciBwbGFjZWQgaW4gZGVmYXVsdCBwYXRoICgvZXRjL3FlbXUvZnNmcmVlemUtaG9vaykuCiMgV2hlbiB0aGUgYWdlbnQgcmVjZWl2ZXMgZnNmcmVlemUtZnJlZXplIHJlcXVlc3QsIHRoaXMgc2NyaXB0IGlzIGlzc3VlZCB3aXRoCiMgImZyZWV6ZSIgYXJndW1lbnQgYmVmb3JlIHRoZSBmaWxlc3lzdGVtIGlzIGZyb3plbi4gQW5kIGZvciBmc2ZyZWV6ZS10aGF3CiMgcmVxdWVzdCwgaXQgaXMgaXNzdWVkIHdpdGggInRoYXciIGFyZ3VtZW50IGFmdGVyIGZpbGVzeXN0ZW0gaXMgdGhhd2VkLgoKTE9HRklMRT0vdmFyL2xvZy9xZ2EtZnNmcmVlemUtaG9vay5sb2cKRlNGUkVFWkVfRD0kKGRpcm5hbWUgLS0gIiQwIikvZnNmcmVlemUtaG9vay5kCgojIENoZWNrIHdoZXRoZXIgZmlsZSAkMSBpcyBhIGJhY2t1cCBvciBycG0tZ2VuZXJhdGVkIGZpbGUgYW5kIHNob3VsZCBiZSBpZ25vcmVkCmlzX2lnbm9yZWRfZmlsZSgpIHsKICAgIGNhc2UgIiQxIiBpbgogICAgICAgICp+IHwgKi5iYWsgfCAqL
@ldmsys
ldmsys / get128FromUUID.c
Created June 14, 2023 05:14
Get __uint128_t integer from UUID string (tested on clang-1403.0.22.14.1)
__uint128_t get128FromUUID(const char* uuid) {
__uint128_t result = 0;
unsigned char currentData, dashcnt = 0;
if(uuid[36] != 0x00)
return (__uint128_t)0xf << 124; // length mismatch
for(unsigned char i=0;i<36;i++) {
if(uuid[i] >= 0x30 && uuid[i] <= 0x39) currentData = uuid[i] - 0x30; // Numberic digit
else if(uuid[i] >= 0x41 && uuid[i] <= 0x46) currentData = 10 + uuid[i] - 0x41; // Capital letter digit
else if(uuid[i] >= 0x61 && uuid[i] <= 0x66) currentData = 10 + uuid[i] - 0x61; // small letter digit
const http = require('http');
const API_KEY = "[INSERT_API_KEY_HERE]"; // https://data.seoul.go.kr/dataList/OA-15488/S/1/datasetView.do
const url = 'http://openapi.seoul.go.kr:8088/'+API_KEY+'/json/WPOSInformationTime/1/5';
async function getTemp() {
return new Promise(function(resolve, reject) {
const req = http.request(url, {
url: url,
method: 'GET'
}, function (res) {
typedef LONG(WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
/* Ref: https://learn.microsoft.com/ko-kr/windows-server/get-started/kms-client-activation-keys */
void kms_activation(const char* server_addr) {
HMODULE hMod = GetModuleHandleW(L"ntdll.dll");
if (!hMod) {
fprintf(stderr, "Error: Loading ntdll.dll failed successfully");
return;
}
@ldmsys
ldmsys / bsod.c
Created June 4, 2023 00:35
이게 뭐였더라
#include <stdio.h>
#include <Windows.h>
typedef NTSTATUS(NTAPI *pdef_RtlAdjustPrivilege) (ULONG privilege,BOOLEAN enable,BOOLEAN current_thread,PBOOLEAN enabled);
typedef NTSTATUS(NTAPI *pdef_NtRaiseHardError)(NTSTATUS error_status,ULONG number_of_parameters,ULONG unicode_string_parameter_mask,PULONG_PTR parameters,ULONG response_option,PULONG reponse);
int main(void) {
pdef_RtlAdjustPrivilege RtlAdjustPrivilege = (pdef_RtlAdjustPrivilege)GetProcAddress(LoadLibraryA("ntdll.dll"), "RtlAdjustPrivilege");
BOOLEAN enabled;
if (RtlAdjustPrivilege(19, TRUE, FALSE, &enabled) == 0)
@ldmsys
ldmsys / detectKeyDown.js
Last active January 6, 2023 07:24
MacBook 버터플라이 키보드 키 중복 이슈 증명용
// 개발자 도구 콘솔에 아래 코드를 붙여넣고 문서를 포커스하여 테스트하세요.
document.clear(); document.write("<br>");
var pk = 0;
window.onkeyup = () => {pk = 0};
window.onkeydown = (k) => {if(pk!=k.keyCode){document.write((+new Date())+k.key+"<br>"); pk=k.keyCode}};