Skip to content

Commit

Permalink
Removed create usert step, can automatically get the password from th…
Browse files Browse the repository at this point in the history
…e director
  • Loading branch information
garrynewman committed Jul 31, 2020
1 parent 31b2610 commit 5d809eb
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 96 deletions.
103 changes: 16 additions & 87 deletions UI/DirectorPatch.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 54 additions & 1 deletion UI/DirectorPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
using System.Diagnostics;
using Renci.SshNet;
using System.Linq.Expressions;
using System.Runtime.InteropServices;
using System.Net;
using System.Security.Cryptography;

namespace Garry.Control4.Jailbreak
{
Expand Down Expand Up @@ -315,6 +318,56 @@ private void PatchDirectorCertificates( object sender, EventArgs e )
}
}

private void OnAddressChanged( object sender, EventArgs e )
{
_ = WorkoutPassword();
}

async Task WorkoutPassword()
{
var address = Address.Text;

await Task.Run( () =>
{
var password = GetDirectorRootPassword( address );
if ( password != null )
{
Invoke( (Action)( () =>
{
if ( Address.Text == address )
{
Password.Text = password;
}
}) );
}
}
);
}

[DllImport( "iphlpapi.dll", ExactSpelling = true )]
public static extern int SendARP( int DestIP, int SrcIP, [Out] byte[] pMacAddr, ref int PhyAddrLen );

private static string GetDirectorRootPassword( string address )
{
var salt = Convert.FromBase64String( "STlqJGd1fTkjI25CWz1hK1YuMURseXA/UnU5QGp6cF4=" );

try
{
var hostIPAddress = IPAddress.Parse( address );
var ab = new byte[6];
int len = ab.Length;
var r = SendARP( (int)hostIPAddress.Address, 0, ab, ref len );
if ( r != 0 ) return null;
var macAddress = BitConverter.ToString( ab, 0, 6 ).Replace( "-", "" );

var password = Convert.ToBase64String( new Rfc2898DeriveBytes( macAddress, salt, macAddress.Length * 397, HashAlgorithmName.SHA384 ).GetBytes( 33 ) );
return password;
}
catch ( System.Exception )
{
return null;
}
}

}
}
}
8 changes: 0 additions & 8 deletions UI/DirectorPatch.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,6 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="label5.Text" xml:space="preserve">
<value>It's time for you to do some work. We need a user so we can add the new certificate to the director. So here's what we need you to do.

1. Open System Manager
2. Right Click on your director in the list (usually starts with EA5)
3. Go to Terminal
4. Run these commands (in the terminal you can right click to paste)</value>
</data>
<data name="label8.Text" xml:space="preserve">
<value>We can copy the new certificates to the composer user settings folder.

Expand Down

0 comments on commit 5d809eb

Please sign in to comment.