// Decompiled with JetBrains decompiler
// Type: HTTPAgent.DataExtractor
// Assembly: WolfFt, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 510BEE3B-1B9B-4B2D-9942-86D11904E770
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Net-Worm.Win32.Mytob.lnt-bef6a2117211c906156a30c3f707a4cf4d485846cbcd1b241053651b23028a95.exe

using System.Collections;
using System.Collections.Specialized;
using System.Text.RegularExpressions;

namespace HTTPAgent
{
  public class DataExtractor
  {
    private DataExtractor()
    {
    }

    public static string[] ExtractDataArray(
      string input,
      string pattern,
      string replacement,
      RegexOptions options)
    {
      ArrayList arrayList = new ArrayList();
      foreach (Match match in Regex.Matches(input, pattern, options))
      {
        if (replacement == string.Empty)
          arrayList.Add((object) match.Value);
        else
          arrayList.Add((object) match.Result(replacement));
      }
      return (string[]) arrayList.ToArray(typeof (string));
    }

    public static string[] ExtractDataArray(string input, string pattern, string replacement) => DataExtractor.ExtractDataArray(input, pattern, replacement, RegexOptions.None);

    public static NameValueCollection ExtractHiddenFields(string input, int x)
    {
      NameValueCollection hiddenFields = new NameValueCollection();
      MatchCollection matchCollection1 = Regex.Matches(input, "<form.+?</form>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
      if (matchCollection1.Count > 0)
      {
        int i = x;
        if (i < 0)
          i = 0;
        if (i > matchCollection1.Count - 1)
          i = matchCollection1.Count - 1;
        MatchCollection matchCollection2 = Regex.Matches(matchCollection1[i].Value, "<input([^>]+?type=\"hidden\"[^>]+?)/?>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
        Regex regex = new Regex("(\\S+?)=\"(.*?)\"", RegexOptions.Compiled | RegexOptions.Singleline);
        foreach (Match match1 in matchCollection2)
        {
          MatchCollection matchCollection3 = regex.Matches(match1.Groups[1].Value);
          string name = "";
          string str = "";
          foreach (Match match2 in matchCollection3)
          {
            if (match2.Groups[1].Value.ToLower() == "name")
              name = match2.Groups[2].Value;
            if (match2.Groups[1].Value.ToLower() == "value")
              str = match2.Groups[2].Value;
          }
          hiddenFields[name] = str;
        }
      }
      return hiddenFields;
    }
  }
}
