mirror of
https://github.com/mfontanini/libtins
synced 2026-01-30 05:24:26 +01:00
Added a portscan example. It's kind of nasty, but works.
This commit is contained in:
@@ -1,3 +1,25 @@
|
||||
/*
|
||||
* libtins is a net packet wrapper library for crafting and
|
||||
* interpreting sniffed packets.
|
||||
*
|
||||
* Copyright (C) 2011 Nasel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __SNIFFER_H
|
||||
#define __SNIFFER_H
|
||||
|
||||
@@ -71,6 +93,11 @@ namespace Tins {
|
||||
* \param max_packets The maximum amount of packets to sniff. 0 == infinite.
|
||||
*/
|
||||
void sniff_loop(const std::string &filter, AbstractSnifferHandler *cback_handler, uint32_t max_packets = 0);
|
||||
|
||||
/**
|
||||
* \brief Stops sniffing loops.
|
||||
*/
|
||||
void stop_sniff();
|
||||
private:
|
||||
bool compile_set_filter(const std::string &filter, bpf_program &prog);
|
||||
|
||||
|
||||
@@ -97,7 +97,8 @@ namespace Tins {
|
||||
*/
|
||||
std::set<std::string> network_interfaces();
|
||||
|
||||
/** \brief Lookup the ip address of the given interface.
|
||||
/**
|
||||
* \brief Lookup the ip address of the given interface.
|
||||
*
|
||||
* If the lookup fails, false will be returned, true otherwise.
|
||||
* \param iface The interface from which to extract the ip address.
|
||||
@@ -105,7 +106,8 @@ namespace Tins {
|
||||
*/
|
||||
bool interface_ip(const std::string &iface, uint32_t &ip);
|
||||
|
||||
/** \brief Lookup the hardware address of the given interface.
|
||||
/**
|
||||
* \brief Lookup the hardware address of the given interface.
|
||||
*
|
||||
* If the lookup fails, false will be returned, true otherwise.
|
||||
* \param iface The interface from which to extract the hardware address.
|
||||
@@ -114,7 +116,8 @@ namespace Tins {
|
||||
*/
|
||||
bool interface_hwaddr(const std::string &iface, uint8_t *buffer);
|
||||
|
||||
/** \brief Lookup the interface identifier.
|
||||
/**
|
||||
* \brief Lookup the interface identifier.
|
||||
*
|
||||
* If the lookup fails, false will be returned, true otherwise.
|
||||
* \param iface The interface from which to extract the identifier.
|
||||
@@ -122,7 +125,18 @@ namespace Tins {
|
||||
*/
|
||||
bool interface_id(const std::string &iface, uint32_t &id);
|
||||
|
||||
/** \brief Convert 32 bit integer into network byte order.
|
||||
/**
|
||||
* \brief Finds the gateway interface matching the given ip.
|
||||
*
|
||||
* This function find the interface which would be the gateway
|
||||
* when sending a packet to the given ip.
|
||||
* \param ip The ip of the interface we are looking for.
|
||||
* \return The interface's name.
|
||||
*/
|
||||
std::string interface_from_ip(uint32_t ip);
|
||||
|
||||
/**
|
||||
* \brief Convert 32 bit integer into network byte order.
|
||||
*
|
||||
* \param data The data to convert.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user