Skip to content

Commit 5e1088f

Browse files
committed
New documentation relying on mkdocs-material and a github action for deploying doc changes
1 parent b58a829 commit 5e1088f

12 files changed

+335
-0
lines changed

.github/workflows/ci.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: ci
2+
on:
3+
push:
4+
branches:
5+
- main
6+
permissions:
7+
contents: write
8+
jobs:
9+
docs:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-python@v4
14+
with:
15+
python-version: 3.x
16+
- uses: actions/cache@v2
17+
with:
18+
key: ${{ github.ref }}
19+
path: .cache
20+
- run: pip install mkdocs-material
21+
- run: mkdocs gh-deploy --force

docs/code_structure.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Code structure
2+
3+
A few pointers on how the Gitxray codebase is structured:
4+
5+
* `gitxray.py` - The main script, creates a gx_context, gx_output and calls X-Ray modules.
6+
7+
The include directory has files split in two naming conventions:
8+
9+
* Suffix: `gh_` - Files that handle GitHub API responses or talk to the GitHub API
10+
* Suffix: `gx_` - Files with more Gitxray-specific logic
11+
12+
Some of the supporting files in the include directory:
13+
14+
* `gx_context.py` - Holds a context of data that is shared across different X-Ray modules and through out execution.
15+
* `gx_output.py` - Takes care of any console printing, as well as text and json output.
16+
17+
For parsing SSH and PGP signatures, we wrote our own code and placed it in:
18+
19+
* `gx_ugly_openpgp_parser.py` - Parses Armors and BLOBs based on RFC4880
20+
* `gx_ugly_ssh_parser.py` - Parses (if you can call that Parsing) SSH Armors and BLOBs
21+
22+
Finally, last but not least important, the X-Rays under the xrays directory:
23+
24+
* `contributors_xray.py` - Handles all Contributor-related data and decides what to log.
25+
* `repository_xray.py` - Handles all Repository-related data and decides what to log.
26+
* `associations_xray.py` - Analyzes and reports all associations carried from prior X-Ray modules.
27+

docs/forensics_spotting.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Forensics and Spotting Associations
2+
3+
Open source projects are under attack, with malicious actors hiding in plain sight. Attackers are normally well-funded and take precautions to avoid detection. Enter some of `gitxray`'s features: If you've woken up today wearing your Batman t-shirt and/or you're carefully looking at evidence while protecting a repository, try leveraging some of `gitxray`'s features.
4+
5+
## Important - Please read
6+
7+
Associations MUST NOT be directly and blindly used to report fake or shadow accounts. They are automatic observations from a piece of well-intended code. Do NOT treat association results as findings directly.
8+
9+
Remember, there is more good than evil out there. We must protect open-source projects by first and foremost respecting open-source developers. Ensure that any actions taken are thoughtful and based on solid evidence, not just automated associations. Collaboration and trust are the foundations of the open-source community, and preserving these values is crucial for its continued success.
10+
## Run a full verbose X-Ray on a repository
11+
``` bash
12+
gitxray -r https://github.com/SampleOrg/Repo1 -v
13+
```
14+
15+
## Focus on associations
16+
Associations are currently supported at a _Repository level only_.
17+
18+
Spotted associations can include:
19+
20+
* Sharing of PGP Keys or Emails
21+
* Accounts that were created and/or updated precisely in the same day
22+
* Accounts which relied on GitHub's Web Editor to sign commits
23+
* Accounts which used the same Algorithms for SSH/PGP signatures
24+
* Armored Keys which displayed the same Comment or Version fields
25+
26+
``` bash
27+
gitxray -r https://github.com/SampleOrg/repo1 -f association
28+
```
29+
30+
## Spot users who are in the Top 3 of Rejected PRs
31+
``` bash
32+
gitxray -r https://github.com/SampleOrg/repo1 -f contributors
33+
```
34+
35+
## Releases and Assets
36+
When reviewing repository Releases and Assets, Gitxray will:
37+
38+
* Print out which users have historically created releases and/or uploaded assets, as well as the % vs. the total amount of releases or assets; so you can flag potential suspicious activity.
39+
40+
* Report on any Assets that were uploaded at least a day AFTER their initial release, which might lead to suggest they've been infected and/or tampered with.
41+
42+
``` bash
43+
gitxray -r https://github.com/SampleOrg/repo1 -f user_input,pass,private
44+
```
45+
46+
## Observing user Recent behaviour
47+
When Verbose mode is enabled, recent events from the past 90 days for each user account will be processed and printed by Gitxray, among which you may spot:
48+
* Accounts which are automatically following other users. You'll likely notice a large amount of consecutive follow events.
49+
* Accounts which are automatically starring repositories. You'll likely notice a large amount of consecutive watching activity.
50+
* Accounts which are forking a large amount of repositories; potentially for the sake of tricking victims into using their tampered fork.
51+
52+
More use-cases for gitxray can be found in the [OSINT and Pentesting](osint_pentest.md) and [Securing your Team and Repositories](securing_repos.md) sections.

docs/ideas_pending.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Ideas pending to be implemented
2+
3+
* Use repository stats, eg the punch_card endpoint to identify commits made at a time of day which break patterns
4+
* SSH Public Keys: Improve BLOB parsing and collect Key strength bits which could be used to link to other User keys.
5+
* Try to identify starring attacks (fake stars in repositories or accounts following eachother) by using a non-expensive path (eg few requests)
6+
* Inspect Issues to identify potential malicious behavior by using a non-expensive path (e.g. a call to events per issue would lead to a lot of data, but it requires 1 request per [open] issue)
7+
* Analyze "reactions" and see if we can identify mood in some way.

docs/images/console_gitxray.png

72.9 KB
Loading

docs/images/logo_gitxray.png

75.4 KB
Loading

docs/index.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Welcome to Gitxray
2+
3+
Gitxray (short for Git X-Ray) is a multifaceted security tool designed for use on GitHub repositories. It serves various use cases, including OSINT, forensics, and security teams, as well as developers looking to secure their repositories, organizations, and related contributors. Gitxray leverages public GitHub REST APIs to gather information that would otherwise be very time-consuming to obtain manually. Additionally, it seeks out information in unconventional places.
4+
5+
## Use-cases when using Gitxray
6+
7+
* [OSINT and Pentesting](osint_pentest.md)
8+
* [Forensics and Spotting Associations](forensics_spotting.md)
9+
* [Securing your Team and Repositories](securing_repos.md)
10+
11+
## Rate Limits and the GitHub API
12+
13+
Gitxray can work out of the box without a GitHub API key, _but_ you'll likely hit RateLimits pretty fast. This is detailed by GitHub in their [documentation here](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#primary-rate-limit-for-unauthenticated-users). A simple read-only token created for PUBLIC repositories will however help you increase those restrictions considerably. If you're not in a hurry or can leave Gitxray running you'll be able to use Gitxray in its full capacity, as it pauses execution while waiting for the limits to lift.
14+
15+
## Reasons to ♥ Gitxray
16+
17+
A few reasons why we think Gitxray is special include:
18+
19+
* It parses Signature BLOBs in order to capture Personal Information, Algorithm configurations, Creation Time subpackets, and more.
20+
* It displays user-supplied data obtained from weird places, such as Key names and copy-paste mistakes appended before/after armored Keys.
21+
* It cross-references data from different users, displaying what we call "*associations*", likely revealing _potential_ shared or fake accounts.
22+
* It inspects Repository releases and identifies when assets were updated *after* being released; _potentially_ implying infected or tampered assets.
23+
* And a lot more for you to discover.
24+
25+
26+
## Ready to get started?
27+
28+
Jump to [Installing and running Gitxray](installing.md) in order to get started.

docs/installing.md

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Installing and running Gitxray
2+
3+
gitxray was written with no use of external package dependencies other than the `requests` library.
4+
5+
## PyPI (PIP) Way
6+
7+
`gitxray` is on PyPI and can be installed with:
8+
9+
```bash
10+
pip install gitxray
11+
```
12+
13+
Once installed, simply run gitxray from your command line by typing:
14+
```bash
15+
gitxray -h
16+
```
17+
18+
## Installing from source
19+
20+
You may also run `gitxray` directly by cloning or downloading its GitHub [repository](https://github.com/kulkansecurity/gitxray/) and running:
21+
22+
```bash
23+
python3 -m pip install -r requirements.txt
24+
cd src/
25+
python3 -m gitxray.gitxray
26+
```
27+
28+
## Command Line Arguments
29+
30+
### Required Arguments
31+
32+
One of the following must be specified:
33+
34+
* `-r, --repository [URL]` - Specify a single repository URL to check. The URL must begin with `https://`. **Example**: `--repository https://github.com/example/repo`
35+
36+
* `-rf, --repositories-file [FILEPATH]` - Provide a file path containing a list of repositories, each on a new line. The file must exist. **Example**: `--repositories-file ./list_of_repos.txt`
37+
38+
* `-o, --organization [URL]` - Specify an organization URL to check all repositories under that organization. The URL must begin with `https://`. **Example**: `--organization https://github.com/exampleOrg`
39+
40+
### Optional Arguments
41+
42+
You'll find these optional but very handy in common gitxray usage.
43+
44+
- `-l, --list` - List contributors if a repository is specified or list repositories if an organization is specified. Useful for further focusing on specific entities. **Example**: `--list`
45+
46+
- `-c, --contributor [USERNAMES]` - A comma-separated list of GitHub usernames to focus on within the specified repository or organization. **Example**: `--contributor user1,user2`
47+
48+
- `-f, --filters [KEYWORDS]` - Comma-separated keywords to filter the results by, such as 'user_input', 'association', or 'mac'. **Example**: `--filters user_input,association,mac`
49+
50+
#### Verbose and Debug
51+
- `-v, --verbose` - Enable verbose output which, for example, provides a detailed list of public events instead of a summary. **Example**: `--verbose`
52+
53+
- `--debug` - Enable Debug mode for a detailed and extensive output. **Example**: `--debug`
54+
55+
#### Output and Formats
56+
57+
- `-out, --outfile [FILEPATH]` - Specify the file path for the output log. Cannot be a directory. **Example**: `--outfile ./output.log`
58+
59+
- `-outformat, --output-format [FORMAT]` - Set the format for the log file. Supported formats are `text` and `json`. Default is `text`. **Example**: `--output-format json`
60+
61+
### Usage Examples
62+
Refer to [Use cases](index.md#use-cases-when-using-gitxray) for combinations of commands aligned with specific use-cases.
63+
64+
``` bash
65+
# Analyze a single repository with verbose output
66+
gitxray --repository https://github.com/example/repo --verbose
67+
68+
# List all repository names under a given Organization
69+
gitxray --organization https://github.com/exampleOrg --list
70+
71+
# Analyze all repositories under an Organization with filters capturing user_input and associations
72+
gitxray -org https://github.com/exampleOrg -f user_input,association
73+
```
74+

docs/osint_pentest.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# OSINT and Pentesting
2+
3+
A common use-case for using `gitxray` is to gather as much information as possible for a target Organization, Repository and/or Contributors. Here are a few suggestions on commands you may want to run. You'll soon discover your own favorite combo.
4+
5+
## Listing repositories for a given Organization
6+
``` bash
7+
gitxray -o https://github.com/SampleOrg -l
8+
```
9+
10+
## Listing contributors for a given Repository
11+
``` bash
12+
gitxray -r https://github.com/SampleOrg/repo1 -l
13+
```
14+
15+
## Examining all contributors in a repository with Verbose enabled
16+
``` bash
17+
gitxray -r https://github.com/SampleOrg/repo1 -v
18+
```
19+
20+
## Filtering for potential disclosures in user_input
21+
``` bash
22+
gitxray -r https://github.com/SampleOrg/repo1 -f user_input,pass
23+
```
24+
25+
## Filtering for collected e-mail addresses
26+
``` bash
27+
gitxray -r https://github.com/SampleOrg/repo1 -f emails
28+
```
29+
30+
## Focusing on personal fields
31+
``` bash
32+
gitxray -r https://github.com/SampleOrg/repo1 -f personal
33+
```
34+
35+
## Searching for key-related information across an entire Organization
36+
``` bash
37+
gitxray -o https://github.com/SampleOrg -f keys
38+
```
39+
40+
## Filtering in Verbose mode for users who recently moved repositories from Private to Public
41+
``` bash
42+
gitxray -o https://github.com/SampleOrg -v -f private
43+
```
44+
45+
More use-cases for gitxray can be found in the [Forensics and Spotting Associations](forensics_spotting.md) and [Securing your Team and Repositories](securing_repos.md) sections.
46+

docs/securing_repos.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Securing your Team and Repositories
2+
3+
If you have one or more repositories to safeguard, then you may be able to leverage `gitxray` to improve the security stance of your repository and/or your development team.
4+
5+
## Checking contributors for information disclosure
6+
7+
You may be concerned about what your team members are currently sharing in their profile to the world.
8+
9+
Filtering results across all Organization repositories focused on personal information and emails
10+
``` bash
11+
gitxray -o https://github.com/SampleOrg -f personal,emails
12+
```
13+
14+
We've discovered A LOT of internal information being disclosed by accident through Key names. Try filtering for user_input to find those cases
15+
``` bash
16+
gitxray -o https://github.com/SampleOrg -f user_input
17+
```
18+
19+
## Checking for contributors who have not signed their commits
20+
Those who have not signed ANY of their commits may need your help in understanding how signing is done and the dangers of impersonation.
21+
22+
``` bash
23+
gitxray -r https://github.com/SampleOrg/repo1 -f "not signed any"
24+
```
25+
26+
## Checking for contributors who have a mix of signed and unsigned commits
27+
These contributors likely need to be reminded of the importance of signing, AND their unsigned commits could require an audit.
28+
29+
``` bash
30+
gitxray -r https://github.com/SampleOrg/repo1 -f "has a mix of"
31+
```
32+
33+
## Checking for broken signatures
34+
These are attempts at signing that have likely failed for multiple reasons. You'll likely want to check the reason behind these failures; as it sometimes is as simple as the contributor not having uploaded their public key to their profile.
35+
36+
``` bash
37+
gitxray -r https://github.com/SampleOrg/repo1 -f signatures
38+
```
39+
40+
More use-cases for gitxray can be found in the [Forensics and Spotting Associations](forensics_spotting.md) and [Securing your Team and Repositories](securing_repos.md) sections.
41+

docs/show_love.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Show your love ♥
2+
3+
If and only If `gitxray` has been helpful to you, your support in spreading the `gitxray` word is appreciated.
4+
5+
* <a href="https://twitter.com/intent/tweet?text=I'm%20using%20Gitxray%20(https://github.com/kulkansecurity/gitxray/)%20developed%20by%20%40kulkansecurity%20and%20I'm%20loving%20it!" target='_blank'>Share on Twitter</a>
6+
* <a href="https://www.linkedin.com/shareArticle?mini=true&title=Gitxray&summary=Alalala&url=https%3A//github.com/kulkansecurity/gitxray/" target='_blank'>Share on LinkedIn - Write about your Gitxray experience</a>
7+
8+
And if you know of anyone looking for a Penetration Testing vendor, send them our way:
9+
10+
* <a href="https://www.kulkan.com/" target='_blank'>Kulkan Security</a>

mkdocs.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
site_name: Gitxray
2+
site_url: https://www.gitxray.com/
3+
repo_url: https://github.com/kulkansecurity/gitxray
4+
theme:
5+
name: readthedocs
6+
language: en
7+
features:
8+
- navigation.expand
9+
10+
nav:
11+
- 'index.md'
12+
- 'installing.md'
13+
- 'osint_pentest.md'
14+
- 'forensics_spotting.md'
15+
- 'securing_repos.md'
16+
- 'ideas_pending.md'
17+
- 'code_structure.md'
18+
- 'show_love.md'
19+
20+
markdown_extensions:
21+
- toc:
22+
permalink:
23+
- attr_list
24+
- md_in_html
25+
- pymdownx.arithmatex:
26+
generic: true
27+
28+
copyright: |
29+
Made with &hearts; by <a href="https://www.kulkan.com" target="_blank" rel="noopener">Kulkan Security</a>

0 commit comments

Comments
 (0)