Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 31-03-2017
Snaked Snaked is offline
Baneado
NULL
 
Registrado: sep 2016
Posts: 102
Poder: 0
Snaked Va por buen camino
Cool Deteccion de redes Wifi (muestra nombre, encriptacion y señal)

Hola, he buscado por internet y he encontrado este codigo un programador llamado RAGE.

Inicialmente era codigo C++ para consola pero lo he adaptado para un TForm con un Memo1 y un TButton para actualizar la deteccion de redes wifi

aqui tenéis el código fuente..... ecfisa, si ves que puedes mejorarlo con alguna caracteristica añadida (o alguno de vosotros) os propongo que vayamos desarrollando entre todos unas cuantas mejoras con el fin de aprender entre todos un poco sobre la programacion de Wifi Adapters y esas cosas

un saludo


Código PHP:

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma comment(lib, "wlanapi.lib")

#include <stdio.h>
#include <windows.h>
#include <wlanapi.h>

#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
bool bWait false;

void DETECTA_REDES(void);
VOID WlanNotification(WLAN_NOTIFICATION_DATA *wlanNotifData,VOID *p);
bool IsVistaOrHigher(void);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponentOwner)
    : 
TForm(Owner)
{

}
//---------------------------------------------------------------------------
 /*
*   WlanScan - by RAGE
*
*   Coded while blasting Doomsday Machine by Arch Enemy.
*
*   Rip the code if you want, just dont use it in a pussy project
*/


void DETECTA_REDES(void)
{
HANDLE hWlan NULL;

    
DWORD dwError 0;
    
DWORD dwSupportedVersion 0;
    
DWORD dwClientVersion = (IsVistaOrHigher() ? 1);

    
GUID guidInterfaceZeroMemory(&guidInterfacesizeof(GUID));

    
WLAN_INTERFACE_INFO_LIST *wlanInterfaceList = (WLAN_INTERFACE_INFO_LIST*)WlanAllocateMemory(sizeof(WLAN_INTERFACE_INFO_LIST));
    
ZeroMemory(wlanInterfaceListsizeof(WLAN_INTERFACE_INFO_LIST));

    
WLAN_AVAILABLE_NETWORK_LIST *wlanNetworkList = (WLAN_AVAILABLE_NETWORK_LIST*)WlanAllocateMemory(sizeof(WLAN_AVAILABLE_NETWORK_LIST));
    
ZeroMemory(wlanNetworkListsizeof(WLAN_AVAILABLE_NETWORK_LIST));

    try
    {
        if(
dwError WlanOpenHandle(dwClientVersionNULL, &dwSupportedVersion, &hWlan) != ERROR_SUCCESS)
            throw(
"[x] Unable access wireless interface");

        if(
dwError WlanEnumInterfaces(hWlanNULL, &wlanInterfaceList) != ERROR_SUCCESS)
            throw(
"[x] Unable to enum wireless interfaces");

        
AnsiString p wlanInterfaceList->InterfaceInfo[0].strInterfaceDescription;
        
Form1->Memo1->Lines->Add(p);

        if(
dwError wlanInterfaceList->InterfaceInfo[0].isState != wlan_interface_state_not_ready)
        {
                if(
wlanInterfaceList->dwNumberOfItems 1)
                {
                    
// TODO: Add processing for multiple wireless cards here
                    
Form1->Memo1->Lines->Add("[!] Detected multiple wireless adapters, using default\n");
                    
guidInterface wlanInterfaceList->InterfaceInfo[0].InterfaceGuid;
                }
                else
                {
                    
guidInterface wlanInterfaceList->InterfaceInfo[0].InterfaceGuid;
                }
        }
        else
            throw(
"[x] Default wireless adapter disabled");

        
DWORD dwPrevNotif 0;

        
// Scan takes awhile so we need to register a callback
        
if(dwError WlanRegisterNotification(hWlanWLAN_NOTIFICATION_SOURCE_ACMTRUE,
          (
WLAN_NOTIFICATION_CALLBACK)WlanNotificationNULLNULL, &dwPrevNotif) != ERROR_SUCCESS)
            throw(
"[x] Unable to register for notifications");

        
Form1->Memo1->Lines->Add("[i] Scanning for nearby networks...\n");
        if(
dwError WlanScan(hWlan, &guidInterfaceNULLNULLNULL) != ERROR_SUCCESS)
            throw(
"[x] Scan failed, check adapter is enabled");

        
// Yawn...
        
while(bWait)
            
Sleep(100);

        
// Unregister callback, don't care if it succeeds or not
        
WlanRegisterNotification(hWlanWLAN_NOTIFICATION_SOURCE_NONETRUENULLNULLNULL, &dwPrevNotif);

        if(
dwError WlanGetAvailableNetworkList(hWlan, &guidInterfaceNULLNULL, &wlanNetworkList) != ERROR_SUCCESS)
            throw(
"[x] Unable to obtain network list");

        for(
unsigned int i 0wlanNetworkList->dwNumberOfItemsi++)
        {

            
"";
            
unsigned char *pp;
            
pp wlanNetworkList->Network[i].dot11Ssid.ucSSID;
                
Form1->Memo1->Lines->Add(AnsiString((char *)pp));
            
wlanNetworkList->Network[i].wlanSignalQuality;
                
Form1->Memo1->Lines->Add(p);



                switch(
wlanNetworkList->Network[i].dot11DefaultAuthAlgorithm)
                {
                        case 
DOT11_AUTH_ALGO_80211_OPEN:
                        case 
DOT11_AUTH_ALGO_80211_SHARED_KEY:
                            
Form1->Memo1->Lines->Add("SECURITY: WEP");
                        break;

                        case 
DOT11_AUTH_ALGO_WPA:
                        case 
DOT11_AUTH_ALGO_WPA_PSK:
                        case 
DOT11_AUTH_ALGO_WPA_NONE:
                            
Form1->Memo1->Lines->Add("SECURITY: WPA");
                        break;

                        case 
DOT11_AUTH_ALGO_RSNA:
                        case 
DOT11_AUTH_ALGO_RSNA_PSK:
                            
Form1->Memo1->Lines->Add("SECURITY: WPA2");
                        break;

                        default:
                            
Form1->Memo1->Lines->Add("SECURITY: UNKNOWN");
                        break;
                }
                
Form1->Memo1->Lines->Add("-----------------------");
        }
    }
    catch(
char *szError)
    {
        
Form1->Memo1->Lines->Add("ERROR:: ");
        
Form1->Memo1->Lines->Add(szError);
    }

    if(
wlanNetworkList)
        
WlanFreeMemory(wlanNetworkList);
    if(
wlanInterfaceList)
        
WlanFreeMemory(wlanInterfaceList);
    if(
hWlan)
        
WlanCloseHandle(hWlanNULL);

    
//return dwError;

}

