Skip to content

Commit 27e957a

Browse files
committed
first commit
0 parents  commit 27e957a

File tree

8 files changed

+772
-0
lines changed

8 files changed

+772
-0
lines changed

.gitignore

Lines changed: 400 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System.Collections.Generic;
2+
3+
namespace DataDial.CountryCodeLookup
4+
{
5+
public static class CountryCodeLookup
6+
{
7+
private static readonly Dictionary<int, string> countryCodes = new()
8+
{
9+
{ 55, "Brasil" },
10+
{ 1, "Estados Unidos/Canadá" },
11+
{ 44, "Reino Unido" },
12+
{ 91, "Índia" },
13+
{ 49, "Alemanha" },
14+
{ 33, "França" },
15+
{ 39, "Itália" },
16+
{ 81, "Japão" }, // Corrigido: removido o espaço extra
17+
{ 61, "Austrália" },
18+
{ 86, "China" },
19+
{ 7, "Rússia" },
20+
{ 34, "Espanha" },
21+
{ 351, "Portugal" },
22+
{ 52, "México" },
23+
{ 64, "Nova Zelândia" },
24+
{ 45, "Dinamarca" },
25+
{ 47, "Noruega" },
26+
{ 353, "Irlanda" },
27+
{ 30, "Grécia" },
28+
{ 43, "Áustria" },
29+
{ 32, "Bélgica" },
30+
{ 36, "Hungria" },
31+
{ 420, "República Tcheca" },
32+
{ 421, "Eslováquia" },
33+
{ 386, "Eslovênia" },
34+
{ 372, "Estônia" },
35+
{ 370, "Lituânia" },
36+
{ 371, "Letônia" },
37+
{ 381, "Sérvia" },
38+
{ 373, "Moldávia" },
39+
{ 359, "Bulgária" }
40+
};
41+
42+
public static string GetCountry(int countryCode)
43+
{
44+
return countryCodes.ContainsKey(countryCode) ? countryCodes[countryCode] : "Desconhecido";
45+
}
46+
}
47+
}

DataDial.csproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="libphonenumber-csharp" Version="8.13.50" />
12+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
13+
<PackageReference Include="Selenium.WebDriver" Version="4.27.0" />
14+
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="131.0.6778.8500" />
15+
<PackageReference Include="Twilio" Version="3.6.29" />
16+
</ItemGroup>
17+
18+
</Project>

DataDial.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35521.163 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataDial", "DataDial.csproj", "{4F123D5E-B920-4535-909E-B5B46A9E45F1}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{4F123D5E-B920-4535-909E-B5B46A9E45F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4F123D5E-B920-4535-909E-B5B46A9E45F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4F123D5E-B920-4535-909E-B5B46A9E45F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4F123D5E-B920-4535-909E-B5B46A9E45F1}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

