- cleanup & updates

This commit is contained in:
makikvues 2021-02-02 17:48:06 +01:00
parent 80288c568a
commit cc24db3ff5
15 changed files with 65 additions and 1667 deletions

View File

@ -1,343 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="New Rule Set" Description=" " ToolsVersion="16.0">
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1801" Action="Warning" />
<Rule Id="CA1804" Action="Warning" />
<Rule Id="CA1811" Action="Warning" />
<Rule Id="CA1812" Action="Warning" />
<Rule Id="CA1823" Action="Warning" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp" RuleNamespace="Microsoft.CodeAnalysis.CSharp">
<Rule Id="AD0001" Action="None" />
<Rule Id="CS0078" Action="None" />
<Rule Id="CS0105" Action="None" />
<Rule Id="CS0108" Action="None" />
<Rule Id="CS0109" Action="None" />
<Rule Id="CS0114" Action="None" />
<Rule Id="CS0162" Action="None" />
<Rule Id="CS0164" Action="None" />
<Rule Id="CS0168" Action="None" />
<Rule Id="CS0183" Action="None" />
<Rule Id="CS0184" Action="None" />
<Rule Id="CS0197" Action="None" />
<Rule Id="CS0219" Action="None" />
<Rule Id="CS0251" Action="None" />
<Rule Id="CS0252" Action="None" />
<Rule Id="CS0253" Action="None" />
<Rule Id="CS0278" Action="None" />
<Rule Id="CS0279" Action="None" />
<Rule Id="CS0280" Action="None" />
<Rule Id="CS0282" Action="None" />
<Rule Id="CS0419" Action="None" />
<Rule Id="CS0420" Action="None" />
<Rule Id="CS0435" Action="None" />
<Rule Id="CS0436" Action="None" />
<Rule Id="CS0437" Action="None" />
<Rule Id="CS0440" Action="None" />
<Rule Id="CS0458" Action="None" />
<Rule Id="CS0464" Action="None" />
<Rule Id="CS0465" Action="None" />
<Rule Id="CS0469" Action="None" />
<Rule Id="CS0472" Action="None" />
<Rule Id="CS0473" Action="None" />
<Rule Id="CS0612" Action="None" />
<Rule Id="CS0618" Action="None" />
<Rule Id="CS0626" Action="None" />
<Rule Id="CS0628" Action="None" />
<Rule Id="CS0642" Action="None" />
<Rule Id="CS0652" Action="None" />
<Rule Id="CS0657" Action="None" />
<Rule Id="CS0658" Action="None" />
<Rule Id="CS0659" Action="None" />
<Rule Id="CS0660" Action="None" />
<Rule Id="CS0661" Action="None" />
<Rule Id="CS0665" Action="None" />
<Rule Id="CS0672" Action="None" />
<Rule Id="CS0675" Action="None" />
<Rule Id="CS0684" Action="None" />
<Rule Id="CS0693" Action="None" />
<Rule Id="CS0728" Action="None" />
<Rule Id="CS0809" Action="None" />
<Rule Id="CS0811" Action="None" />
<Rule Id="CS0824" Action="None" />
<Rule Id="CS1030" Action="None" />
<Rule Id="CS1058" Action="None" />
<Rule Id="CS1062" Action="None" />
<Rule Id="CS1064" Action="None" />
<Rule Id="CS1066" Action="None" />
<Rule Id="CS1072" Action="None" />
<Rule Id="CS1522" Action="None" />
<Rule Id="CS1570" Action="None" />
<Rule Id="CS1571" Action="None" />
<Rule Id="CS1572" Action="None" />
<Rule Id="CS1573" Action="None" />
<Rule Id="CS1574" Action="None" />
<Rule Id="CS1580" Action="None" />
<Rule Id="CS1581" Action="None" />
<Rule Id="CS1584" Action="None" />
<Rule Id="CS1587" Action="None" />
<Rule Id="CS1589" Action="None" />
<Rule Id="CS1590" Action="None" />
<Rule Id="CS1591" Action="None" />
<Rule Id="CS1592" Action="None" />
<Rule Id="CS1616" Action="None" />
<Rule Id="CS1633" Action="None" />
<Rule Id="CS1634" Action="None" />
<Rule Id="CS1635" Action="None" />
<Rule Id="CS1645" Action="None" />
<Rule Id="CS1658" Action="None" />
<Rule Id="CS1668" Action="None" />
<Rule Id="CS1685" Action="None" />
<Rule Id="CS1687" Action="None" />
<Rule Id="CS1690" Action="None" />
<Rule Id="CS1692" Action="None" />
<Rule Id="CS1695" Action="None" />
<Rule Id="CS1696" Action="None" />
<Rule Id="CS1697" Action="None" />
<Rule Id="CS1700" Action="None" />
<Rule Id="CS1701" Action="None" />
<Rule Id="CS1702" Action="None" />
<Rule Id="CS1710" Action="None" />
<Rule Id="CS1711" Action="None" />
<Rule Id="CS1712" Action="None" />
<Rule Id="CS1717" Action="None" />
<Rule Id="CS1718" Action="None" />
<Rule Id="CS1720" Action="None" />
<Rule Id="CS1723" Action="None" />
<Rule Id="CS1734" Action="None" />
<Rule Id="CS1735" Action="None" />
<Rule Id="CS1762" Action="None" />
<Rule Id="CS1927" Action="None" />
<Rule Id="CS1956" Action="None" />
<Rule Id="CS1957" Action="None" />
<Rule Id="CS1974" Action="None" />
<Rule Id="CS1981" Action="None" />
<Rule Id="CS1998" Action="None" />
<Rule Id="CS2002" Action="None" />
<Rule Id="CS2008" Action="None" />
<Rule Id="CS2023" Action="None" />
<Rule Id="CS2029" Action="None" />
<Rule Id="CS2038" Action="None" />
<Rule Id="CS3000" Action="None" />
<Rule Id="CS3001" Action="None" />
<Rule Id="CS3002" Action="None" />
<Rule Id="CS3003" Action="None" />
<Rule Id="CS3005" Action="None" />
<Rule Id="CS3006" Action="None" />
<Rule Id="CS3007" Action="None" />
<Rule Id="CS3008" Action="None" />
<Rule Id="CS3009" Action="None" />
<Rule Id="CS3010" Action="None" />
<Rule Id="CS3011" Action="None" />
<Rule Id="CS3012" Action="None" />
<Rule Id="CS3013" Action="None" />
<Rule Id="CS3014" Action="None" />
<Rule Id="CS3015" Action="None" />
<Rule Id="CS3016" Action="None" />
<Rule Id="CS3017" Action="None" />
<Rule Id="CS3018" Action="None" />
<Rule Id="CS3019" Action="None" />
<Rule Id="CS3021" Action="None" />
<Rule Id="CS3022" Action="None" />
<Rule Id="CS3023" Action="None" />
<Rule Id="CS3024" Action="None" />
<Rule Id="CS3026" Action="None" />
<Rule Id="CS3027" Action="None" />
<Rule Id="CS4014" Action="None" />
<Rule Id="CS4024" Action="None" />
<Rule Id="CS4025" Action="None" />
<Rule Id="CS4026" Action="None" />
<Rule Id="CS7033" Action="None" />
<Rule Id="CS7035" Action="None" />
<Rule Id="CS7080" Action="None" />
<Rule Id="CS7081" Action="None" />
<Rule Id="CS7082" Action="None" />
<Rule Id="CS7090" Action="None" />
<Rule Id="CS7095" Action="None" />
<Rule Id="CS8001" Action="None" />
<Rule Id="CS8002" Action="None" />
<Rule Id="CS8009" Action="None" />
<Rule Id="CS8012" Action="None" />
<Rule Id="CS8018" Action="None" />
<Rule Id="CS8019" Action="None" />
<Rule Id="CS8021" Action="None" />
<Rule Id="CS8029" Action="None" />
<Rule Id="CS8032" Action="None" />
<Rule Id="CS8033" Action="None" />
<Rule Id="CS8034" Action="None" />
<Rule Id="CS8040" Action="None" />
<Rule Id="CS8073" Action="None" />
<Rule Id="CS8094" Action="None" />
<Rule Id="CS8105" Action="None" />
<Rule Id="CS8123" Action="None" />
<Rule Id="CS8305" Action="None" />
<Rule Id="CS8321" Action="None" />
<Rule Id="CS8359" Action="None" />
<Rule Id="CS8360" Action="None" />
<Rule Id="CS8371" Action="None" />
<Rule Id="CS8383" Action="None" />
<Rule Id="CS8387" Action="None" />
<Rule Id="CS8424" Action="None" />
<Rule Id="CS8425" Action="None" />
<Rule Id="CS8509" Action="None" />
<Rule Id="CS8512" Action="None" />
<Rule Id="CS8513" Action="None" />
<Rule Id="CS8519" Action="None" />
<Rule Id="CS8520" Action="None" />
<Rule Id="CS8597" Action="None" />
<Rule Id="CS8600" Action="None" />
<Rule Id="CS8601" Action="None" />
<Rule Id="CS8602" Action="None" />
<Rule Id="CS8603" Action="None" />
<Rule Id="CS8604" Action="None" />
<Rule Id="CS8605" Action="None" />
<Rule Id="CS8606" Action="None" />
<Rule Id="CS8607" Action="None" />
<Rule Id="CS8608" Action="None" />
<Rule Id="CS8609" Action="None" />
<Rule Id="CS8610" Action="None" />
<Rule Id="CS8611" Action="None" />
<Rule Id="CS8612" Action="None" />
<Rule Id="CS8613" Action="None" />
<Rule Id="CS8614" Action="None" />
<Rule Id="CS8615" Action="None" />
<Rule Id="CS8616" Action="None" />
<Rule Id="CS8617" Action="None" />
<Rule Id="CS8618" Action="None" />
<Rule Id="CS8619" Action="None" />
<Rule Id="CS8620" Action="None" />
<Rule Id="CS8621" Action="None" />
<Rule Id="CS8622" Action="None" />
<Rule Id="CS8624" Action="None" />
<Rule Id="CS8625" Action="None" />
<Rule Id="CS8626" Action="None" />
<Rule Id="CS8629" Action="None" />
<Rule Id="CS8631" Action="None" />
<Rule Id="CS8632" Action="None" />
<Rule Id="CS8633" Action="None" />
<Rule Id="CS8634" Action="None" />
<Rule Id="CS8638" Action="None" />
<Rule Id="CS8643" Action="None" />
<Rule Id="CS8644" Action="None" />
<Rule Id="CS8645" Action="None" />
<Rule Id="CS8653" Action="None" />
<Rule Id="CS8654" Action="None" />
<Rule Id="CS8655" Action="None" />
<Rule Id="CS8656" Action="None" />
<Rule Id="CS8667" Action="None" />
<Rule Id="CS8714" Action="None" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp.Features" RuleNamespace="Microsoft.CodeAnalysis.CSharp.Features">
<Rule Id="IDE0001" Action="None" />
<Rule Id="IDE0002" Action="None" />
<Rule Id="IDE0003" Action="None" />
<Rule Id="IDE0003WithoutSuggestion" Action="None" />
<Rule Id="IDE0004" Action="None" />
<Rule Id="IDE0004WithoutSuggestion" Action="None" />
<Rule Id="IDE0005" Action="None" />
<Rule Id="IDE0007" Action="None" />
<Rule Id="IDE0007WithoutSuggestion" Action="None" />
<Rule Id="IDE0008" Action="None" />
<Rule Id="IDE0008WithoutSuggestion" Action="None" />
<Rule Id="IDE0009" Action="None" />
<Rule Id="IDE0009WithoutSuggestion" Action="None" />
<Rule Id="IDE0011" Action="None" />
<Rule Id="IDE0011WithoutSuggestion" Action="None" />
<Rule Id="IDE0016" Action="None" />
<Rule Id="IDE0016WithoutSuggestion" Action="None" />
<Rule Id="IDE0017" Action="None" />
<Rule Id="IDE0017WithoutSuggestion" Action="None" />
<Rule Id="IDE0018" Action="None" />
<Rule Id="IDE0018WithoutSuggestion" Action="None" />
<Rule Id="IDE0019" Action="None" />
<Rule Id="IDE0019WithoutSuggestion" Action="None" />
<Rule Id="IDE0020" Action="None" />
<Rule Id="IDE0020WithoutSuggestion" Action="None" />
<Rule Id="IDE0021" Action="None" />
<Rule Id="IDE0022" Action="None" />
<Rule Id="IDE0023" Action="None" />
<Rule Id="IDE0024" Action="None" />
<Rule Id="IDE0025" Action="None" />
<Rule Id="IDE0026" Action="None" />
<Rule Id="IDE0027" Action="None" />
<Rule Id="IDE0028" Action="None" />
<Rule Id="IDE0028WithoutSuggestion" Action="None" />
<Rule Id="IDE0029" Action="None" />
<Rule Id="IDE0029WithoutSuggestion" Action="None" />
<Rule Id="IDE0030" Action="None" />
<Rule Id="IDE0030WithoutSuggestion" Action="None" />
<Rule Id="IDE0031" Action="None" />
<Rule Id="IDE0031WithoutSuggestion" Action="None" />
<Rule Id="IDE0032" Action="None" />
<Rule Id="IDE0032WithoutSuggestion" Action="None" />
<Rule Id="IDE0034" Action="None" />
<Rule Id="IDE0034WithoutSuggestion" Action="None" />
<Rule Id="IDE0035" Action="None" />
<Rule Id="IDE0035WithoutSuggestion" Action="None" />
<Rule Id="IDE0036" Action="None" />
<Rule Id="IDE0036WithoutSuggestion" Action="None" />
<Rule Id="IDE0037" Action="None" />
<Rule Id="IDE0037WithoutSuggestion" Action="None" />
<Rule Id="IDE0039" Action="None" />
<Rule Id="IDE0039WithoutSuggestion" Action="None" />
<Rule Id="IDE0040" Action="None" />
<Rule Id="IDE0040WithoutSuggestion" Action="None" />
<Rule Id="IDE0041" Action="None" />
<Rule Id="IDE0041WithoutSuggestion" Action="None" />
<Rule Id="IDE0042" Action="None" />
<Rule Id="IDE0042WithoutSuggestion" Action="None" />
<Rule Id="IDE0043" Action="None" />
<Rule Id="IDE0045" Action="None" />
<Rule Id="IDE0045WithoutSuggestion" Action="None" />
<Rule Id="IDE0046" Action="None" />
<Rule Id="IDE0046WithoutSuggestion" Action="None" />
<Rule Id="IDE0047" Action="None" />
<Rule Id="IDE0048" Action="None" />
<Rule Id="IDE0048WithoutSuggestion" Action="None" />
<Rule Id="IDE0049" Action="None" />
<Rule Id="IDE0049WithoutSuggestion" Action="None" />
<Rule Id="IDE0050" Action="None" />
<Rule Id="IDE0050WithoutSuggestion" Action="None" />
<Rule Id="IDE0051" Action="None" />
<Rule Id="IDE0052" Action="None" />
<Rule Id="IDE0053" Action="None" />
<Rule Id="IDE0053WithoutSuggestion" Action="None" />
<Rule Id="IDE0054" Action="None" />
<Rule Id="IDE0054WithoutSuggestion" Action="None" />
<Rule Id="IDE0056" Action="None" />
<Rule Id="IDE0056WithoutSuggestion" Action="None" />
<Rule Id="IDE0057" Action="None" />
<Rule Id="IDE0057WithoutSuggestion" Action="None" />
<Rule Id="IDE0058" Action="None" />
<Rule Id="IDE0059" Action="None" />
<Rule Id="IDE0060" Action="None" />
<Rule Id="IDE0061" Action="None" />
<Rule Id="IDE0062" Action="None" />
<Rule Id="IDE0062WithoutSuggestion" Action="None" />
<Rule Id="IDE0063" Action="None" />
<Rule Id="IDE0063WithoutSuggestion" Action="None" />
<Rule Id="IDE0064" Action="None" />
<Rule Id="IDE0065" Action="None" />
<Rule Id="IDE0066" Action="None" />
<Rule Id="IDE0066WithoutSuggestion" Action="None" />
<Rule Id="IDE1005" Action="None" />
<Rule Id="IDE1005WithoutSuggestion" Action="None" />
<Rule Id="IDE1006" Action="None" />
<Rule Id="IDE1006WithoutSuggestion" Action="None" />
<Rule Id="RE0001" Action="None" />
<Rule Id="RE0001WithoutSuggestion" Action="None" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.Features" RuleNamespace="Microsoft.CodeAnalysis.Features">
<Rule Id="IDE0010" Action="None" />
<Rule Id="IDE0010WithoutSuggestion" Action="None" />
<Rule Id="IDE0033" Action="None" />
<Rule Id="IDE0033WithoutSuggestion" Action="None" />
<Rule Id="IDE0044" Action="None" />
<Rule Id="IDE0044WithoutSuggestion" Action="None" />
<Rule Id="IDE0055" Action="None" />
<Rule Id="IDE0055WithoutSuggestion" Action="None" />
<Rule Id="IDE0067" Action="None" />
<Rule Id="IDE0068" Action="None" />
<Rule Id="IDE0069" Action="None" />
</Rules>
</RuleSet>

