robit ... *hic*
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.2 KiB

package main
import(
"syscall"
"os"
"bytes"
"fmt"
"io"
"strings"
"github.com/lrstanley/girc"
)
//func stainSelect(query string) {
// db, err = sql.Open("mysql","user:"+sqlUser+"@"+sqlHost+"("+sqlHost+":"+sqlPort+")/"+sqlDB)
// defer db.Close()
// if err != nil {
// fmt.Println("[SQL] Fatal error when opening the MySQL database: ", err.Error())
// }
// err = db.Ping()
// if err != nil {
// fmt.Println("[SQL] Fatal error when pinging the MySQL database: ", err.Error())
// }
//}
func Cowrie(c *girc.Client) error {
syscall.Mkfifo(cowPipe, 0600)
for {
// fmt.Println("[IPC] Opening named pipe for reading")
stdout, err := os.OpenFile(cowPipe, os.O_RDONLY, 0600)
var buff bytes.Buffer
if err != nil {
fmt.Println("[IPC] FATAL! Cannot open named pipe!")
return err
os.Exit(2)
}
io.Copy(&buff, stdout)
stdout.Close()
dataStr := buff.String()
if (cowVerbose == 1 && strings.Contains(dataStr, "CMD:")) {
fmt.Println("CMD detected!")
cowSlice := strings.Split(dataStr,"]")
cowPrefix := cowSlice[0]
cowString := strings.Split(cowPrefix, ")")
cowString = strings.Split(cowString[0], ")")
cowSession := cowString[0]
cowIPstr := strings.Split(cowPrefix,",")
cowIP := cowIPstr[0]
cowCmd := "["+cowIP+"]["+cowSession+"] " + cowSlice[1]
fmt.Println(cowCmd)
if !contains(cowSesh,cowSession) {
Phone(c,"(new) Retard alert! Attn:")
PhoneOwner(c,"Retard alert!")
Phone(c,cowPings)
Phone(c,"-----------------")
cowSesh = append(cowSesh,cowSession)
printSlice(cowSesh)
}
Phone(c,dataStr)
}
if cowVerbose == 2 {
fmt.Printf("[IPC] sending data to [IRC]: %s\n", dataStr)
Phone(c,dataStr)
}
}
}
func cowSay(c *girc.Client, str0 string, str1 string, str2 string) {
Phone(c," __,._{i} " + str0)
Phone(c," / _ \\ ")
if (cowVerbose == 0) {
Phone(c," | 6 \\ \\ {red}oo{c} ")
} else if cowVerbose == 1 {
Phone(c," | 6 \\ \\ {green}oo{c} ")
} else {
Phone(c," {yellow}REEE{c} | 6 \\ \\ {green}$${c} ")
}
Phone(c," \\___/ .|__|| ")
Phone(c," __,..=\"^ . , \" ,\\ ")
Phone(c,"<.__________________/ ")
Phone(c,"{white}" + str1)
if str2 != "0" {
Phone(c,"{white}" + str2)
}
}