#include "stdafx.h" #include "string.h" unsigned int ulDaysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; unsigned int ulDaysNumber = 0; char *szCodeLetters = "qwertyuiopasdfghjklzxcvbnm"; char *szCom = ".com"; char szResult[256]; char szBytesResult[8]; char *szMonthName[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; void ulGetDaysPassedSince1970(unsigned int ulYear, unsigned int ulMonth, unsigned int ulDay) { unsigned int ulVar1 = 0; unsigned int ulVar2 = 0; __asm { mov eax, ulMonth push 0Ch cdq pop ecx idiv ecx add ulYear, eax test edx, edx mov ulMonth, edx jge short loc_F7873D32 add ulMonth, ecx dec ulYear loc_F7873D32: mov ecx, ulDay dec ecx push esi push edi jns short loc_F7873D93 mov esi, ulYear add esi, 1900 loc_F7873D43: dec ulMonth jns short loc_F7873D53 dec ulYear dec esi mov ulMonth, 0Bh loc_F7873D53: mov eax, esi and eax, 80000003h jns short loc_F7873D61 dec eax or eax, 0FFFFFFFCh inc eax loc_F7873D61: jnz short loc_F7873D82 mov eax, esi push 100 cdq pop edi idiv edi test edx, edx jnz short loc_F7873D7D mov eax, esi cdq mov edi, 400 idiv edi test edx, edx jnz short loc_F7873D82 loc_F7873D7D: xor eax, eax inc eax jmp short loc_F7873D84 loc_F7873D82: xor eax, eax loc_F7873D84: imul eax, 0Ch add eax, ulMonth add ecx, ulDaysInMonth[eax*4] js short loc_F7873D43 loc_F7873D93: mov edi, ulYear add edi, 1900 push ebx loc_F7873D9D: mov esi, edi and esi, 80000003h jns short loc_F7873DAC dec esi or esi, 0FFFFFFFCh inc esi loc_F7873DAC: jnz short loc_F7873DCD mov eax, edi push 100 cdq pop ebx idiv ebx test edx, edx jnz short loc_F7873DC8 mov eax, edi cdq mov ebx, 400 idiv ebx test edx, edx jnz short loc_F7873DCD loc_F7873DC8: xor eax, eax inc eax jmp short loc_F7873DCF loc_F7873DCD: xor eax, eax loc_F7873DCF: imul eax, 0Ch add eax, ulMonth cmp ecx, ulDaysInMonth[eax*4] jl short loc_F7873E26 test esi, esi jnz short loc_F7873E01 mov eax, edi push 100 cdq pop esi idiv esi test edx, edx jnz short loc_F7873DFC mov eax, edi cdq mov esi, 400 idiv esi test edx, edx jnz short loc_F7873E01 loc_F7873DFC: xor eax, eax inc eax jmp short loc_F7873E03 loc_F7873E01: xor eax, eax loc_F7873E03: imul eax, 12 add eax, ulMonth sub ecx, ulDaysInMonth[eax*4] inc ulMonth cmp ulMonth, 12 jnz short loc_F7873D9D and ulMonth, 0 inc ulYear inc edi jmp loc_F7873D9D loc_F7873E26: mov ebx, ulYear lea edi, [ebx-1970] mov esi, edi inc ecx imul esi, 365 mov eax, ebx and eax, 80000003h mov ulDay, ecx jns short loc_F7873E49 dec eax or eax, 0FFFFFFFCh inc eax loc_F7873E49: mov ulVar1, eax jz short loc_F7873E58 cmp eax, 2 jge short loc_F7873E58 xor ecx, ecx inc ecx jmp short loc_F7873E5A loc_F7873E58: xor ecx, ecx loc_F7873E5A: mov eax, edi cdq and edx, 3 add eax, edx sar eax, 2 add eax, ecx add esi, eax mov eax, ebx push 100 cdq pop ecx idiv ecx test edx, edx mov ulVar2, edx jz short loc_F7873E82 cmp edx, 70 jge short loc_F7873E82 xor ecx, ecx inc ecx jmp short loc_F7873E84 loc_F7873E82: xor ecx, ecx loc_F7873E84: mov eax, edi cdq push 100 pop ebx idiv ebx neg ecx sub ecx, eax mov eax, ulYear add esi, ecx mov ecx, 400 cdq mov ebx, ecx idiv ebx test edx, edx mov ulYear, edx jz short loc_F7873EB3 cmp edx, 370 jge short loc_F7873EB3 xor ebx, ebx inc ebx jmp short loc_F7873EB5 loc_F7873EB3: xor ebx, ebx loc_F7873EB5: mov eax, edi cdq idiv ecx xor edi, edi xor edx, edx xor ecx, ecx add eax, ebx add esi, eax cmp ulMonth, edi pop ebx jle short loc_F7873EF2 loc_F7873ECA: cmp ulVar1, edi jnz short loc_F7873EDE cmp ulVar2, edi jnz short loc_F7873ED9 cmp ulYear, edi jnz short loc_F7873EDE loc_F7873ED9: xor eax, eax inc eax jmp short loc_F7873EE0 loc_F7873EDE: xor eax, eax loc_F7873EE0: imul eax, 12 add eax, edx add ecx, ulDaysInMonth[eax*4] inc edx cmp edx, ulMonth jl short loc_F7873ECA loc_F7873EF2: mov eax, ulDay add ecx, esi pop edi lea eax, [ecx+eax-1] pop esi mov ulDaysNumber, eax } return; } void GenerateDnsName(unsigned int ulYear, unsigned int ulMonth, unsigned int ulDay, unsigned int ulIteration, unsigned int ulMagicNumber) { char szBuffer[256]; memset(szBytesResult, 0, 8); szResult[0] = '\0'; ulDaysNumber = 0; ulGetDaysPassedSince1970(ulYear, ulMonth, ulDay); __asm { lea edi, szBuffer mov ebx, eax mov eax, szCodeLetters mov ulYear, eax push 3 mov eax, ebx xor edx, edx pop ecx div ecx lea ecx, szResult sub ebx, edx mov ulDay, ebx xor esi, esi loc_F7873F3E: mov al, byte ptr [ulDay + esi] xor al, byte ptr [ulMagicNumber + esi] mov dl, al shr dl, 4 mov [ecx], dl inc ecx and al, 0Fh mov [ecx], al inc ecx inc esi cmp esi, 4 jl short loc_F7873F3E mov eax, ulIteration mov byte ptr [ulDay+3], bl and byte ptr [ulDay+3], 0Fh xor esi, esi inc eax mov ulMonth, eax loc_F7873F69: movzx eax, byte ptr [ulDay+3] lea ecx, szResult[esi] movzx edx, byte ptr [ecx] xor eax, edx imul eax, ulMonth push 0Fh cdq pop ebx idiv ebx inc esi cmp esi, 8 mov [ecx], dl jl short loc_F7873F69 xor eax, eax loc_F7873F8A: movzx ecx, szResult[eax] mov edx, ulYear mov cl, [ecx+edx] mov [edi], cl inc edi inc eax cmp eax, 8 jl short loc_F7873F8A mov byte ptr [edi], 0 mov eax, szCom mov ecx, eax loc_F7873FA8: mov dl, [eax] inc eax test dl, dl jnz short loc_F7873FA8 sub eax, ecx mov esi, ecx dec edi loc_F7873FB4: mov cl, [edi+1] inc edi test cl, cl jnz short loc_F7873FB4 mov ecx, eax shr ecx, 2 rep movsd mov ecx, eax and ecx, 3 rep movsb } strncpy(szResult, szBuffer, 12); szResult[12] = '\0'; return; } int main(int argc, char* argv[]) { char szMessage[256]; for (int iYear = 2008; iYear <= 2009; iYear++) { for (int iMonth = 1; iMonth <= 12; iMonth++) { for (int iDay = 1; iDay <= (int)ulDaysInMonth[iMonth-1]; iDay++) { sprintf(szMessage, "\r\n%2d %s %d:", iDay, szMonthName[iMonth-1], iYear); printf(szMessage); for (int i=0; i<4; i++) { if (i!=0) { printf(" "); } GenerateDnsName(iYear, iMonth, iDay, i, 0xB05E6620); sprintf(szMessage, " %s\r\n", szResult); printf(szMessage); } } } } return 0; }