Lord_Zero Ametuar Posts: 122
| This is a simple IRC bot that works like a pinger: connects to a server, joins a channel and sends some information (a hublist pinger sends $BotINFO, this bot will send a chat message). The resouce file (RSRC.RC):
Code: | #include "\masm32\include\RESOURCE.H" 1000 DIALOGEX MOVEABLE IMPURE LOADONCALL DISCARDABLE 10, 10, 240, 56, 0 STYLE DS_MODALFRAME | 0x0004 | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_POPUP | DS_CENTER CAPTION "IRC" FONT 8, "MS Sans Serif", 700, 0 /*FALSE*/ BEGIN RTEXT "Enter &IRC server's address:", 10, 2,7,109,10, SS_LEFT, , 0 EDITTEXT 100, 117,7,116,12, ES_AUTOHSCROLL | ES_LEFT, , 0 DEFPUSHBUTTON "O&K", 1, 65,34,50,15, 0, , 0 PUSHBUTTON "C&ancel", 2, 125,34,50,15, 0, , 0 END | IRCBot.asm:
Code: | .386 .model flat,stdcall option casemap:none include \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\user32.inc include \masm32\include\ws2_32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\user32.lib includelib \masm32\lib\ws2_32.lib dlgProc PROTO :DWORD,:DWORD,:DWORD,:DWORD .data? seed1 dd ? seed2 dd ? wsadata WSADATA <> .code str1 dd 01010010010001010101001101010101B,01110011011001010101010000100000B,01110100001100000100001001110100B,01100101011101000010001000100000B,00100000001000100111010001110011B,0 str2 dd 01000101010101000011101000100000B,01001100010001010100110101000001B,00001101010001010101010001001001B,1010B str3 dd 01001110010010010100111101001010B,01101000011101000010001100100000B,01100110011001010110010001100101B,01100100011001010110001101100001B,01010010010100000000101000001101B dd 01010011010011010101011001001001B,01110100001000110010000001000111B,01100101011001000110010101101000B,01100101011000110110000101100110B,01010100001110100010000001100100B dd 00100000011100110110100101101000B,01101110011000010110100001100011B,00100000011011000110010101101110B,01100110001000000111001101101001B,01101001011010110110001101110101B dd 01001100001000000110011101101110B,00100000010001010100110101000001B,00001101001000010010000100100001B,1010B start: invoke GetModuleHandle,0 invoke WSAStartup,101h,addr wsadata invoke DialogBoxParam,eax,1000,0,addr dlgProc,0 .if eax lea esi,wsadata mov edi,6667 .while byte ptr[esi] .if byte ptr[esi]==':' mov byte ptr[esi],0 inc esi call atoi mov di,ax .break .endif inc esi .endw lea esi,wsadata assume esi:ptr sockaddr_in invoke inet_addr,esi .if eax==INADDR_NONE invoke gethostbyname,esi .if eax mov eax,[eax+12] mov eax,[eax] mov eax,[eax] .endif .endif lea esi,wsadata.szSystemStatus mov [esi].sin_addr,eax mov ax,di xchg al,ah mov [esi].sin_port,ax mov [esi].sin_family,AF_INET xor eax,eax mov dword ptr[esi].sin_zero,eax mov dword ptr[esi].sin_zero[4],eax invoke socket,PF_INET,SOCK_STREAM,IPPROTO_TCP .if eax!=INVALID_SOCKET push eax invoke connect,eax,esi,sizeof sockaddr_in .if eax==0 mov edi,esi mov eax,01001011010000110100100101001110B stosd mov al,20h stosb mov ecx,7 .while ecx push ecx call _rnd mov bl,26 mov ah,0 div bl xchg al,ah add al,65 stosb pop ecx dec ecx .endw mov ax,0a0dh stosw lea edx,str1 call copyedx mov al,34 stosb lea edx,wsadata call copyedx mov al,34 stosb lea edx,str2 call copyedx mov ecx,edi sub ecx,esi mov edx,[esp] invoke send,edx,esi,ecx,0 .while 1 mov edx,[esp] invoke recv,edx,addr wsadata,sizeof wsadata,0 .break .if (eax==SOCKET_ERROR)||(eax==0) lea esi,wsadata mov edi,esi mov ecx,eax .while ecx .if (dword ptr[esi]==01000111010011100100100101010000B)&&(byte ptr[esi+4]==32) mov eax,01000111010011100100111101010000B stosd lodsd .while byte ptr[esi]>31 movsb .endw movsw .break .elseif dword ptr[esi]==00100000001101100011011100110011B pop edx push edx invoke send,edx,addr str3,73,0 invoke Sleep,5000 call closesocket push 0 .break .endif dec ecx inc esi .endw .if edi!=offset wsadata mov ecx,edi sub ecx,offset wsadata mov edx,[esp] invoke send,edx,addr wsadata,ecx,0 .endif .endw .else invoke WSAGetLastError int 3 .endif call closesocket .endif assume esi:nothing .endif invoke WSACleanup invoke ExitProcess,0 strInit dd 00110001001011100011100100110110B,00110110001110010010111000110010B dd 00000000001100000011010100101110B dlgProc PROC hDlg:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD .if uMsg==WM_INITDIALOG invoke SetDlgItemText,hDlg,100,addr strInit .elseif uMsg==WM_COMMAND .if wParam==2 invoke EndDialog,hDlg,0 .elseif wParam==1 invoke GetDlgItemText,hDlg,100,addr wsadata,sizeof WSADATA invoke EndDialog,hDlg,1 .endif .endif xor eax,eax ret dlgProc ENDP atoi: xor eax,eax xor ebx,ebx push edx getdec0:mov bl,[esi] inc esi sub bl,'0' cmp bl,10 jnc _getdec push ebx xor edx,edx mov bl,10 mul ebx pop ebx add eax,ebx jmp getdec0 _getdec:pop edx ret copyedx:.while byte ptr[edx] mov al,[edx] stosb inc edx .endw ret _rnd: push ebx invoke GetTickCount not eax xor seed2,eax mov ecx,seed2 rol seed1,3 add word ptr seed1,cx and ecx,1fffh add ecx,offset start add eax,[ecx] add seed1,eax mov eax,seed1 xor eax,seed2 pop ebx ret end start | To assemble use bldall IRCBot in the directory where these files are saved. Enjoy
|