-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.s
More file actions
339 lines (339 loc) · 5.69 KB
/
client.s
File metadata and controls
339 lines (339 loc) · 5.69 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
.file "client.c"
.text
.type get_response, @function
get_response:
.LFB2:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $240, %rsp
movl %edi, -228(%rbp)
movq %rsi, -240(%rbp)
movq %fs:40, %rax
movq %rax, -8(%rbp)
xorl %eax, %eax
leaq -208(%rbp), %rsi
movl -228(%rbp), %eax
movl $0, %ecx
movl $1602, %edx
movl %eax, %edi
call recv
leaq -208(%rbp), %rax
movq %rax, %rdi
call strlen
movl %eax, -212(%rbp)
movq -240(%rbp), %rax
leaq -208(%rbp), %rdx
movq %rdx, %rsi
movq %rax, %rdi
call strcpy
movl -212(%rbp), %eax
cltq
leaq 1(%rax), %rdx
leaq -208(%rbp), %rax
addq %rax, %rdx
movq -240(%rbp), %rax
addq $801, %rax
movq %rdx, %rsi
movq %rax, %rdi
call strcpy
nop
movq -8(%rbp), %rax
xorq %fs:40, %rax
je .L2
call __stack_chk_fail
.L2:
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2:
.size get_response, .-get_response
.section .rodata
.align 8
.LC0:
.string "Proper usage is ./client <port>"
.LC1:
.string "Could not obtain a socket"
.LC2:
.string "127.0.0.1"
.align 8
.LC3:
.string "Could not bind to port. Is it in use?"
.LC4:
.string "Please input your username: "
.LC5:
.string "%800s"
.LC6:
.string "\nPlease input your password: "
.LC7:
.string "r"
.LC8:
.string "ok"
.LC9:
.string "Access refused."
.LC10:
.string "%s: %s\n"
.LC11:
.string "\\quit"
.LC12:
.string "Ending connection."
.text
.globl main
.type main, @function
main:
.LFB3:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $4176, %rsp
movl %edi, -4164(%rbp)
movq %rsi, -4176(%rbp)
movq %fs:40, %rax
movq %rax, -8(%rbp)
xorl %eax, %eax
movb $0, -1648(%rbp)
movb $0, -832(%rbp)
cmpl $2, -4164(%rbp)
je .L4
movl $.LC0, %edi
movl $0, %eax
call printf
movl $1, %eax
jmp .L16
.L4:
movl $0, %edx
movl $1, %esi
movl $2, %edi
call socket
movl %eax, -4140(%rbp)
cmpl $0, -4140(%rbp)
jne .L6
movl $.LC1, %edi
call perror
movl $1, %eax
jmp .L16
.L6:
movw $2, -4112(%rbp)
movq -4176(%rbp), %rax
addq $8, %rax
movq (%rax), %rax
movq %rax, %rdi
call atoi
movzwl %ax, %eax
movl %eax, %edi
call htons
movw %ax, -4110(%rbp)
leaq -4112(%rbp), %rax
addq $4, %rax
movq %rax, %rdx
movl $.LC2, %esi
movl $2, %edi
call inet_pton
leaq -4112(%rbp), %rcx
movl -4140(%rbp), %eax
movl $16, %edx
movq %rcx, %rsi
movl %eax, %edi
call connect
cmpl $-1, %eax
jne .L7
movl $.LC3, %edi
call perror
movl $1, %eax
jmp .L16
.L7:
movl $.LC4, %edi
movl $0, %eax
call printf
leaq -2448(%rbp), %rax
movq %rax, %rsi
movl $.LC5, %edi
movl $0, %eax
call __isoc99_scanf
movq stdin(%rip), %rdx
leaq -2480(%rbp), %rax
movl $2, %esi
movq %rax, %rdi
call fgets
movl $.LC6, %edi
movl $0, %eax
call printf
movq stdin(%rip), %rdx
leaq -1632(%rbp), %rax
movl $801, %esi
movq %rax, %rdi
call fgets
movl $1, -4144(%rbp)
jmp .L8
.L9:
addl $1, -4144(%rbp)
.L8:
movl -4144(%rbp), %eax
cltq
movzbl -1632(%rbp,%rax), %eax
cmpb $10, %al
jne .L9
movl -4144(%rbp), %eax
cltq
movb $0, -1632(%rbp,%rax)
leaq -2448(%rbp), %rax
movq %rax, %rdi
call strlen
movb %al, -4145(%rbp)
movl -4144(%rbp), %eax
movb %al, -4146(%rbp)
movzbl -1632(%rbp), %eax
cmpb $92, %al
jne .L10
movzbl -1631(%rbp), %eax
cmpb $117, %al
jne .L10
leaq -1632(%rbp), %rax
addq $3, %rax
movl $.LC7, %esi
movq %rax, %rdi
call fopen
movq %rax, -4128(%rbp)
movq -4128(%rbp), %rdx
leaq -1632(%rbp), %rax
movq %rdx, %rcx
movl $801, %edx
movl $1, %esi
movq %rax, %rdi
call fread
movb %al, -4146(%rbp)
subb $1, -4146(%rbp)
.L10:
movzbl -4145(%rbp), %edx
movzbl -4146(%rbp), %eax
addl %edx, %eax
addl $2, %eax
movl %eax, -4136(%rbp)
movl -4136(%rbp), %eax
cltq
movq %rax, %rdi
call malloc
movq %rax, -4120(%rbp)
leaq -2448(%rbp), %rdx
movq -4120(%rbp), %rax
movq %rdx, %rsi
movq %rax, %rdi
call strcpy
movzbl -4146(%rbp), %eax
addl $1, %eax
movslq %eax, %rdx
movzbl -4145(%rbp), %eax
leaq 1(%rax), %rcx
movq -4120(%rbp), %rax
addq %rax, %rcx
leaq -1632(%rbp), %rax
movq %rax, %rsi
movq %rcx, %rdi
call memcpy
movl -4136(%rbp), %eax
movslq %eax, %rdx
movq -4120(%rbp), %rsi
movl -4140(%rbp), %eax
movl $0, %ecx
movl %eax, %edi
call send
movb $0, -2462(%rbp)
leaq -2464(%rbp), %rsi
movl -4140(%rbp), %eax
movl $0, %ecx
movl $2, %edx
movl %eax, %edi
call recv
leaq -2464(%rbp), %rax
movl $.LC8, %esi
movq %rax, %rdi
call strcmp
testl %eax, %eax
je .L11
movl $.LC9, %edi
call puts
movl $1, %eax
jmp .L16
.L11:
call fork
movl %eax, -4132(%rbp)
cmpl $0, -4132(%rbp)
jne .L12
.L13:
leaq -4096(%rbp), %rdx
movl -4140(%rbp), %eax
movq %rdx, %rsi
movl %eax, %edi
call get_response
leaq -4096(%rbp), %rax
leaq 801(%rax), %rdx
leaq -4096(%rbp), %rax
movq %rax, %rsi
movl $.LC10, %edi
movl $0, %eax
call printf
jmp .L13
.L12:
movq stdin(%rip), %rdx
leaq -2481(%rbp), %rax
movl $1, %esi
movq %rax, %rdi
call fgets
.L15:
movq stdin(%rip), %rdx
leaq -816(%rbp), %rax
movl $801, %esi
movq %rax, %rdi
call fgets
leaq -816(%rbp), %rax
movq %rax, %rdi
call strlen
subq $1, %rax
movb $0, -816(%rbp,%rax)
leaq -816(%rbp), %rax
movl $.LC11, %esi
movq %rax, %rdi
call strcmp
testl %eax, %eax
jne .L14
movl $.LC12, %edi
movl $0, %eax
call printf
movl -4132(%rbp), %eax
movl $15, %esi
movl %eax, %edi
call kill
movl $1, %eax
jmp .L16
.L14:
leaq -816(%rbp), %rax
movq %rax, %rdi
call strlen
leaq 1(%rax), %rdx
leaq -816(%rbp), %rsi
movl -4140(%rbp), %eax
movl $0, %ecx
movl %eax, %edi
call send
jmp .L15
.L16:
movq -8(%rbp), %rcx
xorq %fs:40, %rcx
je .L17
call __stack_chk_fail
.L17:
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE3:
.size main, .-main
.ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.6) 5.4.0 20160609"
.section .note.GNU-stack,"",@progbits