Skip to content

Commit

Permalink
Merge branch 'main' into release/10.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienfl-orc committed Nov 16, 2023
2 parents cf641b7 + 37d589e commit b55a779
Show file tree
Hide file tree
Showing 54 changed files with 888 additions and 461 deletions.
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# ChangeLog

## [10.2.3] - 2023-11-15
### Added
- Ntfs: Windows overlay file compression support with resident files
- WolfLauncher: add to element 'command' attribute 'timeout'
- WolfLauncher: Syslog: add some more logs

### Changed
- Yara: do not disable Yara's rule when not referenced in config
- Authenticode: enable ARM PE authenticode check
- Display command line invalid parameter in case of parsing issue

### Fixed
- Ntfs: fix last block decompression
- Ntfs: fix last read position after some decompression
- Ntfs: fix Windows overlay file decompression for some ending block
- Outcome: fix empty process informations for very short lifetime processes
- ci: fix Get-OrcOutcome exit_code existence check


## [10.2.2] - 2023-09-20
### Added
- Allow user to specify any 'key' from 'ORC_Offline' special command set
Expand All @@ -15,6 +34,7 @@
- FastFind: XML output style
- NTFSInfo/FATInfo: unexpected FirstBytes column zero padding


## [10.2.1] - 2023-06-20
### Changed
- Configuration: accept wildcard as exclusion path
Expand Down Expand Up @@ -51,6 +71,20 @@
- FastFind: add missing handling of 'Resurrect' and '/ResurrectRecords'


## [10.1.8] - 2023-09-18
### Added
- Allow user to specify any 'key' from 'ORC_Offline' special command set

### Changed
- Yara: update to 4.3.2

### Fixed
- Yara: possible execution loop issue depending on the rule
- FastFind: in the XML results file the 'Type' values for a registry match was always set to 'Type'
- NTFSInfo/FATInfo: unexpected FirstBytes column zero padding
- Fix log file output suboptions


## [10.1.7] - 2023-04-17
### Added
- Add more log in case of memory starvation
Expand Down
1 change: 1 addition & 0 deletions src/Orc/Mothership_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, LPCWSTR argv[])
}
else
{
Log::Error(L"Failed to parse command line item: '{}'", argv[i] + 1);
PrintUsage();
return E_INVALIDARG;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Orc/Mothership_Run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ HRESULT Main::Launch(const std::wstring& command, const std::wstring& commandArg
HANDLE hMothership = OpenProcess(PROCESS_QUERY_INFORMATION, TRUE, GetCurrentProcessId());
if (hMothership)
{
strCommandLine.append(fmt::format(L" /MothershipHandle={:#x}", reinterpret_cast<size_t>(hMothership)));
strCommandLine.append(fmt::format(L" /Mothership={:#x}", reinterpret_cast<size_t>(hMothership)));
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/OrcCommand/Command/DD/DD_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, LPCWSTR argv[])
;
else
{
Log::Error(L"Failed to parse command line item: '{}'", argv[i] + 1);
PrintUsage();
return E_INVALIDARG;
}
Expand Down
6 changes: 6 additions & 0 deletions src/OrcCommand/Command/FastFind/FastFind_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, LPCWSTR argv[])
else if (UsageOption(argv[i] + 1))
{
}
else
{
Log::Error(L"Failed to parse command line item: '{}'", argv[i] + 1);
PrintUsage();
return E_INVALIDARG;
}
break;
default:
break;
Expand Down
1 change: 1 addition & 0 deletions src/OrcCommand/Command/GetSamples/GetSamples_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, const WCHAR* argv[])
;
else
{
Log::Error(L"Failed to parse command line item: '{}'", argv[i] + 1);
PrintUsage();
return E_INVALIDARG;
}
Expand Down
6 changes: 3 additions & 3 deletions src/OrcCommand/Command/GetSectors/GetSectors_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, LPCWSTR argv[])
;
else
{
Log::Error(L"[!] Unknown option : \"{}\".", argv[i]);
Log::Error(L"Use /help to list the available options.");
exit(-1);
Log::Error(L"Failed to parse command line item: '{}'", argv[i] + 1);
PrintUsage();
return E_INVALIDARG;
}
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion src/OrcCommand/Command/GetThis/GetThis.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class ORCUTILS_API Main : public UtilitiesMain

