From 27e957a229f5d9d5be3fdbeee121d8012d44ee1f Mon Sep 17 00:00:00 2001 From: SayesCode Date: Sat, 30 Nov 2024 17:28:39 -0300 Subject: [PATCH] first commit --- .gitignore | 400 +++++++++++++++++++++++++ CountryCodeLookup/CountryCodeLookup.cs | 47 +++ DataDial.csproj | 18 ++ DataDial.sln | 22 ++ Helpers/SpamChecker.cs | 109 +++++++ Helpers/WebSearch.cs | 47 +++ LICENSE | 21 ++ Program.cs | 108 +++++++ 8 files changed, 772 insertions(+) create mode 100644 .gitignore create mode 100644 CountryCodeLookup/CountryCodeLookup.cs create mode 100644 DataDial.csproj create mode 100644 DataDial.sln create mode 100644 Helpers/SpamChecker.cs create mode 100644 Helpers/WebSearch.cs create mode 100644 LICENSE create mode 100644 Program.cs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..60b2ea0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,400 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +# but not Directory.Build.rsp, as it configures directory-level build defaults +!Directory.Build.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml \ No newline at end of file diff --git a/CountryCodeLookup/CountryCodeLookup.cs b/CountryCodeLookup/CountryCodeLookup.cs new file mode 100644 index 0000000..9ce4932 --- /dev/null +++ b/CountryCodeLookup/CountryCodeLookup.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; + +namespace DataDial.CountryCodeLookup +{ + public static class CountryCodeLookup + { + private static readonly Dictionary 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"; + } + } +} diff --git a/DataDial.csproj b/DataDial.csproj new file mode 100644 index 0000000..6a3010b --- /dev/null +++ b/DataDial.csproj @@ -0,0 +1,18 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + + + diff --git a/DataDial.sln b/DataDial.sln new file mode 100644 index 0000000..12b2b40 --- /dev/null +++ b/DataDial.sln @@ -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 diff --git a/Helpers/SpamChecker.cs b/Helpers/SpamChecker.cs new file mode 100644 index 0000000..c8dbd60 --- /dev/null +++ b/Helpers/SpamChecker.cs @@ -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); + } + } +} diff --git a/Helpers/WebSearch.cs b/Helpers/WebSearch.cs new file mode 100644 index 0000000..4d9519c --- /dev/null +++ b/Helpers/WebSearch.cs @@ -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(); + } + } + } +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ca7c2b9 --- /dev/null +++ b/LICENSE @@ -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. \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..0af4963 --- /dev/null +++ b/Program.cs @@ -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(); + } + + /// + /// Método para obter o nome do país de forma segura, prevenindo duplicatas. + /// + /// Código do país. + /// Nome do país associado ao código ou mensagem de erro. + 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}"; + } + } + } +}