Last active
February 7, 2022 18:09
-
-
Save galehrizky/7d0947ebc204a8766371d62602632549 to your computer and use it in GitHub Desktop.
Backdoor scanner server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by galehdotid | |
// 2022-02-08 | |
// wget -O file.go https://gist.githubusercontent.com/galehrizky/7d0947ebc204a8766371d62602632549/raw/0bb4c2feefe0cea40c6fcab630948102c7e9c29e/scanner.go | |
// go build file.go | |
// ./file -dir | |
package main | |
import ( | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"os" | |
"path/filepath" | |
"regexp" | |
) | |
type Color string | |
const ( | |
ColorBlack Color = "\u001b[30m" | |
ColorRed = "\u001b[31m" | |
ColorGreen = "\u001b[32m" | |
ColorYellow = "\u001b[33m" | |
ColorBlue = "\u001b[34m" | |
ColorReset = "\u001b[0m" | |
) | |
func main() { | |
directory := flag.String("dir", "-dir", "set your directory want to check ") | |
flag.Parse() | |
flagset := make(map[string]bool) | |
flag.Visit(func(f *flag.Flag) { flagset[f.Name] = true }) | |
if flagset["dir"] { | |
file := readDirectory(*directory) | |
f, err := os.Create("backdoor-potensial.txt") | |
if err != nil { | |
log.Fatal(err) | |
} | |
for _, v := range file { | |
if isDirectory(v) { | |
setYourColor(ColorYellow, "[-] Directory :"+v) | |
} else { | |
setYourColor(ColorBlue, "[+] File :"+v) | |
word := backdoorWord() | |
content := readFile(v) | |
matched, _ := regexp.MatchString(word, content) | |
// Test the result. | |
if matched { | |
setYourColor(ColorGreen, "[+] Found match word :"+v) | |
f.WriteString(v + "\n") | |
} | |
} | |
} | |
} else { | |
setYourColor(ColorRed, "[!] Please put your directory !") | |
} | |
} | |
func readDirectory(Directory string) []string { | |
var files []string | |
root := Directory | |
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { | |
files = append(files, path) | |
return nil | |
}) | |
if err != nil { | |
panic(err) | |
} | |
return files | |
} | |
func readFile(Files string) string { | |
content, err := ioutil.ReadFile(Files) | |
if err != nil { | |
log.Fatal(err) | |
} | |
return string(content) | |
} | |
func isDirectory(path string) bool { | |
fileInfo, err := os.Stat(path) | |
if err != nil { | |
return false | |
} | |
return fileInfo.IsDir() | |
} | |
func backdoorWord() string { | |
word := "indoxploit|Adminer|b374k|x1njection|exploit-db|b374k" | |
return word | |
} | |
func setYourColor(color Color, message string) { | |
fmt.Println(string(color), message, string(ColorReset)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment