2013-06-24 21:33:16 +02:00
|
|
|
cmd_help:
|
|
|
|
|
|
|
|
push str_help
|
|
|
|
call [con_write_asciiz]
|
|
|
|
|
2013-07-09 22:55:18 +02:00
|
|
|
jmp wait_for_usercommand
|
|
|
|
|
2013-07-10 11:37:01 +02:00
|
|
|
cmd_bye:
|
|
|
|
|
|
|
|
mcall close, [socketnum]
|
|
|
|
mcall close, [datasocket]
|
|
|
|
|
|
|
|
jmp main
|
|
|
|
|
2013-07-09 23:59:02 +02:00
|
|
|
cmd_pwd:
|
|
|
|
|
2013-07-12 11:58:26 +02:00
|
|
|
mov dword[s], "PWD" + 13 shl 24
|
|
|
|
mov byte[s+4], 10
|
|
|
|
mcall send, [socketnum], s, 5, 0
|
2013-07-09 23:59:02 +02:00
|
|
|
|
|
|
|
jmp wait_for_servercommand
|
|
|
|
|
2013-07-09 22:55:18 +02:00
|
|
|
cmd_cwd:
|
|
|
|
|
|
|
|
mov dword[s], "CWD "
|
|
|
|
|
|
|
|
mov ecx, 256
|
|
|
|
xor al, al
|
|
|
|
mov edi, s
|
|
|
|
repne scasb
|
2013-07-12 11:58:26 +02:00
|
|
|
lea esi, [edi - s]
|
|
|
|
mov word [edi - 2], 0x0a0d
|
2013-07-09 22:55:18 +02:00
|
|
|
|
|
|
|
mcall send, [socketnum], s, , 0
|
|
|
|
|
2013-07-09 23:31:47 +02:00
|
|
|
jmp wait_for_servercommand
|
|
|
|
|
2013-07-10 11:37:01 +02:00
|
|
|
cmd_dele:
|
|
|
|
|
|
|
|
mov dword[s], "DELE"
|
|
|
|
mov byte[s], " "
|
|
|
|
|
|
|
|
mov ecx, 256
|
|
|
|
xor al, al
|
|
|
|
mov edi, s
|
|
|
|
repne scasb
|
2013-07-12 11:58:26 +02:00
|
|
|
lea esi, [edi - s]
|
|
|
|
mov word [edi - 2], 0x0a0d
|
2013-07-10 11:37:01 +02:00
|
|
|
|
|
|
|
mcall send, [socketnum], s, , 0
|
|
|
|
|
|
|
|
jmp wait_for_servercommand
|
|
|
|
|
|
|
|
cmd_list:
|
|
|
|
|
|
|
|
call open_dataconnection
|
|
|
|
|
|
|
|
mov [operation], OPERATION_LIST
|
|
|
|
|
|
|
|
mov dword[s], "LIST"
|
2013-07-12 11:58:26 +02:00
|
|
|
mov word[s+4], 0x0a0d
|
|
|
|
mcall send, [socketnum], s, 6, 0
|
2013-07-10 11:37:01 +02:00
|
|
|
|
|
|
|
jmp wait_for_servercommand
|
|
|
|
|
2013-07-09 23:31:47 +02:00
|
|
|
|
|
|
|
cmd_retr:
|
|
|
|
|
|
|
|
call open_dataconnection
|
|
|
|
|
2013-07-10 11:37:01 +02:00
|
|
|
mov [operation], OPERATION_RETR
|
|
|
|
|
|
|
|
mov [filestruct.subfn], 2 ; create/rewrite file
|
|
|
|
mov [filestruct.offset], 0
|
|
|
|
mov [filestruct.offset+4], 0
|
|
|
|
mov [filestruct.size], 0
|
|
|
|
mov [filestruct.ptr], 0
|
|
|
|
|
|
|
|
lea esi, [s+5]
|
|
|
|
mov edi, filestruct.name
|
|
|
|
mov ecx, 256-5
|
|
|
|
call set_filename
|
|
|
|
|
|
|
|
mcall 70, filestruct
|
|
|
|
cmp eax, -1
|
|
|
|
; je fileerror
|
|
|
|
|
|
|
|
mov [filestruct.subfn], 3 ; write to file
|
|
|
|
|
2013-07-09 23:31:47 +02:00
|
|
|
mov dword[s], "RETR"
|
|
|
|
mov byte[s+4], " "
|
|
|
|
|
|
|
|
mov ecx, 256
|
|
|
|
xor al, al
|
|
|
|
mov edi, s
|
|
|
|
repne scasb
|
2013-07-12 11:58:26 +02:00
|
|
|
lea esi, [edi - s]
|
|
|
|
mov word [edi - 2], 0x0a0d
|
2013-07-09 23:31:47 +02:00
|
|
|
mcall send, [socketnum], s, , 0
|
|
|
|
|
|
|
|
jmp wait_for_servercommand
|
|
|
|
|
|
|
|
|
|
|
|
cmd_stor:
|
|
|
|
|
|
|
|
call open_dataconnection
|
|
|
|
|
2013-07-10 11:37:01 +02:00
|
|
|
mov [operation], OPERATION_STOR
|
|
|
|
|
|
|
|
mov [filestruct.subfn], 0 ; read file
|
|
|
|
mov [filestruct.offset], 0
|
|
|
|
mov [filestruct.offset+4], 0
|
|
|
|
mov [filestruct.size], BUFFERSIZE
|
|
|
|
mov [filestruct.ptr], buffer_ptr2
|
|
|
|
|
|
|
|
lea esi, [s+5]
|
|
|
|
mov edi, filestruct.name
|
|
|
|
mov ecx, 256-5
|
|
|
|
call set_filename
|
|
|
|
|
2013-07-09 23:31:47 +02:00
|
|
|
mov dword[s], "STOR"
|
|
|
|
mov byte[s+4], " "
|
|
|
|
|
|
|
|
mov ecx, 256
|
|
|
|
xor al, al
|
|
|
|
mov edi, s
|
|
|
|
repne scasb
|
2013-07-12 11:58:26 +02:00
|
|
|
lea esi, [edi - s]
|
|
|
|
mov word [edi - 2], 0x0a0d
|
2013-07-09 23:31:47 +02:00
|
|
|
mcall send, [socketnum], s, , 0
|
|
|
|
|
2013-07-10 11:37:01 +02:00
|
|
|
jmp wait_for_servercommand
|
|
|
|
|
|
|
|
|
2013-07-10 12:17:07 +02:00
|
|
|
cmd_lcwd:
|
|
|
|
|
|
|
|
mov esi, s+5
|
|
|
|
mov ecx, 256-5
|
|
|
|
.loop:
|
|
|
|
lodsb
|
|
|
|
cmp al, 10
|
|
|
|
je .done
|
|
|
|
test al, al
|
|
|
|
je .done
|
|
|
|
loop .loop
|
|
|
|
.done:
|
|
|
|
mov byte[esi-1], 0
|
|
|
|
mcall 30, 1, s+5 ; set working directory
|
|
|
|
mcall 30, 2, s, 256 ; and read it again
|
|
|
|
|
|
|
|
invoke con_write_asciiz, str_lcwd
|
|
|
|
invoke con_write_asciiz, s
|
2013-07-12 10:59:34 +02:00
|
|
|
invoke con_write_asciiz, str_newline
|
2013-07-10 12:17:07 +02:00
|
|
|
|
|
|
|
jmp wait_for_usercommand
|
|
|
|
|
2013-07-10 13:19:18 +02:00
|
|
|
cmd_cdup:
|
|
|
|
|
|
|
|
mov dword[s], "CDUP"
|
2013-07-12 11:58:26 +02:00
|
|
|
mov word[s+4], 0x0d0a
|
|
|
|
mcall send, [socketnum], s, 6, 0
|
2013-07-10 13:19:18 +02:00
|
|
|
|
|
|
|
jmp wait_for_servercommand
|
|
|
|
|
|
|
|
cmd_rmd:
|
|
|
|
|
|
|
|
mov dword[s], "RMD "
|
|
|
|
|
|
|
|
mov ecx, 256
|
|
|
|
xor al, al
|
|
|
|
mov edi, s
|
|
|
|
repne scasb
|
2013-07-12 11:58:26 +02:00
|
|
|
lea esi, [edi - s]
|
|
|
|
mov word [edi - 2], 0x0a0d
|
2013-07-10 13:19:18 +02:00
|
|
|
|
|
|
|
mcall send, [socketnum], s, , 0
|
|
|
|
|
|
|
|
jmp wait_for_servercommand
|
|
|
|
|
|
|
|
cmd_mkd:
|
|
|
|
|
|
|
|
mov dword[s], "MKD "
|
|
|
|
|
|
|
|
mov ecx, 256
|
|
|
|
xor al, al
|
|
|
|
mov edi, s
|
|
|
|
repne scasb
|
2013-07-12 11:58:26 +02:00
|
|
|
lea esi, [edi - s]
|
|
|
|
mov word [edi - 2], 0x0a0d
|
2013-07-10 13:19:18 +02:00
|
|
|
|
|
|
|
mcall send, [socketnum], s, , 0
|
|
|
|
|
|
|
|
jmp wait_for_servercommand
|
|
|
|
|
2013-07-10 12:17:07 +02:00
|
|
|
|
2013-07-10 11:37:01 +02:00
|
|
|
|
|
|
|
; esi = source ptr
|
|
|
|
; edi = dest ptr
|
|
|
|
; ecx = max length of source buffer
|
|
|
|
set_filename:
|
|
|
|
|
|
|
|
.loop:
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .done
|
|
|
|
cmp al, ' '
|
|
|
|
je .done
|
|
|
|
cmp al, 10
|
|
|
|
je .done
|
|
|
|
stosb
|
|
|
|
loop .loop
|
|
|
|
.done:
|
|
|
|
xor al, al ; append a 0 byte
|
|
|
|
stosb
|
|
|
|
|
|
|
|
ret
|
|
|
|
|