View File

@ -1,541 +0,0 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
namespace winPEAS._3rdParty.MicroJson
{
//
// JsonParser.cs
//
// Author:
// Michael Ganss <michael@ganss.org>
//
// Copyright (c) 2011 Michael Ganss
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace MicroJson
{
#pragma warning disable 1591
public class ParserException : Exception
{
public int Line { get; private set; }
public int Column { get; private set; }
public ParserException(string msg, int line, int col)
: base(msg)
{
Line = line;
Column = col;
}
}
public interface ILogger
{
void WriteLine(string message, params object[] arguments);
}
public class TextWriterLogger : ILogger
{
public TextWriter Writer { get; set; }
public TextWriterLogger(TextWriter writer)
{
Writer = writer;
}
public void WriteLine(string message, params object[] arguments)
{
if (arguments != null && arguments.Length > 0)
Writer.WriteLine(message, arguments);
else
Writer.WriteLine(message);
}
}
#pragma warning restore 1591
/// <summary>
/// Parses JSON into POCOs.
/// </summary>
public class JsonParser
{
string Input { get; set; }
int InputLength { get; set; }
int Pos { get; set; }
int Line { get; set; }
int Col { get; set; }
/// <summary>
/// Gets or sets the logger.
/// </summary>
/// <value>
/// The logger.
/// </value>
public ILogger Logger { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to collect line info during parsing.
/// </summary>
/// <value>
/// <c>true</c> if line info should be collected during parsing; otherwise, <c>false</c>.
/// </value>
public bool CollectLineInfo { get; set; }
/// <summary>
/// Parse the specified JSON text.
/// </summary>
/// <param name='text'>
/// The JSON text to parse.
/// </param>
public object Parse(string text)
{
if (text == null)
throw BuildParserException("input is null");
Input = text;
InputLength = text.Length;
Pos = 0;
Line = 1;
Col = 1;
var o = Value();
SkipWhitespace();
if (Pos != InputLength)
throw BuildParserException("extra characters at end");
return o;
}
private void WriteLineLog(string msg, params object[] args)
{
if (Logger != null)
{
Logger.WriteLine(msg, args);
}
}
private ParserException BuildParserException(string msg)
{
if (CollectLineInfo)
{
return new ParserException(string.Format(CultureInfo.InvariantCulture, "Parse error: {0} at line {1}, column {2}.", msg, Line, Col), Line, Col);
}
else
{
return new ParserException("Parse error: " + msg + ".", 0, 0);
}
}
private void AdvanceInput(int n)
{
if (CollectLineInfo)
{
for (int i = Pos; i < Pos + n; i++)
{
var c = Input[i];
if (c == '\n')
{
Line++;
Col = 1;
}
else
{
Col++;
}
}
}
Pos += n;
}
private string Accept(string s)
{
var len = s.Length;
if (Pos + len > InputLength)
{
return null;
}
if (Input.IndexOf(s, Pos, len, StringComparison.Ordinal) != -1)
{
var match = Input.Substring(Pos, len);
AdvanceInput(len);
return match;
}
return null;
}
private char Expect(char c)
{
if (Pos >= InputLength || Input[Pos] != c)
{
throw BuildParserException("expected '" + c + "'");
}
AdvanceInput(1);
return c;
}
private object Value()
{
SkipWhitespace();
if (Pos >= InputLength)
{
throw BuildParserException("input contains no value");
}
var nextChar = Input[Pos];
if (nextChar == '"')
{
AdvanceInput(1);
return String();
}
else if (nextChar == '[')
{
AdvanceInput(1);
return List();
}
else if (nextChar == '{')
{
AdvanceInput(1);
return Dictionary();
}
else if (char.IsDigit(nextChar) || nextChar == '-')
{
return Number();
}
else
{
return Literal();
}
}
private object Number()
{
int currentPos = Pos;
bool dotSeen = false;
Accept(c => c == '-', ref currentPos);
ExpectDigits(ref currentPos);
if (Accept(c => c == '.', ref currentPos))
{
dotSeen = true;
ExpectDigits(ref currentPos);
}
if (Accept(c => (c == 'e' || c == 'E'), ref currentPos))
{
Accept(c => (c == '-' || c == '+'), ref currentPos);
ExpectDigits(ref currentPos);
}
var len = currentPos - Pos;
var num = Input.Substring(Pos, len);
if (dotSeen)
{
decimal d;
if (decimal.TryParse(num, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent, CultureInfo.InvariantCulture, out d))
{
WriteLineLog("decimal: {0}", d);
AdvanceInput(len);
return d;
}
else
{
double dbl;
if (double.TryParse(num, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent, CultureInfo.InvariantCulture, out dbl))
{
WriteLineLog("double: {0}", dbl);
AdvanceInput(len);
return dbl;
}
throw BuildParserException("cannot parse decimal number");
}
}
else
{
int i;
if (int.TryParse(num, NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent, CultureInfo.InvariantCulture, out i))
{
WriteLineLog("int: {0}", i);
AdvanceInput(len);
return i;
}
else
{
long l;
if (long.TryParse(num, NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent, CultureInfo.InvariantCulture, out l))
{
WriteLineLog("long: {0}", l);
AdvanceInput(len);
return l;
}
throw BuildParserException("cannot parse integer number");
}
}
}
private bool Accept(Predicate<char> predicate, ref int pos)
{
if (pos < InputLength && predicate(Input[pos]))
{
pos++;
return true;
}
return false;
}
private void ExpectDigits(ref int pos)
{
int start = pos;
while (pos < InputLength && char.IsDigit(Input[pos])) pos++;
if (start == pos) throw BuildParserException("not a number");
}
private string String()
{
int currentPos = Pos;
StringBuilder sb = new StringBuilder();
while (true)
{
if (currentPos >= InputLength)
{
throw BuildParserException("unterminated string");
}
var c = Input[currentPos];
if (c == '"')
{
var len = currentPos - Pos;
AdvanceInput(len + 1);
WriteLineLog("string: {0}", sb);
return sb.ToString();
}
else if (c == '\\')
{
currentPos++;
if (currentPos >= InputLength)
{
throw BuildParserException("unterminated escape sequence string");
}
c = Input[currentPos];
switch (c)
{
case '"':
case '/':
case '\\':
sb.Append(c);
break;
case 'b':
sb.Append('\b');
break;
case 'f':
sb.Append('\f');
break;
case 'n':
sb.Append('\n');
break;
case 'r':
sb.Append('\r');
break;
case 't':
sb.Append('\t');
break;
case 'u':
currentPos += 4;
if (currentPos >= InputLength)
throw BuildParserException("unterminated unicode escape in string");
else
{
int u;
if (!int.TryParse(Input.Substring(currentPos - 3, 4), NumberStyles.AllowHexSpecifier, NumberFormatInfo.InvariantInfo, out u))
throw BuildParserException("not a well-formed unicode escape sequence in string");
sb.Append((char)u);
}
break;
default:
throw BuildParserException("unknown escape sequence in string");
}
}
else if ((int)c < 0x20)
{
throw BuildParserException("control character in string");
}
else
{
sb.Append(c);
}
currentPos++;
}
}
private object Literal()
{
if (Accept("true") != null)
{
WriteLineLog("bool: true");
return true;
}
if (Accept("false") != null)
{
WriteLineLog("bool: false");
return false;
}
if (Accept("null") != null)
{
WriteLineLog("null");
return null;
}
throw BuildParserException("unknown token");
}
private IList<object> List()
{
WriteLineLog("list: [");
List<object> list = new List<object>();
SkipWhitespace();
if (IsNext(']'))
{
AdvanceInput(1); return list;
}
object obj = null;
do
{
SkipWhitespace();
obj = Value();
if (obj != null)
{
list.Add(obj);
SkipWhitespace();
if (IsNext(']')) break;
Expect(',');
}
}
while (obj != null);
Expect(']');
WriteLineLog("]");
return list;
}
private IDictionary<string, object> Dictionary()
{
WriteLineLog("Dictionary: {");
Dictionary<string, object> dict = new Dictionary<string, object>();
SkipWhitespace();
if (IsNext('}'))
{
AdvanceInput(1); return dict;
}
KeyValuePair<string, object>? kvp = null;
do
{
SkipWhitespace();
kvp = KeyValuePair();
if (kvp.HasValue)
{
dict[kvp.Value.Key] = kvp.Value.Value;
}
SkipWhitespace();
if (IsNext('}')) break;
Expect(',');
}
while (kvp != null);
Expect('}');
WriteLineLog("}");
return dict;
}
private KeyValuePair<string, object>? KeyValuePair()
{
Expect('"');
var key = String();
SkipWhitespace();
Expect(':');
var obj = Value();
return new KeyValuePair<string, object>(key, obj);
}
private void SkipWhitespace()
{
int n = Pos;
while (IsWhiteSpace(n)) n++;
if (n != Pos)
{
AdvanceInput(n - Pos);
}
}
private bool IsWhiteSpace(int n)
{
if (n >= InputLength) return false;
char c = Input[n];
return c == ' ' || c == '\t' || c == '\r' || c == '\n';
}
private bool IsNext(char c)
{
return Pos < InputLength && Input[Pos] == c;
}
}
}
}

View File

@ -1,664 +0,0 @@
//
// JsonSerializer.cs
//
// Author:
// Michael Ganss <michael@ganss.org>
//
// Copyright (c) 2011 Michael Ganss
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using winPEAS._3rdParty.MicroJson.MicroJson;
namespace winPEAS._3rdParty.MicroJson
{
/// <summary>
/// Serializes and deserializes JSON.
/// </summary>
public class JsonSerializer
{
/// <summary>
/// Deserializes JSON text into an object of the specified type.
/// </summary>
/// <returns>
/// An object of the specified type deserialized from JSON.
/// </returns>
/// <param name='text'>
/// The JSON text.
/// </param>
/// <typeparam name='T'>
/// The type to deserialize into.
/// </typeparam>
public static T DeserializeObject<T>(string text)
{
return new JsonSerializer().Deserialize<T>(text);
}
/// <summary>
/// Serializes an object into JSON text.
/// </summary>
/// <returns>
/// The JSON text that represents the object.
/// </returns>
/// <param name='obj'>
/// The object to serialize.
/// </param>
public static string SerializeObject(object obj)
{
return new JsonSerializer().Serialize(obj);
}
/// <summary>
/// Deserializes JSON text into an object of the specified type.
/// </summary>
/// <returns>
/// An object of the specified type deserialized from JSON.
/// </returns>
/// <param name='text'>
/// The JSON text.
/// </param>
/// <typeparam name='T'>
/// The type to deserialize into.
/// </typeparam>
public T Deserialize<T>(string text)
{
return Deserialize<T>(text, new JsonParser());
}
/// <summary>
/// Deserializes JSON text into an object of the specified type.
/// </summary>
/// <returns>
/// An object of the specified type deserialized from JSON.
/// </returns>
/// <param name='text'>
/// The JSON text.
/// </param>
/// <param name='parser'>
/// The parser to use.
/// </param>
/// <typeparam name='T'>
/// The type to deserialize into.
/// </typeparam>
public T Deserialize<T>(string text, JsonParser parser)
{
if (parser == null)
{
throw new ArgumentException("An invalid argument was specified.", "parser");
}
var o = parser.Parse(text);
return (T)Deserialize(o, typeof(T));
}
/// <summary>
/// Constructor.
/// </summary>
public JsonSerializer()
{
TypeInfoPropertyName = "@type";
}
/// <summary>
/// <para>
/// Gets or sets a value indicating whether to serialize and deserialize type information
/// for derived classes.
/// </para>
/// <para>
/// When a derived class is serialized and no additional type information is serialized
/// a deserializer does not know the derived class the object originated from. Setting this property to true emits
/// type information in an additional property whose name is indicated by <see cref="TypeInfoPropertyName"/> and
/// deserializing honors this property. Type information is emitted only for types which are derived classes or implement
/// an interface.
/// </para>
/// <para>
/// The type information includes only the class name (no namespace, assembly information etc.) in order to be potentially compatible
/// with other implementations. When deserializing, the type indicated by the type information is searched only in the assembly where the base
/// type is located.
/// </para>
/// The default is false.
/// </summary>
public bool UseTypeInfo { get; set; }
/// <summary>
/// Gets or sets a property name where additional type information is serialized to and deserialized from.
/// The default is "@type".
/// </summary>
public string TypeInfoPropertyName { get; set; }
/// <summary>
/// Deserializes generic POCO object into an object of the specified type.
/// </summary>
/// <returns>
/// An object of the specified type deserialized from POCO.
/// </returns>
/// <param name='value'>
/// The POCO.
/// </param>
/// <typeparam name='T'>
/// The type to deserialize into.
/// </typeparam>
public T Deserialize<T>(object value)
{
return (T)Deserialize(value, typeof(T));
}
static Regex DateTimeRegex = new Regex(@"^/Date\((-?\d+)\)/$");
private Dictionary<string, Type> TypeCache = new Dictionary<string, Type>();
private object Deserialize(object from, Type type)
{
if (from == null)
return null;
var dict = from as IDictionary<string, object>;
if (dict != null)
{
if (UseTypeInfo)
{
object typeNameObject;
if (dict.TryGetValue(TypeInfoPropertyName, out typeNameObject))
{
var typeName = typeNameObject as string;
if (!string.IsNullOrEmpty(typeName))
{
Type derivedType;
if (!TypeCache.TryGetValue(typeName, out derivedType))
{
derivedType = type.Assembly.GetTypes()
.FirstOrDefault(t => t != type && type.IsAssignableFrom(t) && string.Equals(t.Name, typeName, StringComparison.OrdinalIgnoreCase));
TypeCache[typeName] = derivedType ?? typeof(object);
}
if (derivedType != null && derivedType != typeof(object)) type = derivedType;
}
}
}
var to = Activator.CreateInstance(type);
DeserializeDictionary(dict, to);
return to;
}
var list = from as IList;
if (list != null)
{
if (type.IsArray)
{
var elementType = type.GetElementType();
var arr = Array.CreateInstance(elementType, list.Count);
DeserializeArray(list, arr, elementType);
return arr;
}
else
{
var to = (IList)Activator.CreateInstance(type);
DeserializeList(list, to);
return to;
}
}
if (typeof(IList).IsAssignableFrom(type))
{
var to = (IList)Activator.CreateInstance(type);
var itemType = to.GetType().GetProperty("Item").PropertyType;
to.Add(Deserialize(from, itemType));
return to;
}
if (type.IsEnum)
{
return Enum.Parse(type, from.ToString(), true);
}
if (type == typeof(DateTime))
{
var date = from as string;
if (date != null)
{
Match dateTimeMatch = DateTimeRegex.Match(date);
if (dateTimeMatch.Success)
{
var ticks = long.Parse(dateTimeMatch.Groups[1].Value, NumberFormatInfo.InvariantInfo);
var epochTicks = (ticks * 10000) + 621355968000000000;
return new DateTime(epochTicks, DateTimeKind.Utc).ToLocalTime();
}
}
}
if (type == typeof(Guid))
{
var guid = from as string;
if (guid != null)
{
Guid g;
if (Guid.TryParse(guid, out g))
return g;
}
}
if (type == typeof(Uri))
{
var uri = from as string;
if (uri != null)
{
Uri u;
if (Uri.TryCreate(uri, UriKind.RelativeOrAbsolute, out u))
return u;
}
}
if (!type.IsAssignableFrom(from.GetType()))
{
// Nullable handling
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
{
type = type.GetGenericArguments()[0];
}
return Convert.ChangeType(from, type, CultureInfo.InvariantCulture);
}
return from;
}
private void DeserializeArray(IList from, Array to, Type itemType)
{
for (int i = 0; i < from.Count; i++)
{
to.SetValue(Deserialize(from[i], itemType), i);
}
}
private void DeserializeList(IList from, IList to)
{
var itemType = to.GetType().GetProperty("Item").PropertyType;
foreach (var item in from)
{
to.Add(Deserialize(item, itemType));
}
}
private void DeserializeDictionary(IEnumerable<KeyValuePair<string, object>> from, object to)
{
var type = to.GetType();
var dict = to as IDictionary;
if (dict != null)
{
var valType = typeof(object);
while (type != typeof(object))
{
if (type.IsGenericType)
{
valType = type.GetGenericArguments()[1];
break;
}
type = type.BaseType;
}
foreach (var pair in from)
{
dict[pair.Key] = Deserialize(pair.Value, valType);
}
}
else
{
foreach (var pair in from)
{
var member = GetMember(type, pair.Key);
if (member != null)
{
member.Set(to, Deserialize(pair.Value, member.Type));
}
}
}
}
class SetterMember
{
public Type Type { get; set; }
public Action<object, object> Set { get; set; }
}
private Dictionary<string, SetterMember> MemberCache = new Dictionary<string, SetterMember>();
private SetterMember GetMember(Type type, string name)
{
SetterMember member;
var key = name + type.GetHashCode();
if (!MemberCache.TryGetValue(key, out member))
{
var fieldInfo = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);
if (fieldInfo != null)
{
member = new SetterMember
{
Type = fieldInfo.FieldType,
Set = (o, v) => fieldInfo.SetValue(o, v)
};
MemberCache[key] = member;
}
else
{
var propertyInfo = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);
if (propertyInfo != null && propertyInfo.CanWrite)
{
member = new SetterMember
{
Type = propertyInfo.PropertyType,
Set = (o, v) => propertyInfo.SetValue(o, v, null)
};
MemberCache[key] = member;
}
else
{
MemberCache[key] = null;
}
}
}
return member;
}
/// <summary>
/// Serialize the specified object into JSON.
/// </summary>
/// <param name='obj'>
/// The object to serialize.
/// </param>
public string Serialize(object obj)
{
if (obj == null) return "null";
var list = obj as IList;
if (list != null && !(obj is IEnumerable<KeyValuePair<string, object>>))
{
var sb = new StringBuilder("[");
if (list.Count > 0)
{
sb.Append(string.Join(",", list.Cast<object>().Select(i => Serialize(i)).ToArray()));
}
sb.Append("]");
return sb.ToString();
}
var str = obj as string;
if (str != null)
{
return @"""" + EscapeString(str) + @"""";
}
if (obj is int)
{
return obj.ToString();
}
var b = obj as bool?;
if (b.HasValue)
{
return b.Value ? "true" : "false";
}
if (obj is decimal)
{
return ((IFormattable)obj).ToString("G", NumberFormatInfo.InvariantInfo);
}
if (obj is double || obj is float)
{
return ((IFormattable)obj).ToString("R", NumberFormatInfo.InvariantInfo);
}
if (obj is Enum)
{
return @"""" + EscapeString(obj.ToString()) + @"""";
}
if (obj is char)
{
return @"""" + obj + @"""";
}
if (obj.GetType().IsPrimitive)
{
return (string)Convert.ChangeType(obj, typeof(string), CultureInfo.InvariantCulture);
}
if (obj is DateTime)
{
return SerializeDateTime(obj);
}
if (obj is Guid)
{
return @"""" + obj + @"""";
}
if (obj is Uri)
{
return @"""" + obj + @"""";
}
return SerializeComplexType(obj);
}
private static string SerializeDateTime(object o)
{
var d = (DateTime)o;
var ticks = (d.ToUniversalTime().Ticks - 621355968000000000) / 10000;
return @"""\/Date(" + ticks + @")\/""";
}
private static string EscapeString(string src)
{
var sb = new StringBuilder();
foreach (var c in src)
{
if (c == '"' || c == '\\')
{
sb.Append('\\');
sb.Append(c);
}
else if ((int)c < 0x20) // control character
{
var u = (int)c;
switch (u)
{
case '\b':
sb.Append("\\b");
break;
case '\f':
sb.Append("\\f");
break;
case '\n':
sb.Append("\\n");
break;
case '\r':
sb.Append("\\r");
break;
case '\t':
sb.Append("\\t");
break;
default:
sb.Append("\\u");
sb.Append(u.ToString("X4", NumberFormatInfo.InvariantInfo));
break;
}
}
else
sb.Append(c);
}
return sb.ToString();
}
private string SerializeComplexType(object o)
{
var s = new StringBuilder("{");
if (o is IDictionary || o is IEnumerable<KeyValuePair<string, object>>)
{
SerializeDictionary(o, s);
}
else
{
SerializeProperties(o, s);
}
s.Append("}");
return s.ToString();
}
private void SerializeProperties(object o, StringBuilder s)
{
var type = o.GetType();
var members = GetMembers(type);
if (UseTypeInfo && ((type.BaseType != typeof(object) && type.BaseType != null) || type.GetInterfaces().Any()))
{
// emit type info
s.Append(@"""");
s.Append(TypeInfoPropertyName);
s.Append(@""":""");
s.Append(type.Name);
s.Append(@""",");
}
foreach (var member in members)
{
object val = member.Get(o);
if (val != null && (member.DefaultValue == null || !val.Equals(member.DefaultValue)))
{
var v = Serialize(val);
s.Append(@"""");
s.Append(member.Name);
s.Append(@""":");
s.Append(v);
s.Append(",");
}
}
if (s.Length > 0 && s[s.Length - 1] == ',') s.Remove(s.Length - 1, 1);
}
private void SerializeDictionary(object o, StringBuilder s)
{
IEnumerable<KeyValuePair<string, object>> kvps;
var dict = o as IDictionary;
if (dict != null)
kvps = dict.Keys.Cast<object>().Select(k => new KeyValuePair<string, object>(k.ToString(), dict[k]));
else
kvps = (IEnumerable<KeyValuePair<string, object>>)o;
// work around MonoTouch Full-AOT issue
var kvpList = kvps.ToList();
kvpList.Sort((e1, e2) => string.Compare(e1.Key, e2.Key, StringComparison.OrdinalIgnoreCase));
foreach (var kvp in kvpList)
{
s.Append(@"""");
s.Append(kvp.Key);
s.Append(@""":");
s.Append(Serialize(kvp.Value));
s.Append(",");
}
if (s.Length > 0 && s[s.Length - 1] == ',')
s.Remove(s.Length - 1, 1);
}
class GetterMember
{
public string Name { get; set; }
public Func<object, object> Get { get; set; }
public object DefaultValue { get; set; }
}
private Dictionary<Type, GetterMember[]> MembersCache = new Dictionary<Type, GetterMember[]>();
private GetterMember[] GetMembers(Type type)
{
GetterMember[] members;
if (!MembersCache.TryGetValue(type, out members))
{
var props = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase)
.Where(p => p.CanWrite)
.Select(p => BuildGetterMember(p));
var fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase)
.Select(f => BuildGetterMember(f));
members = props.Concat(fields).OrderBy(g => g.Name, StringComparer.OrdinalIgnoreCase).ToArray();
MembersCache[type] = members;
}
return members;
}
private static GetterMember BuildGetterMember(PropertyInfo p)
{
var defaultAttribute = p.GetCustomAttributes(typeof(DefaultValueAttribute), true).FirstOrDefault() as DefaultValueAttribute;
return new GetterMember
{
Name = p.Name,
Get = (Func<object, object>)(o => p.GetValue(o, null)),
DefaultValue = defaultAttribute != null ? defaultAttribute.Value : GetDefaultValueForType(p.PropertyType)
};
}
private static GetterMember BuildGetterMember(FieldInfo f)
{
var defaultAttribute = f.GetCustomAttributes(typeof(DefaultValueAttribute), true).FirstOrDefault() as DefaultValueAttribute;
return new GetterMember
{
Name = f.Name,
Get = (o => f.GetValue(o)),
DefaultValue = defaultAttribute != null ? defaultAttribute.Value : GetDefaultValueForType(f.FieldType)
};
}
private static object GetDefaultValueForType(Type type)
{
return type.IsValueType ? Activator.CreateInstance(type) : null;
}
}
}

