Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SayesCode committed Nov 30, 2024
0 parents commit 27e957a
Show file tree
Hide file tree
Showing 8 changed files with 772 additions and 0 deletions.
400 changes: 400 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions CountryCodeLookup/CountryCodeLookup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Collections.Generic;

namespace DataDial.CountryCodeLookup
{
public static class CountryCodeLookup
{
private static readonly Dictionary<int, string> countryCodes = new()
{
{ 55, "Brasil" },
{ 1, "Estados Unidos/Canadá" },
{ 44, "Reino Unido" },
{ 91, "Índia" },
{ 49, "Alemanha" },
{ 33, "França" },
{ 39, "Itália" },
{ 81, "Japão" }, // Corrigido: removido o espaço extra
{ 61, "Austrália" },
{ 86, "China" },
{ 7, "Rússia" },
{ 34, "Espanha" },
{ 351, "Portugal" },
{ 52, "México" },
{ 64, "Nova Zelândia" },
{ 45, "Dinamarca" },
{ 47, "Noruega" },
{ 353, "Irlanda" },
{ 30, "Grécia" },
{ 43, "Áustria" },
{ 32, "Bélgica" },
{ 36, "Hungria" },
{ 420, "República Tcheca" },
{ 421, "Eslováquia" },
{ 386, "Eslovênia" },
{ 372, "Estônia" },
{ 370, "Lituânia" },
{ 371, "Letônia" },
{ 381, "Sérvia" },
{ 373, "Moldávia" },
{ 359, "Bulgária" }
};

public static string GetCountry(int countryCode)
{
return countryCodes.ContainsKey(countryCode) ? countryCodes[countryCode] : "Desconhecido";
}
}
}
18 changes: 18 additions & 0 deletions DataDial.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="libphonenumber-csharp" Version="8.13.50" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Selenium.WebDriver" Version="4.27.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="131.0.6778.8500" />
<PackageReference Include="Twilio" Version="3.6.29" />
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions DataDial.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35521.163 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataDial", "DataDial.csproj", "{4F123D5E-B920-4535-909E-B5B46A9E45F1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4F123D5E-B920-4535-909E-B5B46A9E45F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4F123D5E-B920-4535-909E-B5B46A9E45F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4F123D5E-B920-4535-909E-B5B46A9E45F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4F123D5E-B920-4535-909E-B5B46A9E45F1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
109 changes: 109 additions & 0 deletions Helpers/SpamChecker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace DataDial.Helpers
{
public static class SpamChecker
{
private const string ConfigFilePath = "config.txt";
private const string TwilioApiUrl = "https://lookups.twilio.com/v1/PhoneNumbers/{0}";
private static readonly HttpClient client = new HttpClient();

public static async Task CheckSpamList(string phoneNumber)
{
var (accountSid, authToken) = GetTwilioCredentials();
if (string.IsNullOrEmpty(accountSid) || string.IsNullOrEmpty(authToken))
{
Console.WriteLine("[ERRO] As credenciais da Twilio não foram encontradas.");
return;
}

try
{
var requestUrl = string.Format(TwilioApiUrl, phoneNumber);
var requestMessage = new HttpRequestMessage(HttpMethod.Get, requestUrl);
requestMessage.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes($"{accountSid}:{authToken}")));

var response = await client.SendAsync(requestMessage);
response.EnsureSuccessStatusCode();

var jsonResponse = await response.Content.ReadAsStringAsync();
dynamic data = JsonConvert.DeserializeObject(jsonResponse);

if (IsSpam(data))
{
Console.WriteLine($"[ALERTA] O número {phoneNumber} foi identificado como possivelmente SPAM.");
}
else
{
Console.WriteLine($"[INFO] O número {phoneNumber} não foi identificado como SPAM.");
}
}
catch (Exception ex)
{
Console.WriteLine($"[ERRO] Não foi possível verificar o número {phoneNumber}: {ex.Message}");
}
}

private static bool IsSpam(dynamic data)
{
if (data?.carrier != null)
{
var carrierName = data.carrier?.name?.ToString()?.ToLower() ?? string.Empty;
var carrierType = data.carrier?.type?.ToString()?.ToLower() ?? string.Empty;

if (carrierName.Contains("spam") || carrierType.Contains("voip") || carrierType.Contains("virtual"))
{
return true;
}
}

return false;
}

private static (string, string) GetTwilioCredentials()
{
if (File.Exists(ConfigFilePath))
{
var lines = File.ReadAllLines(ConfigFilePath);
if (lines.Length >= 2)
{
return (lines[0], lines[1]);
}
}

Console.WriteLine("Você gostaria de verificar se um número é SPAM?");
Console.WriteLine("Aviso: Será necessário fornecer o SID e o Token da sua conta Twilio para realizar a verificação.");
Console.WriteLine("Digite 'sim/s', 'não/n' para continuar:");

string response = Console.ReadLine()?.ToLower();
if (string.Equals(response, "sim") || string.Equals(response, "s"))
{
Console.WriteLine("SID da Twilio não encontrado. Por favor, forneça o SID da sua conta Twilio:");
var userSid = Console.ReadLine();

Console.WriteLine("Token da Twilio não encontrado. Por favor, forneça o Token da sua conta Twilio:");
var userToken = Console.ReadLine();

File.WriteAllLines(ConfigFilePath, new[] { userSid, userToken });

return (userSid, userToken);
}
else if (string.Equals(response, "não") || string.Equals(response, "n"))
{
Console.WriteLine("Operação cancelada. Nenhuma verificação realizada.");
Environment.Exit(0);
}
else
{
Console.WriteLine("Resposta inválida. Por favor, responda com 'sim', 's', 'não' ou 'n'.");
return GetTwilioCredentials();
}

return (string.Empty, string.Empty);
}
}
}
47 changes: 47 additions & 0 deletions Helpers/WebSearch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;

namespace DataDial.Helpers
{
public static class WebSearch
{
public static void SearchOnlineWithDorks(string phoneNumber)
{
Console.WriteLine($"[BUSCA] Verificando redes sociais e informações públicas para {phoneNumber}...");

var options = new ChromeOptions();
options.AddArgument("--headless");

using var driver = new ChromeDriver(options);

try
{
string dorkQuery = $"\"{phoneNumber}\" site:facebook.com OR site:twitter.com OR site:whatsapp.com OR site:linkedin.com";
driver.Navigate().GoToUrl($"https://www.google.com/search?q={dorkQuery}");

var results = driver.FindElements(By.CssSelector(".tF2Cxc"));

if (results.Count == 0)
{
Console.WriteLine("[INFO] Nenhuma informação encontrada diretamente.");
}
else
{
foreach (var result in results)
{
Console.WriteLine($"- {result.Text} ({result.FindElement(By.CssSelector(".yuRUbf a")).GetAttribute("href")})");
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Erro durante a busca online: {ex.Message}");
}
finally
{
driver.Quit();
}
}
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 I'm Matheus

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.
108 changes: 108 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
using System;
using PhoneNumbers;
using DataDial.CountryCodeLookup;
using DataDial.Helpers;

namespace PhoneValidator
{
class Program
{
static void Main(string[] args)
{
// Exibe a ASCII Art primeiro
Console.WriteLine(@" ___ __ ___ _ __");
Console.WriteLine(@" / _ \___ _/ /____ _/ _ \(_)__ _/ /");
Console.WriteLine(@" / // / _ `/ __/ _ `/ // / / _ `/ / ");
Console.WriteLine(@"/____/\_,_/\__/\_,_/____/_/\_,_/_/ ");
Console.WriteLine();

// Configura a cor do texto sem alterar o fundo
Console.ForegroundColor = ConsoleColor.White;

var phoneUtil = PhoneNumberUtil.GetInstance();

Console.Write("Digite o número de telefone com código do país (ex: +5511999999999): ");
string rawNumber = Console.ReadLine();

try
{
// Tenta parsear o número usando a biblioteca
PhoneNumber number = phoneUtil.Parse(rawNumber, null);
bool isValid = phoneUtil.IsValidNumber(number);

if (isValid)
{
// Exibe a validação do número com cor destacada (Verde)
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("\nNúmero válido!");
Console.WriteLine($"Formato Internacional: {phoneUtil.Format(number, PhoneNumberFormat.INTERNATIONAL)}");
Console.WriteLine($"Código do País: {number.CountryCode}");
Console.WriteLine($"Número Nacional: {number.NationalNumber}");

// Obtém o país associado ao código do país
string country = GetCountrySafe(number.CountryCode);
Console.WriteLine($"País: {country}");

// Logs informativos com cor mais neutra (Cinza)
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine("\n[INFO] Iniciando busca online...");
WebSearch.SearchOnlineWithDorks(rawNumber);

Console.WriteLine("\n[INFO] Verificando listas de spam...");
SpamChecker.CheckSpamList(rawNumber);
}
else
{
// Exibe número inválido em vermelho
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\nNúmero inválido!");
}
}
catch (NumberParseException e)
{
// Exibe erro ao processar o número em vermelho
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"\nErro ao processar o número: {e.Message}");
}
catch (Exception e)
{
// Exibe erro inesperado em vermelho
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"\nUm erro inesperado ocorreu: {e.Message}");
}

// Logs de execução do ChromeDriver em cinza
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine("\n[LOG] Starting ChromeDriver 131.0.6778.85 (3d81e41b6f3ac8bcae63b32e8145c9eb0cd60a2d-refs/branch-heads/6778@{#2285}) on port 37035");
Console.WriteLine("[LOG] Only local connections are allowed.");
Console.WriteLine("[LOG] Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.");
Console.WriteLine("[LOG] ChromeDriver was started successfully on port 37035.");
Console.WriteLine("[LOG] DevTools listening on ws://127.0.0.1:37039/devtools/browser/79ea4cd4-bc48-4737-9532-761f9d1dac12");

// Restaura a cor para o padrão
Console.ResetColor();
}

/// <summary>
/// Método para obter o nome do país de forma segura, prevenindo duplicatas.
/// </summary>
/// <param name="countryCode">Código do país.</param>
/// <returns>Nome do país associado ao código ou mensagem de erro.</returns>
private static string GetCountrySafe(int countryCode)
{
try
{
// Verifica se o dicionário já contém o código antes de acessar
return CountryCodeLookup.GetCountry(countryCode);
}
catch (ArgumentException)
{
return "Código de país duplicado ou inválido.";
}
catch (Exception ex)
{
return $"Erro ao buscar país: {ex.Message}";
}
}
}
}

0 comments on commit 27e957a

Please sign in to comment.