@@ -11,6 +11,7 @@ import (
11
11
"time"
12
12
13
13
"github.com/WangYihang/Platypus/lib/util/hash"
14
+ "github.com/WangYihang/Platypus/lib/util/fs"
14
15
"github.com/WangYihang/Platypus/lib/util/log"
15
16
humanize "github.com/dustin/go-humanize"
16
17
"github.com/jedib0t/go-pretty/table"
@@ -153,17 +154,18 @@ func (s *TCPServer) Run() {
153
154
}
154
155
155
156
// step 2: parse language
156
- language := "bash"
157
- if len (target ) > 0 {
158
- // language is the last element of target
159
- language = strings .Replace (target [len (target )- 1 ], "." , "" , - 1 )
157
+ // language is the last element of target
158
+ language := strings .Replace (target [len (target )- 1 ], "." , "" , - 1 )
159
+ templateFilename := fmt .Sprintf ("lib/template/rsh/%s.tpl" , language )
160
+ if language == "" || ! fs .FileExists (templateFilename ) {
161
+ language = "bash"
160
162
}
161
163
162
164
// step 3: read template
163
165
// template rendering in golang tastes like shit,
164
166
// here we will trying to use string replace temporarily.
165
167
// read reverse shell template file from lib/template/rsh/*
166
- templateFilename : = fmt .Sprintf ("lib/template/rsh/%s.tpl" , language )
168
+ templateFilename = fmt .Sprintf ("lib/template/rsh/%s.tpl" , language )
167
169
templateContent , _ := ioutil .ReadFile (templateFilename )
168
170
169
171
// step 4: render target host and port into template
0 commit comments