View File

@ -1,66 +0,0 @@
MicroJson
=========
[![Version](https://img.shields.io/nuget/v/MicroJson.svg)](https://www.nuget.org/packages/MicroJson)
[![Build status](https://ci.appveyor.com/api/projects/status/d71toeu341rclabr/branch/master?svg=true)](https://ci.appveyor.com/project/mganss/microjson/branch/master)
[![Coverage Status](https://coveralls.io/repos/mganss/MicroJson/badge.svg?branch=master&service=github)](https://coveralls.io/github/mganss/MicroJson?branch=master)
MicroJson is a small library for serializing/deserializing [JSON](http://www.json.org/) strings from strongly
typed CLR objects (POCOs). It is basically a replacement for the [JavaScriptSerializer](http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx)
class for situations where you cannot or do not want to use that class. Its aim is neither to be fast nor feature-rich but
rather small and compatible with most environments.
If you are looking for a more fully featured JSON serializer, you should probably take a look at [JSON.Net](http://json.codeplex.com/).
MicroJson consists of two source files you can just drop into your project. It has been tested in the following environments:
- .NET 4.0
- [Mono](http://www.mono-project.com/Main_Page) 2.10
- [MonoTouch](http://www.xamarin.com) ([Touch.Unit](https://github.com/spouliot/Touch.Unit) tests included)
- [Mono for Android](http://www.xamarin.com) ([Andr.Unit](https://github.com/spouliot/Andr.Unit) tests included)
Usage
-----
public class Test
{
public string S { get; set; }
public int I { get; set; }
public List<int> L;
}
var json = @"{
""S"": ""Hello, world."",
""I"": 4711,
""L"": [1, 2, 3]
}";
var t = new JsonSerializer().Deserialize<Test>(json);
Assert.That(t.S, Is.EqualTo("Hello, world."));
Assert.That(4711, Is.EqualTo(t.I));
Assert.That(new[] { 1, 2, 3 }, Is.EquivalentTo(t.L));
var j = new JsonSerializer().Serialize(t);
Assert.That(j, Is.EqualTo(@"{""I"":4711,""L"":[1,2,3],""S"":""Hello, world.""}"));
Notes
-----
Deserialization is a two step process. First, JSON text is deserialized into generic CLR objects, i.e.
JSON arrays into `List<object>` and JSON objects into `Dictionary<object>`. If you only need this, then you can
just include `JsonParser.cs`.
Type information can be preserved when de/serializing by setting the `UseTypeInfo` property to true on the `JsonSerializer` object.
This will emit the class name of a serialized object as an additional property (can be configured through the property `TypeInfoPropertyName`, default is `@type`)
for classes which are derived and/or implement an interface.
License
-------
[MIT X11](http://en.wikipedia.org/wiki/MIT_License)
Used at
---------
[UpdateStar](http://www.updatestar.com/)

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using winPEAS.Helpers;
namespace winPEAS._3rdParty.Watson
{
@ -20,20 +21,24 @@ namespace winPEAS._3rdParty.Watson
{
foreach (Vulnerability vuln in _vulnerabilities.Where(i => i.Vulnerable))
{
Console.WriteLine(" [!] {0} : VULNERABLE", vuln.Identification);
Beaprint.BadPrint($" [!] {vuln.Identification} : VULNERABLE");
foreach (string exploit in vuln.KnownExploits)
{
Console.WriteLine(" [>] {0}", exploit);
Beaprint.BadPrint($" [>] {exploit}");
}
Console.WriteLine();
}
if (_vulnerabilities.Any(e => e.Vulnerable))
Console.WriteLine(" [*] Finished. Found {0} potential vulnerabilities.\r\n", _vulnerabilities.Count(i => i.Vulnerable));
{
Beaprint.BadPrint($" [*] Finished. Found {_vulnerabilities.Count(i => i.Vulnerable)} potential vulnerabilities.\r\n");
}
else
Console.WriteLine(" [*] Finished. Found 0 vulnerabilities.\r\n");
{
Beaprint.GoodPrint(" [*] Finished. Found 0 vulnerabilities.\r\n");
}
}
private List<Vulnerability> Populate()

View File

@ -58,24 +58,24 @@ namespace winPEAS._3rdParty.Watson
#endif
// List of Vulnerabilities
var vulnerabiltiies = new VulnerabilityCollection();
var vulnerabilities = new VulnerabilityCollection();
// Check each one
CVE_2019_0836.Check(vulnerabiltiies, buildNumber, installedKBs);
CVE_2019_0841.Check(vulnerabiltiies, buildNumber, installedKBs);
CVE_2019_1064.Check(vulnerabiltiies, buildNumber, installedKBs);
CVE_2019_1130.Check(vulnerabiltiies, buildNumber, installedKBs);
CVE_2019_1253.Check(vulnerabiltiies, buildNumber, installedKBs);
CVE_2019_1315.Check(vulnerabiltiies, buildNumber, installedKBs);
CVE_2019_1385.Check(vulnerabiltiies, buildNumber, installedKBs);
CVE_2019_1388.Check(vulnerabiltiies, buildNumber, installedKBs);
CVE_2019_1405.Check(vulnerabiltiies, buildNumber, installedKBs);
CVE_2020_0668.Check(vulnerabiltiies, buildNumber, installedKBs);
CVE_2020_0683.Check(vulnerabiltiies, buildNumber, installedKBs);
CVE_2020_1013.Check(vulnerabiltiies, buildNumber, installedKBs);
CVE_2019_0836.Check(vulnerabilities, buildNumber, installedKBs);
CVE_2019_0841.Check(vulnerabilities, buildNumber, installedKBs);
CVE_2019_1064.Check(vulnerabilities, buildNumber, installedKBs);
CVE_2019_1130.Check(vulnerabilities, buildNumber, installedKBs);
CVE_2019_1253.Check(vulnerabilities, buildNumber, installedKBs);
CVE_2019_1315.Check(vulnerabilities, buildNumber, installedKBs);
CVE_2019_1385.Check(vulnerabilities, buildNumber, installedKBs);
CVE_2019_1388.Check(vulnerabilities, buildNumber, installedKBs);
CVE_2019_1405.Check(vulnerabilities, buildNumber, installedKBs);
CVE_2020_0668.Check(vulnerabilities, buildNumber, installedKBs);
CVE_2020_0683.Check(vulnerabilities, buildNumber, installedKBs);
CVE_2020_1013.Check(vulnerabilities, buildNumber, installedKBs);
// Print the results
vulnerabiltiies.ShowResults();
vulnerabilities.ShowResults();
}
}
}

View File

@ -16,8 +16,6 @@ namespace winPEAS.Checks
public static bool IsNoColor = false;
public static bool ExecCmd = false;
public static bool Banner = true;
public static bool IsSearchFast = true;
public static int SearchTime = 50;
public static bool IsDebug = false;
// Create Dynamic blacklists
@ -120,11 +118,6 @@ namespace winPEAS.Checks
Banner = false;
}
if (string.Equals(arg, "searchslow", StringComparison.CurrentCultureIgnoreCase))
{
IsSearchFast = false;
}
if (string.Equals(arg, "wait", StringComparison.CurrentCultureIgnoreCase))
{
wait = true;

View File

@ -8,6 +8,7 @@ using winPEAS.Helpers.Search;
using winPEAS.Info.UserInfo;
using winPEAS.InterestingFiles;
using winPEAS.KnownFileCreds;
using winPEAS.KnownFileCreds.Slack;
using winPEAS.KnownFileCreds.SuperPutty;
namespace winPEAS.Checks
@ -124,6 +125,7 @@ namespace winPEAS.Checks
PrintPossCredsRegs,
PrintUserCredsFiles,
PrintOracleSQLDeveloperConfigFiles,
Slack.PrintInfo,
PrintUsersInterestingFiles,
PrintUsersDocsKeys,
PrintRecentFiles,
@ -132,6 +134,8 @@ namespace winPEAS.Checks
PrintOtherUsersInterestingFiles,
PrintExecutablesInNonDefaultFoldersWithWritePermissions,
}.ForEach(action => CheckRunner.Run(action, isDebug));
SearchHelper.CleanLists();
}
void PrintCloudCreds()

View File

@ -144,7 +144,7 @@ namespace winPEAS.Checks
foreach (var tcpConnectionInfo in NetworkInfoHelper.GetTcpConnections(IPVersion.IPv4, processesByPid))
{
Beaprint.AnsiPrint(
string.Format($"{formatString}",
string.Format(formatString,
" TCP",
tcpConnectionInfo.LocalAddress,
tcpConnectionInfo.LocalPort,
@ -177,7 +177,7 @@ namespace winPEAS.Checks
foreach (var tcpConnectionInfo in NetworkInfoHelper.GetTcpConnections(IPVersion.IPv6, processesByPid))
{
Beaprint.AnsiPrint(
string.Format($"{formatString}",
string.Format(formatString,
" TCP",
$"[{tcpConnectionInfo.LocalAddress}]",
tcpConnectionInfo.LocalPort,
@ -220,7 +220,7 @@ namespace winPEAS.Checks
foreach (var udpConnectionInfo in NetworkInfoHelper.GetUdpConnections(IPVersion.IPv4, processesByPid))
{
Beaprint.AnsiPrint(
string.Format($"{formatString}",
string.Format(formatString,
" UDP",
udpConnectionInfo.LocalAddress,
udpConnectionInfo.LocalPort,
@ -251,7 +251,7 @@ namespace winPEAS.Checks
foreach (var udpConnectionInfo in NetworkInfoHelper.GetUdpConnections(IPVersion.IPv6, processesByPid))
{
Beaprint.AnsiPrint(
string.Format($"{formatString}",
string.Format(formatString,
" UDP",
$"[{udpConnectionInfo.LocalAddress}]",
udpConnectionInfo.LocalPort,

View File

@ -577,11 +577,13 @@ namespace winPEAS.Checks
try
{
string formatString = " {0,-100} {1}\n";
Beaprint.NoColorPrint(string.Format($"{formatString}", "Name", "Sddl"));
foreach (var namedPipe in NamedPipes.GetNamedPipeInfos())
{
Beaprint.BadPrint($" Name: {namedPipe.Name}\n" +
$" Sddl: {namedPipe.Sddl}\n");
Beaprint.PrintLineSeparator();
Beaprint.BadPrint(string.Format(formatString, namedPipe.Name, namedPipe.Sddl));
}
}
catch (Exception ex)
@ -602,7 +604,7 @@ namespace winPEAS.Checks
{
var providerPath = RegistryHelper.GetRegValue("HKLM", $"SOFTWARE\\Classes\\CLSID\\{provider}\\InprocServer32", "");
Beaprint.BadPrint($" Provider: {provider}\n" +
Beaprint.NoColorPrint($" Provider: {provider}\n" +
$" Path: {providerPath}\n");
Beaprint.PrintLineSeparator();

View File

@ -107,7 +107,6 @@ namespace winPEAS.Helpers
{
Console.WriteLine(YELLOW + " [*] " + GREEN + "WinPEAS is a binary to enumerate possible paths to escalate privileges locally" + NOCOLOR);
Console.WriteLine(LBLUE + " quiet" + GRAY + " Do not print banner" + NOCOLOR);
Console.WriteLine(LBLUE + " searchslow" + GRAY + " Sleep while searching files to not consume a notable amount of resources" + NOCOLOR);
Console.WriteLine(LBLUE + " cmd" + GRAY + " Obtain wifi, cred manager and clipboard information executing CMD commands" + NOCOLOR);
Console.WriteLine(LBLUE + " notcolor" + GRAY + " Don't use ansi colors (all white)" + NOCOLOR);
Console.WriteLine(LBLUE + " systeminfo" + GRAY + " Search system information" + NOCOLOR);

View File

@ -203,6 +203,18 @@ namespace winPEAS.Helpers.Search
SearchHelper.GroupPolicyHistory.AddRange(groupPolicyHistoryLegacyFiles);
}
internal static void CleanLists()
{
SearchHelper.RootDirUsers = null;
SearchHelper.RootDirCurrentUser = null;
SearchHelper.ProgramFiles = null;
SearchHelper.ProgramFilesX86 = null;
SearchHelper.DocumentsAndSettings = null;
SearchHelper.GroupPolicyHistory = null;
GC.Collect();
}
internal static IEnumerable<CustomFileInfo> SearchUserCredsFiles()
{
var patterns = new List<string>

View File

@ -7,13 +7,13 @@ namespace winPEAS.Info.NetworkInfo
[StructLayout(LayoutKind.Sequential)]
public abstract class NetworkConnection
{
public virtual Protocol Protocol { get; set; }
public virtual IPAddress LocalAddress { get; set; }
public virtual ushort LocalPort { get; set; }
public virtual int ProcessId { get; set; }
public virtual string ProcessName { get; set; }
public Protocol Protocol { get; set; }
public IPAddress LocalAddress { get; set; }
public ushort LocalPort { get; set; }
public int ProcessId { get; set; }
public string ProcessName { get; set; }
public NetworkConnection(
protected NetworkConnection(
Protocol protocol,
IPAddress localAddress,
ushort localPort,

View File

@ -38,9 +38,8 @@ namespace winPEAS.Info.SystemInfo.NamedPipes
public static IEnumerable<NamedPipeInfo> GetNamedPipeInfos()
{
var namedPipes = new List<string>();
WIN32_FIND_DATA lpFindFileData;
var ptr = FindFirstFile(@"\\.\pipe\*", out lpFindFileData);
var ptr = FindFirstFile(@"\\.\pipe\*", out var lpFindFileData);
namedPipes.Add(lpFindFileData.cFileName);
while (FindNextFile(ptr, out lpFindFileData))
{
@ -52,23 +51,21 @@ namespace winPEAS.Info.SystemInfo.NamedPipes
foreach (var namedPipe in namedPipes)
{
FileSecurity security;
string sddl;
bool isError = false;
try
{
security = File.GetAccessControl(System.String.Format("\\\\.\\pipe\\{0}", namedPipe));
var security = File.GetAccessControl($"\\\\.\\pipe\\{namedPipe}");
sddl = security.GetSecurityDescriptorSddlForm(AccessControlSections.All);
}
catch
{
isError = true;
sddl = "ERROR";
}
if (!string.IsNullOrEmpty(sddl) && !sddl.Equals("ERROR"))
{
yield return new NamedPipeInfo(namedPipe, sddl);
}
else
if (!isError && !string.IsNullOrEmpty(sddl))
{
yield return new NamedPipeInfo(namedPipe, sddl);
}

View File

@ -3,10 +3,10 @@ using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web.Script.Serialization;
using winPEAS._3rdParty.BouncyCastle.crypto.engines;
using winPEAS._3rdParty.BouncyCastle.crypto.modes;
using winPEAS._3rdParty.BouncyCastle.crypto.parameters;
using winPEAS._3rdParty.MicroJson;
namespace winPEAS.KnownFileCreds.Browsers.Decryptor
{
@ -28,7 +28,7 @@ namespace winPEAS.KnownFileCreds.Browsers.Decryptor
var appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);// APPDATA
var path = Path.GetFullPath(appdata + localStatePath);
var v = File.ReadAllText(path);
var json = new JsonSerializer().Deserialize<LocalState>(v);
var json = new JavaScriptSerializer().Deserialize<LocalState>(v);
string key = json.os_crypt.encrypted_key;