summaryrefslogtreecommitdiffstats
path: root/src/c_example.S
diff options
context:
space:
mode:
authorJozanLeClerc <>2022-05-04 20:13:30 +0000
committerJozanLeClerc <>2022-05-04 20:13:30 +0000
commitff7d5861ae846cc22761ebeea89ca709e3140b87 (patch)
tree46a0bc50f5d6eadc1738bab80c184e50d70e2f70 /src/c_example.S
parentFirst commit (diff)
downloadasm-cgi-example-ff7d5861ae846cc22761ebeea89ca709e3140b87.tar.gz
asm-cgi-example-ff7d5861ae846cc22761ebeea89ca709e3140b87.tar.bz2
asm-cgi-example-ff7d5861ae846cc22761ebeea89ca709e3140b87.tar.xz
asm-cgi-example-ff7d5861ae846cc22761ebeea89ca709e3140b87.tar.zst
asm-cgi-example-ff7d5861ae846cc22761ebeea89ca709e3140b87.zip
In progress
FossilOrigin-Name: 99bf5897fcdaba936a96a5f95e2bf10236152ea3
Diffstat (limited to 'src/c_example.S')
-rw-r--r--src/c_example.S60
1 files changed, 50 insertions, 10 deletions
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<html><head><title>Title</title></head><body><h1>hey</h1></body></html>\n"
- len = . - hey
+ str_begin: .ascii "Content-type: text/html\n\n<html>\n\t<head>\n\t\t<title>Title</title>\n\t</head>\n\t<body>\n\t\t<h1>hey</h1>\n\t\t<p>\n\t\t\tSome CPU infos:\n\t\t</p>\n\t\t<pre>\n\t\t\tsysctl hw.model\n\t\t\tsysctl hw.ncpu\n\t\t\tlscpu\n\t\t</pre>\n\t\t<p>\n\t\t\tGives us:\n\t\t</p>\n\t\t<pre>\n\t\t\t"
+ len_begin = . - str_begin
+ str_end: .ascii "\t\t</pre>\n\t</body>\n</html>"
+ 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