• R/O
  • SSH
  • HTTPS

openpishcrawler: Commit


Commit MetaInfo

Revision1 (tree)
Time2019-09-09 00:12:16
Authorsebastiandotnet

Log Message

Initial Commit

Change Summary

Incremental Difference

--- OpenPishCrawler/Controls/SuspendedDataGridView.cs (nonexistent)
+++ OpenPishCrawler/Controls/SuspendedDataGridView.cs (revision 1)
@@ -0,0 +1,77 @@
1+using System;
2+using System.Diagnostics;
3+using System.Windows.Forms;
4+using OpenPishCrawler.Data;
5+
6+namespace OpenPishCrawler.Controls
7+{
8+ public class SuspendedDataGridView : DataGridView
9+ {
10+ public SuspendedDataGridView()
11+ {
12+ AutoGenerateColumns = false;
13+ }
14+
15+ public SuspendedList SuspendedDataSource
16+ {
17+ get
18+ {
19+ return DataSource as SuspendedList;
20+ }
21+ set
22+ {
23+ DataSource = value;
24+ }
25+ }
26+
27+ protected override void OnCellContentClick(DataGridViewCellEventArgs e)
28+ {
29+ base.OnCellContentClick(e);
30+ if (null != SuspendedDataSource &&
31+ Columns[e.ColumnIndex] is DataGridViewButtonColumn)
32+ {
33+ SuspendedDataSource.Remove((Suspended)Rows[e.RowIndex].DataBoundItem);
34+ }
35+ }
36+
37+ protected override void OnCellDoubleClick(DataGridViewCellEventArgs e)
38+ {
39+ base.OnCellDoubleClick(e);
40+ if (null != SuspendedDataSource && e.ColumnIndex == 0)
41+ {
42+ var url = String.Format("{0}{1}", "https://", Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
43+ try
44+ {
45+ Process.Start(url);
46+ }
47+ catch
48+ {
49+ ;
50+ }
51+ }
52+ }
53+
54+ private void Initialize()
55+ {
56+ MultiSelect = false;
57+ RowHeadersVisible = false;
58+
59+ var urlColumn = new DataGridViewTextBoxColumn();
60+ urlColumn.Name = "SuspendedDataGridViewUrlColumn";
61+ urlColumn.DataPropertyName = "Url";
62+ urlColumn.HeaderText = "Url";
63+ urlColumn.ReadOnly = true;
64+ urlColumn.Width = 220;
65+ urlColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
66+
67+ var removeColumn = new DataGridViewButtonColumn();
68+ removeColumn.Name = "SuspendedDataGridViewRemoveColumn";
69+ removeColumn.HeaderText = "Remove";
70+ removeColumn.Width = 100;
71+ removeColumn.UseColumnTextForButtonValue = true;
72+
73+ Columns.Add(urlColumn);
74+ Columns.Add(removeColumn);
75+ }
76+ }
77+}
--- OpenPishCrawler/Controls/WebhostAppDataGridview.cs (nonexistent)
+++ OpenPishCrawler/Controls/WebhostAppDataGridview.cs (revision 1)
@@ -0,0 +1,85 @@
1+using System;
2+using System.Diagnostics;
3+using System.Windows.Forms;
4+using OpenPishCrawler.Data;
5+
6+namespace OpenPishCrawler.Controls
7+{
8+ public class WebhostAppDataGridview : DataGridView
9+ {
10+ public WebhostAppDataGridview()
11+ {
12+ AutoGenerateColumns = false;
13+ }
14+
15+ public PishingPageList PishingPagesDataSource
16+ {
17+ get
18+ {
19+ return DataSource as PishingPageList;
20+ }
21+ set
22+ {
23+ DataSource = value;
24+ }
25+ }
26+
27+ protected override void OnCellContentClick(DataGridViewCellEventArgs e)
28+ {
29+ base.OnCellContentClick(e);
30+ if (null != PishingPagesDataSource &&
31+ Columns[e.ColumnIndex] is DataGridViewButtonColumn)
32+ {
33+ PishingPagesDataSource.Remove((PishingPage)Rows[e.RowIndex].DataBoundItem);
34+ }
35+ }
36+
37+ protected override void OnCellDoubleClick(DataGridViewCellEventArgs e)
38+ {
39+ base.OnCellDoubleClick(e);
40+ if (null != PishingPagesDataSource && e.ColumnIndex == 0)
41+ {
42+ var url = String.Format("{0}{1}", "https://", Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
43+ try
44+ {
45+ Process.Start(url);
46+ }
47+ catch
48+ {
49+ ;
50+ }
51+ }
52+ }
53+
54+ private void Inititalize()
55+ {
56+ MultiSelect = false;
57+ RowHeadersVisible = false;
58+
59+ var urlColumn = new DataGridViewTextBoxColumn();
60+ urlColumn.Name = "WebhostAppDataGridviewUrlColumn";
61+ urlColumn.DataPropertyName = "Url";
62+ urlColumn.HeaderText = "Url";
63+ urlColumn.ReadOnly = true;
64+ urlColumn.Width = 220;
65+ urlColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
66+
67+ var targetColumn = new DataGridViewTextBoxColumn();
68+ targetColumn.Name = "WebhostAppDataGridviewBrandColumn";
69+ targetColumn.DataPropertyName = "TargetBrand";
70+ targetColumn.HeaderText = "Target Brand";
71+ targetColumn.ReadOnly = true;
72+ targetColumn.Width = 140;
73+
74+ var supsendedColumn = new DataGridViewButtonColumn();
75+ supsendedColumn.Name = "WebhostAppDataGridviewSuspendedColumn";
76+ supsendedColumn.HeaderText = "Suspended";
77+ supsendedColumn.Width = 100;
78+ supsendedColumn.UseColumnTextForButtonValue = true;
79+
80+ Columns.Add(urlColumn);
81+ Columns.Add(targetColumn);
82+ Columns.Add(supsendedColumn);
83+ }
84+ }
85+}
--- OpenPishCrawler/Data/PishingPage.cs (nonexistent)
+++ OpenPishCrawler/Data/PishingPage.cs (revision 1)
@@ -0,0 +1,21 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using System.Threading.Tasks;
6+
7+namespace OpenPishCrawler.Data
8+{
9+ public class PishingPage
10+ {
11+ public PishingPage(string url, string targetBrand = "")
12+ {
13+ Url = url;
14+ TargetBrand = targetBrand;
15+ }
16+
17+ public string Url { get; private set; }
18+
19+ public string TargetBrand { get; private set; }
20+ }
21+}
--- OpenPishCrawler/Data/PishingPageList.cs (nonexistent)
+++ OpenPishCrawler/Data/PishingPageList.cs (revision 1)
@@ -0,0 +1,54 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using System.Threading.Tasks;
6+using System.ComponentModel;
7+using OpenPishCrawler.Extensions;
8+
9+namespace OpenPishCrawler.Data
10+{
11+ public class PishingPageList : BindingList<PishingPage>, ITypedList
12+ {
13+ public event Action<PishingPage> Removed;
14+
15+ public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
16+ {
17+ return TypeDescriptor.GetProperties(typeof(PishingPage));
18+ }
19+
20+ public string GetListName(PropertyDescriptor[] listAccessors)
21+ {
22+ throw new NotImplementedException();
23+ }
24+
25+ public new void Add(PishingPage page)
26+ {
27+ if (!Items.Any(e => e.Url.Equals(page.Url)))
28+ base.Add(page);
29+ }
30+
31+ public new bool Remove(PishingPage page)
32+ {
33+ var result = default(bool);
34+ result = base.Remove(page);
35+ if (result)
36+ {
37+ Removed?.Invoke(page);
38+ RemoveMore(page);
39+ }
40+ return result;
41+ }
42+
43+ private void RemoveMore(PishingPage page)
44+ {
45+ var target = page.Url.ToWebHostAppUrl();
46+ var more = Items.Where(e => e.Url.ToWebHostAppUrl().Equals(target, StringComparison.InvariantCultureIgnoreCase));
47+ foreach (var item in more)
48+ {
49+ if(base.Remove(item))
50+ Removed?.Invoke(item);
51+ }
52+ }
53+ }
54+}
--- OpenPishCrawler/Data/Suspended.cs (nonexistent)
+++ OpenPishCrawler/Data/Suspended.cs (revision 1)
@@ -0,0 +1,18 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using System.Threading.Tasks;
6+
7+namespace OpenPishCrawler.Data
8+{
9+ public class Suspended
10+ {
11+ public Suspended(string url)
12+ {
13+ Url = url;
14+ }
15+
16+ public string Url { get; private set; }
17+ }
18+}
--- OpenPishCrawler/Data/SuspendedList.cs (nonexistent)
+++ OpenPishCrawler/Data/SuspendedList.cs (revision 1)
@@ -0,0 +1,38 @@
1+using System;
2+using System.Collections.Generic;
3+using System.ComponentModel;
4+
5+namespace OpenPishCrawler.Data
6+{
7+ public class SuspendedList : BindingList<Suspended>, ITypedList
8+ {
9+ public SuspendedList(IEnumerable<string> items)
10+ {
11+ foreach (var item in items)
12+ Add(new Suspended(item));
13+ }
14+
15+ public event Action ItemDeleted;
16+
17+ public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
18+ {
19+ return TypeDescriptor.GetProperties(typeof(Suspended));
20+ }
21+
22+ public string GetListName(PropertyDescriptor[] listAccessors)
23+ {
24+ throw new NotImplementedException();
25+ }
26+
27+ protected override void OnListChanged(ListChangedEventArgs e)
28+ {
29+ base.OnListChanged(e);
30+ switch (e.ListChangedType)
31+ {
32+ case ListChangedType.ItemDeleted:
33+ ItemDeleted?.Invoke();
34+ break;
35+ }
36+ }
37+ }
38+}
--- OpenPishCrawler/Extensions/StringExtensions.cs (nonexistent)
+++ OpenPishCrawler/Extensions/StringExtensions.cs (revision 1)
@@ -0,0 +1,45 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using System.Threading.Tasks;
6+
7+namespace OpenPishCrawler.Extensions
8+{
9+ public static class StringExtensions
10+ {
11+ private static string[] Prefix { get; set; } = new string[] { "https://", "http://", "www." };
12+
13+ public static bool IsWebHostAppUrl(this string value)
14+ {
15+ var result = default(bool);
16+ var url = value.Trim();
17+ foreach (var item in Prefix)
18+ {
19+ if (url.StartsWith(item, StringComparison.InvariantCultureIgnoreCase))
20+ url = url.Substring(item.Length);
21+ }
22+
23+ var array = url.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
24+ result = array.Length >= 3 && array[1].Equals("000webhostapp", StringComparison.InvariantCultureIgnoreCase);
25+
26+ return result;
27+ }
28+
29+ public static string ToWebHostAppUrl(this string value)
30+ {
31+ var result = value.Trim();
32+ foreach (var item in Prefix)
33+ {
34+ if(result.StartsWith(item, StringComparison.InvariantCultureIgnoreCase))
35+ result = result.Substring(item.Length);
36+ }
37+
38+ var array = result.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
39+ if (array.Length >= 3)
40+ result = String.Format("{0}.{1}.{2}", array[0], array[1], array[2]);
41+
42+ return result;
43+ }
44+ }
45+}
--- OpenPishCrawler/Properties/AssemblyInfo.cs (nonexistent)
+++ OpenPishCrawler/Properties/AssemblyInfo.cs (revision 1)
@@ -0,0 +1,36 @@
1+using System.Reflection;
2+using System.Runtime.CompilerServices;
3+using System.Runtime.InteropServices;
4+
5+// General Information about an assembly is controlled through the following
6+// set of attributes. Change these attribute values to modify the information
7+// associated with an assembly.
8+[assembly: AssemblyTitle("OpenPishCrawler")]
9+[assembly: AssemblyDescription("")]
10+[assembly: AssemblyConfiguration("")]
11+[assembly: AssemblyCompany("")]
12+[assembly: AssemblyProduct("OpenPishCrawler")]
13+[assembly: AssemblyCopyright("Copyright © 2019")]
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+[assembly: ComVisible(false)]
21+
22+// The following GUID is for the ID of the typelib if this project is exposed to COM
23+[assembly: Guid("d188d62a-5abf-46e7-bd88-287900892d4c")]
24+
25+// Version information for an assembly consists of the following four values:
26+//
27+// Major Version
28+// Minor Version
29+// Build Number
30+// Revision
31+//
32+// You can specify all the values or you can default the Build and Revision Numbers
33+// by using the '*' as shown below:
34+// [assembly: AssemblyVersion("1.0.*")]
35+[assembly: AssemblyVersion("1.0.0.0")]
36+[assembly: AssemblyFileVersion("1.0.0.0")]
--- OpenPishCrawler/Properties/Resources.Designer.cs (nonexistent)
+++ OpenPishCrawler/Properties/Resources.Designer.cs (revision 1)
@@ -0,0 +1,71 @@
1+//------------------------------------------------------------------------------
2+// <auto-generated>
3+// This code was generated by a tool.
4+// Runtime Version:4.0.30319.42000
5+//
6+// Changes to this file may cause incorrect behavior and will be lost if
7+// the code is regenerated.
8+// </auto-generated>
9+//------------------------------------------------------------------------------
10+
11+namespace OpenPishCrawler.Properties
12+{
13+
14+
15+ /// <summary>
16+ /// A strongly-typed resource class, for looking up localized strings, etc.
17+ /// </summary>
18+ // This class was auto-generated by the StronglyTypedResourceBuilder
19+ // class via a tool like ResGen or Visual Studio.
20+ // To add or remove a member, edit your .ResX file then rerun ResGen
21+ // with the /str option, or rebuild your VS project.
22+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25+ internal class Resources
26+ {
27+
28+ private static global::System.Resources.ResourceManager resourceMan;
29+
30+ private static global::System.Globalization.CultureInfo resourceCulture;
31+
32+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33+ internal Resources()
34+ {
35+ }
36+
37+ /// <summary>
38+ /// Returns the cached ResourceManager instance used by this class.
39+ /// </summary>
40+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41+ internal static global::System.Resources.ResourceManager ResourceManager
42+ {
43+ get
44+ {
45+ if ((resourceMan == null))
46+ {
47+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenPishCrawler.Properties.Resources", typeof(Resources).Assembly);
48+ resourceMan = temp;
49+ }
50+ return resourceMan;
51+ }
52+ }
53+
54+ /// <summary>
55+ /// Overrides the current thread's CurrentUICulture property for all
56+ /// resource lookups using this strongly typed resource class.
57+ /// </summary>
58+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59+ internal static global::System.Globalization.CultureInfo Culture
60+ {
61+ get
62+ {
63+ return resourceCulture;
64+ }
65+ set
66+ {
67+ resourceCulture = value;
68+ }
69+ }
70+ }
71+}
--- OpenPishCrawler/Properties/Settings.Designer.cs (nonexistent)
+++ OpenPishCrawler/Properties/Settings.Designer.cs (revision 1)
@@ -0,0 +1,30 @@
1+//------------------------------------------------------------------------------
2+// <auto-generated>
3+// This code was generated by a tool.
4+// Runtime Version:4.0.30319.42000
5+//
6+// Changes to this file may cause incorrect behavior and will be lost if
7+// the code is regenerated.
8+// </auto-generated>
9+//------------------------------------------------------------------------------
10+
11+namespace OpenPishCrawler.Properties
12+{
13+
14+
15+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18+ {
19+
20+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21+
22+ public static Settings Default
23+ {
24+ get
25+ {
26+ return defaultInstance;
27+ }
28+ }
29+ }
30+}
--- OpenPishCrawler/Service/OpenPishFactory.cs (nonexistent)
+++ OpenPishCrawler/Service/OpenPishFactory.cs (revision 1)
@@ -0,0 +1,39 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+
5+namespace OpenPishCrawler.Service
6+{
7+ public static class OpenPishFactory
8+ {
9+ private static List<object> Instances { get; set; } = new List<object>();
10+
11+ public static void Initialize()
12+ {
13+ Instances.Add(new OpenPishSuspended());
14+ Instances.Add(new OpenPishReader());
15+ Instances.Add(new OpenPishTimer());
16+ Instances.Add(new OpenPishService());
17+ }
18+
19+ public static T Instance<T>()
20+ {
21+ var result = default(T);
22+ result = (T)Instances.First(e => typeof(T) == e.GetType());
23+ return result;
24+ }
25+
26+ public static void Clear()
27+ {
28+ var instances = Instances.ToArray();
29+ instances.Reverse();
30+ foreach (var item in instances)
31+ {
32+ var disposable = item as IDisposable;
33+ if (null != disposable)
34+ disposable.Dispose();
35+ }
36+ Instances.Clear();
37+ }
38+ }
39+}
--- OpenPishCrawler/Service/OpenPishReader.cs (nonexistent)
+++ OpenPishCrawler/Service/OpenPishReader.cs (revision 1)
@@ -0,0 +1,81 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.IO;
5+using System.Net;
6+using HtmlAgilityPack;
7+using OpenPishCrawler.Data;
8+using OpenPishCrawler.Extensions;
9+
10+namespace OpenPishCrawler.Service
11+{
12+ public class OpenPishReader
13+ {
14+ private IEnumerable<PishingPage> _pishTable;
15+
16+ public event Action PishTableChanged;
17+
18+ public IEnumerable<PishingPage> PishTable
19+ {
20+ get
21+ {
22+ return _pishTable;
23+ }
24+ private set
25+ {
26+ if (value != _pishTable)
27+ {
28+ _pishTable = value;
29+ PishTableChanged?.Invoke();
30+ }
31+ }
32+ }
33+
34+ public void Update()
35+ {
36+ PishTable = ReadOpenPishTable();
37+ }
38+
39+ private IEnumerable<PishingPage> ReadOpenPishTable()
40+ {
41+ var result = default(IEnumerable<PishingPage>);
42+ var document = ReadOpenPishDocument();
43+ result = document.DocumentNode.FirstChild.ChildNodes.First(e => e.Name == "body")
44+ .ChildNodes.First(e => e.Name == "div")
45+ .ChildNodes.First(e => e.Name == "div")
46+ .ChildNodes.First(e => e.Name == "table")
47+ .ChildNodes.First(e => e.Name == "tbody")
48+ .ChildNodes.Where(e => e.Name == "tr").
49+ Where(e => e.ChildNodes[1].InnerText.IsWebHostAppUrl())
50+ .Select(e => new PishingPage(e.ChildNodes[1].InnerText.ToWebHostAppUrl(), e.ChildNodes[3].InnerText));
51+ return result;
52+ }
53+
54+ private HtmlDocument ReadOpenPishDocument()
55+ {
56+ var result = new HtmlDocument();
57+ var page = ReadOpenPishPage();
58+ result.LoadHtml(page);
59+ return result;
60+ }
61+
62+ private string ReadOpenPishPage()
63+ {
64+ var result = default(string);
65+ using (var webClient = new WebClient())
66+ {
67+ webClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
68+ using (var response = webClient.OpenRead("https://openphish.com"))
69+ {
70+ using (var reader = new StreamReader(response))
71+ {
72+ result = reader.ReadToEnd();
73+ response.Close();
74+ reader.Close();
75+ }
76+ }
77+ }
78+ return result;
79+ }
80+ }
81+}
--- OpenPishCrawler/Service/OpenPishService.cs (nonexistent)
+++ OpenPishCrawler/Service/OpenPishService.cs (revision 1)
@@ -0,0 +1,35 @@
1+using System;
2+using OpenPishCrawler.Data;
3+
4+namespace OpenPishCrawler.Service
5+{
6+ public class OpenPishService
7+ {
8+ public OpenPishService()
9+ {
10+ var reader = OpenPishFactory.Instance<OpenPishReader>();
11+ reader.PishTableChanged += Reader_PishTableChanged;
12+
13+ PishingPages.Removed += PishingPages_Removed;
14+ }
15+
16+ private void Reader_PishTableChanged()
17+ {
18+ Action method = delegate()
19+ {
20+ var pishTable = OpenPishFactory.Instance<OpenPishReader>().PishTable;
21+ foreach (var item in pishTable)
22+ PishingPages.Add(item);
23+ };
24+ Program.SyncRoot.Invoke(method);
25+ }
26+
27+ private void PishingPages_Removed(PishingPage page)
28+ {
29+ var suspended = OpenPishFactory.Instance<OpenPishSuspended>();
30+ suspended.Add(page.Url);
31+ }
32+
33+ public PishingPageList PishingPages { get; private set; } = new PishingPageList();
34+ }
35+}
--- OpenPishCrawler/Service/OpenPishSuspended.cs (nonexistent)
+++ OpenPishCrawler/Service/OpenPishSuspended.cs (revision 1)
@@ -0,0 +1,121 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.IO;
5+using System.Xml.Linq;
6+using OpenPishCrawler.Data;
7+
8+namespace OpenPishCrawler.Service
9+{
10+ public class OpenPishSuspended
11+ {
12+ private SuspendedList _view;
13+
14+ public OpenPishSuspended()
15+ {
16+ LoadFromFilesystem();
17+ }
18+
19+ public int Count
20+ {
21+ get
22+ {
23+ return Items.Count;
24+ }
25+ }
26+
27+ private List<string> Items { get; set; } = new List<string>();
28+
29+ private string FolderPath
30+ {
31+ get
32+ {
33+ var assembly = typeof(OpenPishSuspended).Assembly;
34+ var folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), assembly.GetName().Name);
35+ return folderPath;
36+ }
37+ }
38+
39+ private string FilePath
40+ {
41+ get
42+ {
43+ var assembly = typeof(OpenPishSuspended).Assembly;
44+ var filePath = Path.Combine(FolderPath, String.Format("{0}.{1}", assembly.GetName().Name, "xml"));
45+ return filePath;
46+ }
47+ }
48+
49+ public bool Suspended(string url)
50+ {
51+ var result = default(bool);
52+ result = Items.Any(e => e.Equals(url, StringComparison.InvariantCultureIgnoreCase));
53+ return result;
54+ }
55+
56+ public void Add(string url)
57+ {
58+ if (!Suspended(url))
59+ {
60+ Items.Add(url);
61+ SaveToFileSystem();
62+ }
63+ }
64+
65+ public bool Remove(string url)
66+ {
67+ var result = Items.Remove(url);
68+ if(result)
69+ SaveToFileSystem();
70+ return result;
71+ }
72+
73+ public void Clear()
74+ {
75+ if (Items.Count > 0)
76+ {
77+ Items.Clear();
78+ SaveToFileSystem();
79+ }
80+ }
81+
82+ public SuspendedList View()
83+ {
84+ if (null != _view)
85+ throw new InvalidOperationException("Another view is already in use.");
86+ _view = new SuspendedList(Items);
87+ _view.ItemDeleted += Update;
88+ return _view;
89+ }
90+
91+ public void Update()
92+ {
93+ Items.Clear();
94+ foreach (var item in _view)
95+ Items.Add(item.Url);
96+ SaveToFileSystem();
97+ }
98+
99+ private void LoadFromFilesystem()
100+ {
101+ var filePath = FilePath;
102+ Clear();
103+ if (File.Exists(filePath))
104+ {
105+ var rootNode = XElement.Load(filePath).FirstNode as XElement;
106+ Items = rootNode.Elements("Suspended").Select(e => e.Value).ToList();
107+ }
108+ }
109+
110+ private void SaveToFileSystem()
111+ {
112+ var filePath = FilePath;
113+ var rootNode = new XElement(typeof(OpenPishSuspended).Assembly.GetName().Name);
114+ foreach (var item in Items)
115+ rootNode.Add(new XElement("Suspended", item));
116+ if (!Directory.Exists(FolderPath))
117+ Directory.CreateDirectory(FolderPath);
118+ rootNode.Save(filePath);
119+ }
120+ }
121+}
--- OpenPishCrawler/Service/OpenPishTimer.cs (nonexistent)
+++ OpenPishCrawler/Service/OpenPishTimer.cs (revision 1)
@@ -0,0 +1,113 @@
1+using System;
2+using System.ComponentModel;
3+using System.Threading;
4+
5+namespace OpenPishCrawler.Service
6+{
7+ public class OpenPishTimer : INotifyPropertyChanged, IDisposable
8+ {
9+ private bool _enabled;
10+ private ulong _runs;
11+ private ulong _errors;
12+
13+ public event PropertyChangedEventHandler PropertyChanged;
14+
15+ public bool Enabled
16+ {
17+ get
18+ {
19+ return _enabled;
20+ }
21+ set
22+ {
23+ if (value != _enabled)
24+ {
25+ _enabled = value;
26+ OnEnabledChanged();
27+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Enabled)));
28+ }
29+ }
30+ }
31+
32+ public ulong Runs
33+ {
34+ get
35+ {
36+ return _runs;
37+ }
38+ private set
39+ {
40+ if (value != _runs)
41+ {
42+ _runs = value;
43+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Runs)));
44+ }
45+ }
46+ }
47+
48+ public ulong Errors
49+ {
50+ get
51+ {
52+ return _errors;
53+ }
54+ private set
55+ {
56+ if (value != _errors)
57+ {
58+ _errors = value;
59+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Errors)));
60+ }
61+ }
62+ }
63+
64+ private Timer Timer { get; set; }
65+
66+ protected internal virtual void OnEnabledChanged()
67+ {
68+ if (Enabled)
69+ {
70+ Timer = new Timer(TimerTick, null, 0, 90000);
71+ }
72+ else if(null != Timer)
73+ {
74+ Timer.Dispose();
75+ Timer = null;
76+ }
77+ }
78+
79+ private void TimerTick(object state)
80+ {
81+ try
82+ {
83+ Action method = delegate
84+ {
85+ if (Runs == ulong.MaxValue)
86+ Runs = 0;
87+ else
88+ Runs++;
89+ };
90+ Program.SyncRoot.Invoke(method);
91+
92+ var reader = OpenPishFactory.Instance<OpenPishReader>();
93+ reader.Update();
94+ }
95+ catch
96+ {
97+ Action method = delegate
98+ {
99+ if (Errors == ulong.MaxValue)
100+ Errors = 0;
101+ else
102+ Errors++;
103+ };
104+ Program.SyncRoot.Invoke(method);
105+ }
106+ }
107+
108+ public void Dispose()
109+ {
110+ Enabled = false;
111+ }
112+ }
113+}
--- OpenPishCrawler/MainForm.Designer.cs (nonexistent)
+++ OpenPishCrawler/MainForm.Designer.cs (revision 1)
@@ -0,0 +1,264 @@
1+namespace OpenPishCrawler
2+{
3+ partial class MainForm
4+ {
5+ /// <summary>
6+ /// Required designer variable.
7+ /// </summary>
8+ private System.ComponentModel.IContainer components = null;
9+
10+ /// <summary>
11+ /// Clean up any resources being used.
12+ /// </summary>
13+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
14+ protected override void Dispose(bool disposing)
15+ {
16+ if (disposing && (components != null))
17+ {
18+ components.Dispose();
19+ }
20+ base.Dispose(disposing);
21+ }
22+
23+ #region Windows Form Designer generated code
24+
25+ /// <summary>
26+ /// Required method for Designer support - do not modify
27+ /// the contents of this method with the code editor.
28+ /// </summary>
29+ private void InitializeComponent()
30+ {
31+ this.StateCheckBox = new System.Windows.Forms.CheckBox();
32+ this.MainTabControl = new System.Windows.Forms.TabControl();
33+ this.WebhostappPage = new System.Windows.Forms.TabPage();
34+ this.SuspendedPage = new System.Windows.Forms.TabPage();
35+ this.ErrorCountLabel = new System.Windows.Forms.Label();
36+ this.PishDataGridView = new OpenPishCrawler.Controls.WebhostAppDataGridview();
37+ this.UrlColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
38+ this.TargetColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
39+ this.SuspendColumn = new System.Windows.Forms.DataGridViewButtonColumn();
40+ this.SuspendedDataGridView = new OpenPishCrawler.Controls.SuspendedDataGridView();
41+ this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
42+ this.dataGridViewButtonColumn1 = new System.Windows.Forms.DataGridViewButtonColumn();
43+ this.ErrorCountHeaderLabel = new System.Windows.Forms.Label();
44+ this.RunCountHeaderLabel = new System.Windows.Forms.Label();
45+ this.RunCountLabel = new System.Windows.Forms.Label();
46+ this.MainTabControl.SuspendLayout();
47+ this.WebhostappPage.SuspendLayout();
48+ this.SuspendedPage.SuspendLayout();
49+ ((System.ComponentModel.ISupportInitialize)(this.PishDataGridView)).BeginInit();
50+ ((System.ComponentModel.ISupportInitialize)(this.SuspendedDataGridView)).BeginInit();
51+ this.SuspendLayout();
52+ //
53+ // StateCheckBox
54+ //
55+ this.StateCheckBox.AutoSize = true;
56+ this.StateCheckBox.Location = new System.Drawing.Point(12, 10);
57+ this.StateCheckBox.Name = "StateCheckBox";
58+ this.StateCheckBox.Size = new System.Drawing.Size(78, 20);
59+ this.StateCheckBox.TabIndex = 3;
60+ this.StateCheckBox.Text = "Enabled";
61+ this.StateCheckBox.UseVisualStyleBackColor = true;
62+ //
63+ // MainTabControl
64+ //
65+ this.MainTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
66+ | System.Windows.Forms.AnchorStyles.Left)
67+ | System.Windows.Forms.AnchorStyles.Right)));
68+ this.MainTabControl.Controls.Add(this.WebhostappPage);
69+ this.MainTabControl.Controls.Add(this.SuspendedPage);
70+ this.MainTabControl.Location = new System.Drawing.Point(0, 36);
71+ this.MainTabControl.Margin = new System.Windows.Forms.Padding(0);
72+ this.MainTabControl.Name = "MainTabControl";
73+ this.MainTabControl.Padding = new System.Drawing.Point(0, 0);
74+ this.MainTabControl.SelectedIndex = 0;
75+ this.MainTabControl.Size = new System.Drawing.Size(590, 315);
76+ this.MainTabControl.TabIndex = 4;
77+ //
78+ // WebhostappPage
79+ //
80+ this.WebhostappPage.Controls.Add(this.PishDataGridView);
81+ this.WebhostappPage.Location = new System.Drawing.Point(4, 25);
82+ this.WebhostappPage.Margin = new System.Windows.Forms.Padding(0);
83+ this.WebhostappPage.Name = "WebhostappPage";
84+ this.WebhostappPage.Size = new System.Drawing.Size(582, 286);
85+ this.WebhostappPage.TabIndex = 0;
86+ this.WebhostappPage.Text = "000webhostapp";
87+ this.WebhostappPage.UseVisualStyleBackColor = true;
88+ //
89+ // SuspendedPage
90+ //
91+ this.SuspendedPage.Controls.Add(this.SuspendedDataGridView);
92+ this.SuspendedPage.Location = new System.Drawing.Point(4, 25);
93+ this.SuspendedPage.Margin = new System.Windows.Forms.Padding(0);
94+ this.SuspendedPage.Name = "SuspendedPage";
95+ this.SuspendedPage.Size = new System.Drawing.Size(582, 286);
96+ this.SuspendedPage.TabIndex = 1;
97+ this.SuspendedPage.Text = "Suspended";
98+ this.SuspendedPage.UseVisualStyleBackColor = true;
99+ //
100+ // ErrorCountLabel
101+ //
102+ this.ErrorCountLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
103+ this.ErrorCountLabel.AutoSize = true;
104+ this.ErrorCountLabel.ForeColor = System.Drawing.Color.Red;
105+ this.ErrorCountLabel.Location = new System.Drawing.Point(491, 14);
106+ this.ErrorCountLabel.Name = "ErrorCountLabel";
107+ this.ErrorCountLabel.Size = new System.Drawing.Size(15, 16);
108+ this.ErrorCountLabel.TabIndex = 5;
109+ this.ErrorCountLabel.Text = "0";
110+ //
111+ // PishDataGridView
112+ //
113+ this.PishDataGridView.AllowUserToAddRows = false;
114+ this.PishDataGridView.AllowUserToDeleteRows = false;
115+ this.PishDataGridView.AllowUserToOrderColumns = true;
116+ this.PishDataGridView.AllowUserToResizeColumns = false;
117+ this.PishDataGridView.AllowUserToResizeRows = false;
118+ this.PishDataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
119+ this.PishDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None;
120+ this.PishDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
121+ this.PishDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
122+ this.UrlColumn,
123+ this.TargetColumn,
124+ this.SuspendColumn});
125+ this.PishDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
126+ this.PishDataGridView.Location = new System.Drawing.Point(0, 0);
127+ this.PishDataGridView.Margin = new System.Windows.Forms.Padding(4);
128+ this.PishDataGridView.Name = "PishDataGridView";
129+ this.PishDataGridView.PishingPagesDataSource = null;
130+ this.PishDataGridView.RowHeadersVisible = false;
131+ this.PishDataGridView.Size = new System.Drawing.Size(582, 286);
132+ this.PishDataGridView.TabIndex = 1;
133+ //
134+ // UrlColumn
135+ //
136+ this.UrlColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
137+ this.UrlColumn.DataPropertyName = "Url";
138+ this.UrlColumn.HeaderText = "Url";
139+ this.UrlColumn.Name = "UrlColumn";
140+ this.UrlColumn.ReadOnly = true;
141+ //
142+ // TargetColumn
143+ //
144+ this.TargetColumn.DataPropertyName = "TargetBrand";
145+ this.TargetColumn.HeaderText = "Target Brand";
146+ this.TargetColumn.Name = "TargetColumn";
147+ this.TargetColumn.ReadOnly = true;
148+ this.TargetColumn.Width = 140;
149+ //
150+ // SuspendColumn
151+ //
152+ this.SuspendColumn.HeaderText = "Suspended";
153+ this.SuspendColumn.Name = "SuspendColumn";
154+ this.SuspendColumn.UseColumnTextForButtonValue = true;
155+ //
156+ // SuspendedDataGridView
157+ //
158+ this.SuspendedDataGridView.AllowUserToAddRows = false;
159+ this.SuspendedDataGridView.AllowUserToDeleteRows = false;
160+ this.SuspendedDataGridView.AllowUserToResizeColumns = false;
161+ this.SuspendedDataGridView.AllowUserToResizeRows = false;
162+ this.SuspendedDataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
163+ this.SuspendedDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None;
164+ this.SuspendedDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
165+ this.SuspendedDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
166+ this.dataGridViewTextBoxColumn1,
167+ this.dataGridViewButtonColumn1});
168+ this.SuspendedDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
169+ this.SuspendedDataGridView.Location = new System.Drawing.Point(0, 0);
170+ this.SuspendedDataGridView.MultiSelect = false;
171+ this.SuspendedDataGridView.Name = "SuspendedDataGridView";
172+ this.SuspendedDataGridView.RowHeadersVisible = false;
173+ this.SuspendedDataGridView.Size = new System.Drawing.Size(582, 286);
174+ this.SuspendedDataGridView.SuspendedDataSource = null;
175+ this.SuspendedDataGridView.TabIndex = 0;
176+ //
177+ // dataGridViewTextBoxColumn1
178+ //
179+ this.dataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
180+ this.dataGridViewTextBoxColumn1.DataPropertyName = "Url";
181+ this.dataGridViewTextBoxColumn1.HeaderText = "Url";
182+ this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
183+ this.dataGridViewTextBoxColumn1.ReadOnly = true;
184+ //
185+ // dataGridViewButtonColumn1
186+ //
187+ this.dataGridViewButtonColumn1.HeaderText = "Remove";
188+ this.dataGridViewButtonColumn1.Name = "dataGridViewButtonColumn1";
189+ this.dataGridViewButtonColumn1.UseColumnTextForButtonValue = true;
190+ //
191+ // ErrorCountHeaderLabel
192+ //
193+ this.ErrorCountHeaderLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
194+ this.ErrorCountHeaderLabel.AutoSize = true;
195+ this.ErrorCountHeaderLabel.Location = new System.Drawing.Point(441, 14);
196+ this.ErrorCountHeaderLabel.Name = "ErrorCountHeaderLabel";
197+ this.ErrorCountHeaderLabel.Size = new System.Drawing.Size(44, 16);
198+ this.ErrorCountHeaderLabel.TabIndex = 6;
199+ this.ErrorCountHeaderLabel.Text = "Errors";
200+ //
201+ // RunCountHeaderLabel
202+ //
203+ this.RunCountHeaderLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
204+ this.RunCountHeaderLabel.AutoSize = true;
205+ this.RunCountHeaderLabel.Location = new System.Drawing.Point(282, 14);
206+ this.RunCountHeaderLabel.Name = "RunCountHeaderLabel";
207+ this.RunCountHeaderLabel.Size = new System.Drawing.Size(39, 16);
208+ this.RunCountHeaderLabel.TabIndex = 7;
209+ this.RunCountHeaderLabel.Text = "Runs";
210+ //
211+ // RunCountLabel
212+ //
213+ this.RunCountLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
214+ this.RunCountLabel.AutoSize = true;
215+ this.RunCountLabel.Location = new System.Drawing.Point(327, 14);
216+ this.RunCountLabel.Name = "RunCountLabel";
217+ this.RunCountLabel.Size = new System.Drawing.Size(15, 16);
218+ this.RunCountLabel.TabIndex = 8;
219+ this.RunCountLabel.Text = "0";
220+ //
221+ // MainForm
222+ //
223+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
224+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
225+ this.ClientSize = new System.Drawing.Size(591, 354);
226+ this.Controls.Add(this.RunCountLabel);
227+ this.Controls.Add(this.RunCountHeaderLabel);
228+ this.Controls.Add(this.ErrorCountHeaderLabel);
229+ this.Controls.Add(this.ErrorCountLabel);
230+ this.Controls.Add(this.MainTabControl);
231+ this.Controls.Add(this.StateCheckBox);
232+ this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(161)));
233+ this.Margin = new System.Windows.Forms.Padding(4);
234+ this.Name = "MainForm";
235+ this.Text = "OpenPish Crawler";
236+ this.MainTabControl.ResumeLayout(false);
237+ this.WebhostappPage.ResumeLayout(false);
238+ this.SuspendedPage.ResumeLayout(false);
239+ ((System.ComponentModel.ISupportInitialize)(this.PishDataGridView)).EndInit();
240+ ((System.ComponentModel.ISupportInitialize)(this.SuspendedDataGridView)).EndInit();
241+ this.ResumeLayout(false);
242+ this.PerformLayout();
243+
244+ }
245+
246+ #endregion
247+ private Controls.WebhostAppDataGridview PishDataGridView;
248+ private System.Windows.Forms.CheckBox StateCheckBox;
249+ private System.Windows.Forms.DataGridViewTextBoxColumn UrlColumn;
250+ private System.Windows.Forms.DataGridViewTextBoxColumn TargetColumn;
251+ private System.Windows.Forms.DataGridViewButtonColumn SuspendColumn;
252+ private System.Windows.Forms.TabControl MainTabControl;
253+ private System.Windows.Forms.TabPage WebhostappPage;
254+ private System.Windows.Forms.TabPage SuspendedPage;
255+ private Controls.SuspendedDataGridView SuspendedDataGridView;
256+ private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
257+ private System.Windows.Forms.DataGridViewButtonColumn dataGridViewButtonColumn1;
258+ private System.Windows.Forms.Label ErrorCountLabel;
259+ private System.Windows.Forms.Label ErrorCountHeaderLabel;
260+ private System.Windows.Forms.Label RunCountHeaderLabel;
261+ private System.Windows.Forms.Label RunCountLabel;
262+ }
263+}
264+
--- OpenPishCrawler/MainForm.cs (nonexistent)
+++ OpenPishCrawler/MainForm.cs (revision 1)
@@ -0,0 +1,47 @@
1+using System;
2+using System.Windows.Forms;
3+using OpenPishCrawler.Service;
4+
5+namespace OpenPishCrawler
6+{
7+ public partial class MainForm : Form
8+ {
9+ public MainForm()
10+ {
11+ InitializeComponent();
12+ Text = String.Format("{0}", typeof(MainForm).Assembly.GetName().Name, Program.IsAdministrator ? "(Administrator)" : String.Empty);
13+ CreateHandle();
14+ Bind();
15+ }
16+
17+ protected override void OnFormClosing(FormClosingEventArgs e)
18+ {
19+ base.OnFormClosing(e);
20+ if (!e.Cancel)
21+ Unbind();
22+ }
23+
24+ private void Bind()
25+ {
26+ var timer = OpenPishFactory.Instance<OpenPishTimer>();
27+ StateCheckBox.DataBindings.Add(new Binding("Checked", timer, "Enabled",false, DataSourceUpdateMode.OnPropertyChanged));
28+ RunCountLabel.DataBindings.Add(new Binding("Text", timer, "Runs", false, DataSourceUpdateMode.OnPropertyChanged));
29+ ErrorCountLabel.DataBindings.Add(new Binding("Text", timer, "Errors", false, DataSourceUpdateMode.OnPropertyChanged));
30+
31+ var service = OpenPishFactory.Instance<OpenPishService>();
32+ PishDataGridView.PishingPagesDataSource = service.PishingPages;
33+
34+ var suspended = OpenPishFactory.Instance<OpenPishSuspended>();
35+ SuspendedDataGridView.SuspendedDataSource = suspended.View();
36+ }
37+
38+ private void Unbind()
39+ {
40+ StateCheckBox.DataBindings.Clear();
41+ RunCountLabel.DataBindings.Clear();
42+ ErrorCountLabel.DataBindings.Clear();
43+ PishDataGridView.PishingPagesDataSource = null;
44+ SuspendedDataGridView.SuspendedDataSource = null;
45+ }
46+ }
47+}
--- OpenPishCrawler/Program.cs (nonexistent)
+++ OpenPishCrawler/Program.cs (revision 1)
@@ -0,0 +1,47 @@
1+using System;
2+using System.Windows.Forms;
3+using OpenPishCrawler.Service;
4+using System.Security.Principal;
5+
6+namespace OpenPishCrawler
7+{
8+ public static class Program
9+ {
10+ [STAThread]
11+ public static void Main()
12+ {
13+ try
14+ {
15+ OpenPishFactory.Initialize();
16+ Application.EnableVisualStyles();
17+ Application.SetCompatibleTextRenderingDefault(false);
18+ var mainForm = new MainForm();
19+ SyncRoot = mainForm;
20+ Application.Run(mainForm);
21+ }
22+ catch (Exception exception)
23+ {
24+ string message = String.Format("Sudden Death Error{2}{0}{2}{1}", exception.GetType().Name, exception.Message, Environment.NewLine);
25+ MessageBox.Show(message, typeof(Program).Assembly.GetName().Name);
26+ }
27+ finally
28+ {
29+ OpenPishFactory.Clear();
30+ }
31+ }
32+
33+ public static Control SyncRoot { get; private set; }
34+
35+ public static bool IsAdministrator
36+ {
37+ get
38+ {
39+ using (var identity = WindowsIdentity.GetCurrent())
40+ {
41+ var principal = new WindowsPrincipal(identity);
42+ return principal.IsInRole(WindowsBuiltInRole.Administrator);
43+ }
44+ }
45+ }
46+ }
47+}
Show on old repository browser