mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Modified some PacketSender and BaseSniffer functions to take references instead of pointers.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <tins/network_interface.h>
|
||||
#include <tins/utils.h>
|
||||
#include <tins/ethernetII.h>
|
||||
#include <tins/packet_sender.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Tins;
|
||||
@@ -40,13 +41,13 @@ int do_arp_spoofing(NetworkInterface iface, IPv4Address gw, IPv4Address victim,
|
||||
EthernetII::address_type gw_hw, victim_hw;
|
||||
|
||||
// Resolves gateway's hardware address.
|
||||
if(!Utils::resolve_hwaddr(iface, gw, &gw_hw, &sender)) {
|
||||
if(!Utils::resolve_hwaddr(iface, gw, &gw_hw, sender)) {
|
||||
cout << "Could not resolve gateway's ip address.\n";
|
||||
return 5;
|
||||
}
|
||||
|
||||
// Resolves victim's hardware address.
|
||||
if(!Utils::resolve_hwaddr(iface, victim, &victim_hw, &sender)) {
|
||||
if(!Utils::resolve_hwaddr(iface, victim, &victim_hw, sender)) {
|
||||
cout << "Could not resolve victim's ip address.\n";
|
||||
return 6;
|
||||
}
|
||||
@@ -71,7 +72,7 @@ int do_arp_spoofing(NetworkInterface iface, IPv4Address gw, IPv4Address victim,
|
||||
EthernetII to_victim(iface, victim_hw, info.hw_addr, victim_arp);
|
||||
while(true) {
|
||||
// Just send them once every 5 seconds.
|
||||
if(!sender.send(&to_gw) || !sender.send(&to_victim))
|
||||
if(!sender.send(to_gw) || !sender.send(to_victim))
|
||||
return 7;
|
||||
sleep(5);
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
#include <pthread.h>
|
||||
#include <tins/ip.h>
|
||||
#include <tins/tcp.h>
|
||||
#include <tins/ipaddress.h>
|
||||
#include <tins/ip_address.h>
|
||||
#include <tins/ethernetII.h>
|
||||
#include <tins/network_interface.h>
|
||||
#include <tins/sniffer.h>
|
||||
#include <tins/utils.h>
|
||||
#include <tins/packetsender.h>
|
||||
#include <tins/packet_sender.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
@@ -44,8 +44,8 @@ typedef std::pair<Sniffer*, std::string> sniffer_data;
|
||||
/* Our scan handler. This will receive SYNs and RSTs and inform us
|
||||
* the scanned port's status.
|
||||
*/
|
||||
bool handler(PDU *pdu) {
|
||||
TCP *tcp = pdu->find_pdu<TCP>();
|
||||
bool handler(PDU &pdu) {
|
||||
TCP *tcp = pdu.find_pdu<TCP>();
|
||||
if(tcp) {
|
||||
// Ok, it's a TCP PDU. Is RST flag on? Then port is closed.
|
||||
if(tcp->get_flag(TCP::RST)) {
|
||||
@@ -77,7 +77,7 @@ void send_syns(const NetworkInterface &iface, IPv4Address dest_ip, const vector<
|
||||
for(vector<string>::const_iterator it = ips.begin(); it != ips.end(); ++it) {
|
||||
// Set the new port and send the packet!
|
||||
tcp->dport(atoi(it->c_str()));
|
||||
sender.send(&ip);
|
||||
sender.send(ip);
|
||||
}
|
||||
// Wait 1 second.
|
||||
sleep(1);
|
||||
@@ -89,7 +89,7 @@ void send_syns(const NetworkInterface &iface, IPv4Address dest_ip, const vector<
|
||||
ip.src_addr(dest_ip);
|
||||
// We use an ethernet pdu, otherwise the kernel will drop it.
|
||||
EthernetII eth(iface, info.hw_addr, info.hw_addr, ip.clone_pdu());
|
||||
sender.send(ð);
|
||||
sender.send(eth);
|
||||
}
|
||||
|
||||
void *thread_proc(void *param) {
|
||||
|
||||
@@ -92,9 +92,9 @@ private:
|
||||
sender.send(&ip);
|
||||
}
|
||||
|
||||
bool sniff_callback(PDU *pdu) {
|
||||
IP *ip = pdu->find_pdu<IP>();
|
||||
RawPDU *raw = pdu->find_pdu<RawPDU>();
|
||||
bool sniff_callback(PDU &pdu) {
|
||||
IP *ip = pdu.find_pdu<IP>();
|
||||
RawPDU *raw = pdu.find_pdu<RawPDU>();
|
||||
if(ip && raw) {
|
||||
ttl_map::const_iterator iter;
|
||||
IP inner_ip;
|
||||
|
||||
Reference in New Issue
Block a user