Hackerboard Wiki HaboBlog
Hackerboard bei Facebook Hackerboard bei Google+ Hackerboard bei Twitter

[HaBo]

 
Code Kitchen Allgemeines Coder-Forum rund um das Programmieren eigenständiger, ausführbarer Programme.

C - ARP Puffer abfragen

Diskussion: C - ARP Puffer abfragen im Forum Code Kitchen, in der Kategorie Software Home; Anzeige Hi Ich habe ein Programm geschrieben, welches den lokalen ARP-Puffer auf Man in the Middle ARP Poisoning Angriffe überprüft ...

Antwort
Alt 06.10.05, 18:11   #1 (permalink)
 
Registriert seit: 11.09.05
Heinzi Leistung: Facit NTK
Heinzi eine Nachricht über ICQ schicken Heinzi eine Nachricht über AIM schicken Heinzi eine Nachricht über Yahoo! schicken
Likes: 0
Standard C - ARP Puffer abfragen

Anzeige

Hi

Ich habe ein Programm geschrieben, welches den lokalen ARP-Puffer auf Man in the Middle ARP Poisoning Angriffe überprüft (es schaut nach, ob für verschiedene IPs die gleiche MAC eingetragen ist). zZ macht dieses Programm über system("arp -a>>file.txt") eine Datei, die anschließend eingelesen und dann ausgewertet wird. Geht das nicht eleganter?

cu, Heinzi

Heinzi ist offline   Mit Zitat antworten
Alt 07.10.05, 14:22   #2 (permalink)
 
Registriert seit: 13.11.04
The Dude Leistung: Facit NTK
Likes: 0
Standard

Code:
#include <cstdlib>
#include <iostream>
#include <winsock2.h>
#include <Iprtrmib.h>
#include <Iphlpapi.h>

using namespace std;

void initWinsock()
{
  WSADATA wsaData;
  int iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
  if (iResult != NO_ERROR)
    printf("Error at WSAStartup()\n");
}

PMIB_IPNETTABLE readArpCache()
{
  PMIB_IPNETTABLE arpCache = NULL;
  ULONG ulSize  = 0; 
  
  GetIpNetTable(arpCache, &ulSize, TRUE);   // groesse des buffers bestimmen
  arpCache = new MIB_IPNETTABLE[ulSize];
  if (NULL != arpCache)
  {
      GetIpNetTable(arpCache, &ulSize, TRUE); // buffer fuellen
      return arpCache;
  } else {
      cout << "kaputt" << endl;
      return NULL;
  } 
}

void printArpCache(PMIB_IPNETTABLE arpCache)
{
  if (!arpCache)
    return;
  PMIB_IPNETROW arpCacheRow = NULL;
  in_addr ipAddress;
  for (int i = 0; i < arpCache->dwNumEntries; i++) {
    arpCacheRow = &(arpCache->table[i]);
    ipAddress.S_un.S_addr = arpCacheRow->dwAddr;
    if (!arpCache)
      continue;
    printf("IP Address: %s", inet_ntoa(ipAddress));
    printf("    MAC Address: %02x-%02x-%02x-%02x-%02x-%02x\r\n", 
            arpCacheRow->bPhysAddr[0],
            arpCacheRow->bPhysAddr[1],
            arpCacheRow->bPhysAddr[2],
            arpCacheRow->bPhysAddr[3],
            arpCacheRow->bPhysAddr[4],
            arpCacheRow->bPhysAddr[5]);
  }
  delete [] arpCache;
}

int main(int argc, char *argv[])
{
  initWinsock();
  printArpCache(readArpCache());
  system("PAUSE");
  return EXIT_SUCCESS;
}
mehr infos:
http://msdn.microsoft.com/library/de...ntprothelp.asp
http://msdn.microsoft.com/library/de...ipnettable.asp
http://www.codeproject.com/internet/IPHelper.asp
The Dude ist offline   Mit Zitat antworten
   
HaBOT
 
- Anzeige -

Werbung ist gerade online    
Alt 07.10.05, 15:22   #3 (permalink)
Themenstarter
 
Registriert seit: 11.09.05
Heinzi Leistung: Facit NTK
Heinzi eine Nachricht über ICQ schicken Heinzi eine Nachricht über AIM schicken Heinzi eine Nachricht über Yahoo! schicken
Likes: 0
Standard

danke^^
Heinzi ist offline   Mit Zitat antworten
Antwort
   
- Anzeige -

Werbung ist gerade online    

[HaBo] » Software Home » Code Kitchen » C - ARP Puffer abfragen
Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind aus
Pingbacks sind aus
Refbacks sind aus


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
per JS aktuelle URL abfragen... Watchme (Web-) Design und webbasierte Sprachen 2 27.08.09 22:48
get parameter in cgi/c++ abfragen Friedrich Code Kitchen 8 11.10.08 11:02
Netzwerkauslatung abfragen Antibus Code Kitchen 2 17.03.08 16:22
mit C++ phpTicketsystem abfragen MaUs# Code Kitchen 4 09.05.07 19:53
Cursortasten abfragen icecreamman Code Kitchen 6 29.01.05 00:37


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61