Ettercap / ettercap

Ettercap Project
http://www.ettercap-project.org
GNU General Public License v2.0
2.33k stars 489 forks source link

Instruction on how to build for Windows in readme.platforms either don't wrong or are outdated. #749

Open sgeto opened 8 years ago

sgeto commented 8 years ago

Many links are also dead. Or useless. I am using msys2. which made it quite easy to get all the necessary dependencies. But cmake is still complaining. It can't, or doesn't want to find gtk2, it asked for libpcap not winpcap (instructions on how and where to place winpcap on readme.platforms are wrong), and it also says "Sorry, plugins support on Windows is currently unavailable", which doesn't make sense because they are working on 0.7,4. What would I do with ettercap without plugin support anyway? I'm wondering if anyone has been able to build a version on windows after 0.7,4 hand how they went about doing it...

thanks

LocutusOfBorg commented 8 years ago

Many links are also dead. Or useless.

list them please

I am using msys2. which made it quite easy to get all the necessary dependencies. But cmake is still complaining. It can't, or doesn't want to find gtk2,

log please

it asked for libpcap not winpcap (instructions on how and where to place winpcap on readme.platforms are wrong),

please try to patch

cmake/Modules/EttercapLibCheck.cmake

around this line:

find_library(HAVE_PCAP pcap)

or maybe just drop all the above lines, and wait for a winpcap link failure. I can patch it to work with winpcap, but I need somebody testing my patches.

and it also says "Sorry, plugins support on Windows is currently unavailable", which doesn't make sense because they are working on 0.7.4.

    if(OS_MINGW)
        message("Sorry, plugins support on Windows is currently unavailable")
    else(OS_MINGW)
        add_subdirectory(plug-ins)
    endif(OS_MINGW)

in CMakeLists.txt

not sure why somebody disabled it, you can try to remove that if check and see if they builds.

What would I do with ettercap without plugin support anyway?

almost everything, with some limitations

"why would you like to do some hacking on a windows platform?" :)

I'm wondering if anyone has been able to build a version on windows after 0.7,4 hand how they went about doing it...

@gvanem is the best person to ask, I don't have knowledge/time/skills to build stuff on windows, and I don't care really too much about its broken libraries/support, so here we are in best effort on the OS we can't test/develop

gvanem commented 8 years ago

As I've stated elsewhere, I prefer MSVC now (due to it's speed etc.). And since Ettercap is full of GNU-ism, I tend not to care so much about the project anymore. E.g. code like:

      char str[strlen(s->data) + PACKET->DATA.disp_len + 2];

Doesn't work in MSVC (where an alloca() would be just as fine).

And since CMake is IMHO an obfuscated ugly beast, I prefer to hack my own GNU-makefiles for stuff I build.

sgeto commented 8 years ago

@LocutusOfBorg

To outdated and useless links:

The first links to download libnet returns a Nepali(?) blog/website, and the other returns a 404 error: http://www.packetfactory.net/ http://ettercap.sourceforge.net/devel/libnet-1.1.2.1-mingw.tar.gz I didn't bother looking for their replacements, because thanks to the bundle version of libnet, cmake didn't complain (yet).

The link to the gtk development and runtime packages http://www.gimp.org/~tml/gimp/win32/downloads.html is dead. The website of the GTK+ Project http://www.gtk.org/download/windows.php suggests to use the packages maintained and provided by MSYS2. It's actually pretty straight forward, if cmake would find find them of course. Downloading gtk2 and/or gtk3 through MSYS2's package manager places them at the same location it also places ncurses. Not that I think I am capable of doing it, but I think cmake would find it if you could make him look there. After some forth and back, and tears of desperation, I actually realized that I haven't used ettercap's gtk interface (or the curses interface) in a long time. I would be nice (for me and other users) to have it around, but I don't necessary need it. That's why I ran cmake from thereon with the -D ENABLE_GTK=OFF ENABLE_CURSES=OFF option to bypass the error (s).

Pthreads' link is fine. But it is also available from the MSYS2 repo, and cmake seems to be happy with it (or maybe it's just not there yet).

to logs:

I'm going to include two cmake logs; with and without "ENABLE_GTK=OFF". If there're any other logs you need, let me know.

With my very limited knowledge, I took all of your others suggestions seriously and tried to follow them as much as I could. If you are so kind to patch it to work with winpcap, I would be happy to test it.