VOID WlanNotification(WLAN_NOTIFICATION_DATA *wlanNotifData,VOID *p)
{
    if(
wlanNotifData->NotificationCode == wlan_notification_acm_scan_complete)
    {
        
bWait false;
    }
    else if(
wlanNotifData->NotificationCode == wlan_notification_acm_scan_fail)
    {
        
printf("Scanning failed with error: %x\n"wlanNotifData->pData);
        
bWait false;
    }
}

bool IsVistaOrHigher(void)
{
    
OSVERSIONINFO osVersionZeroMemory(&osVersionsizeof(OSVERSIONINFO));
    
osVersion.dwOSVersionInfoSize sizeof(OSVERSIONINFO);

    if(!
GetVersionEx(&osVersion))
        return 
false;

    if(
osVersion.dwMajorVersion >= 6)
        return 
true;
    return 
false;
}


void __fastcall TForm1::Button1Click(TObject *Sender)
{
  
Memo1->Lines->Clear();
  
DETECTA_REDES();
}
//--------------------------------------------------------------------------- 
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Como puedo ver el nivel de señal WIFI ? LDD Redes 3 10-06-2015 20:01:19
Saber si un dispositivo pierde señal Wifi marcial Varios 16 22-10-2013 10:56:17
deteccion de movimiento cmm07 Varios 4 11-10-2010 15:20:27
Detección de movimiento Peregrino Gráficos 8 14-02-2008 06:27:45
Detección de navegador WEB aerosB4 Internet 5 08-03-2004 18:27:10


La franja horaria es GMT +2. Ahora son las 18:49:29.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi