Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
bug fixes
switched .net 4.5 to 4.6.2
switched .net 5.0 to 6.0
added workflow for release assemblies
  • Loading branch information
Kevin-Robertson committed Aug 11, 2022
1 parent 82be237 commit 0fecc18
Show file tree
Hide file tree
Showing 27 changed files with 763 additions and 371 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Release

on:
push:
tags:
- "v*.*.*"

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 Windows
run: |
VERSION=${{ github.ref_name }}
dotnet build -c release -p:Version=${VERSION:1}
- name: Zip
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!*/
- name: Publish Linux/macOS
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
- name: Zip macOS
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/ .
- name: Release .zip
uses: softprops/action-gh-release@v1
with:
files: "Inveigh*.zip"

- name: Release tar.gz
uses: softprops/action-gh-release@v1
with:
files: "Inveigh*.tar.gz"
48 changes: 14 additions & 34 deletions Inveigh/Inveigh.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,35 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net35;net45;net5.0</TargetFrameworks>
<TargetFrameworks>net35;net462;net6.0</TargetFrameworks>
</PropertyGroup>




<PropertyGroup>
<!-- https://github.com/dotnet/msbuild/issues/1333#issuecomment-296346352 -->
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35'">$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
<AutomaticallyUseReferenceAssemblyPackages Condition=" '$(TargetFramework)' == 'net35' ">false</AutomaticallyUseReferenceAssemblyPackages>
<AssemblyName>Inveigh</AssemblyName>
<Version>2.0.0</Version>
</PropertyGroup>



<PropertyGroup Condition="'$(Configuration)|$(TargetFrameworks)|$(Platform)'=='Debug|net35|AnyCPU'">
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net35'">
<Reference Include="System.DirectoryServices.Protocols">
<HintPath>$(WINDIR)\Microsoft.NET\Framework64\v2.0.50727\System.DirectoryServices.Protocols.dll</HintPath>
<private>False</private>
</Reference>
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net35|AnyCPU'">
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net35'">
<Reference Include="System.DirectoryServices.Protocols">
<HintPath>$(WINDIR)\Microsoft.NET\Framework64\v2.0.50727\System.DirectoryServices.Protocols.dll</HintPath>
<private>False</private>
</Reference>
</ItemGroup>


<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="System.DirectoryServices.Protocols">
<Version>5.0.1</Version>
<Version>6.0.1</Version>
</PackageReference>
</ItemGroup>


<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="System.DirectoryServices.Protocols">
<Version>5.0.1</Version>
<Version>6.0.1</Version>
</PackageReference>
</ItemGroup>

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

</Project>
4 changes: 2 additions & 2 deletions Inveigh/Listeners/SMBListener.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* 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 Expand Up @@ -54,7 +54,7 @@ protected override void OutputNegotiation(string protocol, string listenerPort,
protected override void OutputError(Exception ex, int port)
{

if (ex.Message.ToString().Equals("An attempt was made to access a socket in a way forbidden by its access permissions"))
if (ex.Message.ToString().Equals("An attempt was made to access a socket in a way forbidden by its access permissions."))
{
Output.Queue(String.Format("[!] Failed to start SMB listener on port {0}, check IP and port usage.", port));
}
Expand Down
45 changes: 25 additions & 20 deletions Inveigh/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class Program
public static string netbiosDomain = Environment.UserDomainName;
public static string dnsDomain = "";
public static ulong smb2Session = 5548434740922023936; // todo check
public static string version = "2.0.4";
public static string version = "2.0.5";

static void Main(string[] arguments)
{
Expand All @@ -185,6 +185,7 @@ static void Main(string[] arguments)
enabledWindows = false;
}
#endif
bool allValid = true;

if (arguments.Length > 0)
{
Expand Down Expand Up @@ -584,7 +585,7 @@ static void Main(string[] arguments)
if (arguments.Length > 1)
argHelp = arguments[entry.index + 1].ToUpper();
Output.GetHelp(argHelp);
Environment.Exit(0);
allValid &= false;
break;

default:
Expand All @@ -606,42 +607,46 @@ static void Main(string[] arguments)
Console.WriteLine("{0} error - {1}", argument, ex.Message);
}

Environment.Exit(0);
allValid &= false;
}

}

}

Arguments.ValidateArguments();
Arguments.ParseArguments();
Control.ImportSession();
Output.StartupOutput();
Control.StartThreads();
commandHistoryList.Add("");
allValid &= Arguments.ValidateArguments();

