Browse Source

Initial commit

master
Joe 1 year ago
commit
5abadf2a95
7 changed files with 1390 additions and 0 deletions
  1. +559
    -0
      .gitignore
  2. +3
    -0
      FodyWeavers.xml
  3. +630
    -0
      Program.cs
  4. +35
    -0
      Properties/AssemblyInfo.cs
  5. +22
    -0
      README.md
  6. +125
    -0
      ameck.csproj
  7. +16
    -0
      ameck.sln

+ 559
- 0
.gitignore View File

@ -0,0 +1,559 @@
!*.gitkeep
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Nuget personal access tokens and Credentials
nuget.config
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
.idea/
*.sln.iml
### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig
# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt
### vs ###
# User-specific files
# User-specific files (MonoDevelop/Xamarin Studio)
# Mono auto generated files
# Build results
# Visual Studio 2015/2017 cache/options directory
# Uncomment if you have tasks that create the project's static files in wwwroot
# Visual Studio 2017 auto generated files
# MSTest test Results
# NUnit
# Build Results of an ATL Project
# Benchmark Results
# .NET Core
# StyleCop
# Files built by Visual Studio
# Chutzpah Test files
# Visual C++ cache files
# Visual Studio profiler
# Visual Studio Trace Files
# TFS 2012 Local Workspace
# Guidance Automation Toolkit
# ReSharper is a .NET coding add-in
# TeamCity is a build add-in
# DotCover is a Code Coverage Tool
# AxoCover is a Code Coverage Tool
# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]
# Visual Studio code coverage results
# NCrunch
# MightyMoose
# Web workbench (sass)
# Installshield output folder
# DocProject is a documentation generator add-in
# Click-Once directory
# Publish Web Output
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
# NuGet Packages
# NuGet Symbol Packages
# The packages folder can be ignored because of Package Restore
# except build/, which is used as an MSBuild target.
# Uncomment if necessary however generally it will be regenerated when needed
# NuGet v3's project.json files produces more ignorable files
# Microsoft Azure Build Output
# Microsoft Azure Emulator
# Windows Store app package directories and files
# Visual Studio cache files
# files ending in .cache can be ignored
# but keep track of directories ending in .cache
# Others
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
# RIA/Silverlight projects
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
# SQL Server files
# Business Intelligence projects
# Microsoft Fakes
# GhostDoc plugin setting file
# Node.js Tools for Visual Studio
# Visual Studio 6 build log
# Visual Studio 6 workspace options file
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
# Visual Studio LightSwitch build output
# Paket dependency manager
# FAKE - F# Make
# CodeRush personal settings
# Python Tools for Visual Studio (PTVS)
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
# Telerik's JustMock configuration file
# BizTalk build output
# OpenCover UI analysis results
# Azure Stream Analytics local run output
# MSBuild Binary and Structured Log
# NVidia Nsight GPU debugger configuration file
# MFractors (Xamarin productivity tool) working folder
# Local History for Visual Studio
# BeatPulse healthcheck temp database
# Backup folder for Package Reference Convert tool in Visual Studio 2017
# Ionide (cross platform F# VS Code tools) working folder

+ 3
- 0
FodyWeavers.xml View File

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
</Weavers>

+ 630
- 0
Program.cs View File

@ -0,0 +1,630 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Runtime.InteropServices;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Win32;
namespace ame_integrity_check
{
public enum Type
{
File = 1,
Directory = 2,
Process = 3,
Service = 4
}
internal class Scanner : IDisposable
{
private int result = 1;
private bool allFound = true;
private bool found = false;
private bool errorOverride = false;
public Task<bool> displayTask;
public void Dispose() => GC.SuppressFinalize(this);
public async Task<bool> DisplayQuery(string text, int time = 150)
{
Out.WriteCustomString(text, 3, 11);
string maxSpaces = " ";
for (int i = 1; i < 6; i++) {
Console.SetCursorPosition(59, Console.CursorTop);
var spaces = maxSpaces.Remove(0, i);
Console.Write($"[ {spaces.PadLeft(spaces.Length + i, '*')} ]");
Thread.Sleep(time);
}
return true;
}
private static void SetQueryStatus(string status, ConsoleColor color)
{
Console.SetCursorPosition(64 - status.Length, Console.CursorTop);
Console.Write(" [ ");
Out.WriteCustomString(status, 3, 0, foregroundColor: color);
Console.WriteLine(" ]");
}
public async void Query(Type type, string item, bool finalize = false, bool modifyResult = true)
{
item = Environment.ExpandEnvironmentVariables(item);
bool foundItem = false;
try {
switch (type) {
case Type.File:
if (item.Contains("*"))
{
var lastToken = item.LastIndexOf("\\");
var parentPath = item.Remove(lastToken).TrimEnd('\\');
if (parentPath.Contains("*")) throw new ArgumentException("Parent directories to a given file filter cannot contain wildcards.");
var filter = item.Substring(lastToken + 1);
foundItem = Directory.GetFiles(parentPath, filter).Any();
break;
}
foundItem = File.Exists(item);
break;
case Type.Directory:
if (item.Contains("*"))
{
var lastToken = item.LastIndexOf("\\");
var parentPath = item.Remove(lastToken).TrimEnd('\\');
if (parentPath.Contains("*")) throw new ArgumentException("Parent directories to a given file filter cannot contain wildcards.");
var filter = item.Substring(lastToken + 1);
foundItem = Directory.GetDirectories(parentPath, filter).Any();
break;
}
foundItem = Directory.Exists(item);
break;
case Type.Process:
foundItem = Process.GetProcessesByName(item).Any();
break;
case Type.Service:
foundItem = ServiceController.GetServices().Any(x => x.ServiceName.Equals("wuauserv", StringComparison.CurrentCultureIgnoreCase));
break;
default:
foundItem = false;
break;
}
} catch (Exception e) {
errorOverride = true;
}
if (foundItem) found = true;
if (!finalize) return;
await displayTask;
if (errorOverride) {
errorOverride = false;
SetQueryStatus("ERROR", ConsoleColor.DarkRed);
found = false;
return;
}
if (!found) {
if (modifyResult) allFound = false;
SetQueryStatus("Absent", ConsoleColor.Green);
} else {
result = 2;
if (allFound) result = 3;
SetQueryStatus("Present", ConsoleColor.DarkRed);
}
found = false;
}
public void DisplayResult()
{
switch (result) {
case 1:
Out.WriteCustomString("\n\nAME Integrity validated", 1, foregroundColor: ConsoleColor.Green);
break;
case 2:
Out.WriteCustomString("\n\nAME integrity compromised, contact the team for help.", 1, foregroundColor: ConsoleColor.Red);
break;
case 3:
Out.WriteCustomString("\n\nYour system is not ameliorated.", 1, foregroundColor: ConsoleColor.Red);
break;
}
}
}
internal static class Program
{
public static string PreviousTitle;
public static int PreviousBufferHeight;
public static int PreviousBufferWidth;
public static int PreviousSizeHeight;
public static int PreviousSizeWidth;
public const double Ver = 0.9;
public static void Main(string[] args)
{
PreviousSizeHeight = Console.WindowHeight;
PreviousSizeWidth = Console.WindowWidth;
PreviousBufferHeight = Console.BufferHeight;
PreviousBufferWidth = Console.BufferWidth;
Console.SetWindowSize(80, 26);
Console.SetBufferSize(80, 26);
Console.SetWindowSize(80, 26);
Console.Clear();
Console.CursorVisible = false;
PreviousTitle = Console.Title;
Console.Title = "AME Integrity Check";
try { Out.DisableResize(); } catch (Exception) { }
try { Out.DisableQuickEdit(); } catch (Exception) { }
Console.CancelKeyPress += Exit;
Out.WriteCustomString("\n__________________________________________________________" +
$"\n\n| AME Integrity Check v{Ver} |\n\n", 1);
displayStart:
Menu mainMenu = new Menu() {
Choices = {"Check AME Integrity", "Get Support", "", "Exit"},
EndString = "\n__________________________________________________________\n",
Statement = "Use the arrows keys to navigate"
};
var choice = mainMenu.Load();
switch (choice) {
case 0:
RunCheck();
Out.ResetPane();
goto displayStart;
case 1:
Process.Start("https://t.me/joinchat/CR-xFBGQKVt7HPZKgZfbxg");
Out.ResetPane();
goto displayStart;
case 2:
PrepProcessExit();
Environment.Exit(0);
break;
default:
PrepProcessExit();
Environment.Exit(1);
break;
}
}
private static bool detected = false;
private static int result = 1;
private static void RunCheck()
{
Out.ResetPane();
bool legacy = false;
var registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
int winVer = 1;
if (registryKey != null) winVer = Int32.Parse(registryKey.GetValue("CurrentBuildNumber").ToString());
if (winVer < 19044) legacy = true;
using (var scanner = new Scanner())
{
scanner.displayTask = scanner.DisplayQuery("Checking for Windows Defender activity...", 250);
scanner.Query(Type.Process, "MsMpEng", true);
scanner.displayTask = scanner.DisplayQuery("Checking Windows Defender files...", 200);
if (!legacy) {
scanner.Query(Type.Directory, "%ProgramFiles%\\Windows Defender");
scanner.Query(Type.Directory, "%ProgramData%\\Microsoft\\Windows Defender", true);
}
else scanner.Query(Type.Directory, "%ProgramFiles%\\Windows Defender", true);
if (!legacy) {
scanner.displayTask = scanner.DisplayQuery("Checking Windows Update service...", 350);
scanner.Query(Type.Service, "wuauserv", true);
}
scanner.displayTask = scanner.DisplayQuery("Checking Windows Update files...", 220);
scanner.Query(Type.File, "%WINDIR%\\System32\\wuaueng.dll");
scanner.Query(Type.File, "%WINDIR%\\System32\\wuapi.dll", true);
scanner.displayTask = scanner.DisplayQuery("Checking Microsoft Edge...", 200);
scanner.Query(Type.Directory, "%ProgramFiles(x86)%\\Microsoft\\EdgeCore");
scanner.Query(Type.Directory, "%WINDIR%\\SystemApps\\*MicrosoftEdge*", true);
scanner.displayTask = scanner.DisplayQuery("Checking for Microsoft Store activity...", 200);
scanner.Query(Type.Process, "WinStore.App", true, false);
scanner.displayTask = scanner.DisplayQuery("Checking Windows SmartScreen...");
scanner.Query(Type.Process, "smartscreen");
scanner.Query(Type.File, "%WINDIR%\\System32\\smartscreen.exe", true);
scanner.displayTask = scanner.DisplayQuery("Checking SIH Client...");
scanner.Query(Type.File, "%WINDIR%\\System32\\SIHClient.exe", true);
scanner.displayTask = scanner.DisplayQuery("Checking Storage Sense...", 300);
scanner.Query(Type.File, "%WINDIR%\\System32\\StorSvc.dll", true);
scanner.DisplayResult();
}
Out.WriteCustomString("__________________________________________________________\n\n\nPress any key to return to the Menu: ", 3, 11);
ClearBuffer();
Console.CursorVisible = true;
Console.ReadKey(false);
Console.CursorVisible = false;
}
private static bool anyNotPresent;
private static void ClearBuffer()
{
var posCacheTop = Console.CursorTop;
var posCacheLeft = Console.CursorLeft;
while (Console.KeyAvailable) {
Console.ReadKey(false);
}
Console.SetCursorPosition(posCacheLeft, posCacheTop);
Console.Write("".PadLeft(Console.WindowHeight, ' '));
Console.SetCursorPosition(posCacheLeft, posCacheTop);
}
private static void Exit(object sender, ConsoleCancelEventArgs args)
{
PrepProcessExit();
Environment.Exit(0);
}
private static void PrepProcessExit()
{
var parent = ParentProcess.ProcessName;
if (parent.Equals("Explorer", StringComparison.CurrentCultureIgnoreCase)) return;
try { Out.EnableResize(); } catch (Exception) { }
try { Out.EnableQuickEdit(); } catch (Exception) { }
Console.CursorVisible = true;
Console.Clear();
Console.Title = PreviousTitle;
Console.SetWindowSize(PreviousSizeWidth, PreviousSizeHeight);
Console.SetBufferSize(PreviousBufferWidth, PreviousBufferHeight);
}
}
internal static class Out
{
public static void ResetPane(int fromTop = 6)
{
Console.SetCursorPosition(Console.CursorLeft, fromTop - 1);
var length = Console.WindowHeight - fromTop - 1;
for (int i = 0; i < length; i++) {
Console.Write("".PadRight(Console.WindowWidth, ' '));
}
Console.SetCursorPosition(0, fromTop);
}
public static void WriteCustomString(string text, int type, int offset = 11, ConsoleColor foregroundColor = ConsoleColor.DarkYellow, ConsoleColor backgroundColor = ConsoleColor.DarkYellow)
{
bool resetColor = false;
ConsoleColor foregroundCache = Console.ForegroundColor;
ConsoleColor backgroundCache = Console.BackgroundColor;
if (foregroundColor == ConsoleColor.DarkYellow) {
foregroundColor = Console.ForegroundColor;
}
if (backgroundColor == ConsoleColor.DarkYellow) {
backgroundColor = Console.BackgroundColor;
}
if (Console.ForegroundColor != foregroundColor) {
resetColor = true;
Console.ForegroundColor = foregroundColor;
}
if (Console.BackgroundColor != backgroundColor) {
resetColor = true;
Console.BackgroundColor = backgroundColor;
}
switch (type) {
case 1:
// Indented and centered
Console.WriteLine(CenterString(text, offset));
break;
case 2:
Console.WriteLine(text.Insert(0, new string(' ', offset)));
break;
case 3:
var loopOnce = false;
foreach (string line in text.Split('\n')) {
if (line == "") {
Console.WriteLine();
continue;
}
Console.Write(line.Insert(0, new string(' ', offset)));
}
break;
default:
break;
}
if (resetColor) {
Console.ForegroundColor = foregroundCache;
Console.BackgroundColor = backgroundCache;
}
}
private static string CenterString(string text, int offset = 11, int width = 58)
{
StringBuilder subLines = new StringBuilder();
string newLine = "";
foreach (string line in text.Split('\n')) {
if (!subLines.ToString().Equals("")) newLine = "\n";
if (line == "" && !subLines.ToString().Equals("")) {
subLines.Append("\n");
continue;
}
var space = "";
if (!(line.Length % 2).Equals(0) && line.Length != width) {
space = " ";
}
if (line.Length > width) {
for (int index = 0; index < line.Length; index += (width - 10)) {
if (!subLines.ToString().Equals("")) newLine = "\n";
var subLine = line.Substring(index, Math.Min(width - 10, line.Length - index));
subLine = subLine.Trim(' ');
var subCentered = CenterString(subLine, offset, width);
subLines.Append(newLine + subCentered);
}
continue;
}
var leadingLength = (width - line.Length) / 2;
subLines.Append(newLine + space + line.PadLeft(line.Length + leadingLength, ' ').Insert(0, new string(' ', offset)));
}
return subLines.ToString();
}
private const int MF_BYCOMMAND = 0x00000000;
public const int SC_CLOSE = 0xF060;
public const int SC_MINIMIZE = 0xF020;
public const int SC_MAXIMIZE = 0xF030;
public const int SC_SIZE = 0xF000;//resize
[DllImport("user32.dll")]
public static extern int DeleteMenu(IntPtr hMenu, int nPosition, int wFlags);
[DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("kernel32.dll", ExactSpelling = true)]
private static extern IntPtr GetConsoleWindow();
public static void DisableResize()
{
IntPtr handle = GetConsoleWindow();
IntPtr sysMenu = GetSystemMenu(handle, false);
if (handle != IntPtr.Zero)
{
//DeleteMenu(sysMenu, SC_CLOSE, MF_BYCOMMAND);
//DeleteMenu(sysMenu, SC_MINIMIZE, MF_BYCOMMAND);
DeleteMenu(sysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
DeleteMenu(sysMenu, SC_SIZE, MF_BYCOMMAND);//resize
}
}
public static void EnableResize()
{
IntPtr handle = GetConsoleWindow();
GetSystemMenu(handle, true);
}
const uint CHECK_QUICK_EDIT = 0x0040;
const int ENABLE_QUICK_EDIT = 0x40 | 0x80;
// STD_INPUT_HANDLE (DWORD): -10 is the standard input device.
const int STD_INPUT_HANDLE = -10;
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll")]
static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode);
[DllImport("kernel32.dll")]
static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode);
internal static void DisableQuickEdit() {
IntPtr consoleHandle = GetStdHandle(STD_INPUT_HANDLE);
// get current console mode
uint consoleMode;
GetConsoleMode(consoleHandle, out consoleMode);
// set the new mode
SetConsoleMode(consoleHandle, consoleMode &= ~CHECK_QUICK_EDIT);
}
internal static void EnableQuickEdit() {
IntPtr consoleHandle = GetStdHandle(STD_INPUT_HANDLE);
// get current console mode
uint consoleMode;
GetConsoleMode(consoleHandle, out consoleMode);
// set the new mode
SetConsoleMode(consoleHandle, consoleMode|(ENABLE_QUICK_EDIT));
}
}
internal class Menu
{
public List<string> Choices;
public string EndString;
public string Statement;
public int Offset;
public Menu(int offset = 16, string endString = null)
{
Choices = new List<string>();
EndString = endString;
Offset = offset;
}
public int Load()
{
int max = -1;
var posCache = Console.CursorTop;
bool loopedOnce = false;
foreach (string choice in Choices) {
Console.SetCursorPosition(Offset - 2, Console.CursorTop);
if (!loopedOnce) {
Out.WriteCustomString("> " + choice, 2, 0, foregroundColor: ConsoleColor.Green);
loopedOnce = true;
} else {
Out.WriteCustomString(choice, 2, 2);
}
max += 1;
}
if (EndString != null) Out.WriteCustomString(EndString, 1);
if (Statement != null) Out.WriteCustomString(Statement, 2);
int index = 0;
ConsoleKey keyPressed;
Console.SetCursorPosition(Offset, posCache);
while ((keyPressed = Console.ReadKey(true).Key) != ConsoleKey.Enter) {
if (keyPressed == ConsoleKey.DownArrow) {
if (index >= max) continue;
Console.SetCursorPosition(Offset - 2, Console.CursorTop);
Out.WriteCustomString(Choices[index], 3, 2);
if (!String.IsNullOrEmpty(Choices[index + 1])) {
index += 1;
Console.SetCursorPosition(Offset - 2, Console.CursorTop + 1);
Out.WriteCustomString("> " + Choices[index], 3, 0, foregroundColor: ConsoleColor.Green);
} else {
index += 2;
Console.SetCursorPosition(Offset - 2, Console.CursorTop + 2);
Out.WriteCustomString("> " + Choices[index], 3, 0, foregroundColor: ConsoleColor.Green);
}
}
if (keyPressed == ConsoleKey.UpArrow) {
if (!(index > 0)) continue;
Console.SetCursorPosition(Offset - 2, Console.CursorTop);
Out.WriteCustomString(Choices[index], 3, 2);
if (!String.IsNullOrEmpty(Choices[index - 1])) {
index -= 1;
Console.SetCursorPosition(Offset - 2, Console.CursorTop - 1);
Out.WriteCustomString("> " + Choices[index], 3, 0, foregroundColor: ConsoleColor.Green);
} else {
index -= 2;
Console.SetCursorPosition(Offset - 2, Console.CursorTop - 2);
Out.WriteCustomString("> " + Choices[index], 3, 0, foregroundColor: ConsoleColor.Green);
}
}
}
return index;
}
}
public static class ParentProcess
{
public static string ProcessName
{
get { return GetParentProcess().ProcessName; }
}
private static Process GetParentProcess()
{
int iParentPid = 0;
int iCurrentPid = Process.GetCurrentProcess().Id;
IntPtr oHnd = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (oHnd == IntPtr.Zero)
return null;
PROCESSENTRY32 oProcInfo = new PROCESSENTRY32();
oProcInfo.dwSize =
(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(PROCESSENTRY32));
if (Process32First(oHnd, ref oProcInfo) == false)
return null;
do
{
if (iCurrentPid == oProcInfo.th32ProcessID)
iParentPid = (int)oProcInfo.th32ParentProcessID;
}
while (iParentPid == 0 && Process32Next(oHnd, ref oProcInfo));
if (iParentPid > 0)
return Process.GetProcessById(iParentPid);
else
return null;
}
static uint TH32CS_SNAPPROCESS = 2;
[StructLayout(LayoutKind.Sequential)]
public struct PROCESSENTRY32
{
public uint dwSize;
public uint cntUsage;
public uint th32ProcessID;
public IntPtr th32DefaultHeapID;
public uint th32ModuleID;
public uint cntThreads;
public uint th32ParentProcessID;
public int pcPriClassBase;
public uint dwFlags;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szExeFile;
};
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr CreateToolhelp32Snapshot(uint dwFlags, uint th32ProcessID);
[DllImport("kernel32.dll")]
static extern bool Process32First(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
[DllImport("kernel32.dll")]
static extern bool Process32Next(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
}
}

+ 35
- 0
Properties/AssemblyInfo.cs View File

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ame_status_check")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ame_status_check")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1C067083-0635-4B14-A975-60D0B97F9DDA")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

+ 22
- 0
README.md View File

@ -0,0 +1,22 @@
# AME Integrity Check (ameck)
Program for checking the integrity of an AME installation.
![AME Integrity Check Screenshot](screenshot.png)
## Usage
You can download the script by going to the [latest release](https://git.ameliorated.info/Joe/ameck/releases/latest) and selecting `ameck.exe` from the **Downloads** section. Once downloaded, simply run `ameck.exe`.
## Compilation
Compiling the program is very simple:
1. Clone the repository:
`git clone https://git.ameliorated.info/Joe/ameck.git`
2. Open `ameck.sln`
3. Set the build configuration to `Release | Any CPU`
4. Build the project

+ 125
- 0
ameck.csproj View File

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1C067083-0635-4B14-A975-60D0B97F9DDA}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ame_integrity_check</RootNamespace>
<AssemblyName>ameck</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32bit>false</Prefer32bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<DebugType>embedded</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32bit>false</Prefer32bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.IO.FileSystem, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Costura.Fody" Version="5.7.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Fody" Version="6.5.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.Platforms" Version="1.1.0" />
<PackageReference Include="Microsoft.Win32.Primitives" Version="4.3.0" />
<PackageReference Include="NETStandard.Library" Version="1.6.1" />
<PackageReference Include="System.AppContext" Version="4.3.0" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
<PackageReference Include="System.Console" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.EventLog" Version="7.0.0" />
<PackageReference Include="System.Diagnostics.Process" Version="4.1.0" />
<PackageReference Include="System.Diagnostics.Tools" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.Tracing" Version="4.3.0" />
<PackageReference Include="System.Globalization" Version="4.3.0" />
<PackageReference Include="System.Globalization.Calendars" Version="4.3.0" />
<PackageReference Include="System.IO" Version="4.3.0" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="System.Linq" Version="4.3.0" />
<PackageReference Include="System.Linq.Expressions" Version="4.3.0" />
<PackageReference Include="System.Net.Http" Version="4.3.0" />
<PackageReference Include="System.Net.Primitives" Version="4.3.0" />
<PackageReference Include="System.Net.Sockets" Version="4.3.0" />
<PackageReference Include="System.ObjectModel" Version="4.3.0" />
<PackageReference Include="System.Reflection" Version="4.3.0" />
<PackageReference Include="System.Reflection.Extensions" Version="4.3.0" />
<PackageReference Include="System.Reflection.Primitives" Version="4.3.0" />
<PackageReference Include="System.Resources.ResourceManager" Version="4.3.0" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
<PackageReference Include="System.Runtime.Extensions" Version="4.3.0" />
<PackageReference Include="System.Runtime.Handles" Version="4.3.0" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
<PackageReference Include="System.Runtime.Numerics" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.Encoding" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.Primitives" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.0" />
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="7.0.0" />
<PackageReference Include="System.Text.Encoding" Version="4.3.0" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.0" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="System.Threading.Tasks" Version="4.3.0" />
<PackageReference Include="System.Threading.Timer" Version="4.3.0" />
<PackageReference Include="System.Xml.ReaderWriter" Version="4.3.0" />
<PackageReference Include="System.Xml.XDocument" Version="4.3.0" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

+ 16
- 0
ameck.sln View File

@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ameck", "ameck.csproj", "{B1D8E77E-A3AE-4B56-BE50-E47BB77F24A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B1D8E77E-A3AE-4B56-BE50-E47BB77F24A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1D8E77E-A3AE-4B56-BE50-E47BB77F24A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1D8E77E-A3AE-4B56-BE50-E47BB77F24A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1D8E77E-A3AE-4B56-BE50-E47BB77F24A3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

Loading…
Cancel
Save