Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #130 from kitabisa/development
Browse files Browse the repository at this point in the history
v1.1.1
  • Loading branch information
dwisiswant0 committed Mar 16, 2021
2 parents c693211 + e46e34c commit a96938b
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 12 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

All notable changes to this project should be documented in this file.

### v1.1.1

- Add interrupt handler
- Set default logger to debug
- Add notifies if no logs are analyzed
- Refactoring analyzer threads

### v1.1.0

- Upgrade dependencies.
- Upgrade dependencies

### v1.0.3

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ All related documentation about installation, usage & configuration is on our [W

- [teler - Protect Your WebApp!](https://dw1.io/files/teler%20-%20Protect%20Your%20WebApp.pdf) Talks were brought to the **OWASP Jakarta: Virtual AppSec Indonesia 2020** event.
- [Tutorial: Cyber Threat Hunting - Useful Threat Hunting Tools (Part One)](https://youtu.be/0m54WOXO6Gc), Semi Yulianto gave a brief explanation and how to use **teler** in the video.
- [Empowering Teler HTTP Intrusion Detection as WAF with Fail2ban](https://link.medium.com/OXVZIMkZEeb).

## Contributors

Expand Down
3 changes: 3 additions & 0 deletions cmd/teler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ package main
import (
"runtime"

"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/gologger/levels"
"ktbs.dev/teler/internal/runner"
)

func init() {
cpu := runtime.NumCPU()
runtime.GOMAXPROCS(cpu + 1)
gologger.DefaultLogger.SetMaxLevel(levels.LevelDebug)
}

func main() {
Expand Down
2 changes: 1 addition & 1 deletion common/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package common

var (
Email = "infosec@kitabisa.com"
Development = true
Development = false
Version = ""
Banner = `
__ __
Expand Down
41 changes: 31 additions & 10 deletions internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"net/http"
"os"
"os/signal"
"regexp"

"github.com/acarl005/stripansi"
Expand All @@ -30,6 +31,7 @@ func removeLBR(s string) string {
func New(options *common.Options) {
var input *os.File
var out string
var pass int

metric, promserve, promendpoint := prometheus(options)
if metric {
Expand All @@ -49,15 +51,25 @@ func New(options *common.Options) {
jobs := make(chan *gonx.Entry)
gologger.Info().Msg("Analyzing...")

stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt)
go func() {
<-stop
gologger.Warning().Msg("Interuppted. Exiting...")

close(jobs)
done(pass)
}()

con := options.Concurrency
swg := sizedwaitgroup.New(con)
for i := 0; i < con; i++ {
swg.Add()
go func() {
defer swg.Done()
go func() {
for log := range jobs {
swg.Add()
go func(line *gonx.Entry) {
defer swg.Done()

for log := range jobs {
threat, obj := teler.Analyze(options, log)
threat, obj := teler.Analyze(options, line)

if threat {
if metric {
Expand Down Expand Up @@ -93,9 +105,9 @@ func New(options *common.Options) {

alert.New(options, common.Version, obj)
}
}
}()
}
}(log)
}
}()

if options.Stdin {
input = os.Stdin
Expand All @@ -116,10 +128,19 @@ func New(options *common.Options) {
break
}
jobs <- line
pass++
}

close(jobs)

swg.Wait()
done(pass)
}

func done(i int) {
if i == 0 {
gologger.Warning().Msg("No logs analyzed, did you write log format correctly?")
}
gologger.Info().Msg("Done!")

os.Exit(1)
}
10 changes: 10 additions & 0 deletions teler.fail2ban-filter.example.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Fail2Ban filter detected threats in teler log

[Definition]

failregex = \[<HOST>\] \[(Common Web Attack(: .*)?|CVE-[0-9]{4}-[0-9]{4,7}|Bad (IP Address|Referrer|Crawler)|Directory Bruteforce)\] .*$

# NOTES: You can ignore false-positive threats hereby or whitelist in the teler configuration file
ignoreregex =

datepattern = {^LN-BEG}
11 changes: 11 additions & 0 deletions teler.fail2ban-jail.example.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[teler]
enabled = true
port = http,https
filter = teler
logpath = /path/to/teler-threats.log
## Change as you wish
# Ban rules
maxretry = 10
findtime = 60
# Ban in seconds
bantime = 600

0 comments on commit a96938b

Please sign in to comment.