Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!news-transit.tcx.org.uk!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!amsnews11.chello.com!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'skip': 0.04; 'string.': 0.04; 'lines.': 0.05; 'one?': 0.05; 'subject:Python': 0.06; 'behavior.': 0.07; 'does.': 0.07; 'skipping': 0.07; 'tab': 0.07; 'python': 0.08; '"hello': 0.09; '>>>>': 0.09; 'linux.': 0.09; 'reasonable.': 0.09; 'url:github': 0.09; 'output': 0.10; 'am,': 0.12; 'case.': 0.15; 'cc:addr:python-list': 0.15; '"r")': 0.16; '.py': 0.16; 'dave.': 0.16; 'different,': 0.16; 'feed.': 0.16; 'gene': 0.16; 'hangs': 0.16; 'paths.': 0.16; 'pulled': 0.16; 'received:192.168.1.104': 0.16; 'root,': 0.16; 'suggested,': 0.16; 'suggested.': 0.16; 'typo': 0.16; 'url:blob': 0.16; 'variable.': 0.16; 'cheers,': 0.18; 'wrote:': 0.18; '>>>': 0.18; 'seems': 0.19; 'downloaded': 0.21; 'cc:no real name:2**0': 0.21; 'file,': 0.21; 'subject:please': 0.21; "doesn't": 0.23; 'header:In-Reply-To:1': 0.23; 'changed': 0.24; 'there.': 0.24; 'suspect': 0.24; 'cc:2**0': 0.25; 'code': 0.25; 'putting': 0.27; 'version,': 0.28; 'tried': 0.28; 'toward': 0.28; 'looks': 0.28; 'cc:addr:python.org': 0.29; 'print': 0.29; 'pattern': 0.30; 'quoting': 0.30; 'ran': 0.30; 'yes.': 0.30; "didn't": 0.30; 'least': 0.31; 'thanks': 0.31; 'list': 0.32; 'quite': 0.32; "won't": 0.32; 'actually': 0.33; "i've": 0.33; 'it.': 0.33; 'there': 0.33; 'header:User-Agent:1': 0.33; 'source': 0.33; 'match': 0.33; 'file.': 0.34; 'all.': 0.34; 'shows': 0.34; 'probably': 0.34; 'null': 0.34; 'puts': 0.34; "what's": 0.35; 'running': 0.35; 'junk': 0.35; 'skip:" 20': 0.35; 'certain': 0.35; 'file': 0.36; 'something': 0.36; 'page.': 0.36; 'another': 0.36; 'doing': 0.37; 'but': 0.37; 'issue': 0.37; 'two': 0.37; 'not,': 0.37; 'using': 0.37; 'could': 0.38; 'monday,': 0.38; 'run': 0.38; 'put': 0.38; 'perhaps': 0.38; 'skip:o 20': 0.38; 'received:192': 0.38; 'itself.': 0.38; "i'd": 0.39; 'should': 0.39; 'absolute': 0.39; 'empty': 0.39; 'got': 0.39; 'subject:: ': 0.39; 'change': 0.39; 'data': 0.40; 'files': 0.40; 'did': 0.40; 'more': 0.60; 'per': 0.61; 'leading': 0.61; 'back': 0.62; '2011': 0.62; 'world': 0.62; 'high': 0.66; 'bottom': 0.68; 'header:Reply- To:1': 0.70; 'reply-to:no real name:2**0': 0.71; 'soon': 0.72; 'thousand': 0.73; 'failure': 0.74; 'with,': 0.77; '15k': 0.84; '30k': 0.84; 'directories,': 0.84; 'midi': 0.84; 'named:': 0.84; 'otten': 0.84; 'swag,': 0.84; 'stretch': 0.91; 'besides,': 0.93; 'malware': 0.93; 'yours.': 0.95 Date: Mon, 07 Nov 2011 13:14:50 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15 MIME-Version: 1.0 To: gene heskett Subject: Re: Python lesson please References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> <4EB7DD67.5070606@davea.name> <201111071140.12374.gheskett@wdtv.com> In-Reply-To: <201111071140.12374.gheskett@wdtv.com> Content-Type: text/plain; charset=windows-1256; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:HzwXVGubZ2uqeG+e+SIhDV3MfEXAD/qFnbqT4IHHjvn rYLgm6eiNPCzlWFltPkKB+RrcqElBBGJLQ8PBGMTAjiLSK5jLB sH0nihax9FKTmlnsjaOiPWKgi3+AIncPgNDPn1KE1TN6yt0nB5 Y3gGfdP/h4wdHUX73SU/z6uLteTjXXs1VPJaoMXqCbtxxmFGSR eWUd7gatb3zIe8OsuMEKPa6N0N7D/SzJS4Ug+avNGBdeC71jP6 G7SkyeeJydzJdCJT60V1IsxMmOv2P/4HMNV7Q9oNXVgPvcq3TV i8E6VBO6vhTFInkurRGQwu8LO2u6rTq2W3bz+AAc/tmT1VX4w= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 129 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1320689719 news.xs4all.nl 6902 [2001:888:2000:d::a6]:60605 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15426 On 11/07/2011 11:40 AM, gene heskett wrote: > On Monday, November 07, 2011 11:30:45 AM Dave Angel did opine: > Back on the list.. >> On 11/07/2011 06:22 AM, gene heskett wrote: >>> On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: >>> >>> >>>> Are you talking about this one? >>>> >>>> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatte >>>> rns .py >>> >>> Yes. My save as renamed it, still has about 30k of tabs in it. But I >>> pulled it again, using the 'raw' link, saved it, no extra tabs. >>> >>> But it still doesn't work for linux. My python is 2.6.6 >> >> To start with, what's the md5 of the file you downloaded and are >> testing? I get c4592a187f8f7880d3b685537e3bf9a5 > > [root@coyote Download]# md5sum DuquDriverPatterns.py > c4592a187f8f7880d3b685537e3bf9a5 DuquDriverPatterns.py, same as yours. > >> from md5sum. If you get something different, one of us changed the >> file, or you got it before today. >> >> The whole tab issue is a red-herring in this case. But I don't see how >> you can find 30k tabs in a thousand lines. And if I were going to detab >> it, I'd pick 4 spaces, so the code doesn't stretch across the page. > > Down toward the bottom of the file, the tab indentations were as high as 33 > leading tabs per line. Each stanza of the data was tab indented 2 > additional tabs from the one above it in the original file. 30k was > perhaps a poor SWAG, but 10 to 15k seems an entirely reasonable guess. > What program are you using to read the file and support that claim? Neither emacs nor gedit shows more than one leading tab on any line I looked. And if you set tabs to 4 columns, the file looks quite reasonable. Doing a quick scan I see max of 5 tabs on any single line, and 1006 total. maxtabs = 0 totaltabs = 0 f = open("DuquDriverPatterns.py", "r") for line in f: cline = line.replace("\t", "") tabs = len(line) - len(cline) if tabs: print tabs maxtabs = max(maxtabs, tabs) totaltabs += tabs print "max=", maxtabs print "total=", totaltabs >>> >>> >>>> python DuquDriverPatterns.py ./directoryOfMalware >>>> >>>> and the line you are quoting then puts the value >>>> "./directoryOfMalware" into the rootdir variable. >>> >>> If only it would... Using this version, the failure is silent and >>> instant. The only way I've been able to make it "silent and instant" was to give it the name of an empty directory, or a typo representing no directory at all. >>> Besides, the malware could be anyplace on the system. But >>> it needs to skip /dev since it hangs on the midi tree, /mnt and >>> /media because they are not part of the running system even if disks >>> are mounted there. >> >> First, run it on the current directory, and it should list the files in >> that directory: >> >> I ran it in the directory I unzipped it into, so there are two files, >> the README and the source file itself. >> >> $ python DuquDriverPatterns.py . >> Scanning ./README: >> No match for pattern #0 on file named: README >> No match for pattern #1 on file named: README >> No match for pattern #2 on file named: README >> >> etc. >> >> The only way I can see to get NO output is to run it on an empty >> directory: $mkdir junk >> $ python DuquDriverPatterns.py junk >> >> As for skipping certain directories, we can deal with that as soon as >> you get proper behavior for any subtree of directories. >> >> Have you tried adding a print ("Hello World " + rootdir) just before the >> >> for root, subFolders, files in os.walk(rootdir): >> >> line ? Or putting a print len(files) just after it (indented, of >> course) ? > > No, I did try to print the value of rootdir though, indented the same, and > got a null printout, not even a line feed. > If you had put the print I suggested, it would at least print the words "Hello World". Since it did not, you probably didn't actually add the line where I suggested. > Thanks Dave. > > Cheers, Gene In another message you said it doesn't work on absolute file paths. But it does. You can replace any relative directory name with the absolute version, and it won't change the behavior. I suspect you were caught up by a typo for the absolute path string. -- DaveA