Implemented part of the File structure

master
VollRagm 3 years ago
parent a5c4b19627
commit 162e6dd552

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace apphost_extract
{
public class AppHostFile
{
private FileStream FileStream;
public AppHostFileHeader Header { get; set; }
public AppHostFile(FileStream fileStream)
{
FileStream = fileStream;
Header = new AppHostFileHeader(FileStream);
}
public static AppHostFile Open(string path)
{
if (!File.Exists(path)) Log.Fatal("File not found.");
try
{
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
AppHostFile file = new AppHostFile(fs);
return file;
}
catch(Exception ex)
{
Log.Fatal($"Exception when trying to open file: {ex.Message}");
return null;
}
}
}
}

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace apphost_extract
{
public class AppHostFileEntry
{
}
}

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace apphost_extract
{
public class AppHostFileHeader
{
private const int HEADER_OFFSET = 0x1DE7E2;
private const int HEADER_SIZE = 0xD;
private byte[] Raw;
public byte PathLength { get; set; }
public string Path { get; set; }
public int EmbeddedFilesCount { get; set; }
public AppHostManifest Manifest { get; set; }
public AppHostFileHeader(FileStream File)
{
File.Seek(HEADER_OFFSET, SeekOrigin.Begin);
byte[] headerBuffer = new byte[HEADER_SIZE];
File.Read(headerBuffer, 0, HEADER_SIZE);
Raw = headerBuffer;
PathLength = Raw[0xC];
byte[] stringBuffer = new byte[PathLength];
File.Read(stringBuffer, 0, stringBuffer.Length);
Path = Encoding.UTF8.GetString(stringBuffer);
Manifest = new AppHostManifest(File, BitConverter.ToInt32(Raw, 0x8));
}
}
}

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace apphost_extract
{
public class AppHostManifest
{
public IReadOnlyList<AppHostFileEntry> FileEntries { get; set; }
public AppHostManifest(FileStream File, int embeddedFileCount)
{
}
}
}

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public static class Log
{
public static void Critical(object value)
{
Color(ConsoleColor.Magenta);
Console.WriteLine("[!] " + value.ToString());
Color();
}
public static void Info(object value)
{
Color(ConsoleColor.Cyan);
Console.WriteLine("[+] " + value.ToString());
}
public static bool QueryYesNo(string question)
{
var input = QueryString(question);
if (input.ToLower().StartsWith("y")) return true;
else return false;
}
public static string QueryString(string question)
{
Color(ConsoleColor.Yellow);
Console.Write("[?] " + question);
Color();
return Console.ReadLine();
}
public static void Info(object value, ConsoleColor color)
{
Color(color);
Console.WriteLine("[+] " + value.ToString());
}
public static void Error(object value)
{
Color(ConsoleColor.Red);
Console.WriteLine("[-] " + value.ToString());
Color();
}
public static void Fatal(object value)
{
Error(value);
Console.ReadLine();
Environment.Exit(0);
}
private static void Color(ConsoleColor color = ConsoleColor.White)
{
Console.ForegroundColor = color;
}
}

@ -10,6 +10,9 @@ namespace apphost_extract
{
static void Main(string[] args)
{
string path = "testapp.exe";
var file = AppHostFile.Open(path);
}
}
}

@ -43,6 +43,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppHostFile.cs" />
<Compile Include="AppHostFileHeader.cs" />
<Compile Include="AppHostManifest.cs" />
<Compile Include="Log.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

Loading…
Cancel
Save