while (isRunning)
if (allValid)
{
Arguments.ParseArguments();
Control.ImportSession();
Output.StartupOutput();
Control.StartThreads();
commandHistoryList.Add("");

try
while (isRunning)
{
Output.OutputLoop();

if (isRunning)
try
{
Output.OutputLoop();

if (isRunning)
{
Shell.ConsoleLoop();
}

}
catch (Exception ex)
{
Shell.ConsoleLoop();
Console.WriteLine(outputList.Count);
outputList.Add(String.Format("[-] [{0}] Console error detected - {1}", Output.Timestamp(), ex.ToString()));
}

}
catch (Exception ex)
{
Console.WriteLine(outputList.Count);
outputList.Add(String.Format("[-] [{0}] Console error detected - {1}", Output.Timestamp(), ex.ToString()));
}

}

Environment.Exit(0);
}

}
Expand Down
52 changes: 50 additions & 2 deletions Inveigh/Protocols/Quiddity/Quiddity/Clients/SMBClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,71 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Quiddity.NetBIOS;
using Quiddity.SMB;
using Quiddity.SMB2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;

namespace Quiddity.Clients
{
class SMBClient
{
public TCPClient TCPClient { get; set; }

public static NetworkStream tcpStream;

internal void Connect(string ipAddress, int port)
{
TCPClient tcpClient = new TCPClient(ipAddress, port);
tcpClient.Connect(ipAddress, port);
TCPClient = new TCPClient(ipAddress, port);
//TCPClient.Connect(ipAddress, port);
tcpStream = TCPClient.GetStream();
}

internal void Negotiate(string ipAddress, int port)
{
Connect(ipAddress, port);
byte[] readBuffer = new byte[1024];

SMBHeader smbHeader = new SMBHeader
{
Command = 0x72,
Status = 0,
Flags = 0x18,
Flags2 = 51283,
PIDHigh = 0,
SecurityFeatures = new byte[8],
TID = 65535,
PIDLow = 65279,
UID = 0,
MID = 0
};

SMBCOMNegotiateRequest smbCOMNegotiateRequest = new SMBCOMNegotiateRequest();
byte[] sendBuffer = SMBHelper.GetBytes(new NetBIOSSessionService(), smbHeader, smbCOMNegotiateRequest);
tcpStream.Write(sendBuffer, 0, sendBuffer.Length);
tcpStream.Flush();
tcpStream.Read(readBuffer, 0, readBuffer.Length);

NetBIOSSessionService requestNetBIOSSessionService = new NetBIOSSessionService(readBuffer);
SMBHelper smbHelper = new SMBHelper();

if (requestNetBIOSSessionService.Type == 0 || smbHelper.Protocol[0] == 0xfe || smbHelper.Protocol[0] == 0xff)
{
int sessionServiceIndex = 0;

if (requestNetBIOSSessionService.Type == 0)
{
sessionServiceIndex = 4;
}

SMBHeader requestSMBHeader = new SMBHeader();
SMB2Header requestSMB2Header = new SMB2Header();
smbHelper.ReadBytes(readBuffer, sessionServiceIndex);
}

}

Expand Down
2 changes: 1 addition & 1 deletion Inveigh/Protocols/Quiddity/Quiddity/Clients/TCPClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class TCPClient : TcpClient
public TCPClient(string ipAddress, int port) : base(ipAddress, port)
{
this.Client.ReceiveTimeout = 60000;
this.ExclusiveAddressUse = false;
//this.ExclusiveAddressUse = false;
}

}
Expand Down
30 changes: 26 additions & 4 deletions Inveigh/Protocols/Quiddity/Quiddity/Listeners/DHCPv6Listener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;

namespace Quiddity
{
Expand All @@ -46,6 +47,8 @@ public class DHCPv6Listener
public int Prefix { get; set; }
public int Index { get; set; }

public static bool isRunning = false;

public DHCPv6Listener()
{
this.Index = 1;
Expand All @@ -68,14 +71,33 @@ public void Start(IPAddress ipAddress, string mac, string dnsIPv6)
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, 547);
listener.JoinMulticastGroup(IPAddress.Parse("ff02::1:2"));
listener.Client.Bind(ipEndPoint);
isRunning = true;
IAsyncResult udpAsync;

while (true)
{
while (isRunning)
{

try
{
byte[] receiveBuffer = listener.Receive(ref ipEndPoint);
ProcessRequest(receiveBuffer, listener, ipEndPoint, mac, dnsIPv6);
udpAsync = listener.BeginReceive(null, null);

do
{
Thread.Sleep(10);

if (!isRunning)
{
break;
}

}
while (!udpAsync.IsCompleted);

if (isRunning)
{
byte[] receiveBuffer = listener.EndReceive(udpAsync, ref ipEndPoint);
ProcessRequest(receiveBuffer, listener, ipEndPoint, mac, dnsIPv6);
}
}
catch (Exception ex)
{
Expand Down
Loading

0 comments on commit 0fecc18

Please sign in to comment.