Sponsored Content
Top Forums Programming Download file with socket syscall Post 302898440 by recher.jack on Tuesday 22nd of April 2014 07:58:31 AM
Old 04-22-2014
Download file with socket syscall

Hello to all
I want download a file in osx intel 64 with NASM , I want to use socket syscall
This is part of my code

Code:
section .data
command      db "GET /test/2.gif HTTP/1.1\r\nHost: 10.1.1.187\r\n\r\n", 0
; url                   db "http://172.16.207.153/test/2.gif", 0

global main
section .text

main:    
      
    ;Socket
    mov rdx, 6                  ; rdx = IPPROTO_TCP = 6
    mov rsi, 1                  ; rsi = AF_NET = 1 
    mov rdi, 2                  ; rdi = SOCK_STREAM = 2 
    mov rax, 0x2000061            ; socket syscall = 97
    syscall                     ; call socket(SOCK_STREAM, AF_NET, IPPROTO_TCP);
    mov r12, rax                ; Save the socket
  
  
    ;Sock_addr
    mov r13, 0xB901010A50000101 ; IP = FFFFFFFF, Port = 5C11(4444)
    mov r9b, 0xFF               ; The sock_addr_in is + FF from where we need it
    sub r13, r9                 ; So we sub 0xFF from it to get the correct value and avoid a null
    push r13                    ; Push it on the stack
    mov r13, rsp                ; Save the sock_addr_in into r13
;       mov r13, 0xB901010A50000002 ; IP = 0A0101B9, Port = 50(80)
;       push r13                    ; Push it on the stack
;       mov r13, rsp                ; Save the sock_addr_in into r13
 
    ;Connect 
    mov rax, 0x2000062            ; connect syscall = 98
    mov rdi, r12                ; move the saved socket fd into rdi
    mov rsi, r13                ; move the saved sock_addr_in into rsi
    add rdx, 0x10               ; add 0x10 to rdx
    syscall                     ; call connect(rdi, rsi, rdx)
   
    ;sendto 
    mov rax, 0x2000085            ; connect syscall = 113
    mov rdi, r12                ; move the saved socket fd into rdi
 
 
   
  
    mov  r14 , command
    mov  rsi, r14                ; move the saved sock_addr_in into rsi
    
    mov  rdx, 0x2e               ; add 0x2e to rdx
    
    mov  rcx, 0
 
    mov  r8, r13
    
    mov  r9, 0x10
    
    syscall                     ; call sendto(rdi, rsi, rdx)
    
    mov     rdi, r12
    mov     rax, 0x2000006 ; close
    syscall
 
    mov     rax, 0x2000001 ; exit
    mov     rdi, 0x0
    syscall

