Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hack2fun committed Jan 11, 2020
0 parents commit 08e83b2
Show file tree
Hide file tree
Showing 55 changed files with 9,678 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.exe
*.zip
8 changes: 8 additions & 0 deletions .idea/GScan.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 110 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions Misc/allparams.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package Misc

type HostInfo struct {
INIFile string
Host string
Username string
Password string
ErrShow bool
Ports string
Port int
Help bool
Userfile string
Passfile string
Scantype string
Thread int
Timeout int64
Url string
UrlFile string
Show bool
Output string
Cookie string
Header string
}
31 changes: 31 additions & 0 deletions Misc/check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package Misc

import (
"fmt"
"net"
"time"
"os"
)

//Check if port is available
func (h *HostInfo)CheckPort()error{
InfoPrinter.Println("Checking whether the target port is open")
addr:=fmt.Sprintf("%s:%d",h.Host,h.Port)
_,err:=net.DialTimeout("tcp",addr,(time.Duration(h.Timeout))*time.Second)
if err!=nil{
WarnPrinter.Println("Port is closed, please confirm whether the target port is open")
InfoPrinter.Println("If you confirm that the port of this host is open, you can use the -bypass option to bypass port detection")
return err
}else{
InfoPrinter.Println("Port check completed, port open")
InfoPrinter.Println("Starting")
return nil
}
}

func CheckErr(err error){
if err!=nil{
ErrPrinter.Println(err.Error())
os.Exit(0)
}
}
53 changes: 53 additions & 0 deletions Misc/infoprint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package Misc

import(
"log"
"os"
"fmt"
)

const REDCOLOR = "\x1B[0;40;31m[Failed] \x1B[0m"
const GREEN = "\x1B[1;40;32m[Succeed] \x1B[0m"
const ERR = "\x1B[0;40;31m[ERROR] \x1B[0m"
const INFO = "\x1B[1;40;32m[*] \x1B[0m"
const WARN = "\x1B[0;40;31m[*] \x1B[0m"

var SucceedPrinter = log.New(os.Stdout,GREEN,log.LstdFlags)
var FailedPrinter = log.New(os.Stdout,REDCOLOR,log.LstdFlags)
var ErrPrinter = log.New(os.Stdout,ERR,log.LstdFlags)
var InfoPrinter = log.New(os.Stdout,INFO,log.LstdFlags)
var WarnPrinter = log.New(os.Stdout,WARN,log.LstdFlags)
// Successful IP, account and password will be output here
func (h *HostInfo)PrintSuccess(){
info:=fmt.Sprintf("Type: %s IP: %s:%d Username: %s Password: %s",h.Scantype,h.Host,h.Port,h.Username,h.Password)
SucceedPrinter.Println(info)
}

func (h *HostInfo)PrintFail(){
info:=fmt.Sprintf("Type: %s IP: %s:%d Username: %s Password: %s",h.Scantype,h.Host,h.Port,h.Username,h.Password)
FailedPrinter.Println(info)
}

//Output alive ports
func (h *HostInfo)PrintSucceedPort(){
info:=fmt.Sprintf("IP: %s:%d",h.Host,h.Port)
SucceedPrinter.Println(info)
}

//Output died ports
func (h *HostInfo)PrintFailedPort(){
info:=fmt.Sprintf("IP: %s:%d",h.Host,h.Port)
FailedPrinter.Println(info)
}

//Output alive hosts
func (h *HostInfo)PrintSucceedHost(){
info:=fmt.Sprintf("IP: %s is aliving",h.Host)
SucceedPrinter.Println(info)
}

//Output died hosts
func (h *HostInfo)PrintFailedHost(){
info:=fmt.Sprintf("IP: %s is died",h.Host)
FailedPrinter.Println(info)
}
44 changes: 44 additions & 0 deletions Misc/save.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package Misc

import (
"fmt"
"log"
"os"
)

func (h *HostInfo)Save(){

}

func (h *HostInfo)OutputTXT(){
f,err:=os.OpenFile(h.Output,os.O_CREATE|os.O_WRONLY|os.O_APPEND,0666)
if err!=nil {
ErrPrinter.Println(err)
return
}
var SaveFiler = log.New(f,"[*]",log.LstdFlags)

switch h.Scantype {
case "icmp":
info:=fmt.Sprintf("The host %s is up",h.Host)
SaveFiler.Println(info)
case "portscan":
info:=fmt.Sprintf("IP: %s:%d Open",h.Host,h.Port)
SaveFiler.Println(info)
//case "mysql","mssql","postgresql","ftp","mongodb","smb","redis","stmp"
case "urlscan","subdomain":
info:=fmt.Sprintf("%s",h.Url)
SaveFiler.Println(info)
case "auth":
info:=fmt.Sprintf("Type: %s URL: %s Username: %s Password: %s",h.Scantype,h.Url,h.Username,h.Password)
SaveFiler.Println(info)
default:
info:=fmt.Sprintf("Type: %s IP: %s:%d Username: %s Password: %s",h.Scantype,h.Host,h.Port,h.Username,h.Password)
SaveFiler.Println(info)
}
}

func (h *HostInfo)OutputJosn(){

}

24 changes: 24 additions & 0 deletions Parse/PareseConfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package Parse

import (
"errors"
"github.com/go-ini/ini"
"../Misc"
)

var ParseConfigErr=errors.New("An error occurred while parsing the configuration file, please check if your ini file format is correct or the file exists")

var CONFIG = &Misc.HostInfo{}

//Getting information of config file
func GetConfig(filename string)(*Misc.HostInfo,error){
conf,err:=ini.Load(filename)
if err!=nil{
return nil,ParseConfigErr
}
err=conf.Section("CONFIG").MapTo(CONFIG)
if err!=nil{
return nil,ParseConfigErr
}
return CONFIG,nil
}
51 changes: 51 additions & 0 deletions Parse/ParseFile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package Parse

import (
"bufio"
"errors"
"os"
"../Misc"
)

func ParsePass(h *Misc.HostInfo)([]string,error){
switch {
case h.Passfile!="" && h.Password!="":
return nil,errors.New("-p and -P cannot exist at the same time")
case h.Passfile=="" && h.Password=="":
return nil,errors.New("Please use -p or -P to specify the username")
case h.Passfile=="" && h.Password!="":
return []string{h.Password},nil
case h.Passfile!="" && h.Password=="":
file,err:=Readfile(h.Passfile)
return file,err
}
return nil,errors.New("unknown error")
}

func ParseUser(h *Misc.HostInfo)([]string,error){
switch {
case h.Userfile!="" && h.Username!="":
return nil,errors.New("-u and -U cannot exist at the same time")
case h.Userfile=="" && h.Username=="":
return nil,errors.New("Please use -u or -U to specify the username")
case h.Userfile=="" && h.Username!="":
return []string{h.Username},nil
case h.Userfile!="" && h.Username=="":
file,err:=Readfile(h.Userfile)
return file,err
}
return nil,errors.New("unknown error")
}

func Readfile(filename string)([]string,error){
file, err := os.Open(filename)
if err!=nil{
return nil,errors.New("There was an error opening the file")
}
var content []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
content=append(content,scanner.Text())
}
return content,nil
}
Loading

0 comments on commit 08e83b2

Please sign in to comment.