Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88079
| Date | 2015-03-26 13:23 -0400 |
|---|---|
| From | Dave Angel <davea@davea.name> |
| Subject | Re: Basic Python V3 Search Tool using RE module |
| References | <b8b86122-0653-42eb-b9d9-2ba0f45f30f9@googlegroups.com> <b93ae2dd-6dbf-49be-9d21-b30c0926f83a@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.210.1427390652.10327.python-list@python.org> (permalink) |
On 03/26/2015 01:11 PM, Gregg Dotoli wrote: > On Wednesday, March 25, 2015 at 3:43:38 PM UTC-4, Gregg Dotoli wrote: >> This basic script will help to find >> evidence of CryptoWall on a slave drive. Although it is >> just a string, more complex regex patterns can be >> replaced with the string. It is incredible how fast Python is and >> how easy it has helped in quickly assessing a pool of slave drives. >> I'm improving it as we speak. >> >> >> Thanks for your help and patience. I'm new with Python. >> >> >> import os >> import re >> # From the Root >> topdir = "." >> >> # Regex Pattern >> pattern="DECRYPT_I" >> regexp=re.compile(pattern) >> for dirpath,dirnames, files in os.walk(topdir): >> for name in files: >> result=regexp.search(name) >> print(os.path.join(dirpath,name)) >> print (result) >> >> >> >> >> >> Gregg Dotoli > > I posted this because I thought it may be of help to others. This does grep through all the files and is very fast because the regex is compiled in Python , rather than sitting in some directory as an external command. > That is where the optimization comes in. > > Let's close this thread. > > It "grep"s through all the filenames, but there's no open() call or equivalent there at all. it does not look inside a single file. We can stop posting to the thread, but that won't fix the bug in the code. -- DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Basic Python V3 Search Tool using RE module Gregg Dotoli <gdotoli@gmail.com> - 2015-03-25 12:43 -0700
Re: Basic Python V3 Search Tool using RE module Dave Angel <davea@davea.name> - 2015-03-25 21:20 -0400
Re: Basic Python V3 Search Tool using RE module Tim Chase <python.list@tim.thechases.com> - 2015-03-25 20:29 -0500
Re: Basic Python V3 Search Tool using RE module CHIN Dihedral <dihedral88888@gmail.com> - 2015-03-26 06:01 -0700
Re: Basic Python V3 Search Tool using RE module Gregg Dotoli <gdotoli@gmail.com> - 2015-03-26 10:11 -0700
Re: Basic Python V3 Search Tool using RE module Dave Angel <davea@davea.name> - 2015-03-26 13:23 -0400
Re: Basic Python V3 Search Tool using RE module Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-27 10:01 +1100
csiph-web