HRESULT FindMatchingSamples();

void OnMatchingSample(const std::shared_ptr<FileFind::Match>& aMatch, bool bStop);
void OnMatchingSample(const std::shared_ptr<FileFind::Match>& aMatch, bool& bStop);
void OnSampleWritten(const SampleRef& sample, const SampleSpec& sampleSpec, HRESULT hrWrite) const;

public:
Expand Down
1 change: 1 addition & 0 deletions src/OrcCommand/Command/GetThis/GetThis_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, LPCWSTR argv[])
;
else
{
Log::Error(L"Failed to parse command line item: '{}'", argv[i] + 1);
PrintUsage();
return E_INVALIDARG;
}
Expand Down
6 changes: 3 additions & 3 deletions src/OrcCommand/Command/GetThis/GetThis_Run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ void Main::OnSampleWritten(const SampleRef& sample, const SampleSpec& sampleSpec
}
}

void Main::OnMatchingSample(const std::shared_ptr<FileFind::Match>& aMatch, bool bStop)
void Main::OnMatchingSample(const std::shared_ptr<FileFind::Match>& aMatch, bool& bStop)
{
HRESULT hr = E_FAIL;

Expand Down Expand Up @@ -1390,7 +1390,7 @@ void Main::OnMatchingSample(const std::shared_ptr<FileFind::Match>& aMatch, bool
auto sample = CreateSample(aMatch, i, sampleSpec);
UpdateSamplesLimits(sampleSpec, *sample);

// TODO: memory optimization: check that sampleIds is resetted when volume changes
// TODO: memory optimization: check that sampleIds is reset when volume changes
m_sampleIds.insert(SampleId(*sample));

if (config.Output.Type == OutputSpec::Kind::Archive)
Expand Down Expand Up @@ -1527,7 +1527,7 @@ HRESULT Main::Run()
catch (...)
{
Log::Error(L"GetThis failed during sample collection, terminating archive");
return E_ABORT;
return E_UNEXPECTED;
}

return S_OK;
Expand Down
2 changes: 1 addition & 1 deletion src/OrcCommand/Command/NTFSInfo/NTFSInfo_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, LPCWSTR argv[])
catch (...)
{
Log::Error("NTFSInfo failed during argument parsing, exiting");
return E_ABORT;
return E_UNEXPECTED;
}

// argc/argv parameters only
Expand Down
1 change: 1 addition & 0 deletions src/OrcCommand/Command/NTFSUtil/NTFSUtil_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, LPCWSTR argv[])
;
else
{
Log::Error(L"Failed to parse command line item: '{}'", argv[i] + 1);
PrintUsage();
return E_INVALIDARG;
}
Expand Down
10 changes: 3 additions & 7 deletions src/OrcCommand/Command/NTFSUtil/NTFSUtil_Run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "MFTOffline.h"
#include "OfflineMFTReader.h"

#include "Utils/Round.h"
#include "Utils/TypeTraits.h"
#include "Text/Fmt/Boolean.h"
#include "Text/Fmt/Limit.h"
Expand Down Expand Up @@ -1006,11 +1007,6 @@ HRESULT Main::CommandVss()
return S_OK;
}

constexpr uint64_t RoundUp(uint64_t offset, uint64_t pageSize)
{
return (((offset)) + pageSize - 1) & (~(pageSize - 1));
}

HRESULT Orc::Command::NTFSUtil::Main::CommandBitLocker()
{
using namespace BitLocker;
Expand Down Expand Up @@ -1109,7 +1105,7 @@ HRESULT Orc::Command::NTFSUtil::Main::CommandBitLocker()
// Reset pointer to start of info data
reader->Seek(pHeader->InfoOffsets[i]);

auto toRead = RoundUp(infoSize + sizeof(ValidationHeader), pHeader->SectorSize);
auto toRead = RoundUpPow2(infoSize + sizeof(ValidationHeader), pHeader->SectorSize);
info_buffer.SetCount(toRead);
reader->Read(info_buffer, toRead, ullBytesRead);

Expand All @@ -1121,7 +1117,7 @@ HRESULT Orc::Command::NTFSUtil::Main::CommandBitLocker()
continue;
}

const Traits::ByteQuantity size(RoundUp(infoSize + pValidation->Size, pHeader->SectorSize));
const Traits::ByteQuantity size(RoundUpPow2(infoSize + pValidation->Size, pHeader->SectorSize));
PrintValue(metadataNode, L"Size", size);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/OrcCommand/Command/ObjInfo/ObjInfo_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, LPCWSTR argv[])
;
else
{
Log::Error(L"Failed to parse command line item: '{}'", argv[i] + 1);
PrintUsage();
return E_INVALIDARG;
}
Expand Down
2 changes: 1 addition & 1 deletion src/OrcCommand/Command/ToolEmbed/ToolEmbed_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ HRESULT Main::CheckConfiguration()
if (dwMajor < 6 && dwMinor < 2)
{
Log::Error("ToolEmbed cannot be used on downlevel platform, please run ToolEmbed on Windows 7+ systems");
return E_ABORT;
return E_NOTIMPL;
}

switch (config.Todo)
Expand Down
1 change: 1 addition & 0 deletions src/OrcCommand/Command/USNInfo/USNInfo_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, LPCWSTR argv[])
;
else
{
Log::Error(L"Failed to parse command line item: '{}'", argv[i] + 1);
PrintUsage();
return E_INVALIDARG;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ HRESULT wolf_command(ConfigItem& parent, DWORD dwIndex)
return hr;
if (FAILED(hr = parent[dwIndex].AddAttribute(L"optional", WOLFLAUNCHER_COMMAND_OPTIONAL, ConfigItem::OPTION)))
return hr;
if (FAILED(hr = parent[dwIndex].AddAttribute(L"timeout", WOLFLAUNCHER_COMMAND_TIMEOUT, ConfigItem::OPTION)))
return hr;
return S_OK;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ constexpr auto WOLFLAUNCHER_COMMAND_WINVER = 5L;
constexpr auto WOLFLAUNCHER_COMMAND_SYSTEMTYPE = 6L;
constexpr auto WOLFLAUNCHER_COMMAND_QUEUE = 7L;
constexpr auto WOLFLAUNCHER_COMMAND_OPTIONAL = 8L;
constexpr auto WOLFLAUNCHER_COMMAND_TIMEOUT = 9L;

constexpr auto WOLFLAUNCHER_DESTINATION = 0L;
constexpr auto WOLFLAUNCHER_METHOD = 1L;
Expand Down
22 changes: 17 additions & 5 deletions src/OrcCommand/Command/WolfLauncher/Journal.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class Journal
const auto timepoint = std::chrono::system_clock::now();

std::wstring message;
Text::FormatToWithoutEOL(std::back_inserter(message), "{:<16} {:<26} ", commandSet, agent);
Text::FormatToWithoutEOL(
std::back_inserter(message), "{:<16} {:<26} ", commandSet, agent.empty() ? L"Info" : agent);
Text::FormatToWithoutEOL(std::back_inserter(message), std::forward<FmtArgs>(status)...);

// TODO: instead of using console directly the syslog facility could have a custom console sink
Expand All @@ -50,7 +51,18 @@ class Journal
const auto& syslog = Orc::Log::DefaultLogger()->Get(Log::Facility::kSyslog);
if (syslog)
{
syslog->Log(timepoint, level, ToUtf8(message));
std::wstring syslogMessage;
if (agent.empty())
{
Text::FormatToWithoutEOL(std::back_inserter(syslogMessage), "[{}] ", commandSet);
}
else
{
Text::FormatToWithoutEOL(std::back_inserter(syslogMessage), "[{}] [{}] ", commandSet, agent);
}

Text::FormatToWithoutEOL(std::back_inserter(syslogMessage), std::forward<FmtArgs>(status)...);
syslog->Log(timepoint, level, ToUtf8(syslogMessage));
}
}

Expand All @@ -60,14 +72,14 @@ class Journal
Print(commandSet, agent, Log::Level::Info, std::forward<FmtArgs>(status)...);
}

auto Console() { return std::pair<std::lock_guard<std::mutex>, Command::Console&> {m_mutex, m_console}; }
auto Console() { return std::pair<std::lock_guard<std::recursive_mutex>, Command::Console&> {m_mutex, m_console}; }
auto Console() const
{
return std::pair<std::lock_guard<std::mutex>, const Command::Console&> {m_mutex, m_console};
return std::pair<std::lock_guard<std::recursive_mutex>, const Command::Console&> {m_mutex, m_console};
}

private:
mutable std::mutex m_mutex;
mutable std::recursive_mutex m_mutex;
Command::Console& m_console;
};

Expand Down
14 changes: 14 additions & 0 deletions src/OrcCommand/Command/WolfLauncher/WolfExecution_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,20 @@ CommandMessage::Message WolfExecution::SetCommandFromConfigItem(const ConfigItem
}
}

if (item[WOLFLAUNCHER_COMMAND_TIMEOUT])
{
LARGE_INTEGER li;
hr = GetIntegerFromArg(item[WOLFLAUNCHER_COMMAND_TIMEOUT].c_str(), li);
if (FAILED(hr))
{
Log::Debug(L"Failed to initialize command timeout [{}]", SystemError(hr));
return nullptr;
}

std::chrono::minutes timeout(li.QuadPart);
command->SetTimeout(timeout);
}

return command;
}

Expand Down
10 changes: 9 additions & 1 deletion src/OrcCommand/Command/WolfLauncher/WolfExecution_Execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,19 @@ HRESULT WolfExecution::CreateCommandAgent(
{
switch (item->GetEvent())
{
case CommandNotification::Created: {
Log::Debug(L"{}: Created", item->GetKeyword());
}
break;
case CommandNotification::Started:
Log::Debug(L"{}: Started", item->GetKeyword());
break;
case CommandNotification::Terminated:
break;
case CommandNotification::Aborted: {
Log::Debug(L"{}: Aborted", item->GetKeyword());
}
break;
case CommandNotification::Running:
break;
case CommandNotification::ProcessAbnormalTermination:
Expand Down Expand Up @@ -669,7 +677,7 @@ HRESULT WolfExecution::CreateCommandAgent(
if (FAILED(hr))
{
Log::Error(
L"WolfLauncher cmd agent failed during initialisation (output directory: '{}', [{}])",
L"WolfLauncher cmd agent failed during initialisation (output directory: '{}') [{}]",
m_Temporary.Path,
SystemError(hr));
return hr;
Expand Down
3 changes: 2 additions & 1 deletion src/OrcCommand/Command/WolfLauncher/WolfLauncher_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, LPCWSTR argv[])
;
else if (ParameterOption(argv[i] + 1, L"Compression", config.strCompressionLevel))
;
else if (ParameterOption(argv[i] + 1, L"MothershipHandle", config.strMothershipHandle))
else if (ParameterOption(argv[i] + 1, L"Mothership", config.strMothershipHandle))
;
else if (ParameterOption(argv[i] + 1, L"archive_timeout", config.msArchiveTimeOut))
;
Expand Down Expand Up @@ -727,6 +727,7 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, LPCWSTR argv[])
;
else
{
Log::Error(L"Failed to parse command line item: '{}'", argv[i] + 1);
PrintUsage();
return E_INVALIDARG;
}
Expand Down
Loading

0 comments on commit b55a779

Please sign in to comment.