In this code , I can create socket and connect and close it (I see it in wireshark and dtruss don't show error). but sendto syscall not send my command ( wireshark don't show my http request in flow tcp stream and dtruss show -1 err#22 for sendto in return value).

please help me .

Last edited by recher.jack; 04-23-2014 at 02:27 AM..
 

9 More Discussions You Might Find Interesting

1. Programming

recv syscall for socket programming

I have a question regarding the recv syscall. Suppose I have a client/server and the following exchange of message took place: Client --> Server using multiple send syscalls one after another immediately: send "Packet1" send "Packet2" send "Packet3" Server receives in the... (2 Replies)
Discussion started by: heljy
2 Replies

2. UNIX for Advanced & Expert Users

connect problem for sctp socket (ipv6 socket) - Runtime fail Invalid Arguments

Hi, I was porting ipv4 application to ipv6; i was done with TCP transports. Now i am facing problem with SCTp transport at runtime. To test SCTP transport I am using following server and client socket programs. Server program runs fine, but client program fails giving Invalid Arguments for... (0 Replies)
Discussion started by: chandrutiptur
0 Replies

3. Programming

Fork syscall and related issues

Hi all, i just started started learning system programming and want to pursue a career in the sys prog area. below is the program that use a fork() call. i read in one of the tutorials that parent process and child process uses different address spaces and runs concurrently. that meas each... (2 Replies)
Discussion started by: MrUser
2 Replies

4. Programming

socket function to read a webpage (socket.h)

Why does this socket function only read the first 1440 chars of the stream. Why not the whole stream ? I checked it with gdm and valgrind and everything seems correct... #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <string.h> #include... (3 Replies)
Discussion started by: cyler
3 Replies

5. UNIX for Advanced & Expert Users

how to distinguish entry/exit of a syscall when using ptrace?

Hi all, I am using ptrace to keep track of clone syscalls in a program. However, I found that the traced syscall cant be paired. for example, there are some syscalls that have entry, but without exit showing up in the traced sequences. So, is there anyway to distinguish the entry and exit of a... (0 Replies)
Discussion started by: tristartom
0 Replies

6. IP Networking

Clarification - Setting socket options at the same time when socket is listening

I need clarification on whether it is okay to set socket options on a listening socket simultaneously when it is being used in an accept() call? Following is the scenario:- -- Task 1 - is executing in a loop - polling a listen socket, lets call it 'fd', (whose file descriptor is global)... (2 Replies)
Discussion started by: jake24
2 Replies

7. UNIX for Dummies Questions & Answers

is read() syscall really a primitive?

I saw somewhere that describe read() as a primitive. But when I lean signals, it says the read() may be interrupted by a signal. My Question: 1, What is the diffence between primitive and reentrant? 2, Is read() a primitive or reentrant? 3, Are all system calls primitive or reentrant? (2 Replies)
Discussion started by: vistastar
2 Replies

8. UNIX for Advanced & Expert Users

Process on CPU inside syscall

Hello Experts, If a Solaris process is calling some syscall, and right now execution is inside syscall doing only CPU work, for example the inside simplest times syscall, -> app_func => times << we are here now, we have entered in the times, but not exited yet <= times <- app_func... (9 Replies)
Discussion started by: sant
9 Replies

9. Red Hat

Adding our system call Fedora 18 -new syscall

Hi, I wanna add my own system call to Fedora 18 kernel 3.8.2. From kernel 3.3 I heard there is a new system to add system calls. So where i can find a guides ? I wanna print this text: "Hello world!" in terminal, not dmesg. (4 Replies)
Discussion started by: googz
4 Replies
qtmodernizer(1) 					    BSD General Commands Manual 					   qtmodernizer(1)

NAME
qtmodernizer -- Tool to convert legacy movies to modern format with minimal changes. SYNOPSIS
qtmodernizer [options ...] pathToSource [pathToDestination] DESCRIPTION
qtmodernizer is a command line tool to examine a media file which may be in a legacy format or may contain legacy media tracks. In this case a legacy format is one which cannot be read directly by CoreMedia or AVFoundation frameworks. qtmodernizer examines all the tracks to determine if they are all in a form that can currently be played. If all tracks are playable and the format is readable, qtmodernizer does returns and does nothing. If any of the audio or video tracks are encoded with a codec that CoreMedia does not support, that track will be converted to a modern format, usually H.264 for video and AAC for audio (see --useprores for other choices). Command line options of qtmodernize: -h | --help -p | --useprores If -p or --useprores is specified, qtmodernizer will use the ProRes video codec and LPCM audio codec instead of H.264 and AAC-LC. For video tracks it will produce AppleProRes422. For audio it will produce uncompressed output (lpcm). Tracks outher than audio or video are not re-encoded and will not be affected. Either AppleProRes422 may be chosen or the AppleProRes4444 option may be chosen but not both. -p4 | --useprores4444 If -p4 or --useprores4444 is specified, qtmodernizer will use the ProRes4444 video codec and LPCM audio codec instead of H.264 and AAC-LC. For video tracks it will produce AppleProRes4444. For audio it will produce uncompressed output (lpcm). Tracks outher than audio or video are not re-encoded and will not be affected. Either AppleProRes4444 may be chosen or the AppleProRes422 option may be chosen but not both. -r | --replace Normally qtmodernizer will not replace any existing files. If --replace is specified, a file already existing at the destination path will be replaced by the new output. qtmodernizer will not replace the file at original source path used in the command. -v | --verbose Normally qtmodernizer only displays important error or warning messages. Specifying --verbose causes other information about the modernization to be displayed on the command line. --infoonly implies --verbose. -i | --infoonly Causes qtmodernizer to display information about the tracks contained in the source file and what the modernization process would be for each track (if any) but does not actually produce an output file. EXAMPLES
qtmodernize legacy_movie.mov modern_movie.mov Each legacy audio and video track would be re-encoded to a modern (H.264 or AAC) track with other tracks passed through. The resulting movie is saved as modern_movie.mov qtmodernize -p legacy_movie.mov modern_movie.mov Legacy audio and video tracks would be re-encoded like in the above example but the resulting codecs would be ProRes for video and LPCM for audio qtmodernize ~/Movies/legacy_movie.mov This command will create a modernized movie in the ~/Movies directory named "legacy_movie-modernized.mov" HISTORY
qtmodernizer command first appeared in Mac OS X 10.9. Mac OS X June 2, 2019 Mac OS X
All times are GMT -4. The time now is 05:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy