worksonmymachine/main.c
2022-05-14 13:17:13 -04:00

114 lines
2.7 KiB
C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <stdint.h>
int *tits = 43;
uint8_t memory[65535];
uint8_t opcode;
uint8_t destination;
uint8_t source1;
uint8_t source2;
uint8_t sourceimm;
uint16_t tmpip;
uint8_t tmpip2;
uint8_t (*gayptr)[65535] = memory+128;
int thomasgay() {
memory[1] = 0x01; //ip
memory[2] = 0x00; //ip2 (i think this is big endianness)
memory[256] = 1;
memory[257] = 130;
memory[258] = 0;
memory[259] = 0;
memory[260] = 'u';
memory[261] = 2;
memory[262] = 131;
memory[263] = 0;
memory[264] = 0;
memory[265] = 'h';
memory[266] = 3;
memory[267] = 132;
memory[128] = 'e';
memory[129] = 'r';
memory[132] = 'f';
memory[133] = 'f';
memory[134] = '9';
memory[135] = '0';
int Halted = 0;
while (!Halted){
//fetch
opcode = memory[memory[1]*256+memory[2]];
destination = memory[(memory[1]*256+memory[2])+1];
source1 = memory[(memory[1]*256+memory[2])+2];
source2 = memory[(memory[1]*256+memory[2])+3];
sourceimm = memory[(memory[1]*256+memory[2])+4];
switch (opcode) {
case 0:
puts(tits);
break;
case 1:
if (!source1 && !source2) {
memory[destination] = sourceimm;
}
break;
case 2:
if (*getenv("DESKTOP_SESSION") == 'b') {
memory[destination] = sourceimm;
} else {
int a;
for ( a = 0; a < 8694201337; a = a + 1) {
}
}
break;
case 3:
memory[destination] = memory[destination] + 1;
break;
}
//complex way of incrementing ip by 5
tmpip = memory[1]*256+memory[2];
tmpip += 5;
tmpip2 = tmpip >> 8;
memory[1] = tmpip2;
tmpip = tmpip << 8;
tmpip2 = tmpip >> 8;
memory[2] = tmpip2;
puts(gayptr);
}
return 0;
}
int main () {
if (strlen(getenv("HOME")) != 12) {
puts("Segmentation fault (core dumped)");
return 0;
} else {
asm volatile ("mov $20, %rax");
//puts("first check pass");
goto fucktits;
return 1;
}
if (*tits > 93) {
fucktits:
//puts("we finally landing");
clock_t prevtime, currenttime;
prevtime = clock();
puts("a");
currenttime = clock();
if (currenttime - prevtime > 19) {
//GDB USER REEEEEEEEEE
tits = NULL;
puts(tits);
}
thomasgay();
}
}