# metas-detect

> Check hack attempts and seo bots against simple scenarios.

Latest version **2.0.2** (published 2015-09-03) · ISC license · 0 weekly downloads

## Install

```sh
npm install metas-detect
pnpm add metas-detect
yarn add metas-detect
bun add metas-detect
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2015-09-03 |
| First published | 2015-09-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| Author | G33kLabs |
| Maintainers | g33klabs |
| Keywords | express, hack, bot, detect |

## Links

- npm: https://www.npmjs.com/package/metas-detect
- Repository: https://github.com/G33kLabs/node-metas-detect
- Homepage: https://github.com/G33kLabs/node-metas-detect#readme
- Issues: https://github.com/G33kLabs/node-metas-detect/issues
- npm.io page: https://npm.io/package/metas-detect

## Dependencies (7)

- [lodash](https://npm.io/package/lodash.md) ^3.10.1
- [moment](https://npm.io/package/moment.md) ^2.10.6
- [winston](https://npm.io/package/winston.md) ^1.0.1
- [telize-node](https://npm.io/package/telize-node.md) ^1.0.4
- [coffee-script](https://npm.io/package/coffee-script.md) ^1.9.3
- [accept-language](https://npm.io/package/accept-language.md) ^2.0.16
- [winston-mongodb](https://npm.io/package/winston-mongodb.md) ^1.1.2

## Recent versions

- 2.0.2 (latest) — 2015-09-03
- 2.0.1 — 2015-09-03
- 2.0.0 — 2015-09-02
- 1.0.3 — 2015-09-01
- 1.0.2 — 2015-09-01
- 1.0.1 — 2015-09-01
- 1.0.0 — 2015-09-01

## README

NodeJS detect hack attempts 
===========================

New version 2.0

Now 'metas-detect' is an expressjs' middleware.

This module can :
 - Identify bots
 - Geolocate IPs
 - Parse visitor language
 - Detect basic hack attemps 
 - Redirect attackers
 - Log any visit into storage
 - Query logs to build statistics

It better to use it with a winston supported storage and currently, only winston-mongodb is implemented.

**You're really welcome if you want to contribute at this repository and have some good features to add :)**

Installation
------------

```
npm install --save metas-detect
```

Usage
-----

```
// Load library
var MetasDetect = require('metas-detect');

// Instanciate the metasDetect
var metasDetect = new MetasDetect({
    mongodb: {
        db: 'mongodb://locahost/@yourdb',
        username: 'optional',
        password: 'optional'
    }
})

// Load express
var express = require('express');
var app = express();

// Install metasDetect middleware
app.use(metasDetect.middleware.bind(metasDetect))

```

Options
-------

```
    # Hack attempt
    # ------------

        # Display a blue screen of death if an attack is detected ?
        # Stop request here
        hackers_bsod: true

        # Waste time of the hacker before sending a response
        hackers_sleep: 2000

        # The image that scares
        hackers_responseTxt: '''
                uuuuuuu
             uu$$$$$$$$$$$uu
          uu$$$$$$$$$$$$$$$$$uu
         u$$$$$$$$$$$$$$$$$$$$$u
        u$$$$$$$$$$$$$$$$$$$$$$$u
       u$$$$$$$$$$$$$$$$$$$$$$$$$u
       u$$$$$$$$$$$$$$$$$$$$$$$$$u
       u$$$$$$"   "$$$"   "$$$$$$u
       "$$$$"      u$u       $$$$"
        $$$u       u$u       u$$$
        $$$u      u$$$u      u$$$
         "$$$$uu$$$   $$$uu$$$$"
          "$$$$$$$"   "$$$$$$$"
            u$$$$$$$u$$$$$$$u
             u$"$"$"$"$"$"$u
  uuu        $$u$ $ $ $ $u$$       uuu
 u$$$$        $$$$$u$u$u$$$       u$$$$
  $$$$$uu      "$$$$$$$$$"     uu$$$$$$
u$$$$$$$$$$$uu    """""    uuuu$$$$$$$$$$
$$$$"""$$$$$$$$$$uuu   uu$$$$$$$$$"""$$$"
 """      ""$$$$$$$$$$$uu ""$"""
           uuuu ""$$$$$$$$$$uuu
  u$$$uuu$$$$$$$$$uu ""$$$$$$$$$$$uuu$$$
  $$$$$$$$$$""""           ""$$$$$$$$$$$"
   "$$$$$"[      MSG1:22         ]""$$$$""
     $$$"[       MSG2:23         ]$$$$"
        '''

        # Rules to detect attack
        hackers_honeypots:
            'url': [/^(\/administrator\/|\/wp-admin\/|(.*)\.php)/]


    # Bots detection rules
    # --------------------
    bots_honeypots:
        'ua': [
            /(http|https)/
            /BingPreview/
            /Google\ favicon/
            /spider/i
            /crawler/i
            /Twitterbot/i
        ]
        'url': [
            /SiteAuth\.xml$/i
            /^\/robots\.txt$/
        ]


    # Static files detection rules
    # ----------------------------
    static_honeypot: /\.(js|css|woff|woff2|ttf|eot|png|jpg|gif|ico|svg)$/i    

```

Query logs
----------

You can query datas from storage like the example below.

Get all logs for the current day :

```
    timeRef = moment()
    metasDetect.query({
        from: timeRef.clone().startOf('day').toDate()
        until: timeRef.clone().endOf('day').toDate()
        start: 0
        limit: 10000
        order: 'asc'
    }, (err, results) ->
        console.log(err, results)
    )
```

---
_Source: https://npm.io/package/metas-detect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
