⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resolver.asm

📁 ip address resolve
💻 ASM
字号:
.386
.model flat, stdcall
option casemap :none

include /masm32/include/windows.inc
include /masm32/include/user32.inc
include /masm32/include/kernel32.inc
include /masm32/include/wsock32.inc
includelib /masm32/lib/wsock32.lib
includelib /masm32/lib/user32.lib
includelib /masm32/lib/kernel32.lib

   WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
   ResolveIp PROTO :DWORD                               ;proto for helper thread

.data 
    dlgname     db "MAIN",0 
    szTitle     db "Host/Ip Resolver",0
    wsaError    db "Error initializing winsock!",0
    szReady     db "Ready",0
    szResolving db "Resolving...",0
    szReverse   db "Reversing...",0
    unknown     db "Unknown",0

.data?
    wsa WSADATA <?>                                     ;winsock data
    hInstance   dd ?
    szIpaddr   db 256 dup(?)                            
    szHostname db 256 dup(?)
    hMain    dd ?
    hResolve dd ?
    ThreadId dd ?                                       ;hold the thread id
    ip      dd ?
    
.code

start:

        invoke GetModuleHandle, NULL
            mov hInstance, eax
        invoke WSAStartup,101h,offset wsa               ;load winsock version 1.1
            .if eax != NULL                             ;if we did not get a null it worked
                invoke MessageBox,NULL,offset wsaError,offset szTitle,MB_OK + MB_ICONSTOP ;error handling
                    invoke ExitProcess,1                    ;quit if no winsock
            .endif
                invoke DialogBoxParam,hInstance,ADDR dlgname,0,ADDR WndProc,0
                    invoke ExitProcess,0
                    
WndProc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

      .if uMsg == WM_INITDIALOG
            mov eax,hWin
            mov hMain,eax
            invoke GetDlgItem,hWin,2000
            mov hResolve,eax
      .elseif uMsg == WM_COMMAND
            .if wParam == 2000
                invoke CreateThread,0,0,addr ResolveIp,0,0,addr ThreadId    ;call or thread so windows does not freeze
                    invoke CloseHandle,eax
            .endif
                xor eax,eax
                    ret
      .elseif uMsg == WM_CLOSE
            invoke WSACleanup                                               ;free the winsock.dll
                invoke EndDialog,hWin,0  
                    ret
      .endif
    xor eax,eax
        ret 
WndProc endp

ResolveIp proc lParam:DWORD
	invoke EnableWindow,hResolve,FALSE                                 ;disable the resolve button
	invoke GetDlgItemText,hMain,1001,addr szIpaddr,sizeof szIpaddr     ;get the text from the ip box
	   or	eax,eax                                                      ;check return
	       jz ResolveHost		                                     ;if 0 jump to resolve host
	invoke lstrcmp,addr unknown,addr szIpaddr                          ;compare return with unknown string
	   or	eax,eax                                                      ;check eax
	       jz ResolveHost                                              ;jmp to resolve host if 0
	invoke SetDlgItemText,hMain,3000,addr szReverse                    ;change the frame text
	   invoke inet_addr,addr szIpaddr		                         ;converts dotted ip to a in_addr
	       mov	ip,eax			                               ;mov eax into ip
	invoke gethostbyaddr,addr ip,4,2		                         ;gets host info from address info
	   mov ebx,1000	                                                 ;move hostbox id into ebx
	       or eax,eax                                                  ;see if gethost...worked
	           jz Unresolvable	                                     ;if not jump to unresolvable
	mov eax,[eax]                                                      ;mov the pointer returnt by gethost into eax
	   or	eax,eax                                                      ;check return to see if eax contains anything
	       jz Unresolvable	                                           ;if not jump to unresolveable
	invoke SetDlgItemText,hMain,1000,eax                               ;set the info in the host box
	   jmp endResolve                                                  ;jump to the cleanup

Unresolvable:                                                            ;label
	invoke SetDlgItemText,hMain,ebx,addr unknown                       ;set unknown text in correct textbox
	   jmp endResolve                                                    ;jump to cleanup

ResolveHost:	                                                       ;label
	invoke SetDlgItemText,hMain,3000,addr szResolving                  ;change the frame text
	invoke GetDlgItemText,hMain,1000,addr szHostname,sizeof szHostname ;get the text from the host textbox
	   or	eax,eax                                                      ;see if we got something
	       jz endResolve                                               ;nothing in either box so do nothing
	invoke lstrcmp,addr unknown,addr szHostname                        ;compare it to are unknown string
	   or	eax,eax                                                      ;check for 0
	       jz endResolve                                                 ;if so jump to cleanup
	invoke gethostbyname,addr szHostname                               ;
	   mov ebx,1001                                                    ;mov the ip text id into ebx
	       or eax,eax                                                  ;check to see if gethost...returned something
	           jz Unresolvable                                         ;if not jmp to unresolvable
	mov eax,[eax+12]                                                   ;mov through the hosnet struct
	mov eax,[eax]                                                      ;again
	mov eax,[eax]	                                                 ;finally to our wanted info
	invoke inet_ntoa,eax                                               ;convert it to a dotted ip address
	invoke SetDlgItemText,hMain,1001,eax                               ;set the text
	   
endResolve:                                                              ;label
	invoke EnableWindow,hResolve,TRUE                                  ;Re-enable the Resolve button
	invoke SetDlgItemText,hMain,3000,addr szReady                      ;change the frame text
	invoke ExitThread,0                                                ;exit the helper thread
xor eax,eax                                                             
ret

ResolveIp endp
end start


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -