;//code by laomms 2007/7
.586 .model flat,stdcall option casemap:none
include masm32.inc include windows.inc include user32.inc include kernel32.inc include shell32.inc include comctl32.inc include comdlg32.inc include wsock32.inc include wininet.inc include gdi32.inc include advapi32.inc include ws2_32.inc
includelib masm32.lib includelib user32.lib includelib kernel32.lib includelib shell32.lib includelib comctl32.lib includelib comdlg32.lib includelib wsock32.lib includelib wininet.lib includelib gdi32.lib includelib advapi32.lib includelib ws2_32.lib
Download PROTO :DWORD Stripper PROTO :DWORD, :DWORD
.const IDD_Main equ 1000 IDC_DNS equ 1002 IDC_PORT equ 1005 IDC_IPADDR equ 1007 IDC_IP equ 1009 IDC_STC5 equ 1010 IDC_WANIP equ 1011 IDC_START equ 1013 IDC_ABOUT equ 1014 IDC_EXIT equ 1015 IDC_MODIFY equ 1017 IDC_HOST equ 1018 IDC_PCNAME equ 1020 IDC_GETINF equ 1021 IDC_GetWANIP equ 1022 ico equ 2001 WM_SOCKET equ WM_USER+100 .data DNS db 256 dup(0) PortNumber DWORD 80 szFind db 256 dup(0) send3 db 13,10,"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) WebAlert",13,10 db "Accept: */*",13,10 db "Accept-Language: en-us",13,10 db "Proxy-Connection: Keep-Alive",13,10,13,10,0
.data? wsadata WSADATA <?> sock dd ? host dd ? hFile dd ? buffer db 256 dup(?) buffer2 db 128 dup (?) OutBuffer db 128 dup (?) htmlBuffer db 256 dup(?) hDlg HINSTANCE ? hInstance HINSTANCE ? hWinEdit dd ? SendBuf db 4096 dup (?) RecvBuf db 24096 dup (?) ; *** Should be sufficient *** ;1 24 "XPStyle.manifest"
DlgProc proto :DWORD,:DWORD,:DWORD,:DWORD MakeConnection PROTO SetFont proto :DWORD,:DWORD,:DWORD CTEXT MACRO y:VARARG LOCAL sym CONST segment ifidni <y>,<> sym db 0 else sym db y,0 endif CONST ends exitm <offset sym> ENDM return macro value mov eax, value ret endm
.code start: invoke InitCommonControls invoke LoadLibrary,CTEXT('RichEd20.dll') .if eax==0 invoke MessageBox,0,CTEXT('RichEdit控件载入错误!!',0),CTEXT('提示',0),MB_OK or MB_ICONERROR .endif invoke LoadLibrary,CTEXT("Comctl32.dll") invoke GetProcAddress,eax,CTEXT("InitCommonControlsEx") call eax invoke GetModuleHandle, NULL mov hInstance,eax invoke WSAStartup,101h,addr wsadata .if eax != NULL invoke MessageBox,0,CTEXT('网络控件载入错误!!',0),CTEXT('提示',0),MB_OK or MB_ICONERROR .endif invoke DialogBoxParam, hInstance, IDD_Main, NULL, addr DlgProc, NULL invoke FreeLibrary,hWinEdit invoke ExitProcess,eax DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM local @stCf:CHARFORMAT
.if uMsg == WM_INITDIALOG push hWnd pop hDlg invoke LoadIcon,hInstance,ico invoke SendMessage,hWnd,WM_SETICON,1,eax invoke gethostname,offset buffer,sizeof buffer invoke wsprintf,addr buffer2,CTEXT("%s"),addr buffer invoke SetDlgItemText,hWnd,IDC_PCNAME,addr buffer2 invoke gethostbyname,addr buffer mov eax,[eax+12] mov eax,[eax] mov eax,[eax] invoke inet_ntoa,eax invoke SetDlgItemText,hWnd,IDC_IP,eax invoke WSACleanup invoke SetDlgItemText,hWnd,IDC_PORT,CTEXT("80") invoke GetDlgItem,hWnd,IDC_HOST ; RichEdit窗口 mov hWinEdit,eax invoke SendMessage,hWinEdit,EM_SETTEXTMODE,TM_PLAINTEXT,0 invoke RtlZeroMemory,addr @stCf,sizeof @stCf mov @stCf.cbSize,sizeof @stCf mov @stCf.yHeight,9 * 20 mov @stCf.dwMask,CFM_FACE or CFM_SIZE or CFM_BOLD invoke lstrcpy,addr @stCf.szFaceName,CTEXT('宋体',0) invoke SetFont,CTEXT('宋体',0),9 * 20,0 invoke SendMessage,hWinEdit,EM_SETCHARFORMAT,0,addr @stCf invoke SendMessage,hWinEdit,EM_EXLIMITTEXT,0,-1 call OpenTextFile .elseif uMsg == WM_COMMAND mov eax,wParam .if eax==IDC_START invoke GetDlgItemText,hWnd,IDC_DNS,addr DNS,sizeof DNS invoke WSAStartup,0101h, addr wsadata ;Initialize WinSock Invoke gethostbyname,addr DNS .if eax==0 invoke MessageBox,0,CTEXT('错误,地址前面加了,"http://"或地址无效!'),CTEXT('提示',0),MB_OK or MB_ICONERROR ret .endif mov eax,[eax+12] mov eax,[eax] ; copy the pointer to the actual IP address into eax mov eax,[eax] ; copy IP address into eax invoke inet_ntoa,eax invoke SetDlgItemText,hWnd,IDC_IPADDR,eax invoke WSACleanup .elseif eax==IDC_GETINF invoke MakeConnection .elseif eax==IDC_GetWANIP call GetWanIP invoke SetDlgItemText,hWnd,IDC_WANIP,eax .elseif eax==IDC_MODIFY call SaveAs .elseif eax==IDC_ABOUT invoke MessageBox,NULL,CTEXT("-IP地址转换器 by laomms- ",13," --====2007.6====--") ,CTEXT("关于"),MB_OK .elseif eax==IDC_EXIT invoke EndDialog,hWnd,0 .endif .elseif uMsg == WM_CLOSE invoke EndDialog,hWnd,0 .endif xor eax,eax ret DlgProc endp MakeConnection PROC LOCAL wsa:WSADATA LOCAL sin:sockaddr_in LOCAL connectsock:SOCKET invoke GetDlgItemText,hDlg,IDC_DNS,addr DNS,sizeof DNS invoke lstrcpy,addr SendBuf,CTEXT("GET ") invoke lstrcat,addr SendBuf,CTEXT("/mlicence.htm") invoke lstrcat,addr SendBuf,CTEXT(" HTTP/1.1",13,10,"Host: ") invoke lstrcat,addr SendBuf,addr DNS invoke lstrcat,addr SendBuf,addr send3
invoke MessageBoxA,NULL,addr SendBuf,addr DNS,MB_OK invoke WSAStartup,0101h,addr wsa invoke socket,AF_INET,SOCK_STREAM,0 .IF eax==INVALID_SOCKET invoke WSACleanup mov eax,1 ret .ENDIF mov connectsock,eax mov sin.sin_family,AF_INET invoke htons,PortNumber mov sin.sin_port,ax
invoke gethostbyname,addr DNS .IF eax==0 invoke WSACleanup mov eax,1 ret .ENDIF mov eax,[eax+12] mov eax,[eax] mov eax,[eax] mov sin.sin_addr,eax
invoke connect,connectsock,addr sin,sizeof sin .IF eax==SOCKET_ERROR invoke WSACleanup mov eax,1 ret .ENDIF
invoke send,connectsock,addr SendBuf,sizeof SendBuf,0 .IF eax==SOCKET_ERROR invoke WSACleanup mov eax,1 ret .ENDIF invoke recv,connectsock,addr RecvBuf,sizeof RecvBuf,0 .IF eax==SOCKET_ERROR invoke WSACleanup mov eax,1 ret .ENDIF invoke closesocket,connectsock invoke MessageBoxA,NULL,addr RecvBuf,addr DNS,MB_OK xor eax,eax ret MakeConnection ENDP GetWanIP proc uses esi edi ecx LOCAL szComputerName[128]:BYTE LOCAL szCNameLen:DWORD ;LOCAL wsadata:WSADATA LOCAL addWanIP:DWORD
mov szCNameLen,sizeof szComputerName invoke GetComputerName,addr szComputerName,addr szCNameLen invoke WSAStartup,101h,addr wsadata invoke gethostbyname,addr szComputerName mov ebx,eax assume ebx:ptr hostent movzx ecx,[ebx].h_len dec ecx mov eax,[ebx].h_list assume ebx:nothing mov ebx,eax ;得到列表数组的首地 .while ecx>0 mov eax,ebx mov eax,[eax] mov eax,[eax] push ecx invoke inet_ntoa,eax mov addWanIP,eax ;invoke MessageBox,hDlg,addWanIP,addr szComputerName,MB_OK mov ecx,3 lea edi,CTEXT('169');sz169 mov esi,addWanIP repe cmpsb or ecx,0 jnz noFind169 jmp next ;有169开头的 noFind169: mov ecx,3 lea edi,CTEXT('192');sz192 mov esi,addWanIP repe cmpsb or ecx,0 jnz FindWanIP jmp next FindWanIP: invoke WSACleanup ;invoke MessageBox,hDlg,addWanIP,addr szFind,MB_OK mov eax,addWanIP ret next: add ebx,4 pop ecx dec ecx .endw invoke WSACleanup xor eax,eax ret GetWanIP endp ProcStream proc uses ebx edi esi _dwCookie,_lpBuffer,_dwBytes,_lpBytes
.if _dwCookie invoke ReadFile,hFile,_lpBuffer,_dwBytes,_lpBytes,0 .else invoke WriteFile,hFile,_lpBuffer,_dwBytes,_lpBytes,0 .endif xor eax,eax ret
ProcStream endp OpenTextFile proc LOCAL SysPath[128]:byte LOCAL tLen:dword LOCAL strBuffer[512]:byte local editstream:EDITSTREAM
invoke GetSystemDirectory , ADDR SysPath ,Sizeof SysPath invoke lstrcat, addr SysPath, CTEXT("\drivers\etc\hosts") invoke CreateFile,addr SysPath ,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0 mov hFile,eax mov editstream.dwCookie,eax mov editstream.dwError,NULL mov editstream.pfnCallback,offset ProcStream invoke SendMessage,hWinEdit,EM_STREAMIN,SF_TEXT,addr editstream invoke SendMessage,hWinEdit,EM_SETMODIFY,FALSE,0 invoke CloseHandle,hFile ret
OpenTextFile endp SaveAs proc LOCAL SysPath[128]:byte local @stOF:OPENFILENAME local @stES:EDITSTREAM invoke GetSystemDirectory , ADDR SysPath ,Sizeof SysPath invoke lstrcat, addr SysPath, CTEXT("\drivers\etc\hosts") invoke CreateFile,addr SysPath,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0 .if eax != INVALID_HANDLE_VALUE push eax .if hFile invoke CloseHandle,hFile .endif pop eax mov hFile,eax invoke SetFilePointer,hFile,0,0,FILE_BEGIN invoke SetEndOfFile,hFile mov @stES.dwCookie,FALSE mov @stES.dwError,NULL mov @stES.pfnCallback,offset ProcStream invoke SendMessage,hWinEdit,EM_STREAMOUT,SF_TEXT,addr @stES invoke SendMessage,hWinEdit,EM_SETMODIFY,FALSE,0 mov eax,TRUE invoke CloseHandle,hFile ret .else invoke MessageBox,hDlg,CTEXT("保存文件错误!!!"),0,MB_OK .endif mov eax,FALSE ret
SaveAs endp SetFont proc _lpszFont,_dwFontSize,_dwColor local @stCf:CHARFORMAT
invoke RtlZeroMemory,addr @stCf,sizeof @stCf mov @stCf.cbSize,sizeof @stCf mov @stCf.dwMask,CFM_SIZE or CFM_FACE or CFM_BOLD or CFM_COLOR push _dwFontSize pop @stCf.yHeight push _dwColor pop @stCf.crTextColor mov @stCf.dwEffects,0 invoke lstrcpy,addr @stCf.szFaceName,_lpszFont invoke SendMessage,hWinEdit,EM_SETTEXTMODE,1,0 invoke SendMessage,hWinEdit,EM_SETCHARFORMAT,SCF_ALL,addr @stCf ret
SetFont endp end start
|