Here are the examples of the csharp api string.Split(params char[]) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
17893 Examples
19
View Source File : BotMainWindow.xaml.cs
License : GNU General Public License v3.0
Project Creator : 00000vish
License : GNU General Public License v3.0
Project Creator : 00000vish
private void getGamesFromFile()
{
string[] gameList = System.IO.File.ReadAllLines(gameListFile);
foreach (string game in gameList)
{
listView1.Items.Add(new ListViewItem() { Content = game.Split('`')[1], Tag = game.Split('`')[0] });
}
}
19
View Source File : ToolWindow.xaml.cs
License : GNU General Public License v3.0
Project Creator : 00000vish
License : GNU General Public License v3.0
Project Creator : 00000vish
private void getGamesFromFile()
{
string[] gameList = System.IO.File.ReadAllLines(GAME_LIST_FILE);
foreach (string game in gameList)
{
listView1.Items.Add(new ListViewItem() { Content = game.Split('`')[1], Tag = game.Split('`')[0] });
}
}
19
View Source File : Helper.cs
License : MIT License
Project Creator : 0ffffffffh
License : MIT License
Project Creator : 0ffffffffh
public static Dictionary<string, string> ParseOptions(string s)
{
Dictionary<string, string> argDict = new Dictionary<string, string>();
string tmp = "";
bool putTmp = false;
string opt = null;
if (string.IsNullOrEmpty(s))
return argDict;
string[] breaks = s.Split(' ');
foreach (string item in breaks)
{
if (item.StartsWith("\""))
{
tmp = item;
putTmp = true;
}
else if (item.EndsWith("\""))
{
putTmp = false;
if (opt != null)
{
argDict.Add(opt, tmp + item);
opt = null;
}
else
argDict.Add(tmp + item, "");
tmp = "";
}
else
{
if (putTmp)
tmp += item;
else
{
var value = item.Trim();
if (value.Length > 0)
{
if (value.StartsWith("-"))
{
if (opt != null)
{
argDict.Add(opt, "");
}
opt = value;
}
else
{
if (opt != null)
{
argDict.Add(opt, value);
opt = null;
}
else
argDict.Add(value, "");
}
}
}
}
}
if (opt != null)
argDict.Add(opt, "");
breaks = null;
return argDict;
}
19
View Source File : CelesteNetClientRC.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
public static NameValueCollection ParseQueryString(string url) {
NameValueCollection nvc = new();
int indexOfSplit = url.IndexOf('?');
if (indexOfSplit == -1)
return nvc;
url = url.Substring(indexOfSplit + 1);
string[] args = url.Split('&');
foreach (string arg in args) {
indexOfSplit = arg.IndexOf('=');
if (indexOfSplit == -1)
continue;
nvc[arg.Substring(0, indexOfSplit)] = arg.Substring(indexOfSplit + 1);
}
return nvc;
}
19
View Source File : ChatCommands.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
public virtual ChatCMDArg Parse() {
// TODO: Improve or rewrite. This comes from GhostNet, which adopted it from disbot (0x0ade's C# Discord bot).
if (int.TryParse(String, out Int)) {
Type = ChatCMDArgType.Int;
Long = IntRangeFrom = IntRangeTo = Int;
ULong = (ulong) Int;
} else if (long.TryParse(String, out Long)) {
Type = ChatCMDArgType.Long;
ULong = (ulong) Long;
} else if (ulong.TryParse(String, out ULong)) {
Type = ChatCMDArgType.ULong;
} else if (float.TryParse(String, out Float)) {
Type = ChatCMDArgType.Float;
}
if (Type == ChatCMDArgType.String) {
string[] split;
int from, to;
if ((split = String.Split('-')).Length == 2) {
if (int.TryParse(split[0].Trim(), out from) && int.TryParse(split[1].Trim(), out to)) {
Type = ChatCMDArgType.IntRange;
IntRangeFrom = from;
IntRangeTo = to;
}
} else if ((split = String.Split('+')).Length == 2) {
if (int.TryParse(split[0].Trim(), out from) && int.TryParse(split[1].Trim(), out to)) {
Type = ChatCMDArgType.IntRange;
IntRangeFrom = from;
IntRangeTo = from + to;
}
}
}
return this;
}
19
View Source File : Frontend.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
public NameValueCollection ParseQueryString(string url) {
NameValueCollection nvc = new();
int indexOfSplit = url.IndexOf('?');
if (indexOfSplit == -1)
return nvc;
url = url.Substring(indexOfSplit + 1);
string[] args = url.Split('&');
foreach (string arg in args) {
indexOfSplit = arg.IndexOf('=');
if (indexOfSplit == -1)
continue;
nvc[arg.Substring(0, indexOfSplit)] = arg.Substring(indexOfSplit + 1);
}
return nvc;
}
19
View Source File : FileSystemHelper.cs
License : zlib License
Project Creator : 0x0ade
License : zlib License
Project Creator : 0x0ade
public static string ChangePath(string path, char separator) {
// Can't trust File.Exists if MONO_IOMAP_ALL is set.
if (!MONO_IOMAP_ALL) {
string pathMaybe = path;
// Check if target exists in the first place.
if (Directory.Exists(path) || File.Exists(path))
return pathMaybe;
// Try a simpler fix first: Maybe the casing is already correct...
pathMaybe = path.Replace('/', separator).Replace('\\', separator);
if (Directory.Exists(pathMaybe) || File.Exists(pathMaybe))
return pathMaybe;
// Fall back to the slow rebuild.
}
// Check if the path has been rebuilt before.
Dictionary<string, string> cachedPaths;
if (!_CachedChanges.TryGetValue(separator, out cachedPaths))
_CachedChanges[separator] = cachedPaths = new Dictionary<string, string>();
string cachedPath;
if (cachedPaths.TryGetValue(path, out cachedPath))
return cachedPath;
// Split and rebuild path.
string[] pathSplit = path.Split(DirectorySeparatorChars);
StringBuilder builder = new StringBuilder();
bool unixRooted = false;
if (Path.IsPathRooted(path)) {
// The first element in a rooted path will always be correct.
// On Windows, this will be the drive letter.
// On Unix and Unix-like systems, this will be empty.
if (unixRooted = (builder.Length == 0))
// Path is rooted, but the path separator is the root.
builder.Append(separator);
else
builder.Append(pathSplit[0]);
}
for (int i = 1; i < pathSplit.Length; i++) {
string next;
if (i < pathSplit.Length - 1)
next = GetDirectory(builder.ToString(), pathSplit[i]);
else
next = GetTarget(builder.ToString(), pathSplit[i]);
next = next ?? pathSplit[i];
if (i != 1 || !unixRooted)
builder.Append(separator);
builder.Append(next);
}
return cachedPaths[path] = builder.ToString();
}
19
View Source File : XnaToFnaHelper.cs
License : zlib License
Project Creator : 0x0ade
License : zlib License
Project Creator : 0x0ade
public static void ApplyChanges(GraphicsDeviceManager self) {
string forceFullscreen = Environment.GetEnvironmentVariable("XNATOFNA_DISPLAY_FULLSCREEN");
if (forceFullscreen == "0")
self.IsFullScreen = false;
else if (forceFullscreen == "1")
self.IsFullScreen = true;
int forceWidth;
if (int.TryParse(Environment.GetEnvironmentVariable("XNATOFNA_DISPLAY_WIDTH") ?? "", out forceWidth))
self.PreferredBackBufferWidth = forceWidth;
int forceHeight;
if (int.TryParse(Environment.GetEnvironmentVariable("XNATOFNA_DISPLAY_HEIGHT") ?? "", out forceHeight))
self.PreferredBackBufferHeight = forceHeight;
string[] forceSize = (Environment.GetEnvironmentVariable("XNATOFNA_DISPLAY_SIZE") ?? "").Split('x');
if (forceSize.Length == 2) {
if (int.TryParse(forceSize[0], out forceWidth))
self.PreferredBackBufferWidth = forceWidth;
if (int.TryParse(forceSize[1], out forceHeight))
self.PreferredBackBufferHeight = forceHeight;
}
self.ApplyChanges();
}
19
View Source File : MaybeExTest.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
private static async MaybeEx<(string arg1, string arg2)> SplitString(string str, bool async)
{
if (async)
{
await Task.Delay(10);
}
str = await ValidateString(str);
var arr = str?.Split(',');
if (arr == null || arr.Length != 2)
{
return await MaybeEx<(string arg1, string arg2)>.Nothing();
}
return (arr[0].Trim(), arr[1].Trim());
}
19
View Source File : MaybeTest.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
private static async Maybe<(string arg1, string arg2)> SplitString(string str, bool async)
{
if (async)
{
await Task.Delay(10);
}
str = await ValidateString(str);
var arr = str?.Split(',');
if (arr == null || arr.Length != 2)
{
return await Maybe<(string arg1, string arg2)>.Nothing();
}
return (arr[0].Trim(), arr[1].Trim());
}
19
View Source File : FLRPC.cs
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5
public static FLInfo GetFLInfo()
{
FLInfo i = new FLInfo();
//Get replacedle
string fullreplacedle;
if (Process.GetProcessesByName("FL").Length >= 1)
{
fullreplacedle = Processes.GetMainWindowsTilteByProcessName("FL");
}
else if (Process.GetProcessesByName("FL64").Length >= 1)
{
fullreplacedle = Processes.GetMainWindowsTilteByProcessName("FL64");
}
else
{
fullreplacedle = null;
}
// Check if project is new/unsaved
//if yes, return null
//if not, return name
if (!fullreplacedle.Contains("-"))
{
i.projectName = null;
i.appName = fullreplacedle;
}
else
{
string[] splitbyminus = fullreplacedle.Split('-');
i.projectName = splitbyminus[0];
i.appName = splitbyminus[1];
}
//return
return i;
}
19
View Source File : DialogueManagerController.cs
License : MIT License
Project Creator : 0xbustos
License : MIT License
Project Creator : 0xbustos
public bool DisplayNextSentence()
{
foreach (LetterComponent letter in this.letters)
{
GameObject.Destroy( letter.gameObject );
}
this.currentSpeed = this.Model.WaitTime;
this.currentEffect = null;
this.effects.Clear();
this.speeds.Clear();
this.letters.Clear();
this.currentX = 0;
this.currentY = 0;
if (sentences.Count == 0)
{
EndDialogue();
return false;
}
this.Model.ImageText.sprite = sprites.Dequeue();
this.sentence = sentences.Dequeue();
this.audioQueue = voices.Dequeue();
this.Model.WaitTime = 0f;
string onlyWords = string.Empty;
for (int i = 0; i < this.sentence.Length; i++)
{
if (this.sentence[i] == '[')
{
i = this.changeSpeed( i );
}
else if (this.sentence[i] == '<')
{
i = this.changeEffect( i );
}
else
{
this.effects.Add( this.currentEffect );
if (this.sentence[i] != ' ')
{
this.speeds.Add( ( float )this.currentSpeed );
}
onlyWords += this.sentence[i];
}
}
string[] words = onlyWords.Split( ' ' );
int letterSpacing = ( int )( this.fontSize * 0.5 );
int currentIndexEffects = 0;
int currentIndexSpeeds = 0;
foreach (string word in words)
{
GameObject wordObject = new GameObject( word, typeof( RectTransform ) );
wordObject.transform.SetParent( this.Model.DialogueStartPoint );
int wordSize = word.Length * letterSpacing;
if (this.currentX + wordSize > this.boxSize)
{
this.currentX = 0;
this.currentY -= ( int )( this.fontSize * 0.9 );
}
wordObject.GetComponent<RectTransform>().localPosition = new Vector3( currentX, currentY, 0 );
for (int i = 0; i < word.Length; i++)
{
GameObject letterObject = new GameObject( word[i].ToString() );
letterObject.transform.SetParent( wordObject.transform );
Text myText = letterObject.AddComponent<Text>();
myText.text = word[i].ToString();
myText.alignment = TextAnchor.LowerCenter;
myText.fontSize = this.fontSize;
myText.font = this.Model.Font;
myText.material = this.Model.Material;
myText.GetComponent<RectTransform>().localPosition = new Vector3( i * letterSpacing, 0, 0 );
myText.color = new Color( 0.0f, 0.0f, 0.0f, 0.0f );
RectTransform rt = letterObject.GetComponentInParent<RectTransform>();
rt.sizeDelta = new Vector2( this.fontSize, this.fontSize );
rt.pivot = new Vector2( 0, 1 );
LetterComponent letterComponent = letterObject.AddComponent<LetterComponent>();
Letter newLetter = new Letter
{
Character = word[i],
Speed = this.speeds[currentIndexSpeeds],
isActive = false
};
if (this.effects[currentIndexEffects] != null)
{
newLetter.Effect = this.effects[currentIndexEffects].Build( letterObject );
}
letterComponent.Model = newLetter;
this.letters.Add( letterComponent );
currentIndexEffects++;
currentIndexSpeeds++;
}
currentX += wordSize + letterSpacing;
currentIndexEffects++;
}
return true;
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5
static void GetInfo()
{
Console.WriteLine("Would you like to replace your current shortcuts on your desktop? (Y/N)");
switch (Console.ReadKey().Key)
{
case ConsoleKey.Y:
ReplaceDesktop = true;
break;
case ConsoleKey.N:
ReplaceDesktop = false;
break;
default:
ReplaceDesktop = false;
break;
}
Console.WriteLine("\n Leave blank if you don't want to add shortcuts");
Console.Write("\n Where would you like to write (additonal) shortcuts? Write the full path to the folder, seperate folder paths with a comma (,): ");
string feed = Console.ReadLine();
if (feed != null)
{
WriteShortcuts = feed.Split(',');
}
Console.Write("\n Enter the version number of FL Studio (e.g 20): ");
VersionNumber = Console.ReadLine();
Console.WriteLine("Thank you! \n \n");
}
19
View Source File : Helper.cs
License : MIT License
Project Creator : 0xDivyanshu
License : MIT License
Project Creator : 0xDivyanshu
static void Main(string[] args)
{
if (args[0].StartsWith("-location") && args[1].StartsWith("-encrypt") && args[2].StartsWith("-preplacedword") && args[3].StartsWith("-saveTo"))
{
string location = args[0].Split('=')[1];
string algo = args[1].Split('=')[1];
string preplaced = args[2].Split('=')[1];
string writeTo = args[3].Split('=')[1];
preplaced = CreateMD5(preplaced);
byte[] shellcode;
if (location.StartsWith("http") || location.StartsWith("\\"))
{
WebClient wc = new WebClient();
string url = location;
shellcode = wc.DownloadData(url);
}
else
{
shellcode = File.ReadAllBytes(location);
}
if (algo == "aes")
{
byte[] encoded_shellcode = Encrypt(shellcode, preplaced,"1234567891234567");
File.WriteAllBytes(writeTo, encoded_shellcode);
Console.WriteLine("[+] Encrypted aes shellcode written to disk");
return;
}
else if (algo == "xor")
{
byte[] encoded_shellcode = xor_enc(shellcode, preplaced);
File.WriteAllBytes(writeTo, encoded_shellcode);
Console.WriteLine("[+] Encrypted xor shellcode written to disk");
return;
}
}
else
{
help_me();
return;
}
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen
License : GNU General Public License v3.0
Project Creator : 0xthirteen
static void Main(string[] args)
{
if (args.Length < 2)
{
Usage();
return;
}
var arguments = new Dictionary<string, string>();
foreach (string argument in args)
{
int idx = argument.IndexOf('=');
if (idx > 0)
arguments[argument.Substring(0, idx)] = argument.Substring(idx + 1);
}
string username = "";
string preplacedword = "";
if (arguments.ContainsKey("username"))
{
if (!arguments.ContainsKey("preplacedword"))
{
Usage();
return;
}
else
{
username = arguments["username"];
preplacedword = arguments["preplacedword"];
}
}
if (arguments.ContainsKey("preplacedword") && !arguments.ContainsKey("username"))
{
Usage();
return;
}
if (arguments.ContainsKey("computername"))
{
string[] computerNames = arguments["computername"].Split(',');
string eventName = "Debug";
string location = "local";
string droplocation = @"C:\Windows\Temp";
string wnamespace = "root\\CIMv2";
string filename = string.Empty;
string valuename = string.Empty;
string keypath = string.Empty;
string clreplacedname = string.Empty;
foreach (string computerName in computerNames)
{
if (arguments.ContainsKey("eventname"))
{
eventName = arguments["eventname"];
}
if (arguments.ContainsKey("location"))
{
location = arguments["location"];
}
if (arguments.ContainsKey("droplocation"))
{
droplocation = arguments["droplocation"];
}
if (arguments.ContainsKey("filename"))
{
filename = arguments["filename"];
}
if (arguments.ContainsKey("clreplacedname"))
{
clreplacedname = arguments["clreplacedname"];
}
if (arguments.ContainsKey("keypath"))
{
keypath = arguments["keypath"];
}
if (arguments.ContainsKey("valuename"))
{
valuename = arguments["valuename"];
}
if (arguments.ContainsKey("wminamespace"))
{
wnamespace = arguments["wminamespace"];
}
if (arguments.ContainsKey("writetype"))
{
if (arguments["writetype"].ToLower() == "wmi")
{
GetFileContent(location, droplocation, filename, "flat");
WriteToFileWMI(computerName, eventName, username, preplacedword);
}
else if (arguments["writetype"].ToLower() == "smb")
{
WriteToFileSMB(computerName, droplocation, filename, location);
}
else if(arguments["writetype"].ToLower() == "registry")
{
if (valuename == string.Empty)
{
Console.WriteLine("[-] Valuename is required");
return;
}
GetFileContent(location, droplocation, filename, "nonflat");
WriteToRegKey(computerName, username, preplacedword, keypath, valuename);
}
else if (arguments["writetype"].ToLower() == "wmiclreplaced")
{
GetFileContent(location, droplocation, filename, "nonflat");
WriteToWMIClreplaced(computerName, username, preplacedword, wnamespace, clreplacedname);
}
else if (arguments["writetype"].ToLower() == "removewmiclreplaced")
{
RemoveWMIClreplaced(computerName, username, preplacedword, wnamespace, clreplacedname);
}
else if (arguments["writetype"].ToLower() == "removeregkey")
{
RemoveRegValue(computerName, username, preplacedword, keypath, valuename);
}
else
{
Usage();
return;
}
}
else
{
Usage();
}
}
}
else
{
Usage();
return;
}
}
19
View Source File : FileWrite.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen
License : GNU General Public License v3.0
Project Creator : 0xthirteen
static void RemoveRegValue(string host, string username, string preplacedword, string keypath, string keyname)
{
if (!keypath.Contains(":"))
{
Console.WriteLine("[-] Please put ':' inbetween hive and path: HKCU:Location\\Of\\Key");
return;
}
if (!String.IsNullOrEmpty(host))
{
host = "127.0.0.1";
}
string[] reginfo = keypath.Split(':');
string reghive = reginfo[0];
string wmiNameSpace = "root\\CIMv2";
UInt32 hive = 0;
switch (reghive.ToUpper())
{
case "HKCR":
hive = 0x80000000;
break;
case "HKCU":
hive = 0x80000001;
break;
case "HKLM":
hive = 0x80000002;
break;
case "HKU":
hive = 0x80000003;
break;
case "HKCC":
hive = 0x80000005;
break;
default:
Console.WriteLine("[X] Error : Could not get the right reg hive");
return;
}
ConnectionOptions options = new ConnectionOptions();
Console.WriteLine("[+] Target : {0}", host);
if (!String.IsNullOrEmpty(username))
{
Console.WriteLine("[+] User : {0}", username);
options.Username = username;
options.Preplacedword = preplacedword;
}
Console.WriteLine();
ManagementScope scope = new ManagementScope(String.Format("\\\\{0}\\{1}", host, wmiNameSpace), options);
try
{
scope.Connect();
Console.WriteLine("[+] WMI connection established");
}
catch (Exception ex)
{
Console.WriteLine("[X] Failed to connecto to WMI : {0}", ex.Message);
return;
}
try
{
//Probably stay with string value only
ManagementClreplaced registry = new ManagementClreplaced(scope, new ManagementPath("StdRegProv"), null);
ManagementBaseObject inParams = registry.GetMethodParameters("DeleteValue");
inParams["hDefKey"] = hive;
inParams["sSubKeyName"] = keypath;
inParams["sValueName"] = keyname;
ManagementBaseObject outParams1 = registry.InvokeMethod("DeleteValue", inParams, null);
Console.WriteLine("[+] Deleted value at {0} {1}", keypath, keyname);
}
catch (Exception ex)
{
Console.WriteLine(String.Format("[-] {0}", ex.Message));
return;
}
}
19
View Source File : VistaFileSaveDialog.cs
License : GNU General Public License v3.0
Project Creator : 0xC0000054
License : GNU General Public License v3.0
Project Creator : 0xC0000054
private NativeStructs.COMDLG_FILTERSPEC[] GetFilterItems()
{
List<NativeStructs.COMDLG_FILTERSPEC> filterItems = new List<NativeStructs.COMDLG_FILTERSPEC>();
if (!string.IsNullOrWhiteSpace(filter))
{
string[] splireplacedems = filter.Split('|');
// The split filter string array must contain an even number of items.
if ((splireplacedems.Length & 1) == 0)
{
for (int i = 0; i < splireplacedems.Length; i += 2)
{
NativeStructs.COMDLG_FILTERSPEC filterSpec = new NativeStructs.COMDLG_FILTERSPEC
{
pszName = splireplacedems[i],
pszSpec = splireplacedems[i + 1]
};
filterItems.Add(filterSpec);
}
}
}
return filterItems.ToArray();
}
19
View Source File : SQLite.cs
License : GNU General Public License v3.0
Project Creator : 0xfd3
License : GNU General Public License v3.0
Project Creator : 0xfd3
public bool ReadTable(string TableName)
{
int index = -1;
int length = this.master_table_entries.Length - 1;
for (int i = 0; i <= length; i++)
{
if (this.master_table_entries[i].item_name.ToLower().CompareTo(TableName.ToLower()) == 0)
{
index = i;
break;
}
}
if (index == -1)
{
return false;
}
string[] strArray = this.master_table_entries[index].sql_statement.Substring(this.master_table_entries[index].sql_statement.IndexOf("(") + 1).Split(new char[] { ',' });
int num6 = strArray.Length - 1;
for (int j = 0; j <= num6; j++)
{
strArray[j] = (strArray[j]).TrimStart();
int num4 = strArray[j].IndexOf(" ");
if (num4 > 0)
{
strArray[j] = strArray[j].Substring(0, num4);
}
if (strArray[j].IndexOf("UNIQUE") == 0)
{
break;
}
this.field_names = (string[])Utils.CopyArray((Array)this.field_names, new string[j + 1]);
this.field_names[j] = strArray[j];
}
return this.ReadTableFromOffset((ulong)((this.master_table_entries[index].root_num - 1L) * this.page_size));
}
19
View Source File : Program.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen
static void Main(string[] args)
{
AppDomain.CurrentDomain.replacedemblyResolve += (sender, argtwo) => {
replacedembly thisreplacedembly = replacedembly.GetEntryreplacedembly();
String resourceName = string.Format("SharpRDP.{0}.dll.bin",
new replacedemblyName(argtwo.Name).Name);
var replacedembly = replacedembly.GetExecutingreplacedembly();
using (var rs = replacedembly.GetManifestResourceStream(resourceName))
using (var zs = new DeflateStream(rs, CompressionMode.Decompress))
using (var ms = new MemoryStream())
{
zs.CopyTo(ms);
return replacedembly.Load(ms.ToArray());
}
};
var arguments = new Dictionary<string, string>();
foreach (string argument in args)
{
int idx = argument.IndexOf('=');
if (idx > 0)
arguments[argument.Substring(0, idx)] = argument.Substring(idx + 1);
}
string username = string.Empty;
string domain = string.Empty;
string preplacedword = string.Empty;
string command = string.Empty;
string execElevated = string.Empty;
string execw = "";
bool connectdrive = false;
bool takeover = false;
bool nla = false;
if (arguments.ContainsKey("username"))
{
if (!arguments.ContainsKey("preplacedword"))
{
Console.WriteLine("[X] Error: A preplacedword is required");
return;
}
else
{
if (arguments["username"].Contains("\\"))
{
string[] tmp = arguments["username"].Split('\\');
domain = tmp[0];
username = tmp[1];
}
else
{
domain = ".";
username = arguments["username"];
}
preplacedword = arguments["preplacedword"];
}
}
if (arguments.ContainsKey("preplacedword") && !arguments.ContainsKey("username"))
{
Console.WriteLine("[X] Error: A username is required");
return;
}
if ((arguments.ContainsKey("computername")) && (arguments.ContainsKey("command")))
{
Client rdpconn = new Client();
command = arguments["command"];
if (arguments.ContainsKey("exec"))
{
if (arguments["exec"].ToLower() == "cmd")
{
execw = "cmd";
}
else if (arguments["exec"].ToLower() == "powershell" || arguments["exec"].ToLower() == "ps")
{
execw = "powershell";
}
}
if (arguments.ContainsKey("elevated"))
{
if(arguments["elevated"].ToLower() == "true" || arguments["elevated"].ToLower() == "win+r" || arguments["elevated"].ToLower() == "winr")
{
execElevated = "winr";
}
else if(arguments["elevated"].ToLower() == "taskmgr" || arguments["elevated"].ToLower() == "taskmanager")
{
execElevated = "taskmgr";
}
else
{
execElevated = string.Empty;
}
}
if (arguments.ContainsKey("connectdrive"))
{
if(arguments["connectdrive"].ToLower() == "true")
{
connectdrive = true;
}
}
if (arguments.ContainsKey("takeover"))
{
if (arguments["takeover"].ToLower() == "true")
{
takeover = true;
}
}
if (arguments.ContainsKey("nla"))
{
if (arguments["nla"].ToLower() == "true")
{
nla = true;
}
}
string[] computerNames = arguments["computername"].Split(',');
foreach (string server in computerNames)
{
rdpconn.CreateRdpConnection(server, username, domain, preplacedword, command, execw, execElevated, connectdrive, takeover, nla);
}
}
else
{
HowTo();
return;
}
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen
License : GNU General Public License v3.0
Project Creator : 0xthirteen
static void WriteToRegKey(string host, string username, string preplacedword, string keypath, string valuename)
{
if (!keypath.Contains(":"))
{
Console.WriteLine("[-] Please put ':' inbetween hive and path: HKCU:Location\\Of\\Key");
return;
}
string[] reginfo = keypath.Split(':');
string reghive = reginfo[0];
string wmiNameSpace = "root\\CIMv2";
UInt32 hive = 0;
switch (reghive.ToUpper())
{
case "HKCR":
hive = 0x80000000;
break;
case "HKCU":
hive = 0x80000001;
break;
case "HKLM":
hive = 0x80000002;
break;
case "HKU":
hive = 0x80000003;
break;
case "HKCC":
hive = 0x80000005;
break;
default:
Console.WriteLine("[X] Error : Could not get the right reg hive");
return;
}
ConnectionOptions options = new ConnectionOptions();
Console.WriteLine("[+] Target : {0}", host);
if (!String.IsNullOrEmpty(username))
{
Console.WriteLine("[+] User : {0}", username);
options.Username = username;
options.Preplacedword = preplacedword;
}
Console.WriteLine();
ManagementScope scope = new ManagementScope(String.Format("\\\\{0}\\{1}", host, wmiNameSpace), options);
try
{
scope.Connect();
Console.WriteLine("[+] WMI connection established");
}
catch (Exception ex)
{
Console.WriteLine("[X] Failed to connect to to WMI : {0}", ex.Message);
return;
}
try
{
//Probably stay with string value only
ManagementClreplaced registry = new ManagementClreplaced(scope, new ManagementPath("StdRegProv"), null);
ManagementBaseObject inParams = registry.GetMethodParameters("SetStringValue");
inParams["hDefKey"] = hive;
inParams["sSubKeyName"] = reginfo[1];
inParams["sValueName"] = valuename;
inParams["sValue"] = datavals;
ManagementBaseObject outParams = registry.InvokeMethod("SetStringValue", inParams, null);
if(Convert.ToInt32(outParams["ReturnValue"]) == 0)
{
Console.WriteLine("[+] Created {0} {1} and put content inside", keypath, valuename);
}
else
{
Console.WriteLine("[-] An error occured, please check values");
return;
}
}
catch (Exception ex)
{
Console.WriteLine(String.Format("[X] Error : {0}", ex.Message));
return;
}
}
19
View Source File : Dumper.cs
License : MIT License
Project Creator : 13xforever
License : MIT License
Project Creator : 13xforever
private List<string> EnumeratePhysicalDrivesLinux()
{
var cdInfo = "";
try
{
cdInfo = File.ReadAllText("/proc/sys/dev/cdrom/info");
}
catch (Exception e)
{
Log.Debug(e, e.Message);
}
var lines = cdInfo.Split(MultilineSplit, StringSplitOptions.RemoveEmptyEntries);
return lines.Where(s => s.StartsWith("drive name:")).Select(l => Path.Combine("/dev", l.Split(':').Last().Trim())).Where(File.Exists)
.Concat(IOEx.GetFilepaths("/dev", "sr*", SearchOption.TopDirectoryOnly))
.Distinct()
.ToList();
}
19
View Source File : GeneratorClass.cs
License : MIT License
Project Creator : 188867052
License : MIT License
Project Creator : 188867052
private static string GetCrefNamespace(string cref, string @namespace)
{
IList<string> sameString = new List<string>();
var splitNamespace = @namespace.Split('.');
var splitCref = cref.Split('.');
int minLength = Math.Min(splitNamespace.Length, splitCref.Length);
for (int i = 0; i < minLength; i++)
{
if (splitCref[i] == splitNamespace[i])
{
sameString.Add(splitCref[i]);
}
else
{
break;
}
}
cref = cref.Substring(string.Join('.', sameString).Length + 1);
return cref;
}
19
View Source File : Form1.cs
License : MIT License
Project Creator : 1y0n
License : MIT License
Project Creator : 1y0n
private string Handle_Payload()
{
//对用户输入的payload进行一些转换处理,方便下一步的加密
string raw_input = textBox1.Text.Trim().Replace("\r\n", "").Replace("\n", "").Replace("\r", ""); //支持多种linux win换行符
string payload_pattern_csharp = @"\{(.+?)\}";
string payload_pattern_c = @"=.*"";$";
string[] raw_payload_array;
if (Regex.IsMatch(raw_input, payload_pattern_c))
{
//c语言格式的shellcode,转成 csharp 格式
raw_input = raw_input.Replace("\"", "").Replace("\\", ",0").Replace(";", "").Replace("=", "{").Replace("{,", "{ ") + " }";
}
string raw_payload = Regex.Matches(raw_input, payload_pattern_csharp)[0].Value.Replace("{", "").Replace("}", "").Trim();
raw_payload = raw_payload.TrimStart(',');
raw_payload_array = raw_payload.Split(',');
List<byte> byte_payload_list = new List<byte>();
foreach (string i in raw_payload_array)
{
byte_payload_list.Add(string_to_int(i));
}
byte[] payload_result = byte_payload_list.ToArray();
//加密payload并转换为字符串,准备写入文件
byte[] encrypted_payload = Encrypter.Encrypt(KEY, payload_result);
string string_encrypted_payload = string.Join(",", encrypted_payload);
//MessageBox.Show(string_encrypted_payload);
return string_encrypted_payload;
}
19
View Source File : ConditionTaskForm.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
public void RenderConditionFinish(int index)
{
string condition = cmdShell.Condition;
string[] items = condition.Split(';');
if (items.Length >= index)
{
string[] arrs = items[index - 1].Split(',');
ConditionItem ci = null;
SpringBootMonitorItem spring = null;
TomcatMonitorItem tomcat = null;
NginxMonitorItem nginx = null;
string uuid = "", itemUuid = "";
int itemIndex = 0;
SkinComboBox combo = null;
if (index == 1)
{
combo = scb_condition1;
}
else if (index == 2)
{
combo = scb_condition2;
}
else if (index == 3)
{
combo = scb_condition3;
}
foreach (var item in combo.Items)
{
ci = (ConditionItem)item;
if(ci.Index == 0){
spring = (SpringBootMonitorItem) ci.Item;
uuid = spring.Uuid;
itemIndex = spring.Index;
}
else if (ci.Index == 1)
{
tomcat = (TomcatMonitorItem)ci.Item;
uuid = spring.Uuid;
itemIndex = spring.Index;
}
else if (ci.Index == 2)
{
nginx = (NginxMonitorItem)ci.Item;
uuid = spring.Uuid;
itemIndex = spring.Index;
}
if (index == 1)
{
itemUuid = arrs[0];
}
else
{
itemUuid = arrs[0].Substring(1);
}
if (uuid == itemUuid)
{
combo.SelectedItem = item;
InitConditionStatus(index, itemIndex);
break;
}
}
// ========================
if (index == 1)
{
scb_status1.SelectedIndex = arrs[1] == "Y" ? 1 : 0;
if (items.Length >= 2)
{
if (items[index].Substring(0, 1) == "&")
{
rb_q1.Checked = true;
}
else
{
rb_h1.Checked = true;
}
InitCondition(2, new RenderFinishDelegate(RenderConditionFinish));
}
}
else if (index == 2)
{
scb_status2.SelectedIndex = arrs[1] == "Y" ? 1 : 0;
if (items.Length >= 3)
{
if (items[index].Substring(0, 1) == "&")
{
rb_q2.Checked = true;
}
else
{
rb_h2.Checked = true;
}
InitCondition(3, new RenderFinishDelegate(RenderConditionFinish));
}
}
else if (index == 3)
{
scb_status3.SelectedIndex = arrs[1] == "Y" ? 1 : 0;
}
}
}
19
View Source File : Form1.cs
License : MIT License
Project Creator : 1y0n
License : MIT License
Project Creator : 1y0n
private byte[] Random_Key()
{
string t = "";
for (int i = 0; i < 23; i++)
{
RNGCryptoServiceProvider csp = new RNGCryptoServiceProvider();
byte[] byteCsp = new byte[23];
csp.GetBytes(byteCsp);
t = BitConverter.ToString(byteCsp);
}
string[] t_array = t.Split('-');
List<byte> key_list = new List<byte>();
foreach (string i in t_array)
{
key_list.Add(string_to_int(i));
}
return key_list.ToArray();
}
19
View Source File : Core.cs
License : MIT License
Project Creator : 1y0n
License : MIT License
Project Creator : 1y0n
public static string XOR_C(string format, string raw)
{
string result = "";
string[] shellcode_array = raw.Split(',');
string[] temp = new string[shellcode_array.Length];
int j = 234;
int add = 12;
for (int i = 0; i < shellcode_array.Length; i++)
{
temp[i] = string.Format("{0:x2}", string_to_int(shellcode_array[i]) ^ 123 ^ j);
temp[i] = "0x" + temp[i].Substring(temp[i].Length - 2, 2);
j += add;
}
result = string.Join(",", temp);
//转换一下格式
if (format == "c")
{
result = result.Replace("0x", @"\x").Replace(",", "");
}
return result;
}
19
View Source File : Form1.cs
License : MIT License
Project Creator : 200Tigersbloxed
License : MIT License
Project Creator : 200Tigersbloxed
void checkForMessage()
{
WebClient client = new WebClient();
Stream stream = client.OpenRead("https://pastebin.com/raw/vaXRephy");
StreamReader reader = new StreamReader(stream);
String content = reader.ReadToEnd();
string[] splitcontent = content.Split('|');
if(splitcontent[0] == "Y")
{
MessageBox.Show(splitcontent[1], "Message From Developer", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
19
View Source File : IceMonitorForm.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
private void btn_run_Click(object sender, EventArgs e)
{
string cmdstr = shellView.Text;
if(!string.IsNullOrWhiteSpace(cmdstr)){
string[] cmdArr = cmdstr.Split('\n');
foreach(string cmd in cmdArr){
monitorForm.RunShell(cmd.Trim(), true, true);
Thread.Sleep(100);
}
}
}
19
View Source File : MonitorItemForm.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
private void stb_home_url_Enter(object sender, EventArgs e)
{
string sdir = stb_project_source_dir.Text;
string appname = stb_app_name.Text;
string url = stb_home_url.Text;
if(!string.IsNullOrWhiteSpace(sdir) && !string.IsNullOrWhiteSpace(appname) && url.EndsWith("[port]")){
try
{
if (get_spboot_port_run)
{
return;
}
get_spboot_port_run = true;
if (!sdir.EndsWith("/"))
{
sdir += "/";
}
string serverxml = string.Format("{0}{1}/src/main/resources/config/application-dev.yml", sdir, appname);
string targetxml = MainForm.TEMP_DIR + string.Format("application-dev-{0}.yml", DateTime.Now.ToString("MMddHHmmss"));
targetxml = targetxml.Replace("\\", "/");
parentForm.RunSftpShell(string.Format("get {0} {1}", serverxml, targetxml), false, false);
ThreadPool.QueueUserWorkItem((a) =>
{
Thread.Sleep(500);
string port = "", ctx = "";
string yml = YSTools.YSFile.readFileToString(targetxml);
if(!string.IsNullOrWhiteSpace(yml)){
string[] lines = yml.Split('\n');
bool find = false;
int index = 0, start = 0;
foreach(string line in lines){
if (line.Trim().StartsWith("server:"))
{
find = true;
start = index;
}
else if(find && line.Trim().StartsWith("port:")){
port = line.Substring(line.IndexOf(":") + 1).Trim();
}
else if (find && line.Trim().StartsWith("context-path:"))
{
ctx = line.Substring(line.IndexOf(":") + 1).Trim();
}
if (index - start > 4 && start > 0)
{
break;
}
index++;
}
}
if (port != "")
{
stb_home_url.BeginInvoke((MethodInvoker)delegate()
{
stb_home_url.Text = string.Format("http://{0}:{1}{2}", config.Host, port, ctx);
});
}
get_spboot_port_run = false;
File.Delete(targetxml);
});
}
catch(Exception ex) {
logger.Error("Error", ex);
}
}
}
19
View Source File : Form2.cs
License : MIT License
Project Creator : 200Tigersbloxed
License : MIT License
Project Creator : 200Tigersbloxed
void InstallMultiContinued()
{
statuslabel.Text = "Status: Extracting Files";
progressBar1.Value = 80;
DirectoryInfo di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\Files");
foreach (FileInfo file in di.GetFiles())
{
string[] splitdot = file.Name.Split('.');
if (splitdot[1] == "zip")
{
ZipFile.ExtractToDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Files\" + splitdot[0] + @".zip", @"Files\" + splitdot[0]);
}
}
statuslabel.Text = "Status: Moving Files";
progressBar1.Value = 90;
foreach (DirectoryInfo dir in di.GetDirectories())
{
if (multiselected == "a")
{
if (dir.Name == "ca")
{
DirectoryInfo cadi = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\Files\ca");
if (Directory.Exists(bsl + @"\CustomAvatars"))
{
// dont u dare delete someone's custom avatars folder
}
else
{
Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Files\ca\CustomAvatars", bsl + @"\CustomAvatars");
}
if (Directory.Exists(bsl + @"\DynamicOpenVR"))
{
Directory.Delete(bsl + @"\DynamicOpenVR", true);
Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Files\ca\DynamicOpenVR", bsl + @"\DynamicOpenVR");
}
else
{
Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Files\ca\DynamicOpenVR", bsl + @"\DynamicOpenVR");
}
foreach (DirectoryInfo cadir in cadi.GetDirectories())
{
if (cadir.Name == "Plugins")
{
// Don't move CustomAvatar's DLL
}
}
}
}
if(dir.Name == "dc")
{
DirectoryInfo dcdi = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"Files\dc");
foreach (DirectoryInfo dcdir in dcdi.GetDirectories())
{
if (dcdir.Name == "Plugins")
{
foreach (FileInfo file in dcdir.GetFiles())
{
if (File.Exists(bsl + @"\Plugins\" + file.Name)) {
File.Delete(bsl + @"\Plugins\" + file.Name);
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
else
{
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
}
}
if (dcdir.Name == "Libs")
{
foreach (DirectoryInfo dcnativedir in dcdir.GetDirectories())
{
if (Directory.Exists(bsl + @"\Libs\Native")) {
Directory.Delete(bsl + @"\Libs\Native", true);
Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Files\dc\Libs\Native", bsl + @"\Libs\Native");
}
else
{
Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Files\dc\Libs\Native", bsl + @"\Libs\Native");
}
}
}
}
}
if(dir.Name == "dep")
{
DirectoryInfo depdi = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"Files\dep\dep");
foreach (DirectoryInfo depdir in depdi.GetDirectories())
{
if (depdir.Name == "Plugins")
{
foreach (FileInfo file in depdir.GetFiles())
{
if (File.Exists(bsl + @"\Plugins\" + file.Name)) {
File.Delete(bsl + @"\Plugins\" + file.Name);
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
else
{
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
}
}
}
}
if (multiselected == "a")
{
if (dir.Name == "dovr")
{
DirectoryInfo dovrdi = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"Files\dovr");
foreach (DirectoryInfo dovrdir in dovrdi.GetDirectories())
{
if (dovrdir.Name == "Plugins")
{
foreach (FileInfo file in dovrdir.GetFiles())
{
if (File.Exists(bsl + @"\Plugins\" + file.Name))
{
File.Delete(bsl + @"\Plugins\" + file.Name);
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
else
{
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
}
}
if (dovrdir.Name == "Libs")
{
foreach (FileInfo file in dovrdir.GetFiles())
{
if (File.Exists(bsl + @"\Libs\" + file.Name))
{
File.Delete(bsl + @"\Libs\" + file.Name);
File.Move(file.FullName, bsl + @"\Libs\" + file.Name);
}
else
{
File.Move(file.FullName, bsl + @"\Libs\" + file.Name);
}
}
}
}
}
}
if (dir.Name == "multiplayer")
{
DirectoryInfo multiplayerdi = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"Files\multiplayer");
foreach (DirectoryInfo multiplayerdir in multiplayerdi.GetDirectories())
{
if (multiplayerdir.Name == "Plugins")
{
foreach (FileInfo file in multiplayerdir.GetFiles())
{
if (File.Exists(bsl + @"\Plugins\" + file.Name)) {
File.Delete(bsl + @"\Plugins\" + file.Name);
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
else
{
File.Move(file.FullName, bsl + @"\Plugins\" + file.Name);
}
}
}
if (multiplayerdir.Name == "Libs")
{
foreach (FileInfo file in multiplayerdir.GetFiles())
{
if (File.Exists(bsl + @"\Libs\" + file.Name)) {
File.Delete(bsl + @"\Libs\" + file.Name);
File.Move(file.FullName, bsl + @"\Libs\" + file.Name);
}
else
{
File.Move(file.FullName, bsl + @"\Libs\" + file.Name);
}
}
}
}
}
}
if(multiselected == "a")
{
if (File.Exists(@"Files\CustomAvatar.dll"))
{
if (File.Exists(bsl + @"\Plugins\CustomAvatar.dll"))
{
File.Delete(bsl + @"\Plugins\CustomAvatar.dll");
File.Move(@"Files\CustomAvatar.dll", bsl + @"\Plugins\CustomAvatar.dll");
}
else
{
File.Move(@"Files\CustomAvatar.dll", bsl + @"\Plugins\CustomAvatar.dll");
}
}
}
statuslabel.Text = "Status: Complete!";
progressBar1.Value = 100;
allowinstalluninstall = true;
currentlyinstallinguninstalling = false;
button3.BackColor = SystemColors.MenuHighlight;
button4.BackColor = SystemColors.MenuHighlight;
DialogResult dialogResult = MessageBox.Show("Multiplayer is installed! Would you like to exit?", "Complete!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
{
Application.Exit();
}
}
19
View Source File : FileAttrForm.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
private string getFileOwner(string str, int size)
{
string user = "";
if (null != str && str.Length > 5 && str.IndexOf(" ") != -1)
{
string[] arrs = str.Split(' ');
if (arrs.Length > size)
{
int i = 0, j = 0;
foreach (string s in arrs)
{
if (!string.IsNullOrWhiteSpace(s))
{
i++;
if (i >= size)
{
user = arrs[j];
break;
}
}
j++;
}
}
}
return user;
}
19
View Source File : NginxMonitorForm.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
private void btn_run_Click(object sender, EventArgs e)
{
string cmdstr = shellView.Text;
if (!string.IsNullOrWhiteSpace(cmdstr))
{
string[] cmdArr = cmdstr.Split('\n');
foreach (string cmd in cmdArr)
{
monitorForm.RunShell(cmd.Trim(), true);
Thread.Sleep(100);
}
}
}
19
View Source File : YmlFormatUtil.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
public static List<YmlLine> FormatYml(string content, bool beautify = false)
{
List<YmlLine> list = new List<YmlLine>();
string[] lines = content.Split('\n');
YmlLine ylText = null;
int index1 = -1, index2 = -1, count = 0, num = 0;
string startStr = null, endStr = null, line = "";
string key = null, value = null, mh = ":";
List<int> levels = new List<int>();
for(int i = 0, k = lines.Length; i < k; i++){
line = lines[i];
if(line.TrimStart().StartsWith("#")){
ylText = new YmlLine()
{
Text = line + "\n",
Color = Color.Gray
};
list.Add(ylText);
}
else
{
// 非整行注释
// 美化
if (beautify)
{
count = StartSpaceCount(line);
if (count == 0)
{
levels.Clear();
}
// level
if (!levels.Contains(count))
{
levels.Add(count);
levels.Sort();
}
num = levels.IndexOf(count) * 4;
if (num > count)
{
line = GetSpace(num - count) + line;
}
}
// 行中有井号,但不是首位#
index2 = line.IndexOf("#");
if(index2 > 0){
startStr = line.Substring(0, index2);
index1 = startStr.IndexOf(":");
if (index1 > 0)
{
// key
key = startStr.Substring(0, index1);
ylText = new YmlLine()
{
Text = key,
Color = Color.OrangeRed
};
list.Add(ylText);
// :
ylText = new YmlLine()
{
Text = mh,
Color = Color.Violet
};
list.Add(ylText);
// value
value = startStr.Substring(index1 + 1);
ylText = new YmlLine()
{
Text = value,
Color = getTextColor(value)
};
list.Add(ylText);
}
else
{
ylText = new YmlLine()
{
Text = "#" + startStr,
Color = Color.Gray
};
list.Add(ylText);
}
// 注释掉的部分
endStr = line.Substring(index2);
ylText = new YmlLine()
{
Text = endStr + "\n",
Color = Color.Gray
};
list.Add(ylText);
}
else
{
// 行中无井号
startStr = line;
index1 = startStr.IndexOf(":");
if (index1 > 0)
{
// key
key = startStr.Substring(0, index1);
ylText = new YmlLine()
{
Text = key,
Color = Color.OrangeRed
};
list.Add(ylText);
// :
ylText = new YmlLine()
{
Text = mh,
Color = Color.Violet
};
list.Add(ylText);
// value
value = startStr.Substring(index1 + 1);
ylText = new YmlLine()
{
Text = value + "\n",
Color = getTextColor(value)
};
list.Add(ylText);
}
else
{
// 行中无井号,且是不合规的配置值
if (string.IsNullOrWhiteSpace(line))
{
ylText = new YmlLine()
{
Text = line + "\n",
Color = Color.OrangeRed
};
}
else
{
ylText = new YmlLine()
{
Text = "#" + line + "\n",
Color = Color.Gray
};
}
list.Add(ylText);
}
}
}
}
return list;
}
19
View Source File : YmlFormatUtil.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
public static YmlError ValidateYml(string content)
{
YmlError result = null;
string[] lines = content.Split('\n');
int index1 = -1, index2 = -1, lineIndex = 1, index = 0;
string startStr = null;
foreach (string line in lines)
{
if (!line.TrimStart().StartsWith("#"))
{
if (line.IndexOf(" ") != -1 && line.Substring(0, line.IndexOf(" ")).IndexOf("#") == -1)
{
result = new YmlError();
result.line = lineIndex;
result.index = content.IndexOf(" ", index);
result.msg = string.Format("第{0}行,位置{1}包含Tab符", lineIndex, line.IndexOf(" "));
break;
}
else if (!string.IsNullOrWhiteSpace(line))
{
index2 = line.IndexOf("#");
if (index2 > 0)
{
startStr = line.Substring(0, index2);
index1 = startStr.IndexOf(":");
if (index1 <= 0)
{
result = new YmlError();
result.line = lineIndex;
result.index = index;
result.msg = string.Format("第{0}行,格式不正确,缺少冒号", lineIndex);
break;
}
}
else
{
index1 = line.IndexOf(":");
if (index1 <= 0)
{
result = new YmlError();
result.line = lineIndex;
result.index = index;
result.msg = string.Format("第{0}行,格式不正确,缺少冒号", lineIndex);
break;
}
}
}
}
lineIndex++;
index += line.Length;
}
return result;
}
19
View Source File : TsCreator.cs
License : MIT License
Project Creator : 279328316
License : MIT License
Project Creator : 279328316
private string GetTsType(string typeName)
{
string tsTypeStr = "";
List<string> numberTypeList =
("int,int?,int16,int16?,int32,int32?,int64,int64?,decimal,decimal?," +
"double,double?,byte,byte?,long,long?,single,single?").Split(',').ToList();
List<string> boolTypeList = ("bool,bool?,boolean,boolean?").Split(',').ToList();
List<string> stringTypeList =
("string,guid,guid?").Split(',').ToList();
List<string> dateTimeTypeList =
("datetime,datetime?").Split(',').ToList();
if (boolTypeList.Contains(typeName.ToLower()))
{
tsTypeStr = "boolean";
}
else if (stringTypeList.Contains(typeName.ToLower()))
{
tsTypeStr = "string";
}
else if (dateTimeTypeList.Contains(typeName.ToLower()))
{
tsTypeStr = "Date";
}
else if (numberTypeList.Contains(typeName.ToLower()))
{
tsTypeStr = "number";
}
else
{
tsTypeStr = typeName;
#region 去掉Dto,Model命名
if (tsTypeStr.EndsWith("Dto"))
{ //参数类型名称 去掉末尾Dto,Model命名
tsTypeStr = tsTypeStr.Substring(0, tsTypeStr.LastIndexOf("Dto"));
}
else if (tsTypeStr.EndsWith("Dto>"))
{
tsTypeStr = tsTypeStr.Substring(0, tsTypeStr.LastIndexOf("Dto")) + ">";
}
else if (tsTypeStr.EndsWith("Model"))
{
tsTypeStr = tsTypeStr.Substring(0, tsTypeStr.LastIndexOf("Model"));
}
else if (tsTypeStr.EndsWith("Model>"))
{
tsTypeStr = tsTypeStr.Substring(0, tsTypeStr.LastIndexOf("Model")) + ">";
}
#endregion
}
return tsTypeStr;
}
19
View Source File : Resp3HelperTests.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
static object[] PrepareCmd(string cmd, string subcmd = null, params object[] parms)
{
if (string.IsNullOrWhiteSpace(cmd)) throw new ArgumentNullException("Redis command not is null or empty.");
object[] args = null;
if (parms?.Any() != true)
{
if (string.IsNullOrWhiteSpace(subcmd) == false) args = new object[] { cmd, subcmd };
else args = cmd.Split(' ').Where(a => string.IsNullOrWhiteSpace(a) == false).ToArray();
}
else
{
var issubcmd = string.IsNullOrWhiteSpace(subcmd) == false;
args = new object[parms.Length + 1 + (issubcmd ? 1 : 0)];
var argsIdx = 0;
args[argsIdx++] = cmd;
if (issubcmd) args[argsIdx++] = subcmd;
foreach (var prm in parms) args[argsIdx++] = prm;
}
return args;
}
19
View Source File : TomcatMonitorForm.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
private void btn_run_Click(object sender, EventArgs e)
{
string cmdstr = shellView.Text;
if (!string.IsNullOrWhiteSpace(cmdstr))
{
string[] cmdArr = cmdstr.Split('\n');
foreach (string cmd in cmdArr)
{
monitorForm.RunShell(cmd.Trim(), true, true);
Thread.Sleep(100);
}
}
}
19
View Source File : CustomShellForm.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
private void button1_Click(object sender, EventArgs e)
{
string name = stb_name.Text;
string cmdstr = cmd.Text;
if(string.IsNullOrWhiteSpace(name)){
MessageBox.Show(this, "请定义一个名称");
return;
}
if (string.IsNullOrWhiteSpace(cmdstr))
{
MessageBox.Show(this, "请输入要执行的命令");
return;
}
List<TaskShell> cmdList = new List<TaskShell>();
string[] cmds = cmdstr.Split('\n');
TaskShell task = null;
foreach(string c in cmds){
if (!string.IsNullOrWhiteSpace(c.Trim()))
{
task = new TaskShell();
task.Uuid = Guid.NewGuid().ToString("N");
task.Name = "";
task.Shell = c.Trim();
cmdList.Add(task);
}
}
bool isnew = false;
if(shell == null){
shell = new CmdShell();
shell.Uuid = Guid.NewGuid().ToString("N");
shell.Target = uuid;
isnew = true;
}
shell.Name = name;
shell.Type = "自定义脚本";
shell.TaskType = TaskType.Default;
shell.ShellList = cmdList;
if (isnew)
{
config.CustomShellList.Add(shell);
}
AppConfig.Instance.SaveConfig(2);
this.Close();
}
19
View Source File : SftpLinuxForm.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
private string getFileOwner(string str)
{
string user = "";
if (null != str && str.Length > 5 && str.IndexOf(" ") != -1)
{
string[] arrs = str.Split(' ');
if(arrs.Length > 3){
int i = 0, j = 0;
foreach(string s in arrs){
if(!string.IsNullOrWhiteSpace(s)){
i++;
if(i >= 3){
user = arrs[j];
break;
}
}
j++;
}
}
}
return user;
}
19
View Source File : DefaultRedisSocket.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public static KeyValuePair<string, int> SplitHost(string host)
{
if (string.IsNullOrWhiteSpace(host?.Trim()))
return new KeyValuePair<string, int>("127.0.0.1", 6379);
host = host.Trim();
var ipv6 = Regex.Match(host, @"^\[([^\]]+)\]\s*(:\s*(\d+))?$");
if (ipv6.Success) //ipv6+port 格式: [fe80::b164:55b3:4b4f:7ce6%15]:6379
return new KeyValuePair<string, int>(ipv6.Groups[1].Value.Trim(),
int.TryParse(ipv6.Groups[3].Value, out var tryint) && tryint > 0 ? tryint : 6379);
var spt = (host ?? "").Split(':');
if (spt.Length == 1) //ipv4 or domain
return new KeyValuePair<string, int>(string.IsNullOrWhiteSpace(spt[0].Trim()) == false ? spt[0].Trim() : "127.0.0.1", 6379);
if (spt.Length == 2) //ipv4:port or domain:port
{
if (int.TryParse(spt.Last().Trim(), out var testPort2))
return new KeyValuePair<string, int>(string.IsNullOrWhiteSpace(spt[0].Trim()) == false ? spt[0].Trim() : "127.0.0.1", testPort2);
return new KeyValuePair<string, int>(host, 6379);
}
if (IPAddress.TryParse(host, out var tryip) && tryip.AddressFamily == AddressFamily.InterNetworkV6) //test ipv6
return new KeyValuePair<string, int>(host, 6379);
if (int.TryParse(spt.Last().Trim(), out var testPort)) //test ipv6:port
{
var testHost = string.Join(":", spt.Where((a, b) => b < spt.Length - 1));
if (IPAddress.TryParse(testHost, out tryip) && tryip.AddressFamily == AddressFamily.InterNetworkV6)
return new KeyValuePair<string, int>(testHost, 6379);
}
return new KeyValuePair<string, int>(host, 6379);
}
19
View Source File : ClusterAdapter.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
void RefershClusterNodes()
{
foreach (var testConnection in _clusterConnectionStrings)
{
RegisterClusterNode(testConnection);
//尝试求出其他节点,并缓存slot
try
{
var cnodes = AdapterCall<string>("CLUSTER".SubCommand("NODES"), rt => rt.ThrowOrValue<string>()).Split('\n');
foreach (var cnode in cnodes)
{
if (string.IsNullOrEmpty(cnode)) continue;
var dt = cnode.Trim().Split(' ');
if (dt.Length < 9) continue;
if (!dt[2].StartsWith("master") && !dt[2].EndsWith("master")) continue;
if (dt[7] != "connected") continue;
var endpoint = dt[1];
var at40 = endpoint.IndexOf('@');
if (at40 != -1) endpoint = endpoint.Remove(at40);
if (endpoint.StartsWith("127.0.0.1"))
endpoint = $"{DefaultRedisSocket.SplitHost(testConnection.Host).Key}:{endpoint.Substring(10)}";
else if (endpoint.StartsWith("localhost", StringComparison.CurrentCultureIgnoreCase))
endpoint = $"{DefaultRedisSocket.SplitHost(testConnection.Host).Key}:{endpoint.Substring(10)}";
ConnectionStringBuilder connectionString = testConnection.ToString();
connectionString.Host = endpoint;
RegisterClusterNode(connectionString);
for (var slotIndex = 8; slotIndex < dt.Length; slotIndex++)
{
var slots = dt[slotIndex].Split('-');
if (ushort.TryParse(slots[0], out var tryslotStart) &&
ushort.TryParse(slots[1], out var tryslotEnd))
{
for (var slot = tryslotStart; slot <= tryslotEnd; slot++)
_slotCache.AddOrUpdate(slot, connectionString.Host, (k1, v1) => connectionString.Host);
}
}
}
break;
}
catch
{
_ib.TryRemove(testConnection.Host, true);
}
}
if (_ib.GetKeys().Length == 0)
throw new RedisClientException($"All \"clusterConnectionStrings\" failed to connect");
}
19
View Source File : CSRedisCache.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public void Remove(string key) {
if (key == null) {
throw new ArgumentNullException(nameof(key));
}
_redisClient.Del(key.Split('|'));
// TODO: Error handling
}
19
View Source File : CSRedisCache.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public async Task RemoveAsync(string key, CancellationToken token = default(CancellationToken)) {
if (key == null) {
throw new ArgumentNullException(nameof(key));
}
await _redisClient.DelAsync(key.Split('|'));
// TODO: Error handling
}
19
View Source File : YmlFormatUtil.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
public static List<YmlItem> FormatYmlToTree(string content)
{
List<YmlItem> lists = new List<YmlItem>();
string[] lines = content.Split('\n');
YmlItem item = null;
string startStr = "";
List<YmlItem> levels = new List<YmlItem>();
int index1 = -1, index2 = -1, index = 0;
foreach(string line in lines){
if(string.IsNullOrWhiteSpace(line)){
item = new YmlItem();
item.Uuid = "T" + (index++);
item.ImageIndex = 2;
item.Key = "#" + line;
item.Value = "";
item.Level = 0;
item.Common = "";
lists.Add(item);
continue;
}
if(line.TrimStart().StartsWith("#")){
item = new YmlItem();
item.Uuid = "T" + (index++);
item.ImageIndex = 2;
item.Key = line;
item.Value = "";
item.Level = 0;
item.Common = "";
lists.Add(item);
}
else
{
item = new YmlItem();
item.Uuid = "T" + (index++);
item.ImageIndex = 0;
item.Key = "";
item.Value = "";
item.Level = 0;
item.Common = "";
item.SpcCount = StartSpaceCount(line);
if (item.SpcCount == 0)
{
levels.Clear();
item.Level = 0;
}
else
{
// level
for (int i = levels.Count - 1; i >= 0; i-- )
{
if (levels[i].SpcCount < item.SpcCount)
{
item.Level = levels[i].Level + 1;
item.Parent = levels[i];
break;
}
}
}
levels.Add(item);
index2 = line.IndexOf("#");
if (index2 > 0)
{
startStr = line.Substring(0, index2);
item.Common = line.Substring(index2);
}
else
{
startStr = line;
}
index1 = startStr.IndexOf(":");
if (index1 > 0)
{
item.Key = startStr.Substring(0, index1).TrimStart();
item.Value = startStr.Substring(index1 + 1).Trim();
}
else
{
item.Key = startStr.TrimStart();
item.Common = "--格式错误--";
}
if (!string.IsNullOrWhiteSpace(item.Value))
{
item.ImageIndex = 1;
}
lists.Add(item);
}
}
return lists;
}
19
View Source File : RedisClientPool.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
internal void SetHost(string host)
{
if (string.IsNullOrEmpty(host?.Trim())) {
_ip = "127.0.0.1";
_port = 6379;
return;
}
host = host.Trim();
var ipv6 = Regex.Match(host, @"^\[([^\]]+)\]\s*(:\s*(\d+))?$");
if (ipv6.Success) //ipv6+port 格式: [fe80::b164:55b3:4b4f:7ce6%15]:6379
{
_ip = ipv6.Groups[1].Value.Trim();
_port = int.TryParse(ipv6.Groups[3].Value, out var tryint) && tryint > 0 ? tryint : 6379;
return;
}
var spt = (host ?? "").Split(':');
if (spt.Length == 1) //ipv4 or domain
{
_ip = string.IsNullOrEmpty(spt[0].Trim()) == false ? spt[0].Trim() : "127.0.0.1";
_port = 6379;
return;
}
if (spt.Length == 2) //ipv4:port or domain:port
{
if (int.TryParse(spt.Last().Trim(), out var testPort2))
{
_ip = string.IsNullOrEmpty(spt[0].Trim()) == false ? spt[0].Trim() : "127.0.0.1";
_port = testPort2;
return;
}
_ip = host;
_port = 6379;
return;
}
if (IPAddress.TryParse(host, out var tryip) && tryip.AddressFamily == AddressFamily.InterNetworkV6) //test ipv6
{
_ip = host;
_port = 6379;
return;
}
if (int.TryParse(spt.Last().Trim(), out var testPort)) //test ipv6:port
{
var testHost = string.Join(":", spt.Where((a, b) => b < spt.Length - 1));
if (IPAddress.TryParse(testHost, out tryip) && tryip.AddressFamily == AddressFamily.InterNetworkV6)
{
_ip = testHost;
_port = 6379;
return;
}
}
_ip = host;
_port = 6379;
}
19
View Source File : TemplateGenerator.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
void BuildEachDirectory(string templateDirectory, string outputDirectory, TemplateEngin tpl, IDbFirst dbfirst, List<DbTableInfo> tables) {
if (Directory.Exists(outputDirectory) == false) Directory.CreateDirectory(outputDirectory);
var files = Directory.GetFiles(templateDirectory);
foreach (var file in files) {
var fi = new FileInfo(file);
if (string.Compare(fi.Extension, ".FreeSql", true) == 0) {
var outputExtension = "." + fi.Name.Split('.')[1];
if (fi.Name.StartsWith("for-table.")) {
foreach (var table in tables) {
var result = tpl.RenderFile(file, new Dictionary<string, object>() { { "table", table }, { "dbfirst", dbfirst } });
if (result.EndsWith("return;")) continue;
var outputName = table.Name + outputExtension;
var mcls = Regex.Match(result, @"\s+clreplaced\s+(\w+)");
if (mcls.Success) outputName = mcls.Groups[1].Value + outputExtension;
var outputStream = Encoding.UTF8.GetBytes(result);
var fullname = outputDirectory + "/" + outputName;
if (File.Exists(fullname)) File.Delete(fullname);
using (var outfs = File.Open(fullname, FileMode.OpenOrCreate, FileAccess.Write)) {
outfs.Write(outputStream, 0, outputStream.Length);
outfs.Close();
}
}
continue;
} else {
var result = tpl.RenderFile(file, new Dictionary<string, object>() { { "tables", tables }, { "dbfirst", dbfirst } });
var outputName = fi.Name;
var mcls = Regex.Match(result, @"\s+clreplaced\s+(\w+)");
if (mcls.Success) outputName = mcls.Groups[1].Value + outputExtension;
var outputStream = Encoding.UTF8.GetBytes(result);
var fullname = outputDirectory + "/" + outputName;
if (File.Exists(fullname)) File.Delete(fullname);
using (var outfs = File.Open(fullname, FileMode.OpenOrCreate, FileAccess.Write)) {
outfs.Write(outputStream, 0, outputStream.Length);
outfs.Close();
}
}
}
File.Copy(file, outputDirectory + file.Replace(templateDirectory, ""), true);
}
var dirs = Directory.GetDirectories(templateDirectory);
foreach(var dir in dirs) {
BuildEachDirectory(dir, outputDirectory + dir.Replace(templateDirectory, ""), tpl, dbfirst, tables);
}
}
19
View Source File : RazorModel.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public string GetCsName(string name)
{
name = Regex.Replace(name.TrimStart('@', '.'), @"[^\w]", "_");
name = char.IsLetter(name, 0) ? name : string.Concat("_", name);
if (task.OptionsEnreplacedy01) name = UFString(name);
if (task.OptionsEnreplacedy02) name = UFString(name.ToLower());
if (task.OptionsEnreplacedy03) name = name.ToLower();
if (task.OptionsEnreplacedy04) name = string.Join("", name.Split('_').Select(a => UFString(a)));
return name;
}
19
View Source File : RazorModel.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public string GetCsName(string name) {
name = Regex.Replace(name.TrimStart('@', '.'), @"[^\w]", "_");
name = char.IsLetter(name, 0) ? name : string.Concat("_", name);
if (task.OptionsEnreplacedy01) name = UFString(name);
if (task.OptionsEnreplacedy02) name = UFString(name.ToLower());
if (task.OptionsEnreplacedy03) name = name.ToLower();
if (task.OptionsEnreplacedy04) name = string.Join("", name.Split('_').Select(a => UFString(a)));
return name;
}
19
View Source File : ConfigHandler.cs
License : GNU General Public License v3.0
Project Creator : 2dust
License : GNU General Public License v3.0
Project Creator : 2dust
public static int AddBatchServers(ref Config config, string clipboardData, string subid = "")
{
if (Utils.IsNullOrEmpty(clipboardData))
{
return -1;
}
//if (clipboardData.IndexOf("vmess") >= 0 && clipboardData.IndexOf("vmess") == clipboardData.LastIndexOf("vmess"))
//{
// clipboardData = clipboardData.Replace("\r\n", "").Replace("\n", "");
//}
int countServers = 0;
//string[] arrData = clipboardData.Split(new string[] { "\r\n" }, StringSplitOptions.None);
string[] arrData = clipboardData.Split(Environment.NewLine.ToCharArray());
foreach (string str in arrData)
{
//maybe sub
if (str.StartsWith(Global.httpsProtocol) || str.StartsWith(Global.httpProtocol))
{
if (AddSubItem(ref config, str) == 0)
{
countServers++;
}
continue;
}
VmessItem vmessItem = ShareHandler.ImportFromClipboardConfig(str, out string msg);
if (vmessItem == null)
{
continue;
}
vmessItem.subid = subid;
if (vmessItem.configType == (int)EConfigType.Vmess)
{
if (AddServer(ref config, vmessItem, -1, false) == 0)
{
countServers++;
}
}
else if (vmessItem.configType == (int)EConfigType.Shadowsocks)
{
if (AddShadowsocksServer(ref config, vmessItem, -1, false) == 0)
{
countServers++;
}
}
else if (vmessItem.configType == (int)EConfigType.Socks)
{
if (AddSocksServer(ref config, vmessItem, -1, false) == 0)
{
countServers++;
}
}
else if (vmessItem.configType == (int)EConfigType.Trojan)
{
if (AddTrojanServer(ref config, vmessItem, -1, false) == 0)
{
countServers++;
}
}
else if (vmessItem.configType == (int)EConfigType.VLESS)
{
if (AddVlessServer(ref config, vmessItem, -1, false) == 0)
{
countServers++;
}
}
}
ToJsonFile(config);
return countServers;
}
19
View Source File : Config.cs
License : GNU General Public License v3.0
Project Creator : 2dust
License : GNU General Public License v3.0
Project Creator : 2dust
public string getSummary()
{
string summary = string.Format("[{0}] ", ((EConfigType)configType).ToString());
string[] arrAddr = address.Split('.');
string addr;
if (arrAddr.Length > 2)
{
addr = $"{arrAddr[0]}***{arrAddr[arrAddr.Length - 1]}";
}
else if (arrAddr.Length > 1)
{
addr = $"***{arrAddr[arrAddr.Length - 1]}";
}
else
{
addr = address;
}
switch (configType)
{
case (int)EConfigType.Vmess:
summary += string.Format("{0}({1}:{2})", remarks, addr, port);
break;
case (int)EConfigType.Shadowsocks:
summary += string.Format("{0}({1}:{2})", remarks, addr, port);
break;
case (int)EConfigType.Socks:
summary += string.Format("{0}({1}:{2})", remarks, addr, port);
break;
case (int)EConfigType.VLESS:
summary += string.Format("{0}({1}:{2})", remarks, addr, port);
break;
case (int)EConfigType.Trojan:
summary += string.Format("{0}({1}:{2})", remarks, addr, port);
break;
default:
summary += string.Format("{0}", remarks);
break;
}
return summary;
}
See More Examples