@@ -231,11 +231,11 @@ func TestGenerateReverseHTTPS(t *testing.T) {
231231func TestGenerateReverseTCP_Fake (t * testing.T ) {
232232 t .Run ("template" , func (t * testing.T ) {
233233 const (
234- fileNameFlag = "ReverseTCP.java"
235- hostFlag = "${host}"
236- portFlag = "${port}"
237- tokenFlag = "${token}"
238- className = "ReverseTCP\x0C "
234+ fileName = "ReverseTCP.java"
235+ hostFlag = "${host}"
236+ portFlag = "${port}"
237+ tokenFlag = "${token}"
238+ className = "ReverseTCP\x0C "
239239 )
240240
241241 buf := bytes .NewBuffer (make ([]byte , 0 , 128 ))
@@ -244,9 +244,9 @@ func TestGenerateReverseTCP_Fake(t *testing.T) {
244244
245245 size := make ([]byte , 2 )
246246
247- binary .BigEndian .PutUint16 (size , uint16 (len (fileNameFlag )))
247+ binary .BigEndian .PutUint16 (size , uint16 (len (fileName )))
248248 buf .Write (size )
249- buf .WriteString (fileNameFlag )
249+ buf .WriteString (fileName )
250250 buf .Write ([]byte {0x00 , 0x00 })
251251
252252 binary .BigEndian .PutUint16 (size , uint16 (len (hostFlag )))
@@ -275,11 +275,11 @@ func TestGenerateReverseTCP_Fake(t *testing.T) {
275275
276276 t .Run ("compare" , func (t * testing.T ) {
277277 const (
278- fileNameFlag = "ReTCP.java"
279- hostFlag = "127.0.0.1"
280- portFlag = "9979"
281- tokenFlag = "test"
282- className = "ReTCP\x0C "
278+ fileName = "ReTCP.java"
279+ host = "127.0.0.1"
280+ port = "9979"
281+ token = "test"
282+ className = "ReTCP\x0C "
283283 )
284284
285285 buf := bytes .NewBuffer (make ([]byte , 0 , 128 ))
@@ -288,32 +288,125 @@ func TestGenerateReverseTCP_Fake(t *testing.T) {
288288
289289 size := make ([]byte , 2 )
290290
291- binary .BigEndian .PutUint16 (size , uint16 (len (fileNameFlag )))
291+ binary .BigEndian .PutUint16 (size , uint16 (len (fileName )))
292292 buf .Write (size )
293- buf .WriteString (fileNameFlag )
293+ buf .WriteString (fileName )
294294 buf .Write ([]byte {0x00 , 0x00 })
295295
296- binary .BigEndian .PutUint16 (size , uint16 (len (hostFlag )))
296+ binary .BigEndian .PutUint16 (size , uint16 (len (host )))
297297 buf .Write (size )
298- buf .WriteString (hostFlag )
298+ buf .WriteString (host )
299299 buf .Write ([]byte {0x00 , 0x00 })
300300
301- binary .BigEndian .PutUint16 (size , uint16 (len (portFlag )))
301+ binary .BigEndian .PutUint16 (size , uint16 (len (port )))
302302 buf .Write (size )
303- buf .WriteString (portFlag )
303+ buf .WriteString (port )
304+ buf .Write ([]byte {0x00 , 0x00 })
305+
306+ binary .BigEndian .PutUint16 (size , uint16 (len (token )))
307+ buf .Write (size )
308+ buf .WriteString (token )
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+ })
319+ }
320+
321+ func TestGenerateReverseHTTPS_Fake (t * testing.T ) {
322+ t .Run ("template" , func (t * testing.T ) {
323+ const (
324+ fileName = "ReverseHTTPS.java"
325+ urlFlag = "${url}"
326+ uaFlag = "${ua}"
327+ tokenFlag = "${token}"
328+ className = "ReverseHTTPS\x0C "
329+ )
330+
331+ buf := bytes .NewBuffer (make ([]byte , 0 , 128 ))
332+ buf .Write ([]byte {0xCA , 0xFE })
333+ buf .Write ([]byte {0x00 , 0x00 })
334+
335+ size := make ([]byte , 2 )
336+
337+ binary .BigEndian .PutUint16 (size , uint16 (len (fileName )))
338+ buf .Write (size )
339+ buf .WriteString (fileName )
340+ buf .Write ([]byte {0x00 , 0x00 })
341+
342+ binary .BigEndian .PutUint16 (size , uint16 (len (urlFlag )))
343+ buf .Write (size )
344+ buf .WriteString (urlFlag )
345+ buf .Write ([]byte {0x00 , 0x00 })
346+
347+ binary .BigEndian .PutUint16 (size , uint16 (len (uaFlag )))
348+ buf .Write (size )
349+ buf .WriteString (uaFlag )
304350 buf .Write ([]byte {0x00 , 0x00 })
305351
306352 binary .BigEndian .PutUint16 (size , uint16 (len (tokenFlag )))
307353 buf .Write (size )
308354 buf .WriteString (tokenFlag )
309355 buf .Write ([]byte {0x00 , 0x00 })
310356
357+ binary .BigEndian .PutUint16 (size , uint16 (len (className )))
358+ buf .Write (size )
359+ buf .WriteString (className )
360+ buf .Write ([]byte {0x00 , 0x00 })
361+
362+ err := os .WriteFile ("testdata/template/ReverseHTTPS.class" , buf .Bytes (), 0600 )
363+ require .NoError (t , err )
364+ })
365+
366+ t .Run ("compare" , func (t * testing.T ) {
367+ const (
368+ fileName = "ReHTTPS.java"
369+ url = "https://127.0.0.1:8443/test/" +
370+ "0YjdeS7_m93CecZoo8Ntkgs8lRd8_P50Ud2378Ggsvu0FX3VfHF2jbRAQxfUk1Uklj" +
371+ "sZ0Pwz-_bPfTMmytR-fhVGYvyEm-bPNat3i0XRJnm5oH76MBegc7AG3hEe1J1WG3PD" +
372+ "vddN5Id06qqBQR9lZAkJNzFB6VPRJmbsvp_LKp3JDg70FrOcjczkGSRbeht14__lN"
373+ ua = "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"
374+ token = "test"
375+ className = "ReHTTPS\x0C "
376+ )
377+
378+ buf := bytes .NewBuffer (make ([]byte , 0 , 128 ))
379+ buf .Write ([]byte {0xCA , 0xFE })
380+ buf .Write ([]byte {0x00 , 0x00 })
381+
382+ size := make ([]byte , 2 )
383+
384+ binary .BigEndian .PutUint16 (size , uint16 (len (fileName )))
385+ buf .Write (size )
386+ buf .WriteString (fileName )
387+ buf .Write ([]byte {0x00 , 0x00 })
388+
389+ binary .BigEndian .PutUint16 (size , uint16 (len (url )))
390+ buf .Write (size )
391+ buf .WriteString (url )
392+ buf .Write ([]byte {0x00 , 0x00 })
393+
394+ binary .BigEndian .PutUint16 (size , uint16 (len (ua )))
395+ buf .Write (size )
396+ buf .WriteString (ua )
397+ buf .Write ([]byte {0x00 , 0x00 })
398+
399+ binary .BigEndian .PutUint16 (size , uint16 (len (token )))
400+ buf .Write (size )
401+ buf .WriteString (token )
402+ buf .Write ([]byte {0x00 , 0x00 })
403+
311404 binary .BigEndian .PutUint16 (size , uint16 (len (className )- 1 ))
312405 buf .Write (size )
313406 buf .WriteString (className )
314407 buf .Write ([]byte {0x00 , 0x00 })
315408
316- err := os .WriteFile ("testdata/template/compare/ReTCP .class" , buf .Bytes (), 0600 )
409+ err := os .WriteFile ("testdata/template/compare/ReHTTPS .class" , buf .Bytes (), 0600 )
317410 require .NoError (t , err )
318411 })
319412}
0 commit comments