Gitrob is a command line tool which can help organizations and security professionals find sensitive information lingering in publicly available files on GitHub. The tool will iterate over all public organization and member repositories and match filenames against a range of patterns for files that typically contain sensitive or dangerous information.
Looking for sensitive information in GitHub repositories is not a new thing, it has been known for a while that things such as private keys and credentials can be found with GitHub's search functionality, however, Gitrob makes it easier to focus the effort on a specific organization.
Gitrob is written in Ruby and requires at least version 1.9.3 or above. To check which version of Ruby you have installed, simply run
ruby --versionin a terminal.
Should you have an older version installed, it is very easy to upgrade and manage different versions with the Ruby Version Manager (RVM). Please see the RVM website for installation instructions.
Gitrob is packaged as a Ruby gem to make it easy to install and update. To install Ruby gems you'll need the RubyGems tool installed. To check if you have it already, type
gemin a Terminal. If you got it already, it is recommended to do a quick
gem update --systemto make sure you have the latest and greatest version. In case you don't have it installed, download it from here and follow the simple installation instructions.
Gitrob uses a PostgreSQL database to store all the collected data. If you are setting up Gitrob in the Kali linux distribution you already have it installed, you just need to make sure it's running by executing
service postgresql startand install a dependency with
apt-get install libpq-devin a terminal. Here's an excellent guide on how to install PostgreSQL on a Debian based Linux system. If you are setting up Gitrob on a Mac, the easiest way to install PostgreSQL is with Homebrew. Here's a guide on how to install PostgreSQL with Homebrew.
3.1 PostgreSQL user and database
You need to set up a user and a database in PostgreSQL for Gitrob. Execute the following commands in a terminal:
You now have a new PostgreSQL user with the name
sudo su postgres # Not necessary on Mac OS X
createuser -s gitrob --pwprompt
createdb -O gitrob gitrob
gitroband with the password you typed into the prompt. You also created a database with the name
gitrobwhich is owned by the
4. GitHub access tokens
Gitrob works by querying the GitHub API for interesting information, so you need at least one access token to get up and running. The easiest way is to create a Personal Access Token. Press the
Generate new tokenbutton and give the token a description. If you intend on using Gitrob against organizations you're not a member of you don't need to give the token any scopes, as we will only be accessing public data. If you intend to run Gitrob against your own organization, you'll need to check the
read:orgscope to get full coverage.
If you plan on using Gitrob extensively or against a very large organization, it might be necessary to have multiple access tokens to avoid running into rate limiting. These access tokens will have to be from different user accounts.
With all the previous steps completed, you can now finally install Gitrob itself with the following command in a terminal:
This will install the Gitrob Ruby gem along with all its dependencies. Congratulations!
gem install gitrob
6. Configuring Gitrob
Gitrob needs to know how to talk to the PostgreSQL database as well as what access token to use to access the GitHub API. Gitrob comes with a convenient configuration wizard which can be invoked with the following command in a terminal:
The configuration wizard will ask you for the information needed to set up Gitrob. All the information is saved to
~/.gitrobrcand yes, Gitrob will be looking for this file too, so watch out!
Analyzing organizations and users
Analyzing organizations and users is the main feature of Gitrob. The
analyzecommand accepts an arbitrary amount of organization and user logins, which will be bundled into an assessment:
Mixing organizations and users is convenient if you know that a certain user is part of an organization but they do not have their membership public.
gitrob analyze acme,johndoe,janedoe
When the assessment is finished, the
analyzecommand will automatically start up the web server to present the results. This can be avoided by adding the
--no-serveroption to the command.
gitrob help analyzefor more options.
Running Gitrob against custom GitHub Enterprise installations
Gitrob can analyze organizations and users on custom GitHub Enterprise installations instead of the official GitHub site. The
analyzecommand takes several options to control this:
gitrob analyze johndoe --site=https://github.acme.com --endpoint=https://github.acme.com/api/v3 --access-tokens=token1,token2
gitrob help analyzefor more options.
Starting the Gitrob web server
The Gitrob web server can be started with the
By default, the server will listen on localhost:9393. This can, of course, all be controlled:
gitrob server --bind-address=0.0.0.0 --port=8000
gitrob help servermore options.
Adding custom signatures
If you want to look for files that are specific to your organisation or projects, it is easy to add custom signatures.
When Gitrob starts it looks for a file at
~/.gitrobsignatureswhich it expects to be a JSON document with signatures that follow the same structure as the main signatures.json file. Here is an example:
This signature instructs Gitrob to flag files where the filename exactly matches
"caption": "Pidgin OTR private key",
otr.private_key. The caption and description are used in the web interface when displaying the findings.
part: Can be one of:
path: The complete file path
filename: Only the filename
extension: Only the file extension
type: Can be one of:
match: Simple match of part and pattern
regex: Regular expression matching of part and pattern
pattern: The value or regular expression to match with
caption: A short description of the finding
description: More detailed description if needed (set to