Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
176 lines (140 loc) · 3.05 KB

File metadata and controls

176 lines (140 loc) · 3.05 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
.data
path: .space 10000
fd_dir: .space 4
f_readS: .asciz "%s"
f_printS: .asciz "%s\n"
f_printD: .asciz "%d\n"
f_fd: .asciz "fd: %d\n"
f_sb: .asciz "size B: %d\n"
f_skb: .asciz "size KB: %d\n"
fileaddr: .space 4
fd: .space 4
size: .space 4
s_copy: .space 10000
s_dot: .asciz "."
s_dotdot: .asciz ".."
s_slash: .asciz "/"
f_wrongdot: .asciz "This is a dot.\n"
f_wrongdotdot: .asciz "This is a dotdot.\n"
.text
slashAdd:
push %ebp
mov %esp, %ebp
push %eax
push %ecx
push %edx
mov 8(%ebp), %eax # fileaddr
mov $s_slash, %edx
et_slashAdd_while:
mov (%eax), %cl
test %cl, %cl
je et_slashAdd_while_exit
inc %eax
jmp et_slashAdd_while
et_slashAdd_while_exit:
dec %eax
mov (%eax), %cl
mov (%edx), %ch
cmp %cl, %ch
je et_slashAdd_if_exit
et_slashAdd_if:
push $s_slash
push %eax
call strcat
add $8, %esp
et_slashAdd_if_exit:
pop %edx
pop %ecx
pop %eax
pop %ebp
ret
.global main
main:
push $path
push $f_readS
call scanf
add $8, %esp
push $path
call opendir
movl %eax, fd_dir
add $4, %esp
# adauga slash la finalul lui path daca nu exista
push $path
call slashAdd
add $4, %esp
push $path
push $s_copy
call strcpy
add $8, %esp
et_CONCRETE_while_not_zero:
push fd_dir
call readdir
add $4, %esp
cmp $0, %eax
je et_CONCRETE_while_not_zero_exit
push %eax
push $s_copy
push $path
call strcpy
add $8, %esp
pop %eax
movl %eax, fileaddr
addl $11, fileaddr # offset pt a prelua numele fisierului
push fileaddr
push $s_dot
call strcmp
add $8, %esp
# daca e .
cmp $-1, %eax
jne et_CONCRETE_while_not_zero
push fileaddr
push $s_dotdot
call strcmp
add $8, %esp
# daca e ..
cmp $-1, %eax
jne et_CONCRETE_while_not_zero
push fileaddr
push $path
call strcat
add $8, %esp
push $path
push $f_printS
call printf
add $8, %esp
# open file
mov $5, %eax
mov $path, %ebx
xor %ecx, %ecx
xor %edx, %edx
int $0x80
mov %eax, fd
# lseek pt filesize
mov $19, %eax
mov fd, %ebx
mov $0, %ecx
mov $2, %edx
int $0x80
shr $10, %eax
movl %eax, size # marimea in KB
mov fd, %eax
#fd = (fds % 255) + 1
xor %edx, %edx
movl $255, %ecx
div %ecx
mov %edx, fd
addl $1, fd
push fd
push $f_printD
call printf
add $8, %esp
push size
push $f_printD
call printf
add $8, %esp
jmp et_CONCRETE_while_not_zero
et_CONCRETE_while_not_zero_exit:
et_exit:
mov $1, %eax
xor %ebx, %ebx
int $0x80
Morty Proxy This is a proxified and sanitized view of the page, visit original site.