-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a864ff
commit 11c4bc5
Showing
10 changed files
with
836 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Application x:Class="FBI.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:FBI" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Windows; | ||
|
||
namespace FBI | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Windows; | ||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net6.0-windows</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<UseWPF>true</UseWPF> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Octokit" Version="10.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.9.34723.18 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FBI", "FBI.csproj", "{94E4252F-9243-47FC-9BA5-6760AC1AB987}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{94E4252F-9243-47FC-9BA5-6760AC1AB987}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{94E4252F-9243-47FC-9BA5-6760AC1AB987}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{94E4252F-9243-47FC-9BA5-6760AC1AB987}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{94E4252F-9243-47FC-9BA5-6760AC1AB987}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {2440348D-099B-429C-A71A-F139D3A9DE0E} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Saeed Khatami | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
using System.Net.NetworkInformation; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Input; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using Microsoft.Win32; | ||
using Path = System.IO.Path; | ||
|
||
namespace FBI | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MainWindow.xaml | ||
/// </summary> | ||
public partial class MainWindow : Window | ||
{ | ||
private readonly string[] RequieredFiles = new string[] { "BindIP.dll", "BindIP64.dll", "ForceBindIP.exe", "ForceBindIP64.exe" }; | ||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
|
||
BrowseApp.Click += (sender, e) => OpenAppSelector(); | ||
Start.Click += (sender, e) => LaunchApp(); | ||
NetAdapter.DropDownOpened += (sender, e) => LoadAvailableNetworkAdapters(); | ||
} | ||
private string ForceBindIPPath => Environment.CurrentDirectory; | ||
private string ForceBindExe; | ||
private void Window_MouseMove(object sender, MouseEventArgs e) | ||
{ | ||
if (e.LeftButton == MouseButtonState.Pressed) | ||
{ | ||
this.DragMove(); | ||
} | ||
} | ||
private void LoadAvailableNetworkAdapters() | ||
{ | ||
NetAdapter.Items.Clear(); | ||
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) | ||
{ | ||
if (ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet) | ||
{ | ||
foreach (UnicastIPAddressInformation ip in ni.GetIPProperties().UnicastAddresses) | ||
{ | ||
if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) | ||
NetAdapter.Items.Add(new NetworkAdapterInfo(ni.Name, ip.Address.ToString())); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void CheckRequieredFiles() | ||
{ | ||
string curDir = Environment.CurrentDirectory; | ||
foreach (string s in RequieredFiles) | ||
{ | ||
if (!File.Exists(Path.Combine(curDir, s))) | ||
{ | ||
MessageBox.Show("Error code 1", "Error"); | ||
Environment.Exit(-1); | ||
} | ||
} | ||
} | ||
public static int GetExecutableArchitecture(string filePath) | ||
{ | ||
try | ||
{ | ||
using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) | ||
{ | ||
stream.Seek(0x3C, SeekOrigin.Begin); | ||
byte[] peOffsetBytes = new byte[4]; | ||
stream.Read(peOffsetBytes, 0, 4); | ||
int peOffset = BitConverter.ToInt32(peOffsetBytes, 0); | ||
|
||
stream.Seek(peOffset, SeekOrigin.Begin); | ||
byte[] peSignatureBytes = new byte[4]; | ||
stream.Read(peSignatureBytes, 0, 4); | ||
|
||
uint peSignature = BitConverter.ToUInt32(peSignatureBytes, 0); | ||
if (peSignature != 0x00004550) // "PE\0\0" | ||
{ | ||
MessageBox.Show("Error code: 99"); | ||
return 99; | ||
} | ||
|
||
stream.Seek(0x4, SeekOrigin.Current); // Skip machine architecture field | ||
byte[] machineBytes = new byte[2]; | ||
stream.Read(machineBytes, 0, 2); | ||
ushort machine = BitConverter.ToUInt16(machineBytes, 0); | ||
|
||
if (machine == 0x8664) // AMD64 | ||
{ | ||
return 64; | ||
} | ||
else if (machine == 0x014C) // x86 | ||
{ | ||
return 32; | ||
} | ||
else | ||
{ | ||
MessageBox.Show("Error code: 98"); | ||
return 98; | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
string msg = ex.Message; | ||
MessageBox.Show("Error code: 97"); | ||
return 97; | ||
} | ||
} | ||
private void LaunchApp() | ||
{ | ||
try | ||
{ | ||
string targetAppPath = AppPath.Text; | ||
int targetAppArchitecture = GetExecutableArchitecture(targetAppPath); | ||
if (targetAppArchitecture == 32) | ||
{ | ||
ForceBindExe = "ForceBindIP.exe"; | ||
} | ||
else if (targetAppArchitecture == 64) | ||
{ | ||
ForceBindExe = "ForceBindIP64.exe"; | ||
} | ||
else | ||
{ | ||
MessageBox.Show("Error code: 97"); | ||
return; | ||
} | ||
|
||
string args = $"{((NetworkAdapterInfo)NetAdapter.SelectedItem).IP} \"{targetAppPath}\""; | ||
ProcessStartInfo psi = new ProcessStartInfo(); | ||
psi.FileName = Path.Combine(ForceBindIPPath, ForceBindExe); | ||
psi.Arguments = args; | ||
psi.WorkingDirectory = Path.GetDirectoryName(targetAppPath); | ||
Process.Start(psi); | ||
} | ||
catch (Exception ex) | ||
{ | ||
MessageBox.Show(ex.Message); | ||
} | ||
} | ||
|
||
private void OpenAppSelector() | ||
{ | ||
OpenFileDialog diag = new OpenFileDialog(); | ||
diag.Filter = "Application (*.exe)|*.exe"; | ||
diag.Multiselect = false; | ||
diag.Title = "Select a application to open"; | ||
if (diag.ShowDialog() == DialogResult.Equals(true)) | ||
AppPath.Text = diag.FileName; | ||
} | ||
|
||
private void NetAdapter_ContextMenuOpening(object sender, ContextMenuEventArgs e) | ||
{ | ||
LoadAvailableNetworkAdapters(); | ||
} | ||
|
||
private void A_MouseMove(object sender, MouseEventArgs e) | ||
{ | ||
if (e.LeftButton == MouseButtonState.Pressed) | ||
{ | ||
this.DragMove(); | ||
} | ||
} | ||
|
||
private void CheckBox64_Checked(object sender, RoutedEventArgs e) | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace FBI | ||
{ | ||
public class NetworkAdapterInfo | ||
{ | ||
public NetworkAdapterInfo(string name, string ip) | ||
{ | ||
Name = name; | ||
IP = ip; | ||
} | ||
|
||
public string Name { get; private set; } | ||
|
||
public string IP { get; private set; } | ||
|
||
public override string ToString() => $"{Name} - ({IP})"; | ||
} | ||
} |