-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcurl.asm
70 lines (51 loc) · 1.07 KB
/
curl.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
; linuxthor
;
; simple libcurl example
;
; assemble with:
; nasm -f elf64 -o curly.o curly.asm
; gcc curly.o -no-pie -o curly -lcurl
;
BITS 64
extern curl_global_init, curl_easy_init, curl_easy_perform
extern curl_easy_setopt, curl_easy_cleanup, curl_global_cleanup
%define CURLOPT_URL 10002
%define CURL_GLOBAL_DEFAULT 3
global main
main:
push rbp
mov rbp, rsp
mov rdi, CURL_GLOBAL_DEFAULT
xor eax, eax
call curl_global_init
call curl_easy_init
cmp rax, 0
je error
mov [curly], rax
mov rdi, [curly]
mov rsi, CURLOPT_URL
mov rdx, url
xor rax, rax
call curl_easy_setopt
cmp rax, 0
jne error
mov rdi, [curly]
xor eax, eax
call curl_easy_perform
cmp rax, 0
jne error
mov rdi, [curly]
xor eax, eax
call curl_easy_cleanup
call curl_global_cleanup
pop rbp
xor eax, eax
ret
error:
pop rbp
mov rax, 1
ret
section .data
url db 'http://www.example.com/',0
section .bss
curly resq 1