Changeset 1680
- Timestamp:
- 08/13/08 15:44:06 (3 months ago)
- Files:
-
- phoneyc/trunk/honeywalk.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
phoneyc/trunk/honeywalk.py
r1485 r1680 17 17 -d output a Graphviz directed graph 18 18 of URLs walked 19 -D dump alist of URLs on the page 20 -1 only analyze the one URL 19 21 """ % progname 20 22 print usagestr … … 28 30 m = md5.md5(body).hexdigest() 29 31 if len(body) == 0: return '-' 30 try:31 os.stat('/tmp/clamd')32 except OSError: return m, '!!!'33 32 f = open('/tmp/hc-walk-scan-%s' % m, 'wb') 34 33 f.write(body) 35 34 f.close() 35 try: os.stat('/tmp/clamd') 36 except OSError: return m, '!!!' 36 37 o, i, e = popen2.popen3('/usr/local/bin/clamdscan /tmp/hc-walk-scan-%s' % m) 37 38 try: r = o.read().split('\n')[0].split(':')[1].strip() … … 42 43 return m, r 43 44 44 def walk(hc, URL, referrer, visited, depth ):45 def walk(hc, URL, referrer, visited, depth, options): 45 46 if referrer and not depth.has_key(URL): 46 47 depth[URL] = depth[referrer] + 1 … … 73 74 print js, 74 75 print scan(js[0]) 76 if options['do_list']: 77 print URL 78 for l in hc.pages[URL].links: 79 print ' --> %s' % l 75 80 #print hc.vbs_eval(url=URL, html=page.contents) 76 81 #vbs = hc.vbs_eval(URL) 82 if options['do_one']: return 77 83 for url in hc.pages[URL].links: 78 84 if url not in visited and url.startswith('http'): 79 85 host = url.split('/')[2] 80 86 if not hc.ignored(host): 81 walk(hc, url, URL, visited, depth )87 walk(hc, url, URL, visited, depth, options) 82 88 83 89 def main(argv): 84 try: opts, args = getopt.getopt(argv[1:], 'd h')90 try: opts, args = getopt.getopt(argv[1:], 'dD1h') 85 91 except: usage(sys.argv[0]) 86 92 87 do_dot = False 93 options = {} 94 options['do_dot'] = False 95 options['do_one'] = False 96 options['do_list'] = False 88 97 for o, a in opts: 89 if o == '-d': do_dot = True 98 if o == '-d': options['do_dot'] = True 99 elif o == '-D': options['do_list'] = True 100 elif o == '-1': options['do_one'] = True 90 101 else: usage(sys.argv[0]) 91 102 url = args[0] … … 93 104 start = time.time() 94 105 print 'HoneyWalk started at %s UTC' % time.asctime(time.gmtime()) 95 try: walk(hc, url, False, [], {url: 0} )106 try: walk(hc, url, False, [], {url: 0}, options) 96 107 except KeyboardInterrupt: print '' 97 108 end = time.time() 98 109 99 if do_dot:110 if options['do_dot']: 100 111 print 'walked %d URLs in %f seconds' % (hc.cnt, end-start) 101 112 print '\n\ndigraph "%s" {' % url