Helpers/SpamChecker.cs

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
using System;
2+
using System.IO;
3+
using System.Net.Http;
4+
using System.Threading.Tasks;
5+
using Newtonsoft.Json;
6+
7+
namespace DataDial.Helpers
8+
{
9+
public static class SpamChecker
10+
{
11+
private const string ConfigFilePath = "config.txt";
12+
private const string TwilioApiUrl = "https://lookups.twilio.com/v1/PhoneNumbers/{0}";
13+
private static readonly HttpClient client = new HttpClient();
14+
15+
public static async Task CheckSpamList(string phoneNumber)
16+
{
17+
var (accountSid, authToken) = GetTwilioCredentials();
18+
if (string.IsNullOrEmpty(accountSid) || string.IsNullOrEmpty(authToken))
19+
{
20+
Console.WriteLine("[ERRO] As credenciais da Twilio não foram encontradas.");
21+
return;
22+
}
23+
24+
try
25+
{
26+
var requestUrl = string.Format(TwilioApiUrl, phoneNumber);
27+
var requestMessage = new HttpRequestMessage(HttpMethod.Get, requestUrl);
28+
requestMessage.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes($"{accountSid}:{authToken}")));
29+
30+
var response = await client.SendAsync(requestMessage);
31+
response.EnsureSuccessStatusCode();
32+
33+
var jsonResponse = await response.Content.ReadAsStringAsync();
34+
dynamic data = JsonConvert.DeserializeObject(jsonResponse);
35+
36+
if (IsSpam(data))
37+
{
38+
Console.WriteLine($"[ALERTA] O número {phoneNumber} foi identificado como possivelmente SPAM.");
39+
}
40+
else
41+
{
42+
Console.WriteLine($"[INFO] O número {phoneNumber} não foi identificado como SPAM.");
43+
}
44+
}
45+
catch (Exception ex)
46+
{
47+
Console.WriteLine($"[ERRO] Não foi possível verificar o número {phoneNumber}: {ex.Message}");
48+
}
49+
}
50+
51+
private static bool IsSpam(dynamic data)
52+
{
53+
if (data?.carrier != null)
54+
{
55+
var carrierName = data.carrier?.name?.ToString()?.ToLower() ?? string.Empty;
56+
var carrierType = data.carrier?.type?.ToString()?.ToLower() ?? string.Empty;
57+
58+
if (carrierName.Contains("spam") || carrierType.Contains("voip") || carrierType.Contains("virtual"))
59+
{
60+
return true;
61+
}
62+
}
63+
64+
return false;
65+
}
66+
67+
private static (string, string) GetTwilioCredentials()
68+
{
69+
if (File.Exists(ConfigFilePath))
70+
{
71+
var lines = File.ReadAllLines(ConfigFilePath);
72+
if (lines.Length >= 2)
73+
{
74+
return (lines[0], lines[1]);
75+
}
76+
}
77+
78+
Console.WriteLine("Você gostaria de verificar se um número é SPAM?");
79+
Console.WriteLine("Aviso: Será necessário fornecer o SID e o Token da sua conta Twilio para realizar a verificação.");
80+
Console.WriteLine("Digite 'sim/s', 'não/n' para continuar:");
81+
82+
string response = Console.ReadLine()?.ToLower();
83+
if (string.Equals(response, "sim") || string.Equals(response, "s"))
84+
{
85+
Console.WriteLine("SID da Twilio não encontrado. Por favor, forneça o SID da sua conta Twilio:");
86+
var userSid = Console.ReadLine();
87+
88+
Console.WriteLine("Token da Twilio não encontrado. Por favor, forneça o Token da sua conta Twilio:");
89+
var userToken = Console.ReadLine();
90+
91+
File.WriteAllLines(ConfigFilePath, new[] { userSid, userToken });
92+
93+
return (userSid, userToken);
94+
}
95+
else if (string.Equals(response, "não") || string.Equals(response, "n"))
96+
{
97+
Console.WriteLine("Operação cancelada. Nenhuma verificação realizada.");
98+
Environment.Exit(0);
99+
}
100+
else
101+
{
102+
Console.WriteLine("Resposta inválida. Por favor, responda com 'sim', 's', 'não' ou 'n'.");
103+
return GetTwilioCredentials();
104+
}
105+
106+
return (string.Empty, string.Empty);
107+
}
108+
}
109+
}

Helpers/WebSearch.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using OpenQA.Selenium;
2+
using OpenQA.Selenium.Chrome;
3+
using System;
4+
5+
namespace DataDial.Helpers
6+
{
7+
public static class WebSearch
8+
{
9+
public static void SearchOnlineWithDorks(string phoneNumber)
10+
{
11+
Console.WriteLine($"[BUSCA] Verificando redes sociais e informações públicas para {phoneNumber}...");
12+
13+
var options = new ChromeOptions();
14+
options.AddArgument("--headless");
15+
16+
using var driver = new ChromeDriver(options);
17+
18+
try
19+
{
20+
string dorkQuery = $"\"{phoneNumber}\" site:facebook.com OR site:twitter.com OR site:whatsapp.com OR site:linkedin.com";
21+
driver.Navigate().GoToUrl($"https://www.google.com/search?q={dorkQuery}");
22+
23+
var results = driver.FindElements(By.CssSelector(".tF2Cxc"));
24+
25+
if (results.Count == 0)
26+
{
27+
Console.WriteLine("[INFO] Nenhuma informação encontrada diretamente.");
28+
}
29+
else
30+
{
31+
foreach (var result in results)
32+
{
33+
Console.WriteLine($"- {result.Text} ({result.FindElement(By.CssSelector(".yuRUbf a")).GetAttribute("href")})");
34+
}
35+
}
36+
}
37+
catch (Exception ex)
38+
{
39+
Console.WriteLine($"Erro durante a busca online: {ex.Message}");
40+
}
41+
finally
42+
{
43+
driver.Quit();
44+
}
45+
}
46+
}
47+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 I'm Matheus
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Program.cs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
using System;
2+
using PhoneNumbers;
3+
using DataDial.CountryCodeLookup;
4+
using DataDial.Helpers;
5+
6+
namespace PhoneValidator
7+
{
8+
class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
// Exibe a ASCII Art primeiro
13+
Console.WriteLine(@" ___ __ ___ _ __");
14+
Console.WriteLine(@" / _ \___ _/ /____ _/ _ \(_)__ _/ /");
15+
Console.WriteLine(@" / // / _ `/ __/ _ `/ // / / _ `/ / ");
16+
Console.WriteLine(@"/____/\_,_/\__/\_,_/____/_/\_,_/_/ ");
17+
Console.WriteLine();
18+
19+
// Configura a cor do texto sem alterar o fundo
20+
Console.ForegroundColor = ConsoleColor.White;
21+
22+
var phoneUtil = PhoneNumberUtil.GetInstance();
23+
24+
Console.Write("Digite o número de telefone com código do país (ex: +5511999999999): ");
25+
string rawNumber = Console.ReadLine();
26+
27+
try
28+
{
29+
// Tenta parsear o número usando a biblioteca
30+
PhoneNumber number = phoneUtil.Parse(rawNumber, null);
31+
bool isValid = phoneUtil.IsValidNumber(number);
32+
33+
if (isValid)
34+
{
35+
// Exibe a validação do número com cor destacada (Verde)
36+
Console.ForegroundColor = ConsoleColor.Green;
37+
Console.WriteLine("\nNúmero válido!");
38+
Console.WriteLine($"Formato Internacional: {phoneUtil.Format(number, PhoneNumberFormat.INTERNATIONAL)}");
39+
Console.WriteLine($"Código do País: {number.CountryCode}");
40+
Console.WriteLine($"Número Nacional: {number.NationalNumber}");
41+
42+
// Obtém o país associado ao código do país
43+
string country = GetCountrySafe(number.CountryCode);
44+
Console.WriteLine($"País: {country}");
45+
46+
// Logs informativos com cor mais neutra (Cinza)
47+
Console.ForegroundColor = ConsoleColor.Gray;
48+
Console.WriteLine("\n[INFO] Iniciando busca online...");
49+
WebSearch.SearchOnlineWithDorks(rawNumber);
50+
51+
Console.WriteLine("\n[INFO] Verificando listas de spam...");
52+
SpamChecker.CheckSpamList(rawNumber);
53+
}
54+
else
55+
{
56+
// Exibe número inválido em vermelho
57+
Console.ForegroundColor = ConsoleColor.Red;
58+
Console.WriteLine("\nNúmero inválido!");
59+
}
60+
}
61+
catch (NumberParseException e)
62+
{
63+
// Exibe erro ao processar o número em vermelho
64+
Console.ForegroundColor = ConsoleColor.Red;
65+
Console.WriteLine($"\nErro ao processar o número: {e.Message}");
66+
}
67+
catch (Exception e)
68+
{
69+
// Exibe erro inesperado em vermelho
70+
Console.ForegroundColor = ConsoleColor.Red;
71+
Console.WriteLine($"\nUm erro inesperado ocorreu: {e.Message}");
72+
}
73+
74+
// Logs de execução do ChromeDriver em cinza
75+
Console.ForegroundColor = ConsoleColor.Gray;
76+
Console.WriteLine("\n[LOG] Starting ChromeDriver 131.0.6778.85 (3d81e41b6f3ac8bcae63b32e8145c9eb0cd60a2d-refs/branch-heads/6778@{#2285}) on port 37035");
77+
Console.WriteLine("[LOG] Only local connections are allowed.");
78+
Console.WriteLine("[LOG] Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.");
79+
Console.WriteLine("[LOG] ChromeDriver was started successfully on port 37035.");
80+
Console.WriteLine("[LOG] DevTools listening on ws://127.0.0.1:37039/devtools/browser/79ea4cd4-bc48-4737-9532-761f9d1dac12");
81+
82+
// Restaura a cor para o padrão
83+
Console.ResetColor();
84+
}
85+
86+
/// <summary>
87+
/// Método para obter o nome do país de forma segura, prevenindo duplicatas.
88+
/// </summary>
89+
/// <param name="countryCode">Código do país.</param>
90+
/// <returns>Nome do país associado ao código ou mensagem de erro.</returns>
91+
private static string GetCountrySafe(int countryCode)
92+
{
93+
try
94+
{
95+
// Verifica se o dicionário já contém o código antes de acessar
96+
return CountryCodeLookup.GetCountry(countryCode);
97+
}
98+
catch (ArgumentException)
99+
{
100+
return "Código de país duplicado ou inválido.";
101+
}
102+
catch (Exception ex)
103+
{
104+
return $"Erro ao buscar país: {ex.Message}";
105+
}
106+
}
107+
}
108+
}

0 commit comments

Comments
 (0)