a package on network

Тема в разделе "WASM.ENGLISH", создана пользователем dcskm4200, 26 июл 2006.

  1. dcskm4200

    dcskm4200 New Member

    Публикаций:
    0
    Регистрация:
    12 окт 2004
    Сообщения:
    173
    Адрес:
    China
    hello,all

    protocol:GGP
    ip address:224.0.0.22
    ;===================
    what's the package function?

    regards
     
  2. opennetworks

    opennetworks New Member

    Публикаций:
    0
    Регистрация:
    20 окт 2006
    Сообщения:
    436
    try to create DatagramSocket() object.

    if false, you must setup:
    1. Socket,
    2. ServerSocket
    3. Thread support
    4. THREAD NETWORK DRIVER
    5. ip6
     
  3. dcskm4200

    dcskm4200 New Member

    Публикаций:
    0
    Регистрация:
    12 окт 2004
    Сообщения:
    173
    Адрес:
    China
    HELLO,opennetworks
    thanks your answer.

    while a local network was crashed, the package appears.
    which computer does send the package?
    DNS server, or gateway?
     
  4. opennetworks

    opennetworks New Member

    Публикаций:
    0
    Регистрация:
    20 окт 2006
    Сообщения:
    436
    Shift.

    To detect Computer kind you can user InetAddress object.

    to get host by address:

    Код (Text):
    1. InetAddress iana = new InetAddress("224.0.0.22");
    2.  
    3. String host = iana.getByName();
    4.  
    5. ***
    So you can detect ServerName. Try to create connection on 221 or 111 not 80 xor 110 ports to view open ports.
    send PACK message to 221 port:

    msglist 224.0.0.22 221 PACK localhost AS THIS
    >224.0.0.22: 127.0.0.1 1ms * 192.168.0.1
    msglist 224.0.0.22 221 PACK $NS$ THIS AS THIS
    >224.0.0.22: ns1.servername.zone in-addr.arpa 255.255.255.0
    if last message valid - this is DNS SERVER
    if last message - >224.0.0.22: ROUTE TABLE 00 DF 04 C7 AA C0 * 0.0.0.255 then it is router:)
     
  5. dcskm4200

    dcskm4200 New Member

    Публикаций:
    0
    Регистрация:
    12 окт 2004
    Сообщения:
    173
    Адрес:
    China
    hey,opennetworks
    thanks.
    i can't understand what you said

    the packet was disappeared while i used [ip port software] to scan. that's meaning "can't detect Computer"
    the ip address(224.0.0.22) is strange in our local net. so i think the Computer of the ip address has a especial function.
     
  6. opennetworks

    opennetworks New Member

    Публикаций:
    0
    Регистрация:
    20 окт 2006
    Сообщения:
    436
    what language do you speak?
     
  7. opennetworks

    opennetworks New Member

    Публикаций:
    0
    Регистрация:
    20 окт 2006
    Сообщения:
    436
    How do you send packets.

    PACKET command only available on UDP protocol

    DatagramPacket() object must be used and IOException throwed
     
  8. dcskm4200

    dcskm4200 New Member

    Публикаций:
    0
    Регистрация:
    12 окт 2004
    Сообщения:
    173
    Адрес:
    China
    Hey,opennetworks
    thanks.

    asm
    code

    could you modify the following to detect DNS SERVER or ROUTER?
     
  9. dcskm4200

    dcskm4200 New Member

    Публикаций:
    0
    Регистрация:
    12 окт 2004
    Сообщения:
    173
    Адрес:
    China
    Код (Text):
    1. .586               
    2. .model flat,stdcall    
    3. option casemap:none    
    4. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    5. include \masm32\include\windows.inc
    6. include \masm32\include\user32.inc
    7. include \masm32\include\kernel32.inc
    8. include \masm32\include\masm32.inc
    9. include \masm32\include\wsock32.inc
    10.  
    11. includelib \masm32\lib\user32.lib
    12. includelib \masm32\lib\kernel32.lib
    13. includelib \masm32\lib\masm32.lib
    14. includelib \masm32\lib\wsock32.lib
    15. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    16. include \masm32\macros\macros.asm
    17. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    18.     ICO_ICON    equ 2000
    19.     DLG_MAIN    equ 2000
    20.     IDC_IP      equ 2001
    21.     IDC_RECVTEXT    equ 2002
    22.     IDC_SENDTEXT    equ 2003
    23.     IDC_PORT    equ 2004
    24.     ID_SEND     equ 3001
    25.     WM_SOCKET       equ WM_USER + 100
    26. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    27. .data?
    28.     hInstance   dd  ?
    29.     hWinMain    dd  ?
    30.     hSocket     dd  ?
    31.     szReadBuffer    db  32768 dup (?)
    32.     @stWsa      WSADATA <?>
    33. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    34. .const
    35.     szPort      db  '221',0
    36.     szIP        db  '224.0.0.22',0
    37.     szErrIP     db  'INVALID Ip Address!',0
    38.     dwReturn    dd  -1
    39. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    40. .code
    41. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    42. _RecvData proc  _hSocket:SOCKET
    43.     local   @dwRecv,@dwSize
    44.     local   xxSin:sockaddr_in
    45.  
    46.     mov @dwSize,sizeof xxSin
    47.     invoke  RtlZeroMemory,addr szReadBuffer,sizeof szReadBuffer
    48.     invoke  RtlZeroMemory,addr xxSin,sizeof xxSin
    49.     invoke  recvfrom,_hSocket,addr szReadBuffer,sizeof szReadBuffer,0,addr xxSin,addr @dwSize
    50.     .if eax !=  SOCKET_ERROR
    51.         invoke  sendto,hSocket,addr dwReturn,4,0,addr xxSin,sizeof sockaddr_in
    52.         .if eax ==  SOCKET_ERROR
    53.             invoke  WSAGetLastError
    54.             .if eax == WSAEWOULDBLOCK
    55.                 invoke  GetDlgItem,hWinMain,ID_SEND
    56.                 invoke  EnableWindow,eax,FALSE
    57.             .endif
    58.         .endif
    59.         invoke  GetDlgItem,hWinMain,IDC_RECVTEXT
    60.         mov ebx,eax
    61.         invoke  GetWindowTextLength,ebx
    62.         invoke  SendMessage,ebx,EM_SETSEL,eax,eax
    63.         invoke  SendMessage,ebx,EM_REPLACESEL,FALSE,addr szReadBuffer
    64.     .endif
    65.     ret
    66.  
    67. _RecvData endp
    68. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    69. _SendData proc USES ECX
    70.     local   SendBuffer[512]:byte
    71.     local   xxSin:sockaddr_in
    72.  
    73.     invoke  RtlZeroMemory,addr SendBuffer,sizeof SendBuffer
    74.     invoke  RtlZeroMemory,addr xxSin,sizeof xxSin
    75.     invoke  GetDlgItemText,hWinMain,IDC_IP,addr SendBuffer,sizeof SendBuffer
    76.     invoke  inet_addr,addr SendBuffer
    77.     .if eax ==  INADDR_NONE
    78.         invoke  MessageBox,hWinMain,addr szErrIP,NULL,MB_OK or MB_ICONWARNING
    79.         jmp @Exit
    80.     .endif
    81.     mov xxSin.sin_addr,eax
    82.     mov xxSin.sin_family,AF_INET
    83.     invoke  GetDlgItemText,hWinMain,IDC_PORT,addr SendBuffer,sizeof SendBuffer
    84.     invoke  atodw, addr SendBuffer
    85.     invoke  htons,eax
    86.     mov xxSin.sin_port,ax
    87.     invoke  GetDlgItemText,hWinMain,IDC_SENDTEXT,addr SendBuffer,sizeof SendBuffer
    88.     invoke  lstrlen,addr SendBuffer
    89.     .if eax
    90.         mov ecx,eax
    91.         invoke  sendto,hSocket,addr SendBuffer,ecx,0,addr xxSin,sizeof sockaddr_in
    92.         .if eax ==  SOCKET_ERROR
    93.             invoke  WSAGetLastError
    94.             .if eax == WSAEWOULDBLOCK
    95.                 invoke  GetDlgItem,hWinMain,ID_SEND
    96.                 invoke  EnableWindow,eax,FALSE
    97.             .endif
    98.         .endif
    99.     .endif
    100. @Exit:
    101.     ret
    102.  
    103. _SendData endp
    104. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    105. _ProcDlg proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
    106.  
    107.     .if uMsg == WM_SOCKET
    108.         mov eax,lParam
    109.         .if ax ==   FD_READ
    110.             invoke  _RecvData,wParam
    111.         .elseif ax ==   FD_WRITE
    112.             invoke  GetDlgItem,hWnd,ID_SEND
    113.             invoke  EnableWindow,eax,TRUE
    114.         .endif
    115.     .elseif uMsg == WM_COMMAND
    116.         mov eax,wParam
    117.         .if ax ==   ID_SEND
    118.             invoke  _SendData
    119.         .endif
    120.     .elseif uMsg == WM_CLOSE
    121.         invoke  closesocket,hSocket
    122.         invoke  WSACleanup
    123.         invoke  EndDialog,hWinMain,NULL
    124.     .elseif uMsg == WM_INITDIALOG
    125.         m2m hWinMain,hWnd
    126.         invoke  LoadIcon,hInstance, ICO_ICON
    127.         invoke  SendMessage, hWnd, WM_SETICON, ICON_SMALL or ICON_BIG, eax
    128.        
    129.         invoke  SetDlgItemText,hWinMain,IDC_PORT,addr szPort
    130.         invoke  SetDlgItemText,hWinMain,IDC_IP,addr szIP
    131.         invoke  WSAStartup,202h,addr @stWsa
    132.         invoke  socket,AF_INET,SOCK_DGRAM,0
    133.         mov hSocket,eax
    134.         invoke  WSAAsyncSelect,hSocket,hWinMain,WM_SOCKET,FD_READ or FD_WRITE
    135.     .else
    136.         mov eax,FALSE
    137.         ret
    138.     .endif
    139.     mov eax,TRUE
    140.     ret
    141.  
    142. _ProcDlg endp
    143. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    144. start:
    145.     invoke  GetModuleHandle,NULL
    146.         mov     hInstance, eax
    147.     invoke  DialogBoxParam,hInstance,DLG_MAIN,NULL,offset _ProcDlg,0
    148.     invoke  ExitProcess,NULL
    149. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    150.  
    151. end start
     
  10. opennetworks

    opennetworks New Member

    Публикаций:
    0
    Регистрация:
    20 окт 2006
    Сообщения:
    436
    language not supported

    For Network programming i am using Microsoft Visual Studio cause windows or ANT cause UNIX

    I am using ASM for creating Low-level applications only.

    Would you like to view full code in MSVS?
     
  11. dcskm4200

    dcskm4200 New Member

    Публикаций:
    0
    Регистрация:
    12 окт 2004
    Сообщения:
    173
    Адрес:
    China
    Thanks for your time and consideration