From ff7d5861ae846cc22761ebeea89ca709e3140b87 Mon Sep 17 00:00:00 2001 From: JozanLeClerc <> Date: Wed, 4 May 2022 20:13:30 +0000 Subject: In progress FossilOrigin-Name: 99bf5897fcdaba936a96a5f95e2bf10236152ea3 --- Makefile | 9 +++++++-- src/c_example.S | 60 +++++++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 57 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index baaebf5..ab1a625 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ default: all SRCS_DIR := src +INSTALL_DIR := /usr/local/www/jozan SRCS := ${SRCS_DIR}/c_example.S @@ -31,6 +32,7 @@ TARGET := asm-example.cgi SHELL := /bin/sh RM := rm -f MKDIR := mkdir -p +CP := cp MV := mv SED := sed INSTALL := install @@ -38,7 +40,7 @@ INSTALL := install .SUFFIXES: .S .c .S.o .c.o .S.S.o: - ${AS} -o ${.TARGET} ${.IMPSRC} + ${AS} -g -o ${.TARGET} ${.IMPSRC} ${TARGET}: ${OBJS} ${CC} ${CFLAGS} -o ${.TARGET} ${OBJS} ${LDFLAGS} @@ -50,7 +52,10 @@ clean: re: clean all -.PHONY: all clean re +install: + ${CP} ${TARGET} ${INSTALL_DIR} + +.PHONY: all clean re install # Files prefixes # -------------- diff --git a/src/c_example.S b/src/c_example.S index cbd1b0a..81538c7 100644 --- a/src/c_example.S +++ b/src/c_example.S @@ -39,7 +39,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * asm-cgi-example: src/c_example.S - * Mon May 2 21:59:53 CEST 2022 + * Wed May 4 22:06:59 CEST 2022 * Joe */ @@ -47,21 +47,61 @@ .globl main main: + # xorq %rdi, %rdi + # xorq %rsi, %rsi + # xorq %rdx, %rdx + # xorq %rax, %rax + # movb $0x1, %dil + # movq $str_begin, %rsi + # movq $len_begin, %rdx + # movb $0x4, %al /* SYS_write */ + # syscall + + # xorq %rdi, %rdi + # xorq %rsi, %rsi + # xorq %rax, %rax + # movq $sysctl, %rdi + # movq $0x0, %rsi + # movq $0x3b, %rax /* SYS_execve */ + # syscall + + # xorq %rdi, %rdi + # xorq %rsi, %rsi + # xorq %rax, %rax + # movb $0x1, %dil + # movq $str_end, %rsi + # movq $len_end, %rdx + # movb $0x4, %al /* SYS_write */ + # syscall + + xorq %rdx, %rdx + movq $buff, %rdx + pushq %rcx + movq %rcx, %rcx + movb $0x8, %cl + movq $sysctl, (%rdx, %rcx, 1) + movq $model, (%rdx, %rcx, 2) + movq $0x0, (%rdx, %rcx, 4) xorq %rdi, %rdi xorq %rsi, %rsi - xorq %rdx, %rdx xorq %rax, %rax movb $0x1, %dil - movq $len, %rdx - movq $hey, %rsi - movb $0x4, %al + movq (%rdx, %rcx, 1), %rsi + movq $0x6, %rdx + movb $0x4, %al /* SYS_write */ syscall + popq %rcx xorq %rax, %rax - xorq %rdi, %rdi - movb $0x1, %al - syscall + retq .data - hey: .ascii "Content-type: text/html\n\n
\n\t\t\tSome CPU infos:\n\t\t
\n\t\t\n\t\t\tsysctl hw.model\n\t\t\tsysctl hw.ncpu\n\t\t\tlscpu\n\t\t\n\t\t
\n\t\t\tGives us:\n\t\t
\n\t\t\n\t\t\t" + len_begin = . - str_begin + str_end: .ascii "\t\t\n\t\n" + len_end = . - str_end + sysctl: .asciz "/sbin/sysctl" + lscpu: .asciz "/usr/local/bin/lscpu" + model: .asciz "hw.model" + ncpu: .asciz "hw.ncpu" + buff: .byte 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 -- cgit v1.2.3