Rev 5677 | Rev 5708 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5677 | Rev 5680 | ||
---|---|---|---|
Line 27... | Line 27... | ||
27 | mov eax, [esi+addrinfo.ai_addr] |
27 | mov eax, [esi+addrinfo.ai_addr] |
28 | mov eax, [eax+sockaddr_in.sin_addr] |
28 | mov eax, [eax+sockaddr_in.sin_addr] |
29 | mov [sockaddr1.ip], eax |
29 | mov [sockaddr1.ip], eax |
Line 30... | Line 30... | ||
30 | 30 | ||
31 | DEBUGF 1, "Connecting to %u.%u.%u.%u:%u\n", \ |
- | |
32 | [sockaddr1.ip]:1, [sockaddr1.ip+1]:1, \ |
31 | DEBUGF 1, "Connecting to %u.%u.%u.%u:%u\n", \ |
33 | [sockaddr1.ip+2]:1, [sockaddr1.ip+3]:1, \ |
32 | [sockaddr1.ip]:1, [sockaddr1.ip+1]:1, [sockaddr1.ip+2]:1, [sockaddr1.ip+3]:1, \ |
Line 34... | Line 33... | ||
34 | [sockaddr1.port]:2 |
33 | [sockaddr1.port]:2 |
Line 35... | Line 34... | ||
35 | 34 | ||
Line 47... | Line 46... | ||
47 | ; TODO: implement timeout |
46 | ; TODO: implement timeout |
48 | call wait_for_data |
47 | call wait_for_data |
Line 49... | Line 48... | ||
49 | 48 | ||
50 | cmp dword[receive_buffer], "RFB " |
49 | cmp dword[receive_buffer], "RFB " |
51 | jne err_proto |
50 | jne err_proto |
52 | DEBUGF 1, "received: %s\n", receive_buffer |
51 | DEBUGF 1, "Sending handshake\n" |
53 | mcall send, [socketnum], HandShake, 12, 0 |
- | |
54 | DEBUGF 1, "Sending handshake: protocol version\n" |
- | |
55 | 52 | mcall send, [socketnum], HandShake, 12, 0 |
|
Line 56... | Line 53... | ||
56 | call wait_for_data |
53 | call wait_for_data |
57 | 54 | ||
58 | cmp dword[receive_buffer], 0x01000000 |
55 | cmp dword[receive_buffer], 0x01000000 ; no security |
59 | je no_security |
56 | je initialize |
- | 57 | cmp dword[receive_buffer], 0x02000000 ; VNC security |
|
60 | cmp dword[receive_buffer], 0x02000000 |
58 | je vnc_security |
Line 61... | Line 59... | ||
61 | je vnc_security |
59 | |
62 | jmp err_security |
- | |
63 | - | ||
Line -... | Line 60... | ||
- | 60 | jmp err_security |
|
- | 61 | ||
- | 62 | vnc_security: |
|
- | 63 | ||
- | 64 | mov dword[password], 0 |
|
- | 65 | mov dword[password+4], 0 |
|
- | 66 | ||
- | 67 | and [USERbox.flags], not ed_focus |
|
- | 68 | or [USERbox.flags], ed_disabled |
|
- | 69 | or [PASSbox.flags], ed_focus |
|
- | 70 | ||
- | 71 | mov [status], STATUS_REQ_LOGIN |
|
- | 72 | inc [update_gui] |
|
- | 73 | @@: |
|
- | 74 | mcall 5, 10 |
|
- | 75 | cmp [status], STATUS_LOGIN |
|
- | 76 | je @f |
|
- | 77 | cmp [status], STATUS_REQ_LOGIN |
|
- | 78 | je @r |
|
- | 79 | mcall -1 |
|
- | 80 | @@: |
|
- | 81 | DEBUGF 1, "VNC authentication\n" |
|
- | 82 | ||
- | 83 | ; Bit reverse the password and create DES keys |
|
- | 84 | ||
- | 85 | mov ebx, dword[password] |
|
- | 86 | mov edx, ebx |
|
- | 87 | and ebx, 0xf0f0f0f0 |
|
- | 88 | shr ebx, 4 |
|
- | 89 | and edx, 0x0f0f0f0f |
|
- | 90 | shl edx, 4 |
|
- | 91 | or ebx, edx |
|
- | 92 | mov edx, ebx |
|
- | 93 | and ebx, 0xCCCCCCCC |
|
- | 94 | shr ebx, 2 |
|
- | 95 | and edx, 0x33333333 |
|
- | 96 | shl edx, 2 |
|
- | 97 | or ebx, edx |
|
- | 98 | mov edx, ebx |
|
- | 99 | and ebx, 0xAAAAAAAA |
|
- | 100 | shr ebx, 1 |
|
- | 101 | and edx, 0x55555555 |
|
- | 102 | shl edx, 1 |
|
- | 103 | or ebx, edx |
|
- | 104 | bswap ebx |
|
- | 105 | ||
- | 106 | mov eax, dword[password+4] |
|
- | 107 | mov edx, eax |
|
- | 108 | and eax, 0xf0f0f0f0 |
|
- | 109 | shr eax, 4 |
|
- | 110 | and edx, 0x0f0f0f0f |
|
- | 111 | shl edx, 4 |
|
- | 112 | or eax, edx |
|
- | 113 | mov edx, eax |
|
- | 114 | and eax, 0xCCCCCCCC |
|
- | 115 | shr eax, 2 |
|
- | 116 | and edx, 0x33333333 |
|
- | 117 | shl edx, 2 |
|
- | 118 | or eax, edx |
|
- | 119 | mov edx, eax |
|
- | 120 | and eax, 0xAAAAAAAA |
|
- | 121 | shr eax, 1 |
|
- | 122 | and edx, 0x55555555 |
|
- | 123 | shl edx, 1 |
|
- | 124 | or edx, eax |
|
- | 125 | bswap edx |
|
- | 126 | ||
- | 127 | mov edi, keys |
|
- | 128 | call DES_create_keys |
|
- | 129 | ||
- | 130 | ; Encrypt message with DES |
|
- | 131 | ||
- | 132 | mov ebx, dword[receive_buffer+4] |
|
- | 133 | mov edx, dword[receive_buffer+8] |
|
- | 134 | call encrypt_DES |
|
- | 135 | mov dword[receive_buffer+4], ebx |
|
- | 136 | mov dword[receive_buffer+8], edx |
|
- | 137 | ||
- | 138 | mov ebx, dword[receive_buffer+12] |
|
- | 139 | mov edx, dword[receive_buffer+16] |
|
- | 140 | call encrypt_DES |
|
- | 141 | mov dword[receive_buffer+12], ebx |
|
- | 142 | mov dword[receive_buffer+16], edx |
|
- | 143 | ||
- | 144 | ; Blank out the password and key fields in RAM |
|
- | 145 | ||
- | 146 | mov edi, password |
|
- | 147 | mov ecx, 384/4 |
|
- | 148 | xor eax, eax |
|
- | 149 | rep stosd |
|
- | 150 | ||
- | 151 | ; Send the authentication response to server |
|
- | 152 | ||
- | 153 | mcall send, [socketnum], receive_buffer+4, 16, 0 |
|
- | 154 | ||
- | 155 | call wait_for_data |
|
64 | vnc_security: |
156 | cmp dword[receive_buffer], 0 |
- | 157 | jne err_login |
|
65 | mov [status], STATUS_LOGIN |
158 | ; jmp initialize |
66 | call draw_gui |
- | |
Line 67... | Line 159... | ||
67 | 159 | ||
Line 68... | Line 160... | ||
68 | no_security: |
160 | initialize: |
69 | mcall send, [socketnum], ClientInit, 1, 0 |
161 | DEBUGF 1, "Sending ClientInit\n" |
Line 347... | Line 439... | ||
347 | err_security: |
439 | err_security: |
348 | mov [status], STATUS_SECURITY_ERR |
440 | mov [status], STATUS_SECURITY_ERR |
349 | inc [update_gui] |
441 | inc [update_gui] |
350 | mcall -1 |
442 | mcall -1 |
351 | ret |
443 | ret |
- | 444 | ||
- | 445 | err_login: |
|
- | 446 | mov [status], STATUS_LOGIN_FAILED |
|
- | 447 | inc [update_gui] |
|
- | 448 | mcall -1 |
|
- | 449 | ret |