Almost beaten by a counselor! Just because I wrote him a USB virus! Python thief

Source: Internet
Author: User

How to determine the USB stick insert or not?

Incoming group: 548377875 to get dozens of sets of PDFs Oh!

As the headline shows, we really only used 10 lines (actually 11 lines, rounding up a whole:) to complete the "virus". We can find the contents of the USB and lie in the home directory after half a minute of insertion.

How do I select a copy of a file?

Let me give you an example.

I created the Testwalk folder in a directory, there are file123.txt three files, folder123 three folders, where Folder1 file File4.txt and Folder4

Now let's test it.

Root is the current location, and it will take all the folders under the./testwalk/as the root directory and search down

OK, we now need to recursive USB folder, find all the file, look at the size, if less than, such as 3M, copy into the home, greater than to go.

Shutil Module

Os.path.getsize () Judging size

Os.path.getsize (file name) returns a number in bytes, and if used to view the file size, we need to manually write a function to convert it into an easy-to-read form.

In summary, the modification time of each file can be filtered to copy only those files that have been modified or added during a specific period, which is useful in certain situations.

Almost beaten by a counselor! Just because I wrote him a USB virus! Python thief

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.