Metadata-Version: 2.4
Name: loginscan
Version: 0.1.0
Summary: Kendi login endpoint'inizi savunma amaçlı tarayan, bağımlılıksız güvenlik aracı.
Author: Ulku Bayraktar
License: MIT License
        
        Copyright (c) 2026 Ulku Bayraktar
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/ulkubayraktar/loginscan
Keywords: security,login,authentication,self-audit,sql-injection,defensive
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Security
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Dynamic: license-file

# loginscan

A lightweight, dependency-free **defensive self-audit scanner** for login endpoints.
Point it at your own login page or API, and it runs a series of **safe, low-volume**
checks and reports what is wrong and **how to fix it**. You can scan by giving just a
**site link** or a **Swagger/OpenAPI link** — the login endpoint is auto-discovered.

> ⚠️ **Authorized use only.** Run this only against systems you **own** or have **written
> permission** to test. Unauthorized scanning is illegal. The tool refuses to run without
> an explicit confirmation (`--i-own-this` / `authorized=True`).

## Why it's safe

This is not an attack tool. By design it:

- **Does not crack passwords** — no brute-force, no wordlists. The "brute-force" check only
  sends 5–6 requests to see *whether rate limiting exists*.
- **Is low-volume** — a total request budget (default 25) caps every scan.
- **Is non-destructive** — only well-known detection probes; it never modifies data.

## Install

```bash
pip install .
# or, for development:
pip install -e .
```

## Usage

Scan by explicit URL:

```bash
loginscan https://site/login --i-own-this --user alice --success "Welcome"
```

Scan by **site link** (login form auto-discovered):

```bash
loginscan --site https://site/login-page --i-own-this --user alice
```

Scan by **Swagger/OpenAPI link** (JSON spec; endpoint + fields auto-discovered):

```bash
loginscan --swagger https://api.site/openapi.json --i-own-this --user alice
```

Useful options:

| Option | Description |
|---|---|
| `--i-own-this` | **Required.** Asserts you are authorized to test the target. |
| `--user NAME` | A username that really exists (not the password). Strengthens the enumeration check. |
| `--success "text"` | Text that means "login succeeded". Repeatable. |
| `--json-body` | Send credentials as JSON instead of form-encoded. |
| `--username-field` / `--password-field` | Override field names. |
| `--field csrf=abc` | Constant field added to every request. |
| `--max-requests 25` | Total request budget. |
| `--json report.json` | Also write the report as JSON. |
| `--html report.html` | Also write a shareable, styled HTML report. |
| `--insecure` | Disable TLS verification (for your own test server). |

Exit code: `1` if any vulnerability is found, `0` if clean, `2` if unauthorized/misused (handy for CI).

## Python API

```python
from loginscan import Scanner, ScanConfig

cfg = ScanConfig(url="https://site/login", known_username="alice",
                 success_indicators=["Welcome"])
report = Scanner(cfg, authorized=True).run()
print(report.to_text())
print(report.to_json())
```

## Checks

| Check | What it looks for |
|---|---|
| `sqli` | SQL-injection auth bypass + database error leakage |
| `enumeration` | Different responses for existing vs unknown users |
| `ratelimit` | Whether repeated failed logins get blocked |
| `cookies` | Session cookie HttpOnly / Secure / SameSite flags |
| `session` | Predictable session tokens (short / numeric / sequential / low-entropy) |
| `csrf` | CSRF token / cookie / SameSite defense on the login page |
| `open_redirect` | Unvalidated redirect via `?next=`, `?returnUrl=`, etc. |
| `jwt` | Passive JWT weaknesses (`alg=none`, missing `exp`) |
| `headers` | HTTPS, HSTS, nosniff, clickjacking, Referrer-Policy, version disclosure |

## Roadmap (checks to add next, in order)

- [ ] `verb` — HTTP method handling / verb tampering
- [ ] `cors` — permissive CORS on the auth endpoint (`ACAO: *` with credentials)
- [ ] `cache` — sensitive responses missing `Cache-Control: no-store`

## Learning demo

This repo also ships an intentionally **vulnerable** and a **secure** server to try loginscan against:

```bash
python3 vulnerable_app.py     # terminal 1 -> port 8001
loginscan --site http://127.0.0.1:8001/ --i-own-this --user admin --success "Giriş başarılı"
#   -> 4 vulnerabilities found

python3 secure_app.py         # port 8002
loginscan --site http://127.0.0.1:8002/ --i-own-this --user admin --success "Giriş başarılı"
#   -> sqli / enumeration / rate-limit all OK
```

## Releasing to PyPI

The package builds cleanly (`python -m build`) and passes `twine check`. To publish:

1. Create the `loginscan` project on PyPI and add a Trusted Publisher for this repo's
   `Publish to PyPI` workflow (environment `pypi`).
2. Push a version tag: `git tag v0.1.0 && git push origin v0.1.0`.

The workflow then builds and uploads automatically — no API token stored in the repo.

## License

MIT. Authorized use only.
