ctfsendai2018

package module
v0.0.0-...-daa2d23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2018 License: MIT Imports: 9 Imported by: 0

README

ctfsendai2018

仙台CTF 2018 セキュリティ技術競技会(CTF) で使用したWebの問題です。

問題

Quest 1

RESTful APIサーバーのセキュリティ診断をしたところ、制限無しでユーザー情報を取得できてしまう問題が見つかりました。 RESTful APIサーバーにアクセスしてフラグを探してください。

  1. RESTful API のバージョンは、1
  2. 一般的には、/api/v1/users や /api/v1/products といったURLで情報を操作します。

診断対象サーバ http://localhost:8080

Quest 2

セキュリティ診断を続けたところ、どうやら、テストということでjoeアカウントが使われているアカウントがあるようです。

joeアカウントが使われているアカウント見つけてログインしてください。

  1. joeアカウントとは、ユーザーのIDとパスワードが同じアカウントのことを指します。
  2. /api/v1/login にメールアドレスとパスワードをJSON形式でPOSTするとログインすることができます。
  3. JSONはこんな形式です。{"email":"メールアドレス","password":"パスワード"}

診断対象サーバ http://localhost:8080/api/v1/login

Quest 3

ログイン時に生成されたトークンの作り方に問題があるようです。 Pen.2で見つけたユーザーアカウントを使ってログインした後、取得したトークンを解析して、管理者権限でデータを登録してください。 取得したトークンは、Authorizationに設定します。

診断対象サーバ http://localhost:8080/api/v1/users

問題サーバーの使い方

事前にDockerをインストールしてください

Docker イメージの作成
docker build ./ -t sendaictf2018
作成したイメージの作成
docker run -it --rm -p 8080:8080 --name sendaictf2018 sendaictf2018

access command

register
curl http://localhost:8080/api/v1/register -X POST -d '{"email":"hoge@hoge.com","password":"pass"}'
login
curl http://localhost:8080/api/v1/login -X POST -d '{"email":"hoge@hoge.com","password":"pass"}'
read users
curl http://localhost:8080/api/v1/users
add user
EMail    string `json:"email"`
Name     string `json:"name"`
Age      uint8  `json:"age"`
Note     string `json:"note"`
Auth     uint8  `json:"auth"`
curl http://180.42.14.119:8080/api/v1/users -X POST -d '{"id":"aG9nZUBob2dlLmNvbQ","email":"hoge@hoge.com","name":"hoge hoge","age":18}' -H 'Authorization:eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJhdXRoIjoxLCJleHAiOjE5MjQ5NTIzOTksInVzZXIiOiJLb21hdHN1TW9yaXRvbW8ifeKAiw.'

Documentation

Overview

Package ctfsendai2018 is a pseudo customer management system created for the task of CTF Sendai 2018. There are three vulnerabilities in this system, and we exploit the vulnerability from the outside to obtain a hidden flag.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUserID

func NewUserID(email string) string

NewUserID is create new user id

Types

type AuthHandler

type AuthHandler interface {
	Register(*gin.Context)
	Login(*gin.Context)
}

AuthHandler is handler manipulating authentication information

func NewAuthHandler

func NewAuthHandler(uc AuthUsecase) AuthHandler

NewAuthHandler is create new instance

type AuthRepository

type AuthRepository interface {
	Login(*User) (*Authentication, error)
}

AuthRepository is repository manipulating authentication information

func NewAuthRepository

func NewAuthRepository() AuthRepository

NewAuthRepository is create new instance

type AuthUsecase

type AuthUsecase interface {
	Register(string, string) error
	Login(string, string) (*Authentication, error)
}

AuthUsecase is service manipulating authentication information

func NewAuthUsecase

func NewAuthUsecase(a AuthRepository, u UserRepository) AuthUsecase

NewAuthUsecase is create new instance

type Authentication

type Authentication struct {
	Token string
}

Authentication is structure that represents authentication information

type User

type User struct {
	ID       string `json:"id"`
	Password string `json:"-"`
	EMail    string `json:"email"`
	Name     string `json:"name"`
	Age      uint8  `json:"age"`
	Note     string `json:"note"`
	Auth     uint8  `json:"auth"`
}

User は、ユーザー情報を表す構造体

func NewUser

func NewUser(email, passwd string) (*User, error)

NewUser は、新しくユーザー情報のインスタンスを作成する

type UserHandler

type UserHandler interface {
	Add(*gin.Context)
	List(*gin.Context)
}

UserHandler is handler manipulating authentication information

func NewUserHandler

func NewUserHandler(uc UserUsecase) UserHandler

NewUserHandler is create new instance

type UserRepository

type UserRepository interface {
	Add(*User) error
	List() ([]*User, error)
	FetchByEMail(string) (*User, error)
}

UserRepository is repository manipulating user information

func NewUserRepository

func NewUserRepository() UserRepository

NewUserRepository is Create new instance

type UserUsecase

type UserUsecase interface {
	Add(uint8, *User) error
	List(uint8) ([]*User, error)
}

UserUsecase is service manipulating user information

func NewUserUsecase

func NewUserUsecase(rep UserRepository) UserUsecase

NewUserUsecase is create new instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL