gooscan README file 10/15/03 by j0hnny http://johnny.ihackstuff.com The opinions expressed in this document and associated source code and data files are those of j0hnny long and do not represent the opinions of his employer, customers, any governement, state-sponsored agencies, or the blue "Twi'lek Masseuse" that keeps hitting me up for my autograph.... The gooscan data files, contents of the data files, output of this program, concepts or source code may not be used without express permission in advance from the author. The author does not advocate using this tool against any entity without first obtaining express permission in advance from the owner or maintainer of said entity. ] What is gooscan? [ Gooscan is a tool that automates queries against Google search appliances, but with a twist. These particular queries are designed to find potential vulnerabilities on web pages. Think "cgi scanner" that never communicates directly with the target web server, since all queries are answered by a Google appliance, not by the target itself. ] Who is it written for? [ Security professionals: This tool serves as a front-end for an external web server assessment and aids in the "information gathering" phase of a vulnerability assessment. Web server administrators: This tool helps to discover what the web community may already know about you thanks to Google. ] Is this tool legal? [ From http://www.google.com/terms_of_service.html: "You may not send automated queries of any sort to Google's system without express permission in advance from Google." This means that you should not use this tool to query Google without advance express permission. Google appliances, however, do not have these limitations. You should, however, obtain advance express permission from the owner or maintainer of the Google appliance before searching it with any automated tool for various legal and moral reasons. The author wrote this tool not to violate Google's terms of service (ToS), but to raise the awareness of the web security community that a ToS may not discourage the bad guys from writing and running a tool like this for malicious purposes. To that end, only use this tool to query _appliances_ unless you are prepared to face the (as yet unquantified) wrath of Google. ] Why the proxy feature? [ Many companies can only reach the Internet by way of an internal proxy server. When conducting an authorized assessment, it may be necessary to bounce queries of of a web proxy instead of off the Google appliance directly. ] How does this thing work? [ Let's go through the various options to gooscan. <-t target> Required argument: Google appliance to scan. An IP address or host name can be used here. Caution: entering 'www.google.com' here violates Google's terms of service and is neither recommended nor condoned by the author. <-q query | -i query_file> Required argument: the query or query file to send. Gooscan can be used to send an individual query or a series of queries read from a file. The '-q' option takes one argument, which may be any valid Google query. For example, these are valid options: -q googledorks -q "microsoft sucks" -q "intitle:index.of secret" The '-i' option takes one argument, the name of a gooscan data file. See below for information about the included gooscan data files. [-o output_file] Optional argument. Gooscan can create an html output file. No. Gooscan can create a neato html output file. The file includes links to the actual Google search results pages, hence making it neato. [-p proxy:port] Optional argument. This is the address and port of an HTML proxy server. Queries will be sent here and bounced off to the appliance indicated with the '-t' argument. The format can be like '10.1.1.150:80' or 'proxy.validcompany.com:8080'. [-v] Optional argument. Verbose mode. Every program needs a verbose mode, especially when the author sucks with a command-line debugger. [-d] Optional argument. Hex-encode every character in the GET request to the appliance. Some appliances like this, and other appliances choke on this. If you get zero results from a known good search term, you either screwed up this option or the '-x' option. Either that, or my code sucks, which is entirely possible, considering my feeble foo with a command-line debugger. [-s site] Optional argument. This filters only results from a certain site. This is identical to the 'site:' modifier used by the Google search engine. This argument has absolutely no meaning when used against Google appliances. For example, consider the following Google queries: site:microsoft.com linux site:apple.com microsoft site:linux.org microsoft **With advanced express permission from Google**, one could run the following with gooscan to achieve the same results: $ ./gooscan -t www.google.com -s microsoft.com linux $ ./gooscan -t www.google.com -s apple.com microsoft $ ./gooscan -t www.google.com -s linux.org microsoft [-x xtra_appliance_fields] Oh boy. The meat and taters (or if you're on Atkins the meat and meat) of gooscan when scanning appliances. I'm no whiz on the appliance thingies, but theres all this junk that a simple query likes. Consider running a search for "Steve Hansen" at the Google appliance found at Stanford. After entering this search into the Stanford search page, the user is whisked away to a page with this URL (chopped for readability): http://find.stanford.edu/search?q=steve+hansen &site=stanford&client=stanford&proxystylesheet=stanford &output=xml_no_dtd&as_dt=i&as_sitesearch= Breaking this up into chunks that gooscan can understand, we have three distinct pieces. First, the target appliance ('-t') is find.stanford.edu. Next, the query ('-q') is "steve hansen" or "steve+hansen" and last but not least is all the extra junk ('-x'): &site=stanford&client=stanford&proxystylesheet=stanford &output=xml_no_dtd&as_dt=i&as_sitesearch= To run this query with gooscan: $ ./gooscan -t find.stanford.edu -q "steve hansen" \ > -x "&site=stanford&client=stanford&proxystylesheet=stanford\ > &output=xml_no_dtd&as_dt=i&as_sitesearch=" doing lookup of find.stanford.edu... "steve hansen" returned 288 results. Now this can be a real pain in the rearend copying all that gook from the web page and making sure there are no extra spaces in the 'xtra' fields and such, all for one stupid query. However, you really only need to do one manual query to get the 'xtra' junk. Once you get one query working, you can fire up gooscan with the '-i' (input file) option instead of the '-q' (query) option to shoot lots and lots of queries against the appliance (assuming of course that you have advance express permission from the owner/maintainer of said appliance). ] How do the included data files work? [ Yummy. The good stuff. All protein, no carbs. =P Gooscan reads data files to determine what kind of searches to run. The format of the data files is as follows: search_type | search_string | count | description search_type can be one of the following: intitle: find search_string in the title of the page. If requested on the command line, gooscan will append the site query. Example: intitle|error|| This will find the word "error" in the title of a page. inurl: find search_string in the url of the page. If requested on the command line, gooscan will append the site query. Example: inurl|admin|| This will find the word "admin" in the URL of a page. indexof: Find search_string in a directory listing. If requested on the command line, gooscan will append the site query. Directory listings often will have the term "index of" in the title of the page. Gooscan will generate a Google query that looks something like this: intitle:index.of search_string Note: When using the site switch, gooscan automatically performs a generic search for directory listings. That query looks like this: "intitle:index.of site:site_name" If this generic query returns no results, gooscan will skip any subsequent indexof searches. It is a logical conclusion to skip specific indexof searches if the most generic of indexof searches returns nothing. Example: indexof|htaccess|| This search will find .htaccess files sitting in a directory listing on the server. filetype: find search_string as a filename, inserting the site query if requested on the command line. This search_type is a bit unwieldy at first, but works well. First, under- stand what a "file" is in Google-speak. Google sees a word as a filetype if it is the last word in a URL. Remember that a URL is a protocol followed by "://" followed by a host and a full path followed by option characters. Focusing on the full path, the file is the last word found when using "/" as a delimiter. An example may be "http://site.com/cgi-bin/go.cgi?user=j." The "file" in this example according to Google is "go.cgi." If there are no periods in the filename, Google sees the filetype as the whole filename. If there are periods in the filename, Google sees the filetype as the last word found when using "." as the delimiter. In the above example, filetype would be "cgi." If instead the cgi script where "gocgi" the filetype would be "gocgi." When using filetype with goocsan, simply put the filetype in as the search term twice. Example: To search for CGI example above, the gooscan file entry would be: "filetype|cgi cgi||" The filetype is entered twice because a Google query of "filetype:cgi cgi" will not only find the file, but will also supply Google with the required search option. The term "cgi" will always appear in the URL if the filetype is found on the server. raw: This search_type allows the user to build custom queries. The query is passed to Google unmodified, adding a site query if requested in the command line. Example: raw|filetype:xls email username password|| This example will find excel spreadsheets with email username and password inside the document. search string: The search_string is fairly straight-forward. Any string is allowed here except chars '\n' and '|'. This string is "HTML-ized" before sending to Google. The 'A' character is converted to %65, etc. There are some exceptions here, like the fact that spaces are converted to the '+' character. count: This field records the approximate number of hits found when a similar query is run against all of Google. Site is not applied. This value is somewhat arbitrary in that it is based on the rounded numbers supplied by Google and that this number can vary widely based on when and how the search is performed. Still, this number can provide a valuable watermark for sorting data files and creating custom data files. For example, zero- count records could safely be eliminated before running a large search. This count is also interesting with regard to insanely large result numbers. The 'inurl|html' search, for example, yields approximately 650,000,000 results. Most web pages have at least one html file. The results of this search might only be useful as a predecessor to more specific html queries. (This field is currently not used by gooscan.) description: This field describes the search type. Currently, only the filetype data file populates this field. The filetype data file includes every known file extension from fileext.org condensed and run through gooscan. I STRONGLY RECOMMEND NEVER RUNNING A FULL FILETYPE SEARCH! At over 8,000 queries, this search would certainly take quite a while and burn precious resources on the appliance. Instead, a user may consider running pieces of this file through gooscan to search for the existance of certain types of files on the target appliance. (This field is currently not used by gooscan.) ] What are the included data files (*.gs)? [ Several data files are included for various purposes. gdork.gs: This file includes excerpts from the "googledorks" page on http://johnny.ihackstuff.com. In a nutshell, the googledorks examples are glaringly bad examples of sensitive data retrieved by Google. filetype.gs: This HUMONGOUS file contains every known filetype in existance. By selecting interesting lines from this files, a gooscan user can quickly determine what types of files exist on a server that may warrant further investigation. I would suggest creating a subset of this file (you know, like run `head -50 filetype.gs > short_filetype.gs') for use in the field. Do not run this file as is. It's too big. Instead, rely on the numbers in the count field to tell you how many (approximate) sites contain these files in Google. Obviously, the more commonly found extensions are at the top. inurl.gs: Another big file! This searches for the most commonly found strings from various CGI scanners in the URL of a document. Again, this file is sorted by the approximate number of hits in Google, so the most common are at the top. The bottom of this file is interesting, however, as it contains mostly vulnerable CGI scripts. Again, searching only in the URL of the page. indexof.gs: Another big file! This searches for the most commonly found strings from various CGI scanners in directory listings. Again, this file is sorted by the approximate number of hits in Google, so the most common are at the top. The bottom of this file is interesting, however, as it contains mostly vulnerable CGI scripts. Again, searching for the term in a directory listing. ] What output does gooscan provide? [ First, gooscan may provide rounded results of the queries. The results are generally rounded since Google search engine and Google appliances may provide results numbers in this way. Using the '-o' option, HTML output will be produced which provides not only the results (remember, these may be rounded) and the query performed, but also a neato link to the Google results page for that query. ] Known Bugs [ Gooscan assumes that the appliance is sitting at /search on the site, since this is a default configuration, and the way Google does things. If your target site of appliance does not have the /search, gooscan won't work. I'll add that to my todo list. Right now, the code bombs if an empty line is in the gooscan data file. For example, a line like "raw| ||" segfaults the program. I found this the day of the release and never fixed it. If there's an error from the web server instead of a normal page return, gooscan still writes a (bogus) output line to the output file. Again, found this the day of release, never fixed it. ] Final words [ "Don't be a dork. Keep it off the web." I'm a big fan of Google, and I've already told them they're sitting on a goldmine of a security service but they weren't interested. (Hi Steve!) Bah. I'm not bitter, but what a waste! Hey Steve- if you change you mind and decide this is worth cashing in on, drop me a line. I'll play. Otherwise, have a happy IPO and don't choke on all that juicy stock. =PpPPPpPP ] shoutz [ First, thanks be to God for the many blessings in my life, and for providing me with a path to eternal life through the sacrifice of Jesus Christ. Thanks to my family for putting up with my many oddities. (No normal person can code this badly!) Thanks to the googledork community for their support of the database and the forums, especially to Murf and crash_monkey, my moderators, for their support the database and the forums. Thanks to JeiAr at GulfTech Security , Cesar of Appdetective fame, and Mike "supervillain" Carter for the outstanding contrinutions to the googledorks database. Thanks to Mike Walker for fielding many C questions, Dave Murray for the research on the appliance, and Pat Jones for the code cleanup. Thanks to Chris O'Ferrell and Yuki over at the Washington Post for all the media coverage. Shouts to the STRIKEFORCE (what's left of it), Seth Fogie, Anton Rager, Dan Kaminsky, rfp, Mike Schiffman, Dominique Brezinski, Tan, Todd, Christopher (and the whole packetstorm crew), Bruce Potter and Dragorn. When in Vegas, be sure to visit any of the world-class properties of the MGM/Mirage or visit them online at http://mgmmirage.com. =)