initial commit

Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
ale
2025-12-04 00:58:40 +01:00
padre d0c05d13b1
commit 1b51f5a171
Se han modificado 18 ficheros con 3013 adiciones y 6626 borrados

322
README.md
Ver fichero

@@ -1,36 +1,314 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
# Hasher 🔐
## Getting Started
A modern, high-performance hash search and generation tool powered by Elasticsearch and Next.js. Search for hash values to find their plaintext origins or generate hashes from any text input.
First, run the development server:
![Hasher Banner](https://img.shields.io/badge/Next.js-16.0-black?style=for-the-badge&logo=next.js)
![Elasticsearch](https://img.shields.io/badge/Elasticsearch-8.x-005571?style=for-the-badge&logo=elasticsearch)
![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178C6?style=for-the-badge&logo=typescript)
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
## ✨ Features
- 🔍 **Hash Lookup**: Search for MD5, SHA1, SHA256, SHA512, and Bcrypt hashes
- 🔑 **Hash Generation**: Generate multiple hash types from plaintext
- 💾 **Auto-Indexing**: Automatically stores searched plaintext and hashes
- 📊 **Elasticsearch Backend**: Scalable storage with 10 shards for performance
- 🚀 **Bulk Indexing**: Import wordlists via command-line script
- 🎨 **Modern UI**: Beautiful, responsive interface with real-time feedback
- 📋 **Copy to Clipboard**: One-click copying of any hash value
## 🏗️ Architecture
```
┌─────────────┐
│ Next.js │ ← Modern React UI
│ Frontend │
└──────┬──────┘
┌─────────────┐
│ API │ ← REST endpoints
│ Routes │
└──────┬──────┘
┌─────────────┐
│Elasticsearch│ ← Distributed storage
│ 10 Shards │ (localhost:9200)
└─────────────┘
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
## 🚀 Quick Start
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
### Prerequisites
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
- Node.js 18.x or higher
- Elasticsearch 8.x running on `localhost:9200`
- npm or yarn
## Learn More
### Installation
To learn more about Next.js, take a look at the following resources:
1. **Clone the repository**
```bash
git clone <repository-url>
cd hasher
```
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
2. **Install dependencies**
```bash
npm install
```
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
3. **Configure Elasticsearch** (optional)
By default, the app connects to `http://localhost:9200`. To change this:
```bash
export ELASTICSEARCH_NODE=http://your-elasticsearch-host:9200
```
## Deploy on Vercel
4. **Run the development server**
```bash
npm run dev
```
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
5. **Open your browser**
Navigate to [http://localhost:3000](http://localhost:3000)
## 📖 Usage
### Web Interface
1. **Search for a Hash**
- Enter any MD5, SHA1, SHA256, or SHA512 hash
- Click search or press Enter
- View the plaintext result if found in the database
2. **Generate Hashes**
- Enter any plaintext string
- Get instant hash values for all supported algorithms
- Hashes are automatically saved for future lookups
### Bulk Indexing Script
Index large wordlists or dictionaries:
```bash
# Basic usage
npm run index-file wordlist.txt
# With custom batch size
npm run index-file wordlist.txt -- --batch-size 500
# Show help
npm run index-file -- --help
```
**Input file format**: One word/phrase per line
```text
password
admin
123456
qwerty
```
**Script features**:
- ✅ Bulk indexing with configurable batch size
- ✅ Progress indicator with percentage
- ✅ Error handling and reporting
- ✅ Performance metrics (docs/sec)
- ✅ Automatic index refresh
## 🔌 API Reference
### Search Endpoint
**POST** `/api/search`
Search for a hash or generate hashes from plaintext.
**Request Body**:
```json
{
"query": "5f4dcc3b5aa765d61d8327deb882cf99"
}
```
**Response (Hash Found)**:
```json
{
"found": true,
"hashType": "md5",
"hash": "5f4dcc3b5aa765d61d8327deb882cf99",
"results": [{
"plaintext": "password",
"hashes": {
"md5": "5f4dcc3b5aa765d61d8327deb882cf99",
"sha1": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"sha256": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8",
"sha512": "b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86"
}
}]
}
```
**Response (Plaintext Input)**:
```json
{
"found": true,
"isPlaintext": true,
"plaintext": "password",
"hashes": {
"md5": "5f4dcc3b5aa765d61d8327deb882cf99",
"sha1": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"sha256": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8",
"sha512": "b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86"
}
}
```
### Health Check Endpoint
**GET** `/api/health`
Check Elasticsearch connection and index status.
**Response**:
```json
{
"status": "ok",
"elasticsearch": {
"cluster": "elasticsearch",
"status": "green"
},
"index": {
"exists": true,
"name": "hasher",
"stats": {
"documentCount": 1542,
"indexSize": 524288
}
}
}
```
## 🗄️ Elasticsearch Index
### Index Configuration
- **Name**: `hasher`
- **Shards**: 10 (for horizontal scaling)
- **Replicas**: 1 (for redundancy)
### Mapping Schema
```json
{
"plaintext": {
"type": "text",
"analyzer": "lowercase_analyzer",
"fields": {
"keyword": { "type": "keyword" }
}
},
"md5": { "type": "keyword" },
"sha1": { "type": "keyword" },
"sha256": { "type": "keyword" },
"sha512": { "type": "keyword" },
"created_at": { "type": "date" }
}
```
## 📁 Project Structure
```
hasher/
├── app/
│ ├── api/
│ │ ├── search/
│ │ │ └── route.ts # Search endpoint
│ │ └── health/
│ │ └── route.ts # Health check endpoint
│ ├── layout.tsx # Root layout
│ ├── page.tsx # Main UI component
│ └── globals.css # Global styles
├── lib/
│ ├── elasticsearch.ts # ES client & index config
│ └── hash.ts # Hash utilities
├── scripts/
│ └── index-file.ts # Bulk indexing script
├── package.json
├── tsconfig.json
├── next.config.ts
└── README.md
```
## 🛠️ Development
### Build for Production
```bash
npm run build
npm run start
```
### Environment Variables
Create a `.env.local` file:
```env
ELASTICSEARCH_NODE=http://localhost:9200
```
### Linting
```bash
npm run lint
```
## 🔒 Supported Hash Algorithms
| Algorithm | Length (hex) | Detection Pattern |
|-----------|--------------|-------------------|
| MD5 | 32 | `^[a-f0-9]{32}$` |
| SHA1 | 40 | `^[a-f0-9]{40}$` |
| SHA256 | 64 | `^[a-f0-9]{64}$` |
| SHA512 | 128 | `^[a-f0-9]{128}$` |
| Bcrypt | 60 | `^\$2[abxy]\$` |
## 🚀 Performance
- **Bulk Indexing**: ~1000-5000 docs/sec (depending on hardware)
- **Search Latency**: <50ms (typical)
- **Horizontal Scaling**: 10 shards for parallel processing
- **Auto-refresh**: Instant search availability for new documents
## 🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## 📝 License
This project is open source and available under the [MIT License](LICENSE).
## 🙏 Acknowledgments
- Built with [Next.js](https://nextjs.org/)
- Powered by [Elasticsearch](https://www.elastic.co/)
- Icons by [Lucide](https://lucide.dev/)
- Styled with [Tailwind CSS](https://tailwindcss.com/)
## 📧 Support
For issues, questions, or contributions, please open an issue on GitHub.
---
**Made with ❤️ for the security and development community**
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.