update: userprog (tee, tsh, sleep, hex2bin)

This commit is contained in:
2026-01-01 04:22:30 +00:00
parent cf722d75ff
commit 79f46aa971
22 changed files with 1196 additions and 47 deletions
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
as -o free.o free.s
ld -s -o free free.o
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
as --32 -o free32.o free32.s
ld -m elf_i386 -s -N -o free32 free32.o
+5
View File
@@ -0,0 +1,5 @@
.global _start
_start:
mov $60, %rax # sys_exit (64-bit)
mov $0, %rdi # status 0
syscall
+5
View File
@@ -0,0 +1,5 @@
.global _start
_start:
xor %ebx, %ebx
mov $1, %eax
int $0x80
+7
View File
@@ -0,0 +1,7 @@
#!/bin/sh
as --32 -o vuln.o vuln.s
# -N 옵션을 줘서 코드 섹션도 읽기/쓰기 가능하게 하면 쉘코드 실습도 가능하지만,
# 지금은 RET Overwrite만 할 거라 기본 옵션도 상관없음.
ld -m elf_i386 -s -N -o vuln vuln.o
rm vuln.o
+62
View File
@@ -0,0 +1,62 @@
.section .data
msg_normal: .ascii "Normal exit.\n"
msg_secret: .ascii "SUCCESS! Secret function executed!\n"
.section .text
.global _start
# --------------------------------------------------------
# [ ]
# --------------------------------------------------------
secret_function:
# "SUCCESS! ..."
mov $4, %eax # sys_write
mov $1, %ebx # stdout
mov $msg_secret, %ecx
mov $35, %edx # length
int $0x80
#
xor %ebx, %ebx
mov $1, %eax # sys_exit
int $0x80
# --------------------------------------------------------
# [ ] 4 100
# --------------------------------------------------------
vuln_func:
# ( 4)
sub $4, %esp
# sys_read(stdin, buffer=esp, len=100)
mov $3, %eax # sys_read
xor %ebx, %ebx # stdin (0)
mov %esp, %ecx # buffer ( )
mov $100, %edx # [] 4 100 !
int $0x80
#
add $4, %esp
# [ ]
# (RET) ,
# RET ? -> !
ret
# --------------------------------------------------------
# [ ]
# --------------------------------------------------------
_start:
call vuln_func
# ( )
mov $4, %eax
mov $1, %ebx
mov $msg_normal, %ecx
mov $13, %edx
int $0x80
#
xor %ebx, %ebx
mov $1, %eax
int $0x80
+2 -1
View File
@@ -1,3 +1,4 @@
#!/bin/sh
g++ -m32 -c -o free.o free.cpp -ffreestanding && ld -m elf_i386 -o free free.o
g++ -m32 -c -o free.o free.cpp -ffreestanding -nostdlib
ld -m elf_i386 -o free free.o
Executable
+4
View File
@@ -0,0 +1,4 @@
#!/bin/sh
gcc -m32 -c -o free.o free.cpp -ffreestanding -nostdlib
ld -m elf_i386 -o free free.o