Created
February 6, 2025 10:41
-
-
Save lastforkbender/a8ef7dc0c74138b26eee15ed7942cf43 to your computer and use it in GitHub Desktop.
XFH Upan-Inet Remote Proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
section .data | |
SOCKET_ERROR db ") XFH-:Socket creation failed", 0 | |
BIND_ERROR db ") XFH-:Bind failed", 0 | |
RECV_ERROR db ") XFH-:Receive failed", 0 | |
ENCRYPT_ERROR db ") XFH-:Encryption failed", 0 | |
DECRYPT_ERROR db ") XFH-:Decryption failed", 0 | |
BUFFER_SIZE equ 1024 | |
buffer resb BUFFER_SIZE | |
encrypted_buffer resb BUFFER_SIZE | |
client_addr resb 16 | |
addr_len resd 1 | |
sockfd resd 1 | |
port dw 8080 | |
thread_count equ 4 | |
section .bss | |
thread_ids resd thread_count | |
section .text | |
extern socket, bind, recvfrom, sendto, pthread_create, pthread_exit, perror, exit | |
global _start | |
_start: | |
push 0 | |
push 2 | |
push 2 | |
call socket | |
test eax, eax | |
js .socket_error | |
mov [sockfd], eax | |
xor eax, eax | |
mov [client_addr], eax | |
mov [client_addr + 2], word [port] | |
mov dword [client_addr + 4], 0x00000000 | |
push 16 | |
push client_addr | |
push [sockfd] | |
call bind | |
test eax, eax | |
js .bind_error | |
mov ecx, 0 | |
.create_threads: | |
cmp ecx, thread_count | |
jge .wait_threads | |
push eax | |
push client_addr | |
push addr_len | |
push ecx | |
call pthread_create | |
add esp, 16 | |
inc ecx | |
jmp .create_threads | |
.wait_threads: | |
mov ecx, 0 | |
.wait_loop: | |
cmp ecx, thread_count | |
jge .exit | |
;]]]]]%call for pthread_join[*]...[[[[[ | |
inc ecx | |
jmp .wait_loop | |
.exit: | |
mov eax, 1 | |
xor ebx, ebx | |
int 0x80 | |
.socket_error: | |
mov edx, SOCKET_ERROR | |
call perror | |
jmp .exit | |
.bind_error: | |
mov edx, BIND_ERROR | |
call perror | |
jmp .exit | |
thread_function: | |
;]]]]]%...[[[[[ | |
mov ebx, [sockfd] | |
.receive_loop: | |
push addr_len | |
push client_addr | |
push BUFFER_SIZE | |
push buffer | |
push ebx | |
call recvfrom | |
test eax, eax | |
js .recv_error | |
push buffer | |
call decrypt_data | |
test eax, eax | |
js .decrypt_error | |
;]]]]]%process only the needed decrypt[[[[[ | |
push buffer | |
call encrypt_data | |
test eax, eax | |
js .encrypt_error | |
push addr_len | |
push client_addr | |
push encrypted_buffer | |
push eax | |
;]]]]]%eax has length of encryption now[[[[[ | |
push ebx | |
call sendto | |
test eax, eax | |
js .send_error | |
jmp .receive_loop | |
.recv_error: | |
mov edx, RECV_ERROR | |
call perror | |
ret | |
.decrypt_error: | |
mov edx, DECRYPT_ERROR | |
call perror | |
ret | |
.encrypt_error: | |
mov edx, ENCRYPT_ERROR | |
call perror | |
ret | |
.send_error: | |
mov edx, "XFH-:Send Error", 0 | |
call perror | |
ret | |
encrypt_data: | |
;]]]]]***********************[[[[[ | |
mov eax, 0 | |
ret | |
decrypt_data: | |
;]]]]]***********************[[[[[ | |
mov eax, 0 | |
ret | |
;><><><><><><><><><><><><><><><><><>< |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment