VolatileMinds

Application Security and Software Consulting



Using Arachni-sharp

Recently committed to Github were some C# bindings to allow a remote Arachni instance to be driven programmatically from your Mono/.NET applications.

The bindings follow the same Session/Manager pattern as previous bindings, such as the Nexpose or Metasploit bindings. This allows us to separate the transport of the protocol from the functionality of the API.

In 30 lines of code, you can connect to an Arachni RPCD instance, kick off a scan, and watch it while gathering the results:

class MainClass
{
  public static void Main (string[] args)
  {
    using (ArachniSession session = new ArachniSession ("192.168.2.207", 4567, true)) {
      using (ArachniManager manager = new ArachniManager (session)) {
        Console.WriteLine ("Using instance: " + session.InstanceName);
        manager.StartScan ("http://demo.testfire.net/default.aspx");

        bool isRunning = manager.IsBusy ().AsBoolean ();
        List<uint> issues = new List<uint> ();
        DateTime start = DateTime.Now;
        Console.WriteLine ("Starting scan at " + start.ToLongTimeString ());
        while (isRunning) {
          var progress = manager.GetProgress (issues);
          foreach (MessagePackObject p in progress.AsDictionary()["issues"].AsEnumerable()) {
            MessagePackObjectDictionary dict = p.AsDictionary ();
            Console.WriteLine ("Issue found: " + dict ["name"].AsString ());
            issues.Add (dict ["digest"].AsUInt32());
          }
          Thread.Sleep (10000);
          isRunning = manager.IsBusy ().AsBoolean ();
        }
        DateTime end = DateTime.Now;
        Console.WriteLine ("Finishing scan at " + end.ToLongTimeString () + ". Scan took " + ((end - start).ToString ()) + ".");
      }
    }
  }
}

These bindings should be considered beta for the time being, but work very well so far.