October 10th, 2006 at 9:02 am by Nio
使用 Google Code Search 发现代码漏洞
来自 Chris Shiflett:
今天早些时候,Stephen de Vries 发了封邮件到 SecurityFocus 的 web application security mailing list,邮件里提到了 Google Code Search:
Google's code search provides an easy way to find obvious software flaws in open source and example applications.
为了证实他的观点,提供了几个查询实例:
相应地,Chris Shiflett 也列出了几个 PHP & MySQL 相关的查询实例:
- XSS due to echoing raw input: lang:php echo.*\$_(GET|POST)
- XSS due to echoing $_SERVER['PHP_SELF']: lang:php echo.*\$_SERVER\['PHP_SELF']
- SQL injection due to using raw input directly in mysql_query(): lang:php mysql_query\(.*\$_(GET|POST).*\)
- SQL injection due to using raw input directly in a WHERE clause: lang:php "WHERE username='$_"
- Vulnerabilities due to a misplaced trust in $_SERVER['HTTP_REFERER']: lang:php \$_SERVER\['HTTP_REFERER']
Google Code Search 给了 Chris Shiflett 一个启发,那就是创建一个静态的搜索,对源代码进行索引,然后通过查询来检查代码中的漏洞。这个想法很有意思,我想还需要一个查询知识库,把一些常见的漏洞查询语句存入库中,然后创建一个自动检查机制,这样漏洞扫描检测可以更加方便快捷。(Update: 后来发现实际上已经有个叫 Bugle 的利用 Google Code Search 在做这个事情了。)
前一段看到有人搞了一个这种scanner,叫Chorizo!(https://chorizo-scanner.com), 具体没怎么试过,看它网站上的视频还有点意思。
哈哈,这个 Chorizo! 不错,研究研究!