@@ -229,89 +229,91 @@ func TestGenerateReverseHTTPS(t *testing.T) {
229229}
230230
231231func TestGenerateReverseTCP_Fake (t * testing.T ) {
232- const (
233- fileNameFlag = "ReverseTCP.java"
234- hostFlag = "${host}"
235- portFlag = "${port}"
236- tokenFlag = "${token}"
237- className = "ReverseTCP\x0C "
238- )
239-
240- buf := bytes .NewBuffer (make ([]byte , 0 , 128 ))
241- buf .Write ([]byte {0xCA , 0xFE })
242- buf .Write ([]byte {0x00 , 0x00 })
243-
244- size := make ([]byte , 2 )
245-
246- binary .BigEndian .PutUint16 (size , uint16 (len (fileNameFlag )))
247- buf .Write (size )
248- buf .WriteString (fileNameFlag )
249- buf .Write ([]byte {0x00 , 0x00 })
250-
251- binary .BigEndian .PutUint16 (size , uint16 (len (hostFlag )))
252- buf .Write (size )
253- buf .WriteString (hostFlag )
254- buf .Write ([]byte {0x00 , 0x00 })
255-
256- binary .BigEndian .PutUint16 (size , uint16 (len (portFlag )))
257- buf .Write (size )
258- buf .WriteString (portFlag )
259- buf .Write ([]byte {0x00 , 0x00 })
260-
261- binary .BigEndian .PutUint16 (size , uint16 (len (tokenFlag )))
262- buf .Write (size )
263- buf .WriteString (tokenFlag )
264- buf .Write ([]byte {0x00 , 0x00 })
265-
266- binary .BigEndian .PutUint16 (size , uint16 (len (className )))
267- buf .Write (size )
268- buf .WriteString (className )
269- buf .Write ([]byte {0x00 , 0x00 })
270-
271- err := os .WriteFile ("testdata/template/ReverseTCP.class" , buf .Bytes (), 0600 )
272- require .NoError (t , err )
273- }
232+ t .Run ("template" , func (t * testing.T ) {
233+ const (
234+ fileNameFlag = "ReverseTCP.java"
235+ hostFlag = "${host}"
236+ portFlag = "${port}"
237+ tokenFlag = "${token}"
238+ className = "ReverseTCP\x0C "
239+ )
240+
241+ buf := bytes .NewBuffer (make ([]byte , 0 , 128 ))
242+ buf .Write ([]byte {0xCA , 0xFE })
243+ buf .Write ([]byte {0x00 , 0x00 })
244+
245+ size := make ([]byte , 2 )
246+
247+ binary .BigEndian .PutUint16 (size , uint16 (len (fileNameFlag )))
248+ buf .Write (size )
249+ buf .WriteString (fileNameFlag )
250+ buf .Write ([]byte {0x00 , 0x00 })
251+
252+ binary .BigEndian .PutUint16 (size , uint16 (len (hostFlag )))
253+ buf .Write (size )
254+ buf .WriteString (hostFlag )
255+ buf .Write ([]byte {0x00 , 0x00 })
256+
257+ binary .BigEndian .PutUint16 (size , uint16 (len (portFlag )))
258+ buf .Write (size )
259+ buf .WriteString (portFlag )
260+ buf .Write ([]byte {0x00 , 0x00 })
261+
262+ binary .BigEndian .PutUint16 (size , uint16 (len (tokenFlag )))
263+ buf .Write (size )
264+ buf .WriteString (tokenFlag )
265+ buf .Write ([]byte {0x00 , 0x00 })
266+
267+ binary .BigEndian .PutUint16 (size , uint16 (len (className )))
268+ buf .Write (size )
269+ buf .WriteString (className )
270+ buf .Write ([]byte {0x00 , 0x00 })
271+
272+ err := os .WriteFile ("testdata/template/ReverseTCP.class" , buf .Bytes (), 0600 )
273+ require .NoError (t , err )
274+ })
274275
275- func TestGenerateReverseTCP_Fake_Compare (t * testing.T ) {
276- const (
277- fileNameFlag = "ReTCP.java"
278- hostFlag = "127.0.0.1"
279- portFlag = "9979"
280- tokenFlag = "test"
281- className = "ReTCP\x0C "
282- )
283-
284- buf := bytes .NewBuffer (make ([]byte , 0 , 128 ))
285- buf .Write ([]byte {0xCA , 0xFE })
286- buf .Write ([]byte {0x00 , 0x00 })
287-
288- size := make ([]byte , 2 )
289-
290- binary .BigEndian .PutUint16 (size , uint16 (len (fileNameFlag )))
291- buf .Write (size )
292- buf .WriteString (fileNameFlag )
293- buf .Write ([]byte {0x00 , 0x00 })
294-
295- binary .BigEndian .PutUint16 (size , uint16 (len (hostFlag )))
296- buf .Write (size )
297- buf .WriteString (hostFlag )
298- buf .Write ([]byte {0x00 , 0x00 })
299-
300- binary .BigEndian .PutUint16 (size , uint16 (len (portFlag )))
301- buf .Write (size )
302- buf .WriteString (portFlag )
303- buf .Write ([]byte {0x00 , 0x00 })
304-
305- binary .BigEndian .PutUint16 (size , uint16 (len (tokenFlag )))
306- buf .Write (size )
307- buf .WriteString (tokenFlag )
308- buf .Write ([]byte {0x00 , 0x00 })
309-
310- binary .BigEndian .PutUint16 (size , uint16 (len (className )- 1 ))
311- buf .Write (size )
312- buf .WriteString (className )
313- buf .Write ([]byte {0x00 , 0x00 })
314-
315- err := os .WriteFile ("testdata/template/compare/ReTCP.class" , buf .Bytes (), 0600 )
316- require .NoError (t , err )
276+ t .Run ("compare" , func (t * testing.T ) {
277+ const (
278+ fileNameFlag = "ReTCP.java"
279+ hostFlag = "127.0.0.1"
280+ portFlag = "9979"
281+ tokenFlag = "test"
282+ className = "ReTCP\x0C "
283+ )
284+
285+ buf := bytes .NewBuffer (make ([]byte , 0 , 128 ))
286+ buf .Write ([]byte {0xCA , 0xFE })
287+ buf .Write ([]byte {0x00 , 0x00 })
288+
289+ size := make ([]byte , 2 )
290+
291+ binary .BigEndian .PutUint16 (size , uint16 (len (fileNameFlag )))
292+ buf .Write (size )
293+ buf .WriteString (fileNameFlag )
294+ buf .Write ([]byte {0x00 , 0x00 })
295+
296+ binary .BigEndian .PutUint16 (size , uint16 (len (hostFlag )))
297+ buf .Write (size )
298+ buf .WriteString (hostFlag )
299+ buf .Write ([]byte {0x00 , 0x00 })
300+
301+ binary .BigEndian .PutUint16 (size , uint16 (len (portFlag )))
302+ buf .Write (size )
303+ buf .WriteString (portFlag )
304+ buf .Write ([]byte {0x00 , 0x00 })
305+
306+ binary .BigEndian .PutUint16 (size , uint16 (len (tokenFlag )))
307+ buf .Write (size )
308+ buf .WriteString (tokenFlag )
309+ buf .Write ([]byte {0x00 , 0x00 })
310+
311+ binary .BigEndian .PutUint16 (size , uint16 (len (className )- 1 ))
312+ buf .Write (size )
313+ buf .WriteString (className )
314+ buf .Write ([]byte {0x00 , 0x00 })
315+
316+ err := os .WriteFile ("testdata/template/compare/ReTCP.class" , buf .Bytes (), 0600 )
317+ require .NoError (t , err )
318+ })
317319}
0 commit comments