We expect a high standard of professionalism from you at all times while you are taking any of our courses. We expect all students to act in good faith at all times
do this irl its really fun
644[357]might be on webcms but I dont have access to that ll
COMP6447 is cool
reverse engineering
all code is oss if you’re good at re
before re, what about e?
how does your code become a binary?
optimization is the devil
we’re only talking about C binaries
they’re usually just a lot more tedious
surely theres an easier way to do this

very important to have tools that perform analysis
disassembling
e.g. ida, ghidra, radare, binary ninja
debugging
e.g. gdb, ltrace, strace, windbg
im an official:TM: default gdb hater
if you’re using gdb, install an extension e.g. pwndbg, gef, or peda
reversing is hard, and takes a lot of time

lol idk either
time for a demo

how close were we?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *re3(char *s1, char *s2) {
size_t a = strlen(s1);
size_t b = strlen(s2);
s1 = realloc(s1, (a + b + 1));
memcpy(s1 + a, s2, b + 1);
return s1;
}
int main(void) {
return 0;
}
how does assembly work


x86 uses the cdecl calling convention
its just convention, not guaranteed. not everything uses it
function(x, y, z):
push z
push y
push x
call function
add esp, 0xC
basic example
0x30 [ ARGS ] <- parameters
0x28 [ EIP ] <- stored return pointer
0x20 [ EBP ] <- stored frame pointer
0x18 [ AAAAAAAA ] <- local vars
0x10 [ 00000000 ] <- an int?
0x08 [ DEADBEEF ] <- a pointer
0x00 [ 59454554 ] <- 4 characters
referenced in relation to ebp e.g. ebp-0x4
ebp-0x4ebp+0x8instructions give context to the variables they act on

why are these instructions different?
mov eax, dword ptr [esp]
mov eax, word ptr [esp]
mov eax, byte ptr [esp]
mov ax, [esp]
mov al, [esp]
stands for move
mov eax, ebx # eax = ebx
mov eax, [ebx] # eax = *ebx
mov eax, [ebx + 4] # eax = *(ebx + 4)
what might that last one represent?
stands for load effective address
lea eax, [ebx + 8]
# equivalent to
mov eax, ebx
add eax, 8
often used for fast addition/multiplication
lea eax, [ebx * 4 + 8]
the two main comparison instructions
TEST <a> <b> # a & b
CMP <a> <b> # a - b
Sets zero/negative/positive flags in EFLAGS
now we’ve done a comparison, we can (maybe) jump
some will be signed comparisons, some not
degarbage
const print_nums = (nums) => {
nums.forEach((e) => console.log(`Hello ${e}!`));
}
print_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
(function(_0x20a892,_0x42c6a2){const _0x110cc6=_0x3fb9,_0x5e470a=_0x20a892();while(!![]){try{const _0x28667e=-parseInt(_0x110cc6(0xd6))/0x1+-parseInt(_0x110cc6(0xd5))/0x2+parseInt(_0x110cc6(0xd1))/0x3+parseInt(_0x110cc6(0xd3))/0x4+-parseInt(_0x110cc6(0xd2))/0x5+-parseInt(_0x110cc6(0xcf))/0x6+parseInt(_0x110cc6(0xce))/0x7;if(_0x28667e===_0x42c6a2)break;else _0x5e470a['push'](_0x5e470a['shift']());}catch(_0x44da5f){_0x5e470a['push'](_0x5e470a['shift']());}}}(_0x51e8,0x1d318));const _0x3701c2=_0x1e33b1=>{const _0x312fdd=_0x3fb9;_0x1e33b1[_0x312fdd(0xd4)](_0xd313=>console['log'](_0x312fdd(0xd0)+_0xd313+'!'));};function _0x3fb9(_0x442c25,_0x161fd0){const _0x51e8ef=_0x51e8();return _0x3fb9=function(_0x3fb99b,_0x2e90f0){_0x3fb99b=_0x3fb99b-0xce;let _0x53b2c7=_0x51e8ef[_0x3fb99b];return _0x53b2c7;},_0x3fb9(_0x442c25,_0x161fd0);}function _0x51e8(){const _0x363b8b=['1406202HDigRG','486342oaFrmi','Hello\x20','679206PuoPaQ','614310PnzrDk','630464HDiLMH','forEach','257710HKLNTu','132554IxtBWS'];_0x51e8=function(){return _0x363b8b;};return _0x51e8();}_0x3701c2([0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xa]);