Dropping all the lines ABOVE find_library(HAVE_PCAP pcap) in cmake/Modules/EttercapLibCheck.cmake didn't do the trick. :) I cheated and removed the entire statement after find_library(HAVE_PCAP pcap), which of course, is not what we want. I just wanted to see the error that might result from it. There was no error. Instead cmake went straight to the "Sorry, plugins support on Windows is currently unavailable" warning, which I also dropped. After that, cmake produced this error:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CURSES_FORM_LIBRARY
    linked by target "ettercap" in directory /home/Ali/ettercap-0.8.2/src

I then just went ahead and dropped this line:

set(EC_LIBS ${EC_LIBS} ${CURSES_FORM_LIBRARY})

and now... it finished and created a makefile!! :)

I know this makefile is of no use. I just wanted to give a road map for things left to patch/fix in order for cmake to stop crying.

  1. (optional) gtk2 or gtk3
  2. winpcap
  3. (probably optional as well) unset CURSES_FORM_LIBRARY variable

I tell you what: If we (that is, you patching and me testing like there's no tomorrow) manage to create a build, I promise to write a detailed guide on how to build it on windows, and committed it as an update to README.PLATFORMS.

Also: Ettercap without plugins is like bread without butter. Still good, but there's something missing. There's something else (a little unrelated) that I always wanted to know regarding the usage of plugins in ettercap's text mode. Maybe you can help:

How do you tell ettercap to start with more than one plugin enabled? For example if I want ettercap to start running with dns_spoof and autoadd? Separating them by a space or a comma doesn't work. Maybe a semicolon?

ettercap -i wlan1 -Tq -M arp:remote -P dns_spoof;autoadd // //
bash: autoadd: command not found

Also Part 2: I am not a windows fan. But I need it for my real life job. I also only have one laptop and I find it quite cumbersome to dual boot or fire up a virtual machine all the time.

Cheers,

AA

logs: https://1drv.ms/f/s!AsbijvwHoSaBrUDNLLmOi-vTyzvt

sgeto commented 8 years ago

Hey thethere some significant changes happened yesterday night after I replied. I can't go into into too much right now because I'm working but it may makes a lot of the points I mentioned earlier irrelevant. Unfortunately I changed a lot of things in the Ettercap files and my build environment and I'm not exactly sure what did the trick, but the way it looks like changing "find_library(HAVE_PCAP pcap)" to "find_library(HAVE_PCAP wpcap)" leads configuring without any errors. I have to recreate the entire scenario in order to see if that's the only necessary change though. I'm also not sure if it'll build that way... Fingers crossed and thanks for the help so far

I'll write a more detailed explanation when I get home.

CSADn commented 8 years ago

Hi @sgeto, did you managed to compile it on windows mingw?

sgeto commented 8 years ago

Sadly no. I had not much success with msys2 and the i686-mingw-w64 toolchain.

In my opinion, the problem is a combination of building the third-party dependencies/libraries (including bundled ones) and the lack of documentation and support by the community. I struggled with a little with gtk2 at first, but the biggest problem child is Libnet. Just as ettercap itself, there seems to be no successful win32 build attempt after the projects have been revived. Ettercap's change log says it builds (again). I couldn't find anything useful that would confirm that. I wonder who said that...

I'm sadly not a programmer, so I can't hack my way through the source. But I'm afraid that's what it takes to end up with an successful (libnet) build.

Cheating GNU make into thinking libnet has been built pushes the entire building process to about 61%. It realises it at that point and throws a (winpcap related) segmentation fault... 😉 Libnet may build on MSVS as its readme suggests, but downloading visual studio community (it's like 7 or 8 gig's) just to realize that I won't, is, in my opinion, kinda... dismoraling. You can try if you like. If libnet builds, let me know, and we'll take it from there.

All the best

CSADn commented 8 years ago

I'm agree with you, third-party dependencies are a pain in the ass and documentation it's zero.

I'm a senior developer but anyway I cant compile it successfully.

Reading the code I realize that ettercap target library it's GTK3, but I've tried GTK2 and GTK3 with no success. Actually I'm stuck trying cmake to find GTK2 or GTK3 libraries:

console

I was able to compile libnet 1.1.2.1 with MSVS 2015 VC++ on Win32 x86 platform.

Here is the compiled library and the includes needed to build ettercap.

libnet v1.1.2.1 x86

Hope you could get ettercap to compile successfully. Write me back if I can help you, meanwhile I keep fighting cmake to work properly.

Best regards.

sgeto commented 8 years ago

Hey! Great! Thanks a lot! Libnet is already at version 1.2.something, but fingers crossed this version will do! To gtk+: I thing you have to manually point cmake to the the lib and include folders. I completely disabled the gtk and curses interfaces (by setting them both to "OFF" in CMakeLists.txt found in the ettercap's root directory), because, at some point, I just wanted it to compile at all. I'll set it back on and point cmake to them later tonight and see if that works. The necessary variables can be found in ettercap-0.8.2/cmake/Modules/FindGTK3.cmake. Try something like:

pacman --needed --noconfirm -S glib2-devel mingw-w64-i686-gtk3 mingw-w64-i686-gtkmm3 mingw-w64-i686-webkitgtk3

and then (in you build directory) you'd do; cmake -DGTK_BUILD_TYPE=GTK3 -DGTK3_GTK_LIBRARY=/mingw32/lib/gtk-3.0 -DGTK3_GDK_LIBRARY=/mingw32/lib/gdm-3.0 ../

You have to manipulate a few more variables this way in order to get it to finish. Another annoying one would be: -DHAVE_PCAP=/path/to/WpdPack

if you add it to the above commad now, you won't run into a pcap error: cmake -DGTK_BUILD_TYPE=GTK3 -DGTK3_GTK_LIBRARY=/mingw32/lib/gtk-3.0 -DGTK3_GDK_LIBRARY=/mingw32/lib/gdm-3.0 -DHAVE_PCAP=/path/to/WpdPack ../

We still have a long way ahead, as I have already encountered a couple more hurdles during compilation. But one error at a time!

Thanks again!

sgeto commented 8 years ago

Yeah... you also see need Freetype:

pacman --needed --noconfirm -S mingw-w64-i686-freetype

also: you might wanna switch to the mingw32 shell. I'm not sure if ettercap is 64 bit compatible. We should build for 32 bit first. And then repeat the steps for 64 bit.

Sorry another also: is it possible to compile libnet as x64 in MSVS?

sgeto commented 7 years ago

can anyone please explain what the file inet_pton.c is all about? I don't know what to think of it. On windows I think it has ben suceeded and is only important with XP.

I guess I know what it does in general:

inet_pton(), converts an IP address in numbers-and-dots notation into either a struct in_addr or a struct in6_addr depending on whether you specify AF_INET or AF_INET6.

Windows Vista and later have InetPton which does essentially the same thing.

inet_pton() is declared in the file WS2tcpip.h. And InetPton is only a #define to that.

Is it safe/correct to use WS2tcpip.h as a replacement for inet_pton.c?

LocutusOfBorg commented 7 years ago

Hi, I think it is a good replacement, but I'm far from being a windows user/expert.

sgeto commented 7 years ago

hmm... and I'm sadly far from being a useful programmer. I'll try and see what I can come up with...

sgeto commented 7 years ago

Yeah, it didn't work out of the box. But I found that Wireshark has a reimplementation of inet_pton. And it seems to work so far.

@LocutusOfBorg can you please have a look at the file ec_mingw.c at around line 283? I think there may be a syntax error. Here's the snipped:

// commented because os/ec_mingw.c:283:9: error: array subscript is not an integer
//  if ((p[STDOUT_FILENO].events & POLLOUT) && num >= STDOUT_FILENO &&
//      isatty(STDOUT_FILENO) >= 0) {
//    p [STDOUT_FILENO].revents = POLLOUT;
//    ret++;
//  }

Thank you!

sgeto commented 7 years ago

line no 279 too please!

if ((p[STDIN_FILENO].events & POLLIN) && num >= STDIN_FILENO && win_kbhit()) {
    p [STDIN_FILENO].revents = POLLIN;
    ret++;
LocutusOfBorg commented 7 years ago

sorry but I don't understand such code and windows :( seems that STDIN_FILENO is not an integer on windows? @gvanem any clue? you might want to replace it with 0, it should be the best replacement in case the macro is not defined

gvanem commented 7 years ago

@sgeto Try add this at the top:

#ifndef STDIN_FILENO
#define STDIN_FILENO   0
#endif

#ifndef STDOUT_FILENO
#define STDOUT_FILENO  1
#endif

But since I prefer MSVC now, the official ec_mingw.c is way behind my private version. It's here http://www.watt-32.net/misc/ec_mingw.c for reference.

sgeto commented 7 years ago

Thanks. Both of you. Adding this to the top helps a little. Except in one place where I just manually replaced it. I hope that doesn't break anything... I think you should consider replacing the official file with gvanem's version in any case because it comes after other errors as well. Thanks again. Hope you're not too annoyed with me :-D

LocutusOfBorg commented 7 years ago

@gvanem can you please share a patch?

gvanem commented 7 years ago

I already had a .zip at my page. But here is an quick update: http://www.watt-32.net/misc/#Ettercap

The patches are in: http://www.watt-32.net/misc/Ettercap-win-diffs.zip

sgeto commented 7 years ago

Thanks for your efforts.