public Coffee(string brand, double price, Roast roast, Company importer) { this.brand = brand; this.price = price; this.roast = roast; this.importer = importer; }
public Coffee(string brand, string importer, double price, Roast roast) { this.brand = brand; this.importer = importer; this.price = price; this.roast = roast; }
public Coffee(string brand, double price, Roast roast, string importer = "default") { this.brand = brand; this.price = price; this.roast = roast; this.importer = importer; }
protected void Page_Load(object sender, EventArgs e) { var roast = new Roast(); var roastdata = Request.QueryString["roastdata"]; var dataArray = roastdata.Split(';'); var elapsed = int.Parse(dataArray[0]); var temperature = float.Parse(dataArray[1]); var debugstring = dataArray[2]; var command = @"INSERT INTO RoastLog(RoastId, ElapsedTime, Temperature, DebugData) VALUES (@RoastId, @ElapsedTime, @Temperature, @DebugData)"; var _conn = new SqlConnection(ConnectionString.connString); var sqlCommand = new SqlCommand(command); sqlCommand.Parameters.AddWithValue("@RoastId", ((object)roast.Id) ?? DBNull.Value); sqlCommand.Parameters.AddWithValue("@ElapsedTime", elapsed); sqlCommand.Parameters.AddWithValue("@Temperature", temperature); sqlCommand.Parameters.AddWithValue("@DebugData", debugstring); _conn.Open(); sqlCommand.Connection = _conn; sqlCommand.ExecuteNonQuery(); _conn.Close(); }
public void Put(Roast roast) { _logger.LogInformation("Update roast information: {roast}"); // get roast from database var dbRoasts = _context.Roasts.Include(x => x.Beans).ThenInclude(x => x.StockItem); var dbRoast = dbRoasts.FirstOrDefault(x => x.Id == roast.Id); //List<GreenBlend> blendsToRemove = new List<GreenBlend>(); // remove items, which are not yet needed anymore foreach (var bl in dbRoast.Beans) { if (!roast.Beans.Select(x => x.Id).Contains(bl.Id)) { //blendsToRemove.Add(bl); var sbl = _context.GreenBlends.FirstOrDefault(x => x.Id == bl.Id); _context.GreenBlends.Remove(sbl); } } _context.SaveChanges(); List <GreenBlend> blend = new List <GreenBlend>(); // add new items foreach (var bl in roast.Beans) { var b = _context.GreenBlends.FirstOrDefault(x => x.Id == bl.Id); blend.Add(b); } dbRoast.Beans = blend; _context.Entry(dbRoast).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); }
public IActionResult Add([Bind("RoastId", "Name", "Price", "CurrentRoast", "Strength", "ImagePath")] Roast roast) { DbContext _context = new WeLoveCoffeeDbContext(); var _roast = _context.Add(roast); _context.SaveChanges(); return(Redirect("/Roast")); }
static async Task Main() { Config.LoadConfig(); // loads the config AdvancedLogger.LoadAdvancedLoggerConfig(); // Loads the AdvancedLogger config await Roast.InstallRoastList().ConfigureAwait(false); // Installs the default roast list await Roast.FillRoastListAsync().ConfigureAwait(false); // fills the roast list with the default roasts new RoleCreator().CreateAllPaths(RoleList); StartAsync().ConfigureAwait(false).GetAwaiter().GetResult(); // runs the start task, configured await to be false, gets the awaiter in the Task and then returns the result }
protected void Page_Load(object sender, EventArgs e) { double currentTemperature; if (double.TryParse(Request.QueryString["temperature"], out currentTemperature)) { var activeRoast = new Roast(); activeRoast.CurrentTemp = currentTemperature; activeRoast.Save(); } }
public void Execute(Dictionary <string, string> arguments) { string spn = ""; string user = ""; string OU = ""; string outFile = ""; if (arguments.ContainsKey("/spn")) { spn = arguments["/spn"]; } if (arguments.ContainsKey("/user")) { user = arguments["/user"]; } if (arguments.ContainsKey("/ou")) { OU = arguments["/ou"]; } if (arguments.ContainsKey("/outfile")) { outFile = arguments["/outfile"]; } if (arguments.ContainsKey("/creduser")) { if (!Regex.IsMatch(arguments["/creduser"], ".+\\.+", RegexOptions.IgnoreCase)) { Console.WriteLine("\r\n[X] /creduser specification must be in fqdn format (domain.com\\user)\r\n"); return; } string[] parts = arguments["/creduser"].Split('\\'); string domainName = parts[0]; string userName = parts[1]; if (!arguments.ContainsKey("/credpassword")) { Console.WriteLine("\r\n[X] /credpassword is required when specifying /creduser\r\n"); return; } string password = arguments["/credpassword"]; System.Net.NetworkCredential cred = new System.Net.NetworkCredential(userName, password, domainName); Roast.Kerberoast(spn, user, OU, cred, outFile); } else { Roast.Kerberoast(spn, user, OU, null, outFile); } }
public void Execute(Dictionary <string, string> arguments) { string user = ""; string domain = ""; string dc = ""; string format = "john"; if (arguments.ContainsKey("/user")) { string[] parts = arguments["/user"].Split('\\'); if (parts.Length == 2) { domain = parts[0]; user = parts[1]; } else { user = arguments["/user"]; } } if (arguments.ContainsKey("/domain")) { domain = arguments["/domain"]; } if (arguments.ContainsKey("/dc")) { dc = arguments["/dc"]; } if (arguments.ContainsKey("/format")) { format = arguments["/format"]; } if (String.IsNullOrEmpty(user)) { Console.WriteLine("\r\n[X] You must supply a user name!\r\n"); return; } if (String.IsNullOrEmpty(domain)) { domain = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName; } if (String.IsNullOrEmpty(dc)) { Roast.ASRepRoast(user, domain, "", format); } else { Roast.ASRepRoast(user, domain, dc, format); } }
public Coffee CreateCoffee() { Console.WriteLine("anna kahvin merkki:"); string brand = Console.ReadLine(); Console.WriteLine("anna kahvin hinta:"); double price = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("anna paahto (1-5):"); int paahto = int.Parse(Console.ReadLine()); Roast roast = (Roast)paahto; Company importer = null; bool importerSelected = false; while (!importerSelected) { Console.Clear(); Console.WriteLine("mikä on maahantuoja?"); Console.WriteLine("1) Valitse yritys listasta."); Console.WriteLine("2) Uusi yritys."); int selected = int.Parse(Console.ReadLine()); switch (selected) { case 1: Console.Clear(); importer = SelectCompanyFromList(); importerSelected = true; break; case 2: Console.Clear(); importer = AddNewCompanyToList(); importerSelected = true; break; case 3: Console.Clear(); importer = null; importerSelected = true; break; default: break; } } Coffee newCoffee = new Coffee(brand, price, roast, importer); return(newCoffee); }
public IActionResult Update([Bind("RoastId", "Name", "Price", "CurrentRoast", "Strength", "ImagePath")] Roast roast) { DbContext _context = new WeLoveCoffeeDbContext(); var _dbRoast = _context.Set <Roast>().Where(p => p.RoastId == roast.RoastId).FirstOrDefault(); _dbRoast.Name = roast.Name; _dbRoast.Price = roast.Price; _dbRoast.CurrentRoast = roast.CurrentRoast; _dbRoast.Strength = roast.Strength; _dbRoast.ImagePath = roast.ImagePath; _context.SaveChanges(); return(Redirect("Index")); }
public static void SetRoasts(DbContext _context) { Roast roast = new Roast() { RoastId = 1, CurrentRoast = true, Name = "Classic Aldi Röstung", Price = 6.99M, ImagePath = "https://images.unsplash.com/photo-1581191852946-c8b7c9caf935?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=60" }; Roast roast1 = new Roast() { RoastId = 2, CurrentRoast = false, Name = "Mövenpick Special", Price = 12.99M, ImagePath = "" }; _context.Set <Roast>().AddRange(roast, roast1); _context.SaveChanges(); }
public int Post(Roast roast) { if (roast.CuppingInfo != null) { roast.CuppingInfo = _context.Cuppings.FirstOrDefault(x => x.Id == roast.CuppingInfo.Id); } List <GreenBlend> blend = new List <GreenBlend>(); roast.Beans.ForEach(x => blend.Add(_context.GreenBlends.FirstOrDefault(k => k.Id == x.Id))); roast.Beans.Clear(); roast.Beans.AddRange(blend); _context.Add <Roast>(roast); _context.SaveChanges(); return(roast.Id); }
protected void Page_Load(object sender, EventArgs e) { var activeRoast = new Roast(); if (activeRoast.ProfileId.HasValue) { var activeProfile = new Profile(activeRoast.ProfileId.Value); ProfileLiteral.Text = activeProfile.ProfileText; } else { ProfileLiteral.Text = "0"; activeRoast.StatusId = (int)Classes.RoastStatus.ErrorUnspecified; activeRoast.Save(); } }
public void Execute(Dictionary <string, string> arguments) { string user = ""; string domain = ""; string dc = ""; string format = "john"; string compositeUserName; // TODO : Clarify in original source code. if (arguments.TryGetValue("/user", out compositeUserName)) { string[] parts = compositeUserName.Split('\\'); switch (parts.Length) { case 2: domain = parts[0]; user = parts[1]; break; case 1: user = compositeUserName; break; default: throw new ApplicationException(); } } if (string.IsNullOrEmpty(domain)) { // Because we don't want to override the value from the /user parameter unless it is not // explictly stated in the /user argument. arguments.TryGetValue("/domain", out domain); } arguments.TryGetValue("/dc", out dc); arguments.TryGetValue("/format", out format); if (string.IsNullOrEmpty(user)) { Console.WriteLine("\r\n[X] You must supply a user name!\r\n"); return; } if (string.IsNullOrEmpty(domain)) { domain = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName; } Roast.ASRepRoast(user, domain, string.IsNullOrEmpty(dc) ? string.Empty : dc, format); }
private static bool IsNewStatusValid(Roast roast, int newStatusCode) { switch (newStatusCode) { case 105: return(roast.StatusId == (int)RoastStatus.RoasterOnlineReady || roast.StatusId == newStatusCode); case 115: return(roast.StatusId == (int)RoastStatus.ProfileLoadedReadyForRoastingWithProfile || roast.StatusId == newStatusCode); case 145: return(roast.StatusId == (int)RoastStatus.ProfileLoadedReadyForRoastingWithProfile || roast.StatusId == newStatusCode); case 205: return(roast.StatusId == (int)RoastStatus.RoasterOnlineReady || roast.StatusId == (int)RoastStatus.ProfileLoadedReadyForRoastingWithProfile || roast.StatusId == (int)RoastStatus.RoastingWithProfile || roast.StatusId == newStatusCode); case 305: return(roast.StatusId == (int)RoastStatus.LoadProfile || roast.StatusId == (int)RoastStatus.StartedLoadingProfile || roast.StatusId == (int)RoastStatus.ProfileLoadedReadyForRoastingWithProfile || roast.StatusId == (int)RoastStatus.StartRoasting || roast.StatusId == (int)RoastStatus.InitiatingProfileRoastInsertingBulb || roast.StatusId == (int)RoastStatus.RoastingWithProfile || roast.StatusId == (int)RoastStatus.StartManualRoasting || roast.StatusId == (int)RoastStatus.InitiatingManualRoastInsertingBulb || roast.StatusId == (int)RoastStatus.RoastingWithManualControl || roast.StatusId == newStatusCode); } return(false); }
protected void Page_Load(object sender, EventArgs e) { int receivedCode; int.TryParse(Request.QueryString["code"], out receivedCode); var roast = new Roast(); switch (receivedCode) { case 105: // Load profile case 115: // Start roasting case 205: // Start manual roasting case 305: roast.StatusId = (int)RoastStatus.ErrorCurrentStatusIsNotValidForTheCurrentStateOfTheRoaster; break; case 30: // Roaster online - ready if (roast.StatusId == (int)RoastStatus.NoCommunicationYet || roast.StatusId == (int)RoastStatus.RemoveProfile || roast.StatusId == (int)RoastStatus.EndingRoast || roast.StatusId == (int)RoastStatus.ResetEgEndRoastEjectBulb || roast.StatusId == receivedCode) { if ((roast.StatusId == (int)RoastStatus.EndingRoast || roast.StatusId == (int)RoastStatus.ResetEgEndRoastEjectBulb) && roast.EndTime == null) { roast.EndTime = DateTime.Now; roast.Save(); roast.CreateNewRoast(); } roast.StatusId = receivedCode; } else if (roast.StatusId == (int)RoastStatus.LoadProfile || roast.StatusId == (int)RoastStatus.StartManualRoasting) { // roast status correct - already set - send to roaster } else { roast.StatusId = (int)RoastStatus.ErrorCurrentStatusIsNotValidForTheCurrentStateOfTheRoaster; } break; case 106: // Started loading profile if (roast.StatusId == (int)RoastStatus.LoadProfile || roast.StatusId == receivedCode) { roast.StatusId = receivedCode; } else if (roast.StatusId == (int)RoastStatus.ResetEgEndRoastEjectBulb) { // roast status correct - already set - send to roaster } else { roast.StatusId = (int)RoastStatus.ErrorCurrentStatusIsNotValidForTheCurrentStateOfTheRoaster; } break; case 110: // Profile loaded - ready for roasting with profile if (roast.StatusId == (int)RoastStatus.LoadProfile || roast.StatusId == (int)RoastStatus.StartedLoadingProfile || roast.StatusId == receivedCode) { roast.StatusId = receivedCode; } else if (roast.StatusId == (int)RoastStatus.StartRoasting || roast.StatusId == (int)RoastStatus.RemoveProfile || roast.StatusId == (int)RoastStatus.StartManualRoasting || roast.StatusId == (int)RoastStatus.ResetEgEndRoastEjectBulb) { // roast status correct - already set - send to roaster } else { roast.StatusId = (int)RoastStatus.ErrorCurrentStatusIsNotValidForTheCurrentStateOfTheRoaster; } break; case 120: // Initiating profile roast (inserting bulb) if (roast.StatusId == (int)RoastStatus.StartRoasting || roast.StatusId == receivedCode) { roast.StatusId = receivedCode; } else if (roast.StatusId == (int)RoastStatus.ResetEgEndRoastEjectBulb) { // roast status correct - already set - send to roaster } else { roast.StatusId = (int)RoastStatus.ErrorCurrentStatusIsNotValidForTheCurrentStateOfTheRoaster; } break; case 130: // Roasting with profile if (roast.StatusId == (int)RoastStatus.StartRoasting || roast.StatusId == (int)RoastStatus.InitiatingProfileRoastInsertingBulb || roast.StatusId == receivedCode) { if (roast.StartTime == null) { roast.StartTime = DateTime.Now; PushNotification pn = new PushNotification(); pn.SendNotification(); } if (String.IsNullOrEmpty(roast.ProfileText)) { Profile profile = new Profile((int)roast.ProfileId); roast.ProfileText = profile.ProfileText; } roast.StatusId = receivedCode; } else if (roast.StatusId == (int)RoastStatus.StartManualRoasting || roast.StatusId == (int)RoastStatus.ResetEgEndRoastEjectBulb) { // roast status correct - already set - send to roaster } else { roast.StatusId = (int)RoastStatus.ErrorCurrentStatusIsNotValidForTheCurrentStateOfTheRoaster; } break; case 210: // Initiating manual roast (inserting bulb) if (roast.StatusId == (int)RoastStatus.StartManualRoasting || roast.StatusId == receivedCode) { roast.StatusId = receivedCode; } else if (roast.StatusId == (int)RoastStatus.ResetEgEndRoastEjectBulb) { // roast status correct - already set - send to roaster } else { roast.StatusId = (int)RoastStatus.ErrorCurrentStatusIsNotValidForTheCurrentStateOfTheRoaster; } break; case 220: // Roasting with manual control if (roast.StatusId == (int)RoastStatus.StartManualRoasting || roast.StatusId == (int)RoastStatus.InitiatingManualRoastInsertingBulb || roast.StatusId == receivedCode) { if (roast.StartTime == null) { roast.StartTime = DateTime.Now; PushNotification pn = new PushNotification(); pn.SendNotification(); } if (roast.ManualControlStartTime == null) { roast.ManualControlStartTime = DateTime.Now; } roast.StatusId = receivedCode; } else if (roast.StatusId == (int)RoastStatus.ResetEgEndRoastEjectBulb) { // roast status correct - already set - send to roaster } else { roast.StatusId = (int)RoastStatus.ErrorCurrentStatusIsNotValidForTheCurrentStateOfTheRoaster; } break; case 310: // Ending roast (will return to 30) if (roast.StatusId == (int)RoastStatus.ResetEgEndRoastEjectBulb || roast.StatusId == receivedCode) { roast.StatusId = receivedCode; } else { roast.StatusId = (int)RoastStatus.ErrorCurrentStatusIsNotValidForTheCurrentStateOfTheRoaster; } break; case 400: // Error - unspecified case 401: // Error - Current status is not valid for the current state of the roaster case 402: // Error - Roaster not online roast.StatusId = receivedCode; break; } roast.Save(); StatusLiteral.Text = "{" + roast.StatusId + "}"; // for now: send back the current status code }
protected void Page_Load(object sender, EventArgs e) { var roast = new Roast(); TemperatureLiteral.Text = "{" + Math.Floor((roast.CurrentTargetTemp ?? 0)).ToString() + "}"; }
public void Execute(Dictionary <string, string> arguments) { Console.WriteLine("\r\n[*] Action: Kerberoasting\r\n"); string spn = ""; List <string> spns = null; string user = ""; string OU = ""; string outFile = ""; string domain = ""; string dc = ""; string ldapFilter = ""; string supportedEType = "rc4"; bool useTGTdeleg = false; bool listUsers = false; KRB_CRED TGT = null; string pwdSetAfter = ""; string pwdSetBefore = ""; int resultLimit = 0; int delay = 0; int jitter = 0; bool simpleOutput = false; bool enterprise = false; bool autoenterprise = false; if (arguments.ContainsKey("/spn")) { // roast a specific single SPN spn = arguments["/spn"]; } if (arguments.ContainsKey("/spns")) { spns = new List <string>(); if (System.IO.File.Exists(arguments["/spns"])) { string fileContent = Encoding.UTF8.GetString(System.IO.File.ReadAllBytes(arguments["/spns"])); foreach (string s in fileContent.Split('\n')) { if (!String.IsNullOrEmpty(s)) { spns.Add(s.Trim()); } } } else { foreach (string s in arguments["/spns"].Split(',')) { spns.Add(s); } } } if (arguments.ContainsKey("/user")) { // roast a specific user (or users, comma-separated user = arguments["/user"]; } if (arguments.ContainsKey("/ou")) { // roast users from a specific OU OU = arguments["/ou"]; } if (arguments.ContainsKey("/domain")) { // roast users from a specific domain domain = arguments["/domain"]; } if (arguments.ContainsKey("/dc")) { // use a specific domain controller for kerberoasting dc = arguments["/dc"]; } if (arguments.ContainsKey("/outfile")) { // output kerberoasted hashes to a file instead of to the console outFile = arguments["/outfile"]; } if (arguments.ContainsKey("/simple")) { // output kerberoasted hashes to the output file format instead, to the console simpleOutput = true; } if (arguments.ContainsKey("/aes")) { // search for users w/ AES encryption enabled and request AES tickets supportedEType = "aes"; } if (arguments.ContainsKey("/rc4opsec")) { // search for users without AES encryption enabled roast supportedEType = "rc4opsec"; } if (arguments.ContainsKey("/ticket")) { // use an existing TGT ticket when requesting/roasting string kirbi64 = arguments["/ticket"]; if (Helpers.IsBase64String(kirbi64)) { byte[] kirbiBytes = Convert.FromBase64String(kirbi64); TGT = new KRB_CRED(kirbiBytes); } else if (System.IO.File.Exists(kirbi64)) { byte[] kirbiBytes = System.IO.File.ReadAllBytes(kirbi64); TGT = new KRB_CRED(kirbiBytes); } else { Console.WriteLine("\r\n[X] /ticket:X must either be a .kirbi file or a base64 encoded .kirbi\r\n"); } } if (arguments.ContainsKey("/usetgtdeleg") || arguments.ContainsKey("/tgtdeleg")) { // use the TGT delegation trick to get a delegated TGT to use for roasting useTGTdeleg = true; } if (arguments.ContainsKey("/pwdsetafter")) { // filter for roastable users w/ a pwd set after a specific date pwdSetAfter = arguments["/pwdsetafter"]; } if (arguments.ContainsKey("/pwdsetbefore")) { // filter for roastable users w/ a pwd set before a specific date pwdSetBefore = arguments["/pwdsetbefore"]; } if (arguments.ContainsKey("/ldapfilter")) { // additional LDAP targeting filter ldapFilter = arguments["/ldapfilter"].Trim('"').Trim('\''); } if (arguments.ContainsKey("/resultlimit")) { // limit the number of roastable users resultLimit = Convert.ToInt32(arguments["/resultlimit"]); } if (arguments.ContainsKey("/delay")) { delay = Int32.Parse(arguments["/delay"]); if (delay < 100) { Console.WriteLine("[!] WARNING: delay is in milliseconds! Please enter a value > 100."); return; } } if (arguments.ContainsKey("/jitter")) { try { jitter = Int32.Parse(arguments["/jitter"]); } catch { Console.WriteLine("[X] Jitter must be an integer between 1-100."); return; } if (jitter <= 0 || jitter > 100) { Console.WriteLine("[X] Jitter must be between 1-100"); return; } } if (arguments.ContainsKey("/stats")) { // output stats on the number of kerberoastable users, don't actually roast anything listUsers = true; } if (arguments.ContainsKey("/enterprise")) { // use enterprise principals in the request, requires /spn and (/ticket or /tgtdeleg) enterprise = true; } if (arguments.ContainsKey("/autoenterprise")) { // use enterprise principals in the request if roasting with the SPN fails, requires /ticket or /tgtdeleg, does nothing is /spn or /spns is supplied autoenterprise = true; } if (arguments.ContainsKey("/creduser")) { // provide an alternate user to use for connection creds if (!Regex.IsMatch(arguments["/creduser"], ".+\\.+", RegexOptions.IgnoreCase)) { Console.WriteLine("\r\n[X] /creduser specification must be in fqdn format (domain.com\\user)\r\n"); return; } string[] parts = arguments["/creduser"].Split('\\'); string domainName = parts[0]; string userName = parts[1]; // provide an alternate password to use for connection creds if (!arguments.ContainsKey("/credpassword")) { Console.WriteLine("\r\n[X] /credpassword is required when specifying /creduser\r\n"); return; } string password = arguments["/credpassword"]; System.Net.NetworkCredential cred = new System.Net.NetworkCredential(userName, password, domainName); Roast.Kerberoast(spn, spns, user, OU, domain, dc, cred, outFile, simpleOutput, TGT, useTGTdeleg, supportedEType, pwdSetAfter, pwdSetBefore, ldapFilter, resultLimit, delay, jitter, listUsers, enterprise, autoenterprise); } else { Roast.Kerberoast(spn, spns, user, OU, domain, dc, null, outFile, simpleOutput, TGT, useTGTdeleg, supportedEType, pwdSetAfter, pwdSetBefore, ldapFilter, resultLimit, delay, jitter, listUsers, enterprise, autoenterprise); } }
protected void Page_Load(object sender, EventArgs e) { var jsonString = Request.Form["data"]; if (String.IsNullOrEmpty(jsonString)) { return; } var interfaceObject = new JavaScriptSerializer().Deserialize <InterfaceObject>(jsonString); //var interfaceObject = new InterfaceObject(); var roast = new Roast(); switch (interfaceObject.Action) { case (int)InterfaceAction.SetStatus: if (IsNewStatusValid(roast, interfaceObject.StatusCode)) { if (interfaceObject.StatusCode == (int)RoastStatus.StartManualRoasting && roast.CurrentTemp.HasValue) { roast.CurrentTargetTemp = Math.Floor(roast.CurrentTemp.Value); } roast.StatusId = interfaceObject.StatusCode; roast.Save(); } break; case (int)InterfaceAction.SaveProfile: interfaceObject.Profile.Save(); break; case (int)InterfaceAction.GetProfile: var profileId = 0; if (interfaceObject.ProfileId > 0) { profileId = interfaceObject.ProfileId; } else if (roast.ProfileId.HasValue) { profileId = roast.ProfileId.Value; } interfaceObject.Profile = new Profile(profileId); break; case (int)InterfaceAction.GetProfiles: interfaceObject.Profiles = LoadProfilesFromDb(); break; case (int)InterfaceAction.SetProfile: if (GetElapsedTime(roast.Id ?? 0) == 0 && (roast.StatusId == (int)RoastStatus.RoasterOnlineReady)) { roast.StatusId = (int)RoastStatus.LoadProfile; roast.ProfileId = interfaceObject.ProfileId; roast.Save(); } break; case (int)InterfaceAction.GetStatus: interfaceObject.StatusCode = roast.StatusId ?? 0; interfaceObject.CurrentTemp = roast.CurrentTemp; interfaceObject.ElapsedTime = GetElapsedTime(roast.Id ?? 0); interfaceObject.ProfileId = roast.ProfileId ?? 0; if (roast.StatusId == (int)RoastStatus.StartManualRoasting || roast.StatusId == (int)RoastStatus.InitiatingManualRoastInsertingBulb || roast.StatusId == (int)RoastStatus.RoastingWithManualControl) { interfaceObject.ManualTargetTemp = roast.CurrentTargetTemp; } break; case (int)InterfaceAction.SetManualRoastTemperature: roast.CurrentTargetTemp = interfaceObject.ManualTargetTemp; roast.Save(); break; case (int)InterfaceAction.GetManualRoastTemperature: interfaceObject.ManualTargetTemp = roast.CurrentTargetTemp; break; case (int)InterfaceAction.DeleteProfile: var profile = new Profile(interfaceObject.ProfileId); profile.Delete(); break; case (int)InterfaceAction.MasterReset: roast.CreateNewRoast(); break; case (int)InterfaceAction.RemoveProfile: if (roast.StatusId == (int)RoastStatus.ProfileLoadedReadyForRoastingWithProfile) { roast.ProfileId = null; roast.StatusId = (int)RoastStatus.RemoveProfile; roast.Save(); } break; case (int)InterfaceAction.SetFirstCrack: int FirstElapsed = (int)GetElapsedTime(roast.Id ?? 0); if (FirstElapsed > 0) { roast.FirstCrackElapsed = FirstElapsed; roast.FirstCrackTemp = GetTemperatureAverage(roast.Id ?? 0, 3); roast.Save(); } break; case (int)InterfaceAction.SetSecondCrack: int SecondElapsed = (int)GetElapsedTime(roast.Id ?? 0); if (SecondElapsed > 0) { roast.SecondCrackElapsed = SecondElapsed; roast.SecondCrackTemp = GetTemperatureAverage(roast.Id ?? 0, 3); roast.Save(); } break; } var json = new JavaScriptSerializer().Serialize(interfaceObject); StatusLiteral.Text = json; }
public void Execute(Dictionary <string, string> arguments) { string spn = ""; bool adminCount = false; string user = ""; string OU = ""; string outFile = ""; string domain = ""; int delay = 0; int jitter = 0; string dc = ""; string supportedEType = "rc4"; bool useTGTdeleg = false; KRB_CRED TGT = null; if (arguments.ContainsKey("/admincount")) { adminCount = true; } if (arguments.ContainsKey("/delay")) { delay = Int32.Parse(arguments["/delay"]); } if (arguments.ContainsKey("/jitter")) { jitter = Int32.Parse(arguments["/jitter"]); } if (arguments.ContainsKey("/spn")) { spn = arguments["/spn"]; } if (arguments.ContainsKey("/user")) { user = arguments["/user"]; } if (arguments.ContainsKey("/ou")) { OU = arguments["/ou"]; } if (arguments.ContainsKey("/domain")) { domain = arguments["/domain"]; } if (arguments.ContainsKey("/dc")) { dc = arguments["/dc"]; } if (arguments.ContainsKey("/outfile")) { outFile = arguments["/outfile"]; } if (arguments.ContainsKey("/aes")) { supportedEType = "aes"; } if (arguments.ContainsKey("/rc4opsec")) { supportedEType = "rc4opsec"; } if (arguments.ContainsKey("/ticket")) { string kirbi64 = arguments["/ticket"]; if (Helpers.IsBase64String(kirbi64)) { byte[] kirbiBytes = Convert.FromBase64String(kirbi64); TGT = new KRB_CRED(kirbiBytes); } else if (System.IO.File.Exists(kirbi64)) { byte[] kirbiBytes = System.IO.File.ReadAllBytes(kirbi64); TGT = new KRB_CRED(kirbiBytes); } else { Console.WriteLine("\r\n[X] /ticket:X must either be a .kirbi file or a base64 encoded .kirbi\r\n"); } } if (arguments.ContainsKey("/usetgtdeleg") || arguments.ContainsKey("/tgtdeleg")) { useTGTdeleg = true; } if (arguments.ContainsKey("/creduser")) { if (!Regex.IsMatch(arguments["/creduser"], ".+\\.+", RegexOptions.IgnoreCase)) { Console.WriteLine("\r\n[X] /creduser specification must be in fqdn format (domain.com\\user)\r\n"); return; } string[] parts = arguments["/creduser"].Split('\\'); string domainName = parts[0]; string userName = parts[1]; if (!arguments.ContainsKey("/credpassword")) { Console.WriteLine("\r\n[X] /credpassword is required when specifying /creduser\r\n"); return; } string password = arguments["/credpassword"]; System.Net.NetworkCredential cred = new System.Net.NetworkCredential(userName, password, domainName); Roast.Kerberoast(spn, adminCount, user, OU, domain, dc, cred, outFile, TGT, useTGTdeleg, supportedEType, delay, jitter); } else { Roast.Kerberoast(spn, adminCount, user, OU, domain, dc, null, outFile, TGT, useTGTdeleg, supportedEType, delay, jitter); } }
public void Execute(Dictionary <string, string> arguments) { Console.WriteLine("\r\n[*] Action: AS-REP roasting\r\n"); string user = ""; string domain = ""; string dc = ""; string ou = ""; string format = "john"; string ldapFilter = ""; string outFile = ""; if (arguments.ContainsKey("/user")) { string[] parts = arguments["/user"].Split('\\'); if (parts.Length == 2) { domain = parts[0]; user = parts[1]; } else { user = arguments["/user"]; } } if (arguments.ContainsKey("/domain")) { domain = arguments["/domain"]; } if (arguments.ContainsKey("/dc")) { dc = arguments["/dc"]; } if (arguments.ContainsKey("/ou")) { ou = arguments["/ou"]; } if (arguments.ContainsKey("/ldapfilter")) { // additional LDAP targeting filter ldapFilter = arguments["/ldapfilter"].Trim('"').Trim('\''); } if (arguments.ContainsKey("/format")) { format = arguments["/format"]; } if (arguments.ContainsKey("/outfile")) { outFile = arguments["/outfile"]; } if (String.IsNullOrEmpty(domain)) { domain = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName; } if (arguments.ContainsKey("/creduser")) { if (!Regex.IsMatch(arguments["/creduser"], ".+\\.+", RegexOptions.IgnoreCase)) { Console.WriteLine("\r\n[X] /creduser specification must be in fqdn format (domain.com\\user)\r\n"); return; } string[] parts = arguments["/creduser"].Split('\\'); string domainName = parts[0]; string userName = parts[1]; if (!arguments.ContainsKey("/credpassword")) { Console.WriteLine("\r\n[X] /credpassword is required when specifying /creduser\r\n"); return; } string password = arguments["/credpassword"]; System.Net.NetworkCredential cred = new System.Net.NetworkCredential(userName, password, domainName); Roast.ASRepRoast(domain, user, ou, dc, format, cred, outFile, ldapFilter); } else { Roast.ASRepRoast(domain, user, ou, dc, format, null, outFile, ldapFilter); } }
public void Execute(Dictionary <string, string> arguments) { Console.WriteLine("\r\n[*] Action: Kerberoasting\r\n"); string spn = ""; string user = ""; string OU = ""; string outFile = ""; string domain = ""; string dc = ""; string ldapFilter = ""; string supportedEType = "rc4"; bool useTGTdeleg = false; bool listUsers = false; KRB_CRED TGT = null; string pwdSetAfter = ""; string pwdSetBefore = ""; int resultLimit = 0; bool simpleOutput = false; if (arguments.ContainsKey("/spn")) { // roast a specific single SPN spn = arguments["/spn"]; } if (arguments.ContainsKey("/user")) { // roast a specific user (or users, comma-separated user = arguments["/user"]; } if (arguments.ContainsKey("/ou")) { // roast users from a specific OU OU = arguments["/ou"]; } if (arguments.ContainsKey("/domain")) { // roast users from a specific domain domain = arguments["/domain"]; } if (arguments.ContainsKey("/dc")) { // use a specific domain controller for kerberoasting dc = arguments["/dc"]; } if (arguments.ContainsKey("/outfile")) { // output kerberoasted hashes to a file instead of to the console outFile = arguments["/outfile"]; } if (arguments.ContainsKey("/simple")) { // output kerberoasted hashes to the output file format instead, to the console simpleOutput = true; } if (arguments.ContainsKey("/aes")) { // search for users w/ AES encryption enabled and request AES tickets supportedEType = "aes"; } if (arguments.ContainsKey("/rc4opsec")) { // search for users without AES encryption enabled roast supportedEType = "rc4opsec"; } if (arguments.ContainsKey("/ticket")) { // use an existing TGT ticket when requesting/roasting string kirbi64 = arguments["/ticket"]; if (Helpers.IsBase64String(kirbi64)) { byte[] kirbiBytes = Convert.FromBase64String(kirbi64); TGT = new KRB_CRED(kirbiBytes); } else if (System.IO.File.Exists(kirbi64)) { byte[] kirbiBytes = System.IO.File.ReadAllBytes(kirbi64); TGT = new KRB_CRED(kirbiBytes); } else { Console.WriteLine("\r\n[X] /ticket:X must either be a .kirbi file or a base64 encoded .kirbi\r\n"); } } if (arguments.ContainsKey("/usetgtdeleg") || arguments.ContainsKey("/tgtdeleg")) { // use the TGT delegation trick to get a delegated TGT to use for roasting useTGTdeleg = true; } if (arguments.ContainsKey("/pwdsetafter")) { // filter for roastable users w/ a pwd set after a specific date pwdSetAfter = arguments["/pwdsetafter"]; } if (arguments.ContainsKey("/pwdsetbefore")) { // filter for roastable users w/ a pwd set before a specific date pwdSetBefore = arguments["/pwdsetbefore"]; } if (arguments.ContainsKey("/ldapfilter")) { // additional LDAP targeting filter ldapFilter = arguments["/ldapfilter"].Trim('"').Trim('\''); } if (arguments.ContainsKey("/resultlimit")) { // limit the number of roastable users resultLimit = Convert.ToInt32(arguments["/resultlimit"]); } if (arguments.ContainsKey("/stats")) { // output stats on the number of kerberoastable users, don't actually roast anything listUsers = true; } if (arguments.ContainsKey("/creduser")) { // provide an alternate user to use for connection creds if (!Regex.IsMatch(arguments["/creduser"], ".+\\.+", RegexOptions.IgnoreCase)) { Console.WriteLine("\r\n[X] /creduser specification must be in fqdn format (domain.com\\user)\r\n"); return; } string[] parts = arguments["/creduser"].Split('\\'); string domainName = parts[0]; string userName = parts[1]; // provide an alternate password to use for connection creds if (!arguments.ContainsKey("/credpassword")) { Console.WriteLine("\r\n[X] /credpassword is required when specifying /creduser\r\n"); return; } string password = arguments["/credpassword"]; System.Net.NetworkCredential cred = new System.Net.NetworkCredential(userName, password, domainName); Roast.Kerberoast(spn, user, OU, domain, dc, cred, outFile, simpleOutput, TGT, useTGTdeleg, supportedEType, pwdSetAfter, pwdSetBefore, ldapFilter, resultLimit, listUsers); } else { Roast.Kerberoast(spn, user, OU, domain, dc, null, outFile, simpleOutput, TGT, useTGTdeleg, supportedEType, pwdSetAfter, pwdSetBefore, ldapFilter, resultLimit, listUsers); } }
public Coffee(Roast roast, Type type, int caffeineContent) { Roast = roast; Type = type; CaffeineContent = caffeineContent; }