Skip to content

Commit 23b4d47

Browse files
authored
Merge pull request #65 from bman46/Combat-Instagram-Detection
Combat Instagram Detection
2 parents cc6705b + 45abb33 commit 23b4d47

File tree

4 files changed

+55
-8
lines changed

4 files changed

+55
-8
lines changed

Instagram Reels Bot/Helpers/Instagram/IGAccount.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using InstagramApiSharp.API.Builder;
45
using InstagramApiSharp.Classes;
6+
using InstagramApiSharp.Classes.Android.DeviceInfo;
57
using InstagramApiSharp.Logger;
8+
using Org.BouncyCastle.Asn1.X500;
69

710
namespace Instagram_Reels_Bot.Helpers.Instagram
811
{
@@ -29,14 +32,29 @@ public void InitializeAPI()
2932
.Build();
3033

3134
// Set the Android Device:
32-
//instaApi.SetDevice(InstagramProcessor.device);
35+
if (StaticDevice == null)
36+
{
37+
StaticDevice = AndroidDeviceGenerator.GetRandomAndroidDevice();
38+
}
39+
else
40+
{
41+
Random rand = new Random();
42+
StaticDevice.IGBandwidthSpeedKbps = $"{rand.Next(1233, 1567)}.{rand.Next(100, 999)}";
43+
StaticDevice.IGBandwidthTotalTimeMS = rand.Next(781, 999).ToString();
44+
StaticDevice.DeviceId = ApiRequestMessage.GenerateDeviceIdFromGuid(StaticDevice.DeviceGuid);
45+
}
3346
}
3447

3548
/// <summary>
3649
/// The 2FA secret code for generating OTPs
3750
/// </summary>
3851
public string OTPSecret { get; set; }
3952

53+
/// <summary>
54+
/// List of times that this account should be used at
55+
/// </summary>
56+
public AndroidDevice StaticDevice { get; set; }
57+
4058
/// <summary>
4159
/// Set to true if the account has be blocked or failed to log in.
4260
/// Defaults to false.

Instagram Reels Bot/Helpers/Instagram/InstagramProcessor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Instagram_Reels_Bot.Helpers.Instagram;
1010
using InstagramApiSharp;
1111
using InstagramApiSharp.Classes;
12+
using InstagramApiSharp.Classes.Android.DeviceInfo;
1213
using Microsoft.Extensions.Configuration;
1314

1415
namespace Instagram_Reels_Bot.Helpers
@@ -71,6 +72,10 @@ public void InstagramLogin(IGAccount account)
7172
//Set the user:
7273
instaApi.SetUser(account);
7374

75+
//Set the device
76+
instaApi.SetDevice(account.StaticDevice);
77+
Console.WriteLine(instaApi.GetCurrentDevice().DeviceId);
78+
7479
//Get the state file
7580
string stateFile;
7681
if (config["StateFile"] != null && config["StateFile"] != "")
@@ -197,6 +202,7 @@ public static void LoadAccounts()
197202
for(int i = 0; i < creds.Count; i++)
198203
{
199204
creds[i].UsageTimes = config.GetSection("IGAccounts:" + i + ":UsageTimes").Get<List<IGAccount.OperatingTime>>();
205+
creds[i].StaticDevice = config.GetSection("IGAccounts:" + i + ":StaticDevice").Get<AndroidDevice>();
200206
}
201207
Accounts = creds;
202208
}

Instagram Reels Bot/Instagram Reels Bot.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Discord.Net.Commands" Version="3.8.1" />
11-
<PackageReference Include="Discord.Net.Core" Version="3.8.1" />
12-
<PackageReference Include="Discord.Net.WebSocket" Version="3.8.1" />
10+
<PackageReference Include="Discord.Net.Commands" Version="3.9.0" />
11+
<PackageReference Include="Discord.Net.Core" Version="3.9.0" />
12+
<PackageReference Include="Discord.Net.WebSocket" Version="3.9.0" />
1313
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
1414
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
1515
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
1616
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
17-
<PackageReference Include="MongoDB.Driver" Version="2.18.0" />
17+
<PackageReference Include="MongoDB.Driver" Version="2.19.0" />
1818
<PackageReference Include="OpenGraph-Net" Version="4.0.1" />
19-
<PackageReference Include="Discord.Net.Interactions" Version="3.8.1" />
20-
<PackageReference Include="Otp.NET" Version="1.2.2" />
19+
<PackageReference Include="Discord.Net.Interactions" Version="3.9.0" />
20+
<PackageReference Include="Otp.NET" Version="1.3.0" />
2121
<PackageReference Include="Bman46InstagramApiSharpLabs" Version="1.7.6" />
22-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.1" />
22+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.3" />
2323
</ItemGroup>
2424

2525
<ItemGroup>

Instagram Reels Bot/Services/CommandHandler.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
using Instagram_Reels_Bot.Helpers.Instagram;
1414
using System.IO;
1515
using System.Collections.Generic;
16+
using InstagramApiSharp.Classes.Android.DeviceInfo;
17+
using System.Text.Json;
1618

1719
namespace Instagram_Reels_Bot.Services
1820
{
@@ -257,6 +259,27 @@ public async Task MessageReceivedAsync(SocketMessage rawMessage)
257259
await message.ReplyAsync("State files removed.");
258260
}
259261
}
262+
else if (message.Content.ToLower().StartsWith("generatedevice"))
263+
{
264+
if (!string.IsNullOrEmpty(_config["OwnerID"]) && message.Author.Id == ulong.Parse(_config["OwnerID"]))
265+
{
266+
AndroidDevice device = AndroidDeviceGenerator.GetRandomAndroidDevice();
267+
string jsonString = "```\n" + JsonSerializer.Serialize(device) + "\n```";
268+
await message.ReplyAsync("Device:\n" + jsonString);
269+
}
270+
}
271+
else if (message.Content.ToLower().StartsWith("accountdevice"))
272+
{
273+
if (!string.IsNullOrEmpty(_config["OwnerID"]) && message.Author.Id == ulong.Parse(_config["OwnerID"]))
274+
{
275+
foreach (IGAccount user in InstagramProcessor.AccountFinder.Accounts)
276+
{
277+
AndroidDevice device = user.StaticDevice;
278+
string jsonString = "```\n" + JsonSerializer.Serialize(device) + "\n```";
279+
await message.ReplyAsync(user.UserName+" Device:\n" + jsonString);
280+
}
281+
}
282+
}
260283
return;
261284
}
262285

0 commit comments

Comments
 (0)