Simple anti-USB virus (Cannot delete malformed folder)

Source: Internet
Author: User
A long fashion is the way to prevent users from deleting it.

A long time ago also use the method to prevent the U disk virus

As shown below

:


The principle of anti-U-disk virus is to create one such file on each disk

Let's take a few win APIs

DWORD WINAPI getlogicaldrivestrings (<span style= "White-space:pre" >  </span>//Get disk    _in_  DWORD  nbufferlength,    _out_ LPTSTR lpbuffer  );
<span style= "Color:rgb (69, 69, 69); font-family: ' Segoe UI ', ' Lucida Grande ', Verdana, Arial, Helvetica, Sans-serif; font-size:14px; line-height:20.0060005187988px; " >fills a buffer with strings so specify valid drives in the system.</span>

A second API

BOOL WINAPI createdirectory (    _in_     lpctstr               lppathname,    _in_opt_ lpsecurity_attributes lpSecurityAttributes  );  <span style= "Color:rgb (69, 69, 69); font-family: ' Segoe UI ', ' Lucida Grande ', Verdana, Arial, Helvetica, Sans-serif; font-size:14px; line-height:20.0060005187988px; " >creates a new directory. </span>

Here is the code

#include "stdafx.h"  #include <windows.h>    void Immuntiyautorun ()  {      //Create a folder that cannot be deleted      Char Szdriverstr[maxbyte] = {0};        DWORD Dwlen = Getlogicaldrivestringsa (Maxbyte, szdriverstr);        for (int i = 0; i < Dwlen; i+=4)      {          char szroot[4] = {}, Szpath[max_path] = {0};          strncpy_s (Szroot, &szdriverstr[i], 4);          strcpy_s (szpath, szroot);          strcat_s (szpath, "Autorun.inf");          if (! Createdirectorya (szpath, nullptr))              printf_s ("error:%d", GetLastError ());          strcat_s (szpath, "\\anti......\\");          if (! Createdirectorya (szpath, nullptr))              printf_s ("error:%d", GetLastError ());      }        }    int _tmain (int argc, _tchar* argv[])  {        immuntiyautorun ();      GetChar ();      return 0;  }

This creates a malformed folder with a trailing "..." under each of the disks.


But note that with the win API can remove him oh.

BOOL WINAPI removedirectory (    _in_ lpctstr lppathname  );

The above is a simple anti-U disk virus (deleted malformed folder) content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.