Showing
24 changed files
with
651 additions
and
30 deletions
VulnNotti/material-dashboard-html-v2.0.0/material-dashboard-html-v2.0.0/.DS_Store
deleted
100644 → 0
No preview for this file type
VulnNotti/material-dashboard-html-v2.0.0/material-dashboard-html-v2.0.0/BS4/.DS_Store
deleted
100644 → 0
No preview for this file type
VulnNotti/material-dashboard-html-v2.0.0/material-dashboard-html-v2.0.0/BS4/assets/.DS_Store
deleted
100644 → 0
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
VulnNotti/material-dashboard-html-v2.0.0/material-dashboard-html-v2.0.0/BS4/docs/.DS_Store
deleted
100644 → 0
No preview for this file type
No preview for this file type
Vulnerablity_DB/Flicker/Class1.cs
0 → 100644
Vulnerablity_DB/Flicker/Element.cs
0 → 100644
1 | +using System; | ||
2 | + | ||
3 | +namespace Flicker | ||
4 | +{ | ||
5 | + public abstract class Element : IRenderable | ||
6 | + { | ||
7 | + public readonly int Height; | ||
8 | + public readonly int Width; | ||
9 | + public readonly int X; | ||
10 | + public readonly int Y; | ||
11 | + | ||
12 | + protected Element(int x, int y, int width, int height) | ||
13 | + { | ||
14 | + X = x; | ||
15 | + Y = y; | ||
16 | + Width = width; | ||
17 | + Height = height; | ||
18 | + } | ||
19 | + | ||
20 | + protected Element(float x, float y, float width, float height) | ||
21 | + { | ||
22 | + x = x.Clamp(0, .99f); | ||
23 | + y = y.Clamp(0, .99f); | ||
24 | + width = width.Clamp(0, .99f); | ||
25 | + height = height.Clamp(0, .99f); | ||
26 | + | ||
27 | + X = (int)(Console.BufferWidth * x); | ||
28 | + Y = (int)(Console.BufferHeight * y); | ||
29 | + Width = (int)(Console.BufferWidth * width); | ||
30 | + Height = (int)(Console.BufferHeight * height); | ||
31 | + } | ||
32 | + | ||
33 | + public bool Visible { get; set; } = true; | ||
34 | + public char Border { get; set; } = ' '; | ||
35 | + public int Padding { get; set; } = 1; // Must be at least 1 (to make room for header), TODO enforce this | ||
36 | + public ConsoleColor Foreground { get; set; } = ConsoleColor.White; | ||
37 | + public ConsoleColor Background { get; set; } = ConsoleColor.Black; | ||
38 | + public Renderer AssociatedRenderer { get; set; } | ||
39 | + | ||
40 | + public virtual void HandleKey(ConsoleKeyInfo key) { } | ||
41 | + | ||
42 | + /// <summary> | ||
43 | + /// Draw this element | ||
44 | + /// </summary> | ||
45 | + void IRenderable.Render(bool selected) | ||
46 | + { | ||
47 | + if (!Visible) return; | ||
48 | + | ||
49 | + Console.ForegroundColor = Foreground; | ||
50 | + Console.BackgroundColor = Background; | ||
51 | + Console.CursorLeft = X; | ||
52 | + Console.CursorTop = Y; | ||
53 | + | ||
54 | + Tools.Console.Fill( | ||
55 | + X, | ||
56 | + Y, | ||
57 | + Width, | ||
58 | + Height, | ||
59 | + ' ' | ||
60 | + ); | ||
61 | + | ||
62 | + if (Border != ' ') | ||
63 | + { | ||
64 | + // Top and bottom borders | ||
65 | + Console.CursorLeft = X; | ||
66 | + Console.CursorTop = Y; | ||
67 | + Console.Write(new string(Border, Width)); | ||
68 | + Console.CursorLeft = X; | ||
69 | + Console.CursorTop = Y + Height - 1; | ||
70 | + Console.Write(new string(Border, Width)); | ||
71 | + | ||
72 | + // Left and right borders | ||
73 | + for (var y = Y; y < Y + Height - 1; ++y) | ||
74 | + { | ||
75 | + Tools.Console.WriteAt(X, y, Border.ToString()); | ||
76 | + Tools.Console.WriteAt(X + Width - 1, y, Border.ToString()); | ||
77 | + } | ||
78 | + } | ||
79 | + | ||
80 | + if (selected) | ||
81 | + Tools.Console.WriteAt( | ||
82 | + X, Y, | ||
83 | + new string('\u2580', Width), | ||
84 | + ConsoleColor.Red | ||
85 | + ); | ||
86 | + | ||
87 | + Console.CursorLeft = X + Padding * 2; | ||
88 | + Console.CursorTop = Y + Padding; | ||
89 | + | ||
90 | + CustomRender(); | ||
91 | + | ||
92 | + Console.ResetColor(); | ||
93 | + } | ||
94 | + | ||
95 | + public void Select() => AssociatedRenderer.Select(this); | ||
96 | + | ||
97 | + public void Destroy() => AssociatedRenderer.Destroy(this); | ||
98 | + | ||
99 | + protected virtual void CustomRender() { } | ||
100 | + } | ||
101 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
Vulnerablity_DB/Flicker/Extensions.cs
0 → 100644
1 | +using System.Collections.Generic; | ||
2 | +using System.Linq; | ||
3 | +using System.Text.RegularExpressions; | ||
4 | + | ||
5 | +namespace Flicker | ||
6 | +{ | ||
7 | + internal static class Extensions | ||
8 | + { | ||
9 | + internal static IEnumerable<string> Chunks(this string str, int size) | ||
10 | + { | ||
11 | + return Regex.Matches(str, "(.{1," + size + "})").Cast<Match>().Select(m => m.Value); | ||
12 | + } | ||
13 | + } | ||
14 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
Vulnerablity_DB/Flicker/Flicker.csproj
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
4 | + <PropertyGroup> | ||
5 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
6 | + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
7 | + <ProjectGuid>{DB1A8C9F-3FA2-4D8C-BBBA-F88F245E13B4}</ProjectGuid> | ||
8 | + <OutputType>Library</OutputType> | ||
9 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
10 | + <RootNamespace>Flicker</RootNamespace> | ||
11 | + <AssemblyName>Flicker</AssemblyName> | ||
12 | + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
13 | + <FileAlignment>512</FileAlignment> | ||
14 | + <NuGetPackageImportStamp> | ||
15 | + </NuGetPackageImportStamp> | ||
16 | + </PropertyGroup> | ||
17 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
18 | + <DebugSymbols>true</DebugSymbols> | ||
19 | + <DebugType>full</DebugType> | ||
20 | + <Optimize>false</Optimize> | ||
21 | + <OutputPath>bin\Debug\</OutputPath> | ||
22 | + <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
23 | + <ErrorReport>prompt</ErrorReport> | ||
24 | + <WarningLevel>4</WarningLevel> | ||
25 | + </PropertyGroup> | ||
26 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
27 | + <DebugType>pdbonly</DebugType> | ||
28 | + <Optimize>true</Optimize> | ||
29 | + <OutputPath>bin\Release\</OutputPath> | ||
30 | + <DefineConstants>TRACE</DefineConstants> | ||
31 | + <ErrorReport>prompt</ErrorReport> | ||
32 | + <WarningLevel>4</WarningLevel> | ||
33 | + </PropertyGroup> | ||
34 | + <ItemGroup> | ||
35 | + <Reference Include="System" /> | ||
36 | + <Reference Include="System.Core" /> | ||
37 | + <Reference Include="System.Xml.Linq" /> | ||
38 | + <Reference Include="System.Data.DataSetExtensions" /> | ||
39 | + <Reference Include="Microsoft.CSharp" /> | ||
40 | + <Reference Include="System.Data" /> | ||
41 | + <Reference Include="System.Net.Http" /> | ||
42 | + <Reference Include="System.Xml" /> | ||
43 | + </ItemGroup> | ||
44 | + <ItemGroup> | ||
45 | + <Compile Include="Element.cs" /> | ||
46 | + <Compile Include="Extensions.cs" /> | ||
47 | + <Compile Include="IRenderable.cs" /> | ||
48 | + <Compile Include="Properties\AssemblyInfo.cs" /> | ||
49 | + <Compile Include="Renderer.cs" /> | ||
50 | + <Compile Include="MenuElement.cs" /> | ||
51 | + <Compile Include="InputElement.cs" /> | ||
52 | + <Compile Include="TextElement.cs" /> | ||
53 | + <Compile Include="Tools.cs" /> | ||
54 | + </ItemGroup> | ||
55 | + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
56 | + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
57 | + Other similar extension points exist, see Microsoft.Common.targets. | ||
58 | + <Target Name="BeforeBuild"> | ||
59 | + </Target> | ||
60 | + <Target Name="AfterBuild"> | ||
61 | + </Target> | ||
62 | + --> | ||
63 | +</Project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
Vulnerablity_DB/Flicker/IRenderable.cs
0 → 100644
1 | +using System; | ||
2 | + | ||
3 | +namespace Flicker | ||
4 | +{ | ||
5 | + public interface IRenderable | ||
6 | + { | ||
7 | + Renderer AssociatedRenderer { get; set; } | ||
8 | + | ||
9 | + void Render(bool selected); | ||
10 | + | ||
11 | + void HandleKey(ConsoleKeyInfo key); | ||
12 | + | ||
13 | + void Select(); | ||
14 | + | ||
15 | + void Destroy(); | ||
16 | + } | ||
17 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
Vulnerablity_DB/Flicker/InputElement.cs
0 → 100644
1 | +using System; | ||
2 | + | ||
3 | +namespace Flicker | ||
4 | +{ | ||
5 | + public class InputElement : Element | ||
6 | + { | ||
7 | + public InputElement(out string result, string label) | ||
8 | + : base(0, 0, 0, 0) | ||
9 | + { | ||
10 | + Visible = false; | ||
11 | + Console.Clear(); | ||
12 | + Tools.Console.Fill(0, 1, Console.BufferWidth, Console.BufferHeight - 2, '\u2588'); | ||
13 | + Tools.Console.WriteAt(0, 0, label); | ||
14 | + result = Console.ReadLine(); | ||
15 | + } | ||
16 | + } | ||
17 | + | ||
18 | + public class InputElement<T> : Element | ||
19 | + { | ||
20 | + public InputElement(out T result, string label) | ||
21 | + : base(0, 0, 0, 0) | ||
22 | + { | ||
23 | + Visible = false; | ||
24 | + Console.Clear(); | ||
25 | + Tools.Console.Fill(0, 1, Console.BufferWidth, Console.BufferHeight - 2, '\u2588'); | ||
26 | + Tools.Console.WriteAt(0, 0, label); | ||
27 | + | ||
28 | + var input = Console.ReadLine(); | ||
29 | + | ||
30 | + try | ||
31 | + { | ||
32 | + result = (T)Convert.ChangeType(input, typeof(T)); | ||
33 | + } | ||
34 | + catch | ||
35 | + { | ||
36 | + // Fail silently | ||
37 | + result = default(T); | ||
38 | + } | ||
39 | + } | ||
40 | + } | ||
41 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
Vulnerablity_DB/Flicker/MenuElement.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | + | ||
4 | +namespace Flicker | ||
5 | +{ | ||
6 | + public class MenuElement : Element | ||
7 | + { | ||
8 | + public MenuElement(int x, int y, int width, int height) | ||
9 | + : base(x, y, width, height) { } | ||
10 | + | ||
11 | + public MenuElement(float x, float y, float width, float height) | ||
12 | + : base(x, y, width, height) { } | ||
13 | + | ||
14 | + public List<MenuItem> Items { get; set; } = new List<MenuItem>(); | ||
15 | + private int SelectedIndex { get; set; } | ||
16 | + | ||
17 | + public override void HandleKey(ConsoleKeyInfo key) | ||
18 | + { | ||
19 | + switch (key.Key) | ||
20 | + { | ||
21 | + case ConsoleKey.UpArrow: | ||
22 | + SelectedIndex = (--SelectedIndex).Wrap(0, Items.Count - 1); | ||
23 | + break; | ||
24 | + | ||
25 | + case ConsoleKey.DownArrow: | ||
26 | + SelectedIndex = (++SelectedIndex).Wrap(0, Items.Count - 1); | ||
27 | + break; | ||
28 | + | ||
29 | + case ConsoleKey.Enter: | ||
30 | + Items[SelectedIndex].Method(); | ||
31 | + break; | ||
32 | + } | ||
33 | + } | ||
34 | + | ||
35 | + protected override void CustomRender() | ||
36 | + { | ||
37 | + for (var i = 0; i < Items.Count; ++i) | ||
38 | + { | ||
39 | + Console.BackgroundColor = Background; | ||
40 | + Console.ForegroundColor = Foreground; | ||
41 | + | ||
42 | + if (i == SelectedIndex) | ||
43 | + { | ||
44 | + Console.BackgroundColor = ConsoleColor.DarkGray; | ||
45 | + Console.ForegroundColor = ConsoleColor.White; | ||
46 | + } | ||
47 | + | ||
48 | + Console.Write(Items[i].Label); | ||
49 | + ++Console.CursorTop; | ||
50 | + Console.CursorLeft = X + Padding * 2; | ||
51 | + } | ||
52 | + } | ||
53 | + } | ||
54 | + | ||
55 | + public class MenuItem | ||
56 | + { | ||
57 | + public Action Method { get; set; } | ||
58 | + public string Label { get; set; } | ||
59 | + } | ||
60 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +using System.Reflection; | ||
2 | +using System.Runtime.InteropServices; | ||
3 | + | ||
4 | +// General Information about an assembly is controlled through the following | ||
5 | +// set of attributes. Change these attribute values to modify the information | ||
6 | +// associated with an assembly. | ||
7 | + | ||
8 | +[assembly: AssemblyTitle("Flicker")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("")] | ||
12 | +[assembly: AssemblyProduct("Flicker")] | ||
13 | +[assembly: AssemblyCopyright("Copyright © 2016")] | ||
14 | +[assembly: AssemblyTrademark("")] | ||
15 | +[assembly: AssemblyCulture("")] | ||
16 | + | ||
17 | +// Setting ComVisible to false makes the types in this assembly not visible | ||
18 | +// to COM components. If you need to access a type in this assembly from | ||
19 | +// COM, set the ComVisible attribute to true on that type. | ||
20 | + | ||
21 | +[assembly: ComVisible(false)] | ||
22 | + | ||
23 | +// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
24 | + | ||
25 | +[assembly: Guid("db1a8c9f-3fa2-4d8c-bbba-f88f245e13b4")] | ||
26 | + | ||
27 | +// Version information for an assembly consists of the following four values: | ||
28 | +// | ||
29 | +// Major Version | ||
30 | +// Minor Version | ||
31 | +// Build Number | ||
32 | +// Revision | ||
33 | +// | ||
34 | +// You can specify all the values or you can default the Build and Revision Numbers | ||
35 | +// by using the '*' as shown below: | ||
36 | +// [assembly: AssemblyVersion("1.0.*")] | ||
37 | + | ||
38 | +[assembly: AssemblyVersion("1.0.0.0")] | ||
39 | +[assembly: AssemblyFileVersion("1.0.0.0")] | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
Vulnerablity_DB/Flicker/Renderer.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | + | ||
4 | +namespace Flicker | ||
5 | +{ | ||
6 | + public class Renderer | ||
7 | + { | ||
8 | + public Renderer() | ||
9 | + { | ||
10 | + // Make buffer the size of the window | ||
11 | + Console.BufferWidth = Console.WindowWidth; | ||
12 | + Console.BufferHeight = Console.WindowHeight; | ||
13 | + Console.CursorVisible = false; | ||
14 | + } | ||
15 | + | ||
16 | + private List<IRenderable> RenderItems { get; } = new List<IRenderable>(); | ||
17 | + private int SelectedIndex { get; set; } | ||
18 | + | ||
19 | + public void Render() | ||
20 | + { | ||
21 | + while (true) | ||
22 | + { | ||
23 | + Console.ResetColor(); | ||
24 | + Console.Clear(); | ||
25 | + | ||
26 | + try | ||
27 | + { | ||
28 | + foreach (var el in RenderItems) | ||
29 | + el.Render(RenderItems[SelectedIndex] == el); | ||
30 | + } | ||
31 | + catch | ||
32 | + { | ||
33 | + // Nom | ||
34 | + } | ||
35 | + | ||
36 | + Poll(); | ||
37 | + } | ||
38 | + } | ||
39 | + | ||
40 | + private void Poll() | ||
41 | + { | ||
42 | + var key = Console.ReadKey(false); | ||
43 | + | ||
44 | + if ((key.Modifiers & ConsoleModifiers.Control) != 0) | ||
45 | + { | ||
46 | + switch (key.Key) | ||
47 | + { | ||
48 | + case ConsoleKey.RightArrow: | ||
49 | + SelectedIndex = (++SelectedIndex).Wrap(0, RenderItems.Count - 1); | ||
50 | + break; | ||
51 | + | ||
52 | + case ConsoleKey.LeftArrow: | ||
53 | + SelectedIndex = (--SelectedIndex).Wrap(0, RenderItems.Count - 1); | ||
54 | + break; | ||
55 | + } | ||
56 | + | ||
57 | + return; | ||
58 | + } | ||
59 | + | ||
60 | + RenderItems[SelectedIndex].HandleKey(key); | ||
61 | + } | ||
62 | + | ||
63 | + public bool Register(IRenderable element) | ||
64 | + { | ||
65 | + element.AssociatedRenderer = this; | ||
66 | + RenderItems.Add(element); | ||
67 | + return true; | ||
68 | + } | ||
69 | + | ||
70 | + public void Select(IRenderable element) | ||
71 | + { | ||
72 | + SelectedIndex = RenderItems.IndexOf(element); | ||
73 | + } | ||
74 | + | ||
75 | + public void Destroy(IRenderable element) | ||
76 | + { | ||
77 | + RenderItems.Remove(element); | ||
78 | + } | ||
79 | + } | ||
80 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
Vulnerablity_DB/Flicker/TextElement.cs
0 → 100644
1 | +using System; | ||
2 | + | ||
3 | +namespace Flicker | ||
4 | +{ | ||
5 | + public class TextElement : Element | ||
6 | + { | ||
7 | + public TextElement(int x, int y, int width, int height) | ||
8 | + : base(x, y, width, height) { } | ||
9 | + | ||
10 | + public TextElement(float x, float y, float width, float height) | ||
11 | + : base(x, y, width, height) { } | ||
12 | + | ||
13 | + public string Text { get; set; } = ""; | ||
14 | + public bool Wrap { get; set; } = true; | ||
15 | + | ||
16 | + protected override void CustomRender() | ||
17 | + { | ||
18 | + if (!Wrap) | ||
19 | + { | ||
20 | + Console.Write(Text); | ||
21 | + return; | ||
22 | + } | ||
23 | + | ||
24 | + foreach (var line in Text.Chunks(Width - Padding * 4)) | ||
25 | + { | ||
26 | + Console.Write(line.Trim()); | ||
27 | + ++Console.CursorTop; | ||
28 | + Console.CursorLeft = X + Padding * 2; | ||
29 | + } | ||
30 | + } | ||
31 | + } | ||
32 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
Vulnerablity_DB/Flicker/Tools.cs
0 → 100644
1 | +using System; | ||
2 | + | ||
3 | +namespace Flicker | ||
4 | +{ | ||
5 | + internal static class Tools | ||
6 | + { | ||
7 | + public static T Clamp<T>(this T val, T min) | ||
8 | + where T : IComparable<T> => | ||
9 | + val.CompareTo(min) < 0 | ||
10 | + ? min | ||
11 | + : val; | ||
12 | + | ||
13 | + public static T Clamp<T>(this T val, T min, T max) | ||
14 | + where T : IComparable<T> => | ||
15 | + val.CompareTo(min) < 0 | ||
16 | + ? min | ||
17 | + : val.CompareTo(max) > 0 | ||
18 | + ? max | ||
19 | + : val; | ||
20 | + | ||
21 | + public static T Wrap<T>(this T val, T min, T max) | ||
22 | + where T : IComparable<T> => | ||
23 | + val.CompareTo(min) < 0 | ||
24 | + ? max | ||
25 | + : val.CompareTo(max) > 0 | ||
26 | + ? min | ||
27 | + : val; | ||
28 | + | ||
29 | + public static class Console | ||
30 | + { | ||
31 | + public static void WriteAt(int x, int y, string str) | ||
32 | + { | ||
33 | + System.Console.CursorLeft = x; | ||
34 | + System.Console.CursorTop = y; | ||
35 | + System.Console.Write(str); | ||
36 | + } | ||
37 | + | ||
38 | + public static void WriteAt(int x, int y, string str, ConsoleColor colour) | ||
39 | + { | ||
40 | + var old = System.Console.ForegroundColor; | ||
41 | + System.Console.ForegroundColor = colour; | ||
42 | + WriteAt(x, y, str); | ||
43 | + System.Console.ForegroundColor = old; | ||
44 | + } | ||
45 | + | ||
46 | + public static void Fill(int x, int y, int width, int height, char c) | ||
47 | + { | ||
48 | + for (var i = x; i < x + width; ++i) | ||
49 | + for (var j = y; j < y + height; ++j) | ||
50 | + WriteAt(i, j, c.ToString()); | ||
51 | + } | ||
52 | + | ||
53 | + public static void Fill(int x, int y, int width, int height, char c, ConsoleColor colour) | ||
54 | + { | ||
55 | + var old = System.Console.ForegroundColor; | ||
56 | + System.Console.ForegroundColor = colour; | ||
57 | + Fill(x, y, width, height, c); | ||
58 | + System.Console.ForegroundColor = old; | ||
59 | + } | ||
60 | + } | ||
61 | + } | ||
62 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -24,6 +24,28 @@ namespace VulnCrawler | ... | @@ -24,6 +24,28 @@ namespace VulnCrawler |
24 | public IEnumerable<string> CriticalList { get; set; } | 24 | public IEnumerable<string> CriticalList { get; set; } |
25 | 25 | ||
26 | } | 26 | } |
27 | + | ||
28 | + public class UserBlock | ||
29 | + { | ||
30 | + public int Len { get; set; } | ||
31 | + public string FuncName { get; set; } | ||
32 | + public string Hash { get; set; } | ||
33 | + public string Path { get; set; } | ||
34 | + | ||
35 | + public override bool Equals(object obj) | ||
36 | + { | ||
37 | + var block = obj as UserBlock; | ||
38 | + return block != null && | ||
39 | + Hash == block.Hash; | ||
40 | + } | ||
41 | + | ||
42 | + public override int GetHashCode() | ||
43 | + { | ||
44 | + var hashCode = -481433985; | ||
45 | + hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Hash); | ||
46 | + return hashCode; | ||
47 | + } | ||
48 | + } | ||
27 | protected Regex extractMethodLine; | 49 | protected Regex extractMethodLine; |
28 | protected HashSet<string> ReservedList { get; } | 50 | protected HashSet<string> ReservedList { get; } |
29 | protected abstract string ReservedFileName { get; } | 51 | protected abstract string ReservedFileName { get; } |
... | @@ -121,7 +143,7 @@ namespace VulnCrawler | ... | @@ -121,7 +143,7 @@ namespace VulnCrawler |
121 | /// <returns>함수 문자열</returns> | 143 | /// <returns>함수 문자열</returns> |
122 | protected abstract string GetOriginalFunc(Stream oldStream, string methodName); | 144 | protected abstract string GetOriginalFunc(Stream oldStream, string methodName); |
123 | 145 | ||
124 | - public abstract IDictionary<int, List<string>> CrawlUserCode(StreamReader reader); | 146 | + public abstract IDictionary<int, IEnumerable<UserBlock>> CrawlUserCode(StreamReader reader); |
125 | 147 | ||
126 | protected abstract IList<Block> GetCriticalBlocks(string srcCode, IEnumerable<string> criticalList); | 148 | protected abstract IList<Block> GetCriticalBlocks(string srcCode, IEnumerable<string> criticalList); |
127 | /// <summary> | 149 | /// <summary> | ... | ... |
... | @@ -533,7 +533,7 @@ namespace VulnCrawler | ... | @@ -533,7 +533,7 @@ namespace VulnCrawler |
533 | 533 | ||
534 | var removes = Regex.Split(blockCode, Environment.NewLine, RegexOptions.Multiline); | 534 | var removes = Regex.Split(blockCode, Environment.NewLine, RegexOptions.Multiline); |
535 | StringBuilder builder = new StringBuilder(); | 535 | StringBuilder builder = new StringBuilder(); |
536 | - Console.ForegroundColor = ConsoleColor.DarkYellow; | 536 | + // Console.ForegroundColor = ConsoleColor.DarkYellow; |
537 | foreach (var item in removes) | 537 | foreach (var item in removes) |
538 | { | 538 | { |
539 | if (string.IsNullOrWhiteSpace(item)) | 539 | if (string.IsNullOrWhiteSpace(item)) |
... | @@ -543,8 +543,8 @@ namespace VulnCrawler | ... | @@ -543,8 +543,8 @@ namespace VulnCrawler |
543 | string rm = regex1.Replace(item, ""); | 543 | string rm = regex1.Replace(item, ""); |
544 | builder.Append(rm); | 544 | builder.Append(rm); |
545 | } | 545 | } |
546 | - Console.WriteLine(builder.ToString()); | 546 | + // Console.WriteLine(builder.ToString()); |
547 | - Console.ResetColor(); | 547 | + // Console.ResetColor(); |
548 | string line = builder.ToString(); | 548 | string line = builder.ToString(); |
549 | 549 | ||
550 | var varList = ExtractMethodVariantList(line, skipDefine: false); | 550 | var varList = ExtractMethodVariantList(line, skipDefine: false); |
... | @@ -642,9 +642,11 @@ namespace VulnCrawler | ... | @@ -642,9 +642,11 @@ namespace VulnCrawler |
642 | return temp; | 642 | return temp; |
643 | } | 643 | } |
644 | 644 | ||
645 | - public override IDictionary<int, List<string>> CrawlUserCode(StreamReader reader) | 645 | + public override IDictionary<int, IEnumerable<UserBlock>> CrawlUserCode(StreamReader reader) |
646 | { | 646 | { |
647 | - var dict = new Dictionary<int, List<string>>(); | 647 | + |
648 | + | ||
649 | + var dict = new Dictionary<int, IEnumerable<UserBlock>>(); | ||
648 | StringBuilder oldBuilder = new StringBuilder(); | 650 | StringBuilder oldBuilder = new StringBuilder(); |
649 | 651 | ||
650 | bool found = false; | 652 | bool found = false; |
... | @@ -662,33 +664,74 @@ namespace VulnCrawler | ... | @@ -662,33 +664,74 @@ namespace VulnCrawler |
662 | 664 | ||
663 | bool found3 = false; | 665 | bool found3 = false; |
664 | 666 | ||
665 | - | 667 | + bool com = false; |
668 | + | ||
666 | while (!reader.EndOfStream) | 669 | while (!reader.EndOfStream) |
667 | { | 670 | { |
671 | + | ||
668 | string line = reader.ReadLine(); | 672 | string line = reader.ReadLine(); |
669 | - Console.WriteLine(line); | 673 | + string trim = line.Trim(); |
674 | + if (commentLine) | ||
675 | + { | ||
676 | + // 혹시 범위 주석이 끝났는지 체크 | ||
677 | + if (regex1.IsMatch(trim)) | ||
678 | + { | ||
679 | + commentLine = false; | ||
680 | + trim = regex1.Split(trim)[1]; | ||
681 | + } | ||
682 | + else | ||
683 | + { | ||
684 | + continue; | ||
685 | + } | ||
686 | + } | ||
687 | + | ||
688 | + // /* ~ 패턴 | ||
689 | + if (regex3.IsMatch(trim)) | ||
690 | + { | ||
691 | + // /* ~ */ 패턴이 아닌 경우 | ||
692 | + if (!regex4.IsMatch(trim)) | ||
693 | + { | ||
694 | + commentLine = true; | ||
695 | + } | ||
696 | + trim = Regex.Split(trim, "/*")[0]; | ||
697 | + } | ||
698 | + if (com) | ||
699 | + { | ||
700 | + if (trim.StartsWith("*")) | ||
701 | + { | ||
702 | + continue; | ||
703 | + } | ||
704 | + else | ||
705 | + { | ||
706 | + com = false; | ||
707 | + } | ||
708 | + } | ||
670 | // 메서드를 찾은 경우 | 709 | // 메서드를 찾은 경우 |
671 | if (found3) | 710 | if (found3) |
672 | { | 711 | { |
673 | string obStr = oldBuilder.ToString(); | 712 | string obStr = oldBuilder.ToString(); |
674 | obStr = Abstract(obStr, new Dictionary<string, string>(), new Dictionary<string, string>()); | 713 | obStr = Abstract(obStr, new Dictionary<string, string>(), new Dictionary<string, string>()); |
675 | - | ||
676 | if (!dict.ContainsKey(obStr.Length)) | 714 | if (!dict.ContainsKey(obStr.Length)) |
677 | { | 715 | { |
678 | - dict[obStr.Length] = new List<string>(); | 716 | + dict[obStr.Length] = new HashSet<UserBlock>(); |
679 | } | 717 | } |
680 | - dict[obStr.Length].Add(MD5HashFunc(obStr)); | 718 | + string funcName = new string(oldBuilder.ToString().TakeWhile(c => c != '{').ToArray()); |
719 | + | ||
720 | + (dict[obStr.Length] as HashSet<UserBlock>).Add(new UserBlock | ||
721 | + { | ||
722 | + Hash = MD5HashFunc(obStr), | ||
723 | + Len = obStr.Length, | ||
724 | + FuncName = funcName, | ||
725 | + }); | ||
681 | oldBuilder.Clear(); | 726 | oldBuilder.Clear(); |
682 | found = false; | 727 | found = false; |
683 | found2 = false; | 728 | found2 = false; |
684 | found3 = false; | 729 | found3 = false; |
685 | bracketCount = -1; | 730 | bracketCount = -1; |
686 | commentLine = false; | 731 | commentLine = false; |
687 | - | ||
688 | } | 732 | } |
689 | if (found) | 733 | if (found) |
690 | { | 734 | { |
691 | - string trim = line.Trim(); | ||
692 | // 범위 주석 진행되고 있으면 넘어감 | 735 | // 범위 주석 진행되고 있으면 넘어감 |
693 | if (trim.StartsWith("#")) | 736 | if (trim.StartsWith("#")) |
694 | { | 737 | { |
... | @@ -718,7 +761,6 @@ namespace VulnCrawler | ... | @@ -718,7 +761,6 @@ namespace VulnCrawler |
718 | commentLine = true; | 761 | commentLine = true; |
719 | } | 762 | } |
720 | trim = Regex.Split(trim, "/*")[0]; | 763 | trim = Regex.Split(trim, "/*")[0]; |
721 | - | ||
722 | } | 764 | } |
723 | // 비어있는 경우 넘어감 | 765 | // 비어있는 경우 넘어감 |
724 | if (string.IsNullOrWhiteSpace(trim)) | 766 | if (string.IsNullOrWhiteSpace(trim)) |
... | @@ -732,15 +774,10 @@ namespace VulnCrawler | ... | @@ -732,15 +774,10 @@ namespace VulnCrawler |
732 | // 메서드 시작 괄호 찾은 경우 | 774 | // 메서드 시작 괄호 찾은 경우 |
733 | if (found2) | 775 | if (found2) |
734 | { | 776 | { |
735 | - | ||
736 | oldBuilder.AppendLine(line); | 777 | oldBuilder.AppendLine(line); |
737 | // 괄호가 모두 닫혔으니 종료 | 778 | // 괄호가 모두 닫혔으니 종료 |
738 | if (bracketCount < 0) | 779 | if (bracketCount < 0) |
739 | { | 780 | { |
740 | - if (reader.EndOfStream) | ||
741 | - { | ||
742 | - Console.WriteLine("파일끝"); | ||
743 | - } | ||
744 | found3 = true; | 781 | found3 = true; |
745 | continue; | 782 | continue; |
746 | } | 783 | } |
... | @@ -758,9 +795,6 @@ namespace VulnCrawler | ... | @@ -758,9 +795,6 @@ namespace VulnCrawler |
758 | //아직 { 괄호를 못찾았는데 );를 만났다면 메서드 선언 부분이니 넘어감 | 795 | //아직 { 괄호를 못찾았는데 );를 만났다면 메서드 선언 부분이니 넘어감 |
759 | if (trim.EndsWith(");")) | 796 | if (trim.EndsWith(");")) |
760 | { | 797 | { |
761 | - Console.WriteLine("-------"); | ||
762 | - Console.WriteLine(trim); | ||
763 | - Console.WriteLine("-----"); | ||
764 | found = false; | 798 | found = false; |
765 | oldBuilder.Clear(); | 799 | oldBuilder.Clear(); |
766 | continue; | 800 | continue; |
... | @@ -782,7 +816,7 @@ namespace VulnCrawler | ... | @@ -782,7 +816,7 @@ namespace VulnCrawler |
782 | // 메서드 찾았는지 확인 | 816 | // 메서드 찾았는지 확인 |
783 | if (Regex.IsMatch(line, RegexFuncPattern)) | 817 | if (Regex.IsMatch(line, RegexFuncPattern)) |
784 | { | 818 | { |
785 | - string trim = line.Trim(); | 819 | + |
786 | // 주석으로 시작했다면 넘어감 | 820 | // 주석으로 시작했다면 넘어감 |
787 | if (trim.StartsWith("//")) | 821 | if (trim.StartsWith("//")) |
788 | { | 822 | { |
... | @@ -791,6 +825,7 @@ namespace VulnCrawler | ... | @@ -791,6 +825,7 @@ namespace VulnCrawler |
791 | 825 | ||
792 | if (trim.StartsWith("/*")) | 826 | if (trim.StartsWith("/*")) |
793 | { | 827 | { |
828 | + com = true; | ||
794 | continue; | 829 | continue; |
795 | } | 830 | } |
796 | 831 | ||
... | @@ -821,9 +856,19 @@ namespace VulnCrawler | ... | @@ -821,9 +856,19 @@ namespace VulnCrawler |
821 | 856 | ||
822 | if (!dict.ContainsKey(obStr.Length)) | 857 | if (!dict.ContainsKey(obStr.Length)) |
823 | { | 858 | { |
824 | - dict[obStr.Length] = new List<string>(); | 859 | + dict[obStr.Length] = new HashSet<UserBlock>(); |
825 | } | 860 | } |
826 | - dict[obStr.Length].Add(MD5HashFunc(obStr)); | 861 | + string funcName = new string(oldBuilder.ToString().TakeWhile(c => c != '{').ToArray()); |
862 | + | ||
863 | + | ||
864 | + (dict[obStr.Length] as HashSet<UserBlock>).Add(new UserBlock | ||
865 | + { | ||
866 | + Hash = MD5HashFunc(obStr), | ||
867 | + Len = obStr.Length, | ||
868 | + FuncName = funcName, | ||
869 | + | ||
870 | + | ||
871 | + }); | ||
827 | oldBuilder.Clear(); | 872 | oldBuilder.Clear(); |
828 | found = false; | 873 | found = false; |
829 | found2 = false; | 874 | found2 = false; |
... | @@ -831,6 +876,7 @@ namespace VulnCrawler | ... | @@ -831,6 +876,7 @@ namespace VulnCrawler |
831 | bracketCount = -1; | 876 | bracketCount = -1; |
832 | commentLine = false; | 877 | commentLine = false; |
833 | 878 | ||
879 | + | ||
834 | } | 880 | } |
835 | 881 | ||
836 | 882 | ... | ... |
... | @@ -81,7 +81,7 @@ namespace VulnCrawler | ... | @@ -81,7 +81,7 @@ namespace VulnCrawler |
81 | throw new NotImplementedException(); | 81 | throw new NotImplementedException(); |
82 | } | 82 | } |
83 | 83 | ||
84 | - public override IDictionary<int, List<string>> CrawlUserCode(StreamReader reader) | 84 | + public override IDictionary<int, IEnumerable<UserBlock>> CrawlUserCode(StreamReader reader) |
85 | { | 85 | { |
86 | throw new NotImplementedException(); | 86 | throw new NotImplementedException(); |
87 | } | 87 | } | ... | ... |
1 | -using System; | 1 | + |
2 | +using System; | ||
2 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
3 | using System.IO; | 4 | using System.IO; |
4 | using System.Linq; | 5 | using System.Linq; |
... | @@ -13,10 +14,13 @@ namespace VulnUserCodeAnalyzer | ... | @@ -13,10 +14,13 @@ namespace VulnUserCodeAnalyzer |
13 | { | 14 | { |
14 | static void Main(string[] args) | 15 | static void Main(string[] args) |
15 | { | 16 | { |
17 | + var hashDict = new Dictionary<int, HashSet<VulnAbstractCrawler.UserBlock>>(); | ||
18 | + | ||
16 | DirectoryInfo dirInfo = new DirectoryInfo(@"c:\code"); | 19 | DirectoryInfo dirInfo = new DirectoryInfo(@"c:\code"); |
17 | var codeFiles = dirInfo.EnumerateFiles("*.c", SearchOption.AllDirectories); | 20 | var codeFiles = dirInfo.EnumerateFiles("*.c", SearchOption.AllDirectories); |
18 | - | 21 | + int totalFileCount = codeFiles.Count(); |
19 | var crawler = new VulnC(); | 22 | var crawler = new VulnC(); |
23 | + int count = 0; | ||
20 | foreach (var codeFile in codeFiles) | 24 | foreach (var codeFile in codeFiles) |
21 | { | 25 | { |
22 | Console.WriteLine(codeFile.FullName); | 26 | Console.WriteLine(codeFile.FullName); |
... | @@ -27,16 +31,44 @@ namespace VulnUserCodeAnalyzer | ... | @@ -27,16 +31,44 @@ namespace VulnUserCodeAnalyzer |
27 | 31 | ||
28 | foreach (var item in dict) | 32 | foreach (var item in dict) |
29 | { | 33 | { |
30 | - Console.WriteLine($"----{item.Key}->"); | 34 | + if (!hashDict.ContainsKey(item.Key)) |
35 | + { | ||
36 | + hashDict[item.Key] = new HashSet<VulnAbstractCrawler.UserBlock>(); | ||
37 | + } | ||
31 | foreach (var hash in item.Value) | 38 | foreach (var hash in item.Value) |
32 | { | 39 | { |
33 | - Console.WriteLine(hash); | 40 | + hash.Path = codeFile.FullName; |
41 | + hashDict[item.Key].Add(hash); | ||
34 | } | 42 | } |
35 | } | 43 | } |
44 | + | ||
45 | + count++; | ||
46 | + double per = ((double)count / (double)totalFileCount) * 100; | ||
47 | + | ||
48 | + Console.Clear(); | ||
49 | + Console.WriteLine($"{count} / {totalFileCount} :: {per.ToString("#0.0")}%, 개체 수 : {hashDict.Count}"); | ||
50 | + | ||
51 | + //if (count > 20) | ||
52 | + //{ | ||
53 | + // break; | ||
54 | + //} | ||
55 | + } | ||
56 | + | ||
57 | + | ||
58 | + } | ||
59 | + | ||
60 | + foreach (var set in hashDict) | ||
61 | + { | ||
62 | + Console.WriteLine($"-----key:{set.Key}"); | ||
63 | + foreach (var hash in set.Value) | ||
64 | + { | ||
65 | + Console.WriteLine($"{hash.FuncName}, {hash.Hash}, {hash.Len}, {hash.Path}"); | ||
36 | } | 66 | } |
37 | } | 67 | } |
38 | 68 | ||
39 | 69 | ||
70 | + | ||
40 | } | 71 | } |
41 | } | 72 | } |
73 | + | ||
42 | } | 74 | } | ... | ... |
-
Please register or login to post a comment