Skip to content

Commit

Permalink
proxy auth fix
Browse files Browse the repository at this point in the history
Fixed proxy auth capture issue
Added Costura.Fody
  • Loading branch information
Kevin-Robertson committed Sep 18, 2022
1 parent 0294aa1 commit c7e26ad
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 25 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]

name: Dev

jobs:
build:
runs-on: windows-latest
defaults:
run:
shell: bash

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x

- name: Restore Dependencies
run: dotnet restore

- name: Build
run: |
VERSION=${{ github.ref_name }}
dotnet build -c debug
- name: Zip - Build
run: |
7z a -tzip -mx9 Inveigh-net3.5-dev.zip $PWD/Inveigh/bin/debug/net35/*
7z a -tzip -mx9 Inveigh-net4.6.2-dev.zip $PWD/Inveigh/bin/debug/net462/*
7z a -tzip -mx9 Inveigh-net6.0-dev.zip $PWD/Inveigh/bin/debug/net6.0/* -x!*/
- name: Publish - Trimmed/Single File
run: |
VERSION=${{ github.ref_name }}
dotnet publish --self-contained=true -p:PublishSingleFile=true -p:PublishTrimmed=true -r linux-x64 -f net6.0 -p:AssemblyName=inveigh -c debug
dotnet publish --self-contained=true -p:PublishSingleFile=true -p:PublishTrimmed=true -r osx-x64 -f net6.0 -p:AssemblyName=inveigh -c debug
dotnet publish --self-contained=true -p:PublishSingleFile=true -p:PublishTrimmed=true -r win-x64 -f net6.0 -c debug
- name: Zip - Publish
run: |
tar -czvf Inveigh-net6.0-linux-x64-trimmed-single-dev.tar.gz --directory=$PWD/Inveigh/bin/debug/net6.0/linux-x64/publish/ .
tar -czvf Inveigh-net6.0-osx-x64-trimmed-single-dev.tar.gz --directory=$PWD/Inveigh/bin/debug/net6.0/osx-x64/publish/ .
7z a -tzip -mx9 Inveigh-net6.0-win-x64-trimmed-single-dev.zip $PWD/Inveigh/bin/debug/net6.0/win-x64/publish/*
- name: Release .zip
if: "! startsWith(github.event_name, 'pull_request')"
uses: softprops/action-gh-release@v1
with:
name: Dev Branch Debug Builds
tag_name: development
prerelease: true
files: "Inveigh*.zip"
body: |
Latest ${{ github.ref_name }} branch debug builds (${{ github.sha }})
- name: Release tar.gz
uses: softprops/action-gh-release@v1
with:
tag_name: development
files: "Inveigh*.tar.gz"
16 changes: 9 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,29 @@ jobs:
- name: Restore Dependencies
run: dotnet restore

- name: Build Windows
- name: Build
run: |
VERSION=${{ github.ref_name }}
dotnet build -c release -p:Version=${VERSION:1}
- name: Zip
- name: Zip - Build
run: |
7z a -tzip -mx9 Inveigh-net3.5-win-64-${{ github.ref_name }}.zip $PWD/Inveigh/bin/release/net35/*
7z a -tzip -mx9 Inveigh-net4.6.2-win-64-${{ github.ref_name }}.zip $PWD/Inveigh/bin/release/net462/*
7z a -tzip -mx9 Inveigh-net6.0-win-64-${{ github.ref_name }}.zip $PWD/Inveigh/bin/release/net6.0/* -x!*/
7z a -tzip -mx9 Inveigh-net3.5-${{ github.ref_name }}.zip $PWD/Inveigh/bin/release/net35/*
7z a -tzip -mx9 Inveigh-net4.6.2-${{ github.ref_name }}.zip $PWD/Inveigh/bin/release/net462/*
7z a -tzip -mx9 Inveigh-net6.0-${{ github.ref_name }}.zip $PWD/Inveigh/bin/release/net6.0/* -x!*/
- name: Publish Linux/macOS
- name: Publish - Trimmed/Single File
run: |
VERSION=${{ github.ref_name }}
dotnet publish --self-contained=true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:Version=${VERSION:1} -r linux-x64 -f net6.0 -p:AssemblyName=inveigh -c release
dotnet publish --self-contained=true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:Version=${VERSION:1} -r osx-x64 -f net6.0 -p:AssemblyName=inveigh -c release
dotnet publish --self-contained=true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:Version=${VERSION:1} -r win-x64 -f net6.0 -c release
- name: Zip macOS
- name: Zip - Publish
run: |
tar -czvf Inveigh-net6.0-linux-x64-trimmed-single-${{ github.ref_name }}.tar.gz --directory=$PWD/Inveigh/bin/release/net6.0/linux-x64/publish/ .
tar -czvf Inveigh-net6.0-osx-x64-trimmed-single-${{ github.ref_name }}.tar.gz --directory=$PWD/Inveigh/bin/release/net6.0/osx-x64/publish/ .
7z a -tzip -mx9 Inveigh-net6.0-win-x64-trimmed-single-${{ github.ref_name }}.zip $PWD/Inveigh/bin/release/net6.0/win-x64/publish/*
- name: Release .zip
uses: softprops/action-gh-release@v1
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "Inveigh/Inveigh/Protocols/Quiddity"]
path = Inveigh/Inveigh/Protocols/Quiddity
url = https://192.168.99.78:3000/kevin/Quiddity.git
[submodule "Inveigh/Protocols/Inveigh/Protocols/Quiddity"]
path = Inveigh/Protocols/Inveigh/Protocols/Quiddity
url = https://192.168.99.78:3000/kevin/Quiddity.git
3 changes: 3 additions & 0 deletions Inveigh/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
</Weavers>
141 changes: 141 additions & 0 deletions Inveigh/FodyWeavers.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeReferences" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if runtime assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseRuntimeReferencePaths" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCleanup" type="xs:boolean">
<xs:annotation>
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
23 changes: 23 additions & 0 deletions Inveigh/Inveigh.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net35;net462;net6.0</TargetFrameworks>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFrameworks)|$(Platform)'=='Debug|net35|AnyCPU'">
Expand All @@ -29,8 +30,30 @@
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<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.6.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<DefineConstants>ISNET6_0</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<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.6.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
12 changes: 6 additions & 6 deletions Inveigh/Protocols/Quiddity/Quiddity/Listeners/HTTPListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ internal void ReceiveClient(object parameters)
}

}

if (type.Equals("Proxy"))
{
response.StatusCode = "407";
Expand Down Expand Up @@ -326,22 +326,22 @@ internal void ReceiveClient(object parameters)
response.WWWAuthenticate = string.Concat("Basic realm=", HTTPRealm);
}

if (!string.IsNullOrEmpty(request.Authorization) && (request.Authorization.ToUpper().StartsWith("NTLM ") || request.Authorization.ToUpper().StartsWith("NEGOTIATE ")) || (!string.IsNullOrEmpty(request.ProxyAuthorization)) && request.ProxyAuthorization.ToUpper().StartsWith("NTLM "))
if (!string.IsNullOrEmpty(request.Authorization) && (request.Authorization.ToUpper().StartsWith("NTLM ") || request.Authorization.ToUpper().StartsWith("NEGOTIATE ")) || (!string.IsNullOrEmpty(request.ProxyAuthorization) && request.ProxyAuthorization.ToUpper().StartsWith("NTLM ")))
{
string authorization = request.Authorization;

if (!string.IsNullOrEmpty(request.ProxyAuthorization))
{
authorization = request.ProxyAuthorization;
}

NTLMNegotiate ntlm = new NTLMNegotiate();
ntlm.ReadBytes(Convert.FromBase64String(request.Authorization.Split(' ')[1]), 0);
ntlm.ReadBytes(Convert.FromBase64String(authorization.Split(' ')[1]), 0);

if (ntlm.MessageType == 1)
{
byte[] timestamp = BitConverter.GetBytes(DateTime.Now.ToFileTime());
NTLMChallenge challenge = new NTLMChallenge(Challenge, NetbiosDomain, ComputerName, DNSDomain, ComputerName, DNSDomain);
NTLMChallenge challenge = new NTLMChallenge(Challenge, NetbiosDomain, ComputerName, DNSDomain, ComputerName, DNSDomain, timestamp);
byte[] challengeData = challenge.GetBytes(ComputerName);
ntlmChallenge = BitConverter.ToString(challenge.ServerChallenge).Replace("-", "");
string sessionTimestamp = BitConverter.ToString(timestamp).Replace("-", "");
Expand Down Expand Up @@ -387,7 +387,7 @@ internal void ReceiveClient(object parameters)

try
{
byte[] timestamp = new byte[8];
byte[] timestamp = new byte[8];
Buffer.BlockCopy(ntlmResponse.NtChallengeResponse, 24, timestamp, 0, 8);
string sessionTimestamp = BitConverter.ToString(timestamp).Replace("-", "");
ntlmChallenge = httpSessionTable[sessionTimestamp].ToString();
Expand Down
10 changes: 10 additions & 0 deletions Inveigh/Protocols/Quiddity/Quiddity/Protocols/HTTP/HTTPRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class HTTPRequest
public string Accept { get; set; }
public string AcceptEncoding { get; set; }
public string AcceptLanguage { get; set; }
public string CacheControl { get; set; }
public string ProxyConnection{ get; set; }
public string Authorization { get; set; }
public string ProxyAuthorization { get; set; }

Expand Down Expand Up @@ -142,6 +144,10 @@ public void GetField(string field, string value)
this.AcceptLanguage = value;
break;

case "CACHE-CONTROL:":
this.ProxyConnection = value;
break;

case "AUTHORIZATION:":
this.Authorization = value;
break;
Expand All @@ -150,6 +156,10 @@ public void GetField(string field, string value)
this.ProxyAuthorization = value;
break;

case "PROXY-CONNECTION:":
this.ProxyConnection = value;
break;

}

}
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2021, Kevin Robertson
Copyright (c) 2022, Kevin Robertson
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
Loading

0 comments on commit c7e26ad

Please sign in to comment.