...
 
Commits (2)
......@@ -85,7 +85,7 @@ func processMessage(bot *tgbotapi.BotAPI, update tgbotapi.Update) {
}
return
case "sshscan":
case "sshscan", "scanssh":
if len(args) == 0 || len(args[0]) == 0 {
msg.Text = sshscan.GetHelp()
} else if len(args) == 1 {
......
package pingcomm
import (
"bytes"
"net"
"os/exec"
......@@ -39,26 +40,29 @@ func GetStringResponse(target string) string {
} else if isPrivateIP(net.ParseIP(target)) {
return "*Not allowed*\nYou have no permission to ping a private IP address."
} else {
out, err := exec.Command("sh", "-c", "ping -c 3 -i 0.2 -W1 -n "+target).Output()
if err != nil {
return err.Error()
}
return "*Ping to " + target + "*\n\n```\n" + string(out) + "\n```"
cmd := exec.Command("sh", "-c", "ping -c 3 -i 0.2 -W1 -n "+target)
var out bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &out
cmd.Run()
return "*Ping to " + target + "*\n\n```\n" + out.String() + "\n```"
}
} else if govalidator.IsIPv6(target) {
out, err := exec.Command("sh", "-c", "ping6 -c 2 -i 0.2 "+target).Output()
if err != nil {
return err.Error()
}
return "*Ping6 to " + target + "*\n\n```\n" + string(out) + "\n```"
cmd := exec.Command("sh", "-c", "ping6 -c 3 -i 0.2 "+target)
var out bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &out
cmd.Run()
return "*Ping6 to " + target + "*\n\n```\n" + out.String() + "\n```"
} else if govalidator.IsDNSName(target) {
out, err := exec.Command("sh", "-c", "ping -c 3 -i 0.2 -W1 -n "+target).Output()
if err != nil {
return err.Error()
}
return "*Domain ping to " + target + "*\n\n```\n" + string(out) + "\n```"
cmd := exec.Command("sh", "-c", "ping -c 3 -i 0.2 -W1 -n "+target)
var out bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &out
cmd.Run()
return "*Domain ping to " + target + "*\n\n```\n" + out.String() + "\n```"
}
return "*Target is not valid*\nPlease provide a valid IPv4, IPv6 or domain name."
......