sshmitm.tutorial.gitserver package
Fake Git hosting server for SSH-MITM tutorials.
Exposes a GitLab-like web UI backed entirely by in-memory dataclasses. No real git repositories are involved — the UI is purely cosmetic to create a realistic phishing/credential-reuse scenario.
Usage:
from sshmitm.tutorial.gitserver import GitServer, GitServerConfig, GitUser, GitRepo, GitCommit
config = GitServerConfig(
brand="CorpGit",
users=[
GitUser(
username="alice",
fullname="Alice Smith",
bio="Backend engineer",
pubkeys=["ssh-ed25519 AAAA... alice@workstation"],
repos=[
GitRepo(
name="infra-scripts",
description="Internal infrastructure scripts",
language="Shell",
commits=[
GitCommit("Fix deploy pipeline", "alice", "2 days ago"),
],
)
],
)
],
)
srv = GitServer(config)
srv.start()
print(srv.url)
# use srv.port, srv.url
- class sshmitm.tutorial.gitserver.GitCommit(message, author, age, sha='')
Bases:
objectA single (fake) commit entry shown in a repository’s commit history.
- Parameters:
message (
str) – Commit message shown in the UI.author (
str) – Author name or username.age (
str) – Human-readable age string, e.g."3 days ago".sha (
str, default:'') – Hex SHA shown in the UI. Auto-computed from message and author if left empty.
- __init__(message, author, age, sha='')
- Parameters:
message (
str)author (
str)age (
str)sha (
str, default:'')
- age: str
- author: str
- message: str
- sha: str = ''
- class sshmitm.tutorial.gitserver.GitRepo(name, description='', language='', visibility='public', stars=0, forks=0, updated='', commits=<factory>)
Bases:
objectA fake repository listed on a user’s profile page.
- Parameters:
name (
str) – Repository slug (used in the URL/{username}/{name}).description (
str, default:'') – One-line summary shown on the profile card.language (
str, default:'') – Primary language badge (e.g."Python").visibility (
str, default:'public') –"public","internal", or"private".stars (
int, default:0) – Star count shown on the card.forks (
int, default:0) – Fork count shown on the card.updated (
str, default:'') – Human-readable last-update string, e.g."Updated 3 days ago".commits (
list[GitCommit], default:<factory>) – Ordered list ofGitCommitobjects shown on the repo page (most recent first).
- __init__(name, description='', language='', visibility='public', stars=0, forks=0, updated='', commits=<factory>)
- Parameters:
name (
str)description (
str, default:'')language (
str, default:'')visibility (
str, default:'public')stars (
int, default:0)forks (
int, default:0)updated (
str, default:'')commits (
list[GitCommit], default:<factory>)
- commits: list[GitCommit]
- description: str = ''
- forks: int = 0
- language: str = ''
- name: str
- stars: int = 0
- updated: str = ''
- visibility: str = 'public'
- class sshmitm.tutorial.gitserver.GitServer(config)
Bases:
objectFake Git-hosting HTTP server.
Starts an
aiohttpapplication in a background daemon thread. The server is ready whenstart()returns.- Parameters:
config (
GitServerConfig) –GitServerConfigdescribing the hosted content.Example:: – srv = GitServer(config) srv.start() print(srv.url) # “http://127.0.0.1:54321” print(srv.port) # 54321
- __init__(config)
- Parameters:
config (
GitServerConfig)
- property port: int
Actual TCP port the server is listening on.
- start()
Start the server in a background daemon thread and block until ready.
- Return type:
None
- stop()
No-op: the server runs in a daemon thread and exits with the process.
- Return type:
None
- property url: str
Base URL of the server (
http://127.0.0.1:{port}).
- class sshmitm.tutorial.gitserver.GitServerConfig(users=<factory>, brand='LogfileGit', port=0)
Bases:
objectTop-level configuration for a
GitServerinstance.- Parameters:
users (
list[GitUser], default:<factory>) – All user accounts hosted on this server.brand (
str, default:'LogfileGit') – Site name shown in the navigation bar (e.g."LogfileGit").port (
int, default:0) – TCP port to bind on.0lets the OS pick a free port.
- __init__(users=<factory>, brand='LogfileGit', port=0)
- Parameters:
users (
list[GitUser], default:<factory>)brand (
str, default:'LogfileGit')port (
int, default:0)
- brand: str = 'LogfileGit'
- port: int = 0
- users: list[GitUser]
- class sshmitm.tutorial.gitserver.GitUser(username, fullname='', bio='', pubkeys=<factory>, repos=<factory>)
Bases:
objectA fake user account hosted on the
GitServer.- Parameters:
username (
str) – URL-safe username (used in/{username}).fullname (
str, default:'') – Display name shown on the profile page.bio (
str, default:'') – Short biography line.pubkeys (
list[str], default:<factory>) – Raw SSH public key lines ("ssh-ed25519 AAAA... comment"). Accessible at/{username}.keys.repos (
list[GitRepo], default:<factory>) – Repositories owned by this user.
- __init__(username, fullname='', bio='', pubkeys=<factory>, repos=<factory>)
- Parameters:
username (
str)fullname (
str, default:'')bio (
str, default:'')pubkeys (
list[str], default:<factory>)repos (
list[GitRepo], default:<factory>)
- bio: str = ''
- fullname: str = ''
- pubkeys: list[str]
- repos: list[GitRepo]
- username: str