Advertisement
Guest User

Adonis Alpha

a guest
Nov 20th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Threading;
  7. using System.Diagnostics;
  8.  
  9. namespace trails
  10. {
  11.     class Program
  12.     {
  13.         /*PREFIX*/
  14.         public static string prefix = pfxHome;
  15.  
  16.         //PREFIXES\\
  17.         public static string pfxHome = null;
  18.         public static string pfxModule = "";
  19.  
  20.         //STATES\\
  21.         public static string open = "open";
  22.         public static string closed = "closed";
  23.         public static string both = "both";
  24.         public static string selection = null;
  25.         public static string setSelection = null;
  26.         public static string setValue = null;
  27.         //public static string settingValue = null; uncomment if doesnt work
  28.  
  29.         //MODULES\\
  30.         public static string[] modules = new string[] {
  31.         "pscan", "ping"
  32.         };
  33.  
  34.         public static List<module> list = new List<module> {
  35.         new module("127.0.0.1", "pscan", "22", "Port Scanner", "open", null, null),
  36.         new module("127.0.0.1", "ping", "", "Ping", "1", "", "")
  37.         };
  38.  
  39.  
  40.         //LOADING MODULES
  41.         //public static module pscan = new module ("127.0.0.1", "22", "Port Scanner", "22", null, null);
  42.         //public static module ping = new module("", "", "ping", "1", "", "");
  43.  
  44.         static void Main(string[] args)
  45.         {
  46.             p("Adonis v1 ~ Type 'help' in console for more commands.");
  47.             //var gInput = Console.ReadLine();
  48.             Adonis();
  49.             // p(pscan.print());
  50.         }
  51.  
  52.         static void p(string arg)
  53.         {
  54.             Console.WriteLine(arg);
  55.         }
  56.  
  57.         static void Adonis()
  58.         {
  59.             Console.Write("adonis@" + prefix + "# ");
  60.             string adonisInput = Console.ReadLine();
  61.             CmdCheck(adonisInput);
  62.         }
  63.  
  64.         static void CmdCheck(string arg)
  65.         {
  66.             if (arg.Contains("use"))
  67.             {
  68.                 if(prefix != pfxHome)
  69.                 {
  70.                     p("Logical Error: '" + arg + "', module already selected; try 'back'.");
  71.                     Adonis();
  72.                 }
  73.                 if(arg.Contains(" "))
  74.                 {
  75.                     string str = arg;
  76.                     string[] tokens = str.Split(' ');
  77.                     string chosenExploit = tokens[1];
  78.                     selection = chosenExploit;
  79.                     prefix = selection;
  80.                     if (!(modules.Any(chosenExploit.Contains)))
  81.                     {
  82.                         prefix = pfxHome;
  83.                         selection = null;
  84.                         p("Invalid Syntax: '" + arg + "', 'use <arg>'; missing argument.");
  85.                         Adonis();
  86.                     }
  87.                     if (modules.Any(chosenExploit.Contains))
  88.                     {
  89.                         Adonis();
  90.                     }
  91.                     Adonis();
  92.                 }
  93.                 else { p("Invalid Syntax: '" + arg + "', 'use <arg>'; missing argument."); Adonis(); }
  94.             }
  95.             if(arg == "show options")
  96.             {
  97.                 if(!(selection == null))
  98.                 {
  99.                     p(list.FirstOrDefault(x => x.module_id == prefix)?.print());
  100.                     Adonis();
  101.                 }
  102.                 if(selection == null)
  103.                 {
  104.                     p("Logical Error: '" + arg + "', no module is selected; null prefix.");
  105.                     Adonis();
  106.                 }
  107.             }
  108.             if(arg.Contains("set"))
  109.             {
  110.                 if(prefix == pfxHome)
  111.                 {
  112.                     p("Logical Error: '" + arg + "', no module is selected; null prefix.");
  113.                     Adonis();
  114.                 }
  115.                 if(arg.Contains(" "))
  116.                 {
  117.                     string str = arg;
  118.                     string[] tokens = str.Split(' ');
  119.                     string settingOption = tokens[1];
  120.                     setSelection = settingOption;
  121.                     string str2 = str.Replace(" ", "");
  122.                     p(str2);
  123.                     string settingValue = tokens[2]; // create error handling for "set " and "set a " and such, especially "set "
  124.                     setValue = settingValue;
  125.                     SetValues(setSelection, setValue);
  126.                     Adonis();
  127.                 }
  128.                 p("Invalid Syntax: '" + arg + "', 'set <arg1> <arg2>'; missing argument.");
  129.                 Adonis();
  130.             }
  131.  
  132.             if(arg == cmdHelp)
  133.             {
  134.                 Help();
  135.             }
  136.             if(arg == cmdBack)
  137.             {
  138.                 Back();
  139.             }
  140.             p("Unknown command, '" + arg + "', type 'help' for commands.");
  141.             Adonis();
  142.         }
  143.        
  144.         //COMMANDS\\
  145.         public static string cmdHelp = "help";
  146.         public static string cmdBack = "back";
  147.  
  148.         static void Help()
  149.         {
  150.             p("\nCommands ~");
  151.             p("help                   .......... Returns this window");
  152.             p("use <module>           .......... Selects a module");
  153.             p("back                   .......... Exit a module (prefix)");
  154.             p("show options           .......... Show current options for module");
  155.             p("");
  156.             Adonis();
  157.         }
  158.         static void Back()
  159.         {
  160.             prefix = pfxHome;
  161.             Adonis();
  162.         }
  163.  
  164.         static void SetValues(string setOption, string setTo)
  165.         {
  166.             if(setOption == "target_ip") // ping the selected target_ip, if timed out- relay error, if not, continue.
  167.             {
  168.                 list.FirstOrDefault(x => x.module_id == prefix)?.setTargetIp(setTo);
  169.             }
  170.             if (setOption == "target_port")
  171.             {
  172.                 list.FirstOrDefault(x => x.module_id == prefix)?.setTargetPort(setTo);
  173.             }
  174.             if (setOption == "specific_port")
  175.             {
  176.                 if (setTo == closed)
  177.                 {
  178.                     list.FirstOrDefault(x => x.module_id == prefix)?.setSpecificPort(setTo);
  179.                     Adonis();
  180.                 }
  181.                 if (setTo == open)
  182.                 {
  183.                     list.FirstOrDefault(x => x.module_id == prefix)?.setSpecificPort(setTo);
  184.                     Adonis();
  185.                 }
  186.                 if (setTo == both)
  187.                 {
  188.                     list.FirstOrDefault(x => x.module_id == prefix)?.setSpecificPort(setTo);
  189.                     Adonis();
  190.                 }
  191.                 p("Invalid Syntax: 'set " + setOption + " " + setTo + "', 'set <arg1> <arg2>'; incorrect argument. Try 'open', 'closed', or 'both'.");
  192.                 Adonis();
  193.             }
  194.         }
  195.     }
  196.    
  197.     public class module
  198.     {
  199.         private string printTarget_ip = null;
  200.         private string printTarget_port = null;
  201.         private string printModule_name = null;
  202.         private string printSpecific_port = null;
  203.         public string target_ip { get; set; }
  204.         public string target_port { get; set; }
  205.         public string module_name { get; set; }
  206.         public string specific_port { get; set; }
  207.         public string local_ip { get; set; }
  208.         public string local_port { get; set; }
  209.         public string module_id { get; set; }
  210.         public module(string TargetIP, string ModuleId, string TargetPort, string ModuleName, string SpecificPort, string LocalIP, string LocalPort)
  211.         {
  212.             target_ip = TargetIP;
  213.             target_port = TargetPort;
  214.             module_name = ModuleName;
  215.             specific_port = SpecificPort;
  216.             local_ip = LocalIP;
  217.             local_port = LocalPort;
  218.             module_id = ModuleId;
  219.         }
  220.        
  221.         public string targetIp()
  222.         {
  223.             return target_ip;
  224.         }
  225.         public string targetPort()
  226.         {
  227.             return target_port;
  228.         }
  229.         public string moduleName()
  230.         {
  231.             return module_name;
  232.         }
  233.         public string specificPort()
  234.         {
  235.             return specific_port;
  236.         }
  237.  
  238.         public string setTargetIp(string setChange)
  239.         {
  240.             target_ip = setChange;
  241.             return target_ip;
  242.         }
  243.         public string setTargetPort(string setChange)
  244.         {
  245.             target_port = setChange;
  246.             return target_port;
  247.         }
  248.         public string setModuleName(string setChange)
  249.         {
  250.             module_name = setChange;
  251.             return module_name;
  252.         }
  253.         public string setSpecificPort(string setChange)
  254.         {
  255.             specific_port = setChange;
  256.             return specific_port;
  257.         }
  258.         public string print()
  259.         {
  260.             // TARGET_IP
  261.             if (target_ip != null)
  262.             {
  263.                 printTarget_ip = "target_ip: " + target_ip + "\n";
  264.             }
  265.             else if (target_ip == null)
  266.             {
  267.                 printTarget_ip = null;
  268.             }
  269.  
  270.             // TARGET_PORT
  271.             if (target_port != null)
  272.             {
  273.                 printTarget_port = "target_port: " + target_port + "\n";
  274.             }
  275.             if (target_port == null)
  276.             {
  277.                 printTarget_port = null;
  278.             }
  279.  
  280.             // MODULE_NAME
  281.             if (module_name != null)
  282.             {
  283.                 printModule_name = module_name + "\n";
  284.             }
  285.             else if (module_name == null)
  286.             {
  287.                 printModule_name = null;
  288.             }
  289.  
  290.             // SPECIFIC_PORT
  291.             if (specific_port != null)
  292.             {
  293.                 printSpecific_port = "specific_port: " + specific_port + "\n";
  294.             }
  295.             if (specific_port == null)
  296.             {
  297.                 printSpecific_port = null;
  298.             }
  299.  
  300.             string WriteMethods =
  301.                 printModule_name + printTarget_ip + printTarget_port + printSpecific_port;
  302.  
  303.             return WriteMethods;
  304.         }
  305.  
  306.         public string launch()
  307.         {
  308.             return null;
  309.         }
  310.     }
  311. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement