Skip to content

Commit

Permalink
Fixes init.d based service collector on linux. (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfs authored Apr 9, 2019
1 parent c75d1e4 commit 5fdc744
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Lib/Collectors/Service/ServiceCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.Data.Sqlite;
using Newtonsoft.Json;
using Serilog;
using System.Text.RegularExpressions;

namespace AttackSurfaceAnalyzer.Collectors.Service
{
Expand Down Expand Up @@ -201,15 +202,18 @@ public override void Execute()
result = runner.RunExternalCommand("ls", "/etc/init.d/ -l");

lines = result.Split('\n');
lines.ToList().RemoveAt(0);
String pattern = @".*\s(.*)";

foreach (var _line in lines)
{
var _fields = _line.Split('\t');
Match match = Regex.Match(_line, pattern);
GroupCollection groups = match.Groups;
var serviceName = groups[1].ToString();

var obj = new ServiceObject()
{
DisplayName = _fields[8],
ServiceName = _fields[8],
DisplayName = serviceName,
ServiceName = serviceName,
StartType = "Unknown",
CurrentState = "Unknown"
};
Expand Down

0 comments on commit 5fdc744

Please sign in to comment.