mirror of
https://github.com/openbullet/openbullet.git
synced 2023-10-21 07:33:42 -05:00
Fixed issue with wordlists selected from disk instead of manager
This commit is contained in:
@@ -7,6 +7,7 @@ using RuriLib.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenBullet.ViewModels
|
||||
@@ -62,7 +63,7 @@ namespace OpenBullet.ViewModels
|
||||
{
|
||||
Bots = r.BotsAmount,
|
||||
Config = r.ConfigName,
|
||||
Wordlist = r.WordlistName,
|
||||
Wordlist = r.Wordlist.Path,
|
||||
ProxyMode = r.ProxyMode
|
||||
}
|
||||
));
|
||||
@@ -88,8 +89,17 @@ namespace OpenBullet.ViewModels
|
||||
|
||||
instance.SetConfig(configVM.Config, false);
|
||||
|
||||
var wordlist = OB.WordlistManager.Wordlists.FirstOrDefault(w => w.Name == r.Wordlist)
|
||||
?? throw new Exception($"The Wordlist {r.Wordlist} was not found in the WordlistManager");
|
||||
// Try to get the Wordlist from the Manager
|
||||
var wordlist = OB.WordlistManager.Wordlists.FirstOrDefault(w => w.Path == r.Wordlist);
|
||||
|
||||
// If not found, try to get it from disk
|
||||
if (wordlist == null)
|
||||
{
|
||||
if (!File.Exists(r.Wordlist))
|
||||
throw new Exception($"The Wordlist {r.Wordlist} was not found in the WordlistManager or on Disk");
|
||||
|
||||
wordlist = WordlistManagerViewModel.FileToWordlist(r.Wordlist);
|
||||
}
|
||||
|
||||
instance.SetWordlist(wordlist);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,20 @@ namespace OpenBullet.ViewModels
|
||||
return WordlistsCollection.Where(x => x.Name == name).First();
|
||||
}
|
||||
|
||||
public static Wordlist FileToWordlist(string path)
|
||||
{
|
||||
// Build the wordlist object
|
||||
var wordlist = new Wordlist(Path.GetFileNameWithoutExtension(path), path, OB.Settings.Environment.WordlistTypes.First().Name, "");
|
||||
|
||||
// Get the first line
|
||||
var first = File.ReadLines(wordlist.Path).First();
|
||||
|
||||
// Set the correct wordlist type
|
||||
wordlist.Type = OB.Settings.Environment.RecognizeWordlistType(first);
|
||||
|
||||
return wordlist;
|
||||
}
|
||||
|
||||
#region CRUD Operations
|
||||
// Create
|
||||
public void Add(Wordlist wordlist)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using OpenBullet.Views.Main.Runner;
|
||||
using OpenBullet.ViewModels;
|
||||
using OpenBullet.Views.Main.Runner;
|
||||
using OpenBullet.Views.UserControls;
|
||||
using RuriLib.Models;
|
||||
using System.ComponentModel;
|
||||
@@ -80,17 +81,8 @@ namespace OpenBullet
|
||||
ofd.ShowDialog();
|
||||
try
|
||||
{
|
||||
// Build the wordlist object
|
||||
var wordlist = new Wordlist(Path.GetFileNameWithoutExtension(ofd.FileName), ofd.FileName, OB.Settings.Environment.WordlistTypes.First().Name, "");
|
||||
|
||||
// Get the first line
|
||||
var first = File.ReadLines(wordlist.Path).First();
|
||||
|
||||
// Set the correct wordlist type
|
||||
wordlist.Type = OB.Settings.Environment.RecognizeWordlistType(first);
|
||||
|
||||
// Add the wordlist to the runner
|
||||
((Runner)Caller).SetWordlist(wordlist);
|
||||
((Runner)Caller).SetWordlist(WordlistManagerViewModel.FileToWordlist(ofd.FileName));
|
||||
|
||||
((MainDialog)Parent).Close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user