githubEdit

Gitea Pentesting

Gitea is a forge software package for hosting software development version control using Git.

Common Directories

/api/swagger
/api/v1/repos/search?q=test
/api/v1/users/search?q=test
/api/v1/users/<username>/repos
/explore/organizations
/explore/repos
/explore/users

# OAuth
/.well-known/openid-configuration
/login/oauth/authorize
/login/oauth/access_token
/login/oauth/userinfo
/login/oauth/keys

Investigation

Source Code in Repositories

If we can access to repositories, we might be able to find sensitive information e.g. credentials, subdomains, other domains, secret keys, etc. So check the source code.

Go Back to Previous Commits

We can see the source code of previous commits and find sensitive information accidentally disclosed by committers.

Get Secrets in Web Hooks

In the existing repository, we may find the secret value in the repository → Settings → Web Hooks.

Find User Credentials

If we have access to the target system and the repository, that is pushed in Gitea, exists in the system, we might be able to find the credential.

Git Fetch Remote Code Execution (RCE)

Metasploit

Git Hooks Remote Code Execution (RCE)

CVE-2020-14144arrow-up-right It affects Gitea version from 1.1.0 to 1.13.

1. Login

Access to the Gitea dashboard and login as the existing account.

2. Create a New Repository

3. Go to the Repository’s Settings

In the new repository we’ve created, go to Settings → Git Hooks → post-receive.

4. Update to the Reverse Shell Payload

In the post-receive edit page, inject the payload as below:

5. Start Listener in Terminal

To receive the outcoming connection of the git hook, start listener.

6. Create the New Repository in Terminal

After pushing, git hook triggered and execute the reverse shell command. Now we should get a shell.

Swagger API

We can access to /api/swagger to interact with Swagger API.

Get New Token & Authorize

We need a token to use Swagger API.

  1. Register a new account in Gitea top page.

  2. Go to /user/settings/applications and generate a new token.

  3. Copy the token value e.g. “fa2c2428817d64c1b890d404a905f7be2ffd4bde”.

  4. Go to /api/swagger.

  5. Click “Authorize” button. The modal window opens.

  6. Paste the token in the “Token” section.

Delete the Two-Factor

Dump Credentials in Database

Reference: Cracking Gitea's PBKDF2 Password Hashesarrow-up-right

Gitea has the database file so we can find user hashes from this file.

Once the hashes found, we can crack them using gitea2hashcatarrow-up-right.

Copy the output and crack it with Hashcat